proxmark3/tools/hitag2crack/README.md

208 lines
8.3 KiB
Markdown
Raw Normal View History

2020-01-16 18:11:14 +08:00
HiTag2 Cracking Suite
---------------------
Authors:
* Attacks 1, 2, 3, 4 : Kevin Sheldrake <kev@headhacking.com>
* Attacks 5, 5gpu : anonymous, based on https://github.com/factoritbv/hitag2hell by FactorIT B.V.
2021-01-14 18:33:29 +08:00
* Attack 5opencl : Gabriele Gristina <gabriele.gristina@gmail.com>, based on 5gpu
2020-01-16 18:11:14 +08:00
Introduction
------------
These tools are implementations of the four attacks detailed in the papers,
Gone In 360 Seconds - Hijacking With HiTag 2 by Roel Verdult, Flavio Garcia
and Josep Balasch, and Lock It And Still Lose It - on the (In)Security of
Automotive Remote Keyless Entry Systems by Flavio Garcia, David Oswald,
Timo Kasper and Pierre Pavlides. The first three attacks come from the first
paper and the fourth attack comes from the second paper.
2021-09-15 01:52:05 +08:00
_note_
2021-10-17 05:43:31 +08:00
There are no Proxmark3 client implemented commands for these attacks. Only separate executables to be compiled and run on your own system.
2021-09-15 01:52:05 +08:00
No guarantees of working binaries on all systems. Some work on linux only.
There is no easy way to extract the needed data from a live system and use with these tools.
You can use the `RFIdler` device but the Proxmark3 client needs some more love. Feel free to contribute.
2020-01-16 18:11:14 +08:00
Attack 1
--------
Attack 1 is a nonce replay and length extension attack. This is an attack on
a single HiTag2 RFID tag, given a single encrypted nonce and challenge
response value pair (nR, aR) for the tag's UID. The attack runs entirely on
2020-04-04 19:55:26 +08:00
the Proxmark3 with it acting like a RWD that replays the same encrypted nonce
2020-01-16 18:11:14 +08:00
and challenge response pair for every interaction; this fixes the key stream
that the tag's PRNG outputs to the same stream for every interaction.
2020-04-04 19:55:26 +08:00
By brute forcing a subset of the encrypted command space, the Proxmark3 finds a
2020-01-16 18:11:14 +08:00
single valid encrypted command - invalid commands return a known unencrypted
error response so finding a valid one is simply a case of trying different
values until a response other than the error response is received.
It then bit flips the valid encrypted command to find the other 15 valid
encrypted commands. By knowing the contents of page 0 - it's the UID that
is presented in clear at the start of each interaction - it tries each
2020-04-04 19:55:26 +08:00
encrypted response in turn, assuming each to be the encrypted version of
2020-01-16 18:11:14 +08:00
'read page 0 non-inverted' and each response to be the encrypted version of
page 0.
For each attempted command, it calculates the key stream that would have
correctly generated the encrypted command and response:
command ++ response XOR key stream = encrypted command ++ encrypted response
therefore:
key stream = command ++ response XOR encrypted command ++ encrypted response
It then tests the potentially recovered key stream by creating an encrypted
command that consumes as much of it as possible, re-initialising with the same
2020-04-04 19:55:26 +08:00
encrypted nonce and challenge response pair (to set the key stream to the
2020-01-16 18:11:14 +08:00
same stream as that which produced the encrypted command response it is
testing), and then sending this extended encrypted command. If the response
is not the error response, then the key stream is valid and the response is
the encryption of the page 0 contents (the UID).
When one of the valid encrypted commands satisfies this situation, the
recovered key stream must be the output of the PRNG for the given encrypted
nonce and challenge response pair.
2020-04-04 19:55:26 +08:00
The Proxmark3 then uses this key stream to encrypt commands and decrypt the
2020-01-16 18:11:14 +08:00
responses, and therefore requests the contents of all 8 pages. Pages 1 and 2
contain the encryption key.
Attack 2
--------
Attack 2 is a time/space trade off to recover the key for situations where the
tag has been configured to prevent reading of pages 1 and 2. This attack uses
a pre-computed table of 2^37 PRNG states and resultant PRNG output, sorted on
2020-04-04 19:55:26 +08:00
the PRNG output. The Proxmark3 is used to recover 2048 bits of key stream using
2020-01-16 18:11:14 +08:00
a modification of attack 1 and this is used to search the table for matching
PRNG output. When the output is found, it is tested for validity (by testing
previous or following PRNG output) and then the PRNG state is rolled back to
2020-04-04 19:55:26 +08:00
the initialisation state, from which the unencrypted nonce and key can be
2020-01-16 18:11:14 +08:00
recovered.
Attack 3
--------
Attack 3 is a cryptanalytic attack that focuses on the RWD and a bias in the
PRNG output. By capturing 136 encrypted nonce and challenge response pairs,
candidates for the first 34 bits of the key can be identified, and for each
the remaining 14 bits can be brute forced.
Attack 4
--------
Attack 4 is a fast correlative attack on the key based on a number of captured
encrypted nonce and challenge response pairs (up to 32, but 16 usually
sufficient). It starts by guessing the first 16 bits of the key and scores
all these guesses against how likely they are to be the correct key, given the
encrypted nonces and the keystream they should produce. Each guess is then
expanded by 1 bit and the process iterates, with only the best guesses taken
forward to the next iteration.
Attack 5
--------
Attack 5 is heavily based on the HiTag2 Hell CPU implementation from https://github.com/factoritbv/hitag2hell by FactorIT B.V.,
with the following changes:
* Main takes a UID and 2 {nR},{aR} pairs as arguments and searches for states producing the first aR sample, reconstructs the corresponding key candidates and tests them against the second nR,aR pair;
* Reuses the Hitag helping functions of the other attacks.
Attack 5gpu
-----------
Attack 5gpu is identical to attack 5, simply the code has been ported to OpenCL
to run on GPUs and is therefore much faster than attack 5.
2021-01-14 18:33:29 +08:00
Attack 5opencl
--------------
Attack 5opencl is an optimized OpenCL version based on 5gpu.
It runs on multi GPUs/CPUs and is faster than 5gpu.
2020-04-04 19:55:26 +08:00
Usage details: Attack 1
-----------------------
2020-01-16 18:11:14 +08:00
Attack 1 requires a valid tag and a valid encrypted nonce and challenge
response pair. The attacker needs to obtain a valid tag and then use this to
obtain a valid encrypted nonce and challenge response pair. This can be
2020-04-04 19:55:26 +08:00
achieved by using the Proxmark3 `lf hitag sniff` command, placing the coil on the RWD and
2020-01-16 18:11:14 +08:00
presenting the valid tag. The encrypted nonce and challenge response pairs
2021-09-15 01:52:05 +08:00
can then be read out.
_note_ the Proxmark3 hitag sniff command isn't good enough yet to collect the needed data.
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
**TODO** example
2021-09-15 01:52:05 +08:00
2020-04-04 19:55:26 +08:00
Usage details: Attack 2
-----------------------
2020-01-16 18:11:14 +08:00
Attack 2 requires the same resources as attack 1, plus a pre-computed table.
The table can be generated on a disk with >1.5TB of storage, although it takes
2020-04-04 19:55:26 +08:00
some time (allow a couple of days, privilege SSD). This can be
achieved by using the Proxmark3 `lf hitag sniff` command, placing the coil on the RWD and
presenting the valid tag. The encrypted nonce and challenge response pairs
2021-09-15 01:52:05 +08:00
can then be read out.
2020-04-04 19:55:26 +08:00
2021-09-15 01:52:05 +08:00
_note_ the Proxmark3 hitag sniff command isn't good enough yet to collect the needed data.
2020-04-04 19:55:26 +08:00
2021-09-15 01:52:05 +08:00
**TODO** example
2020-04-04 19:55:26 +08:00
Usage details: Attack 3
-----------------------
2020-01-16 18:11:14 +08:00
Attack 3 requires only interaction with the RWD and does not require a valid
tag, although it does require a HiTag2 tag that the RWD will initially respond
to; e.g. you could potentially use any HiTag2 tag as long as the RWD starts
the crypto handshake with it. It requires >=136 encrypted nonce and challenge
response pairs for the same tag UID.
2021-09-15 01:52:05 +08:00
_note_ the Proxmark3 hitag sniff command isn't good enough yet to collect the needed data.
2020-01-16 18:11:14 +08:00
2021-09-15 01:52:05 +08:00
**TODO** will be ht2 sim or sniff with actual tag ?
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
Usage details: Attack 4
-----------------------
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
Attack 4 requires the same information as attack 3, but only 16-32 encrypted
nonce and challenge response pairs are required.
2020-01-16 18:11:14 +08:00
2021-09-15 01:52:05 +08:00
_note_ the Proxmark3 hitag sniff command isn't good enough yet to collect the needed data.
2020-01-16 18:11:14 +08:00
2021-09-15 01:52:05 +08:00
**TODO** example
2020-01-16 18:11:14 +08:00
Usage details: Attack 5
-----------------------
Attack 5 requires two encrypted nonce and challenge
response value pairs (nR, aR) for the tag's UID.
2021-09-15 01:52:05 +08:00
**TODO** example
2021-01-14 06:37:10 +08:00
Usage details: Attack 5gpu/5opencl
----------------------------------
2021-01-14 18:33:29 +08:00
Attacks 5gpu and 5opencl require two encrypted nonce and challenge
response value pairs (nR, aR) for the tag's UID.
2021-09-15 01:52:05 +08:00
**TODO** example
2021-01-14 06:37:10 +08:00
2021-04-09 21:24:18 +08:00
5opencl supports a number of additional parameters, see [crack5opencl/README.md](/tools/hitag2crack/crack5opencl/README.md) for details.
2021-01-14 06:37:10 +08:00
2020-04-04 19:55:26 +08:00
Usage details: Next steps
-------------------------
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
Once the key has been recovered using one of these attacks, the Proxmark3 can
be configured to operate as a RWD and will capture tags using that key.
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
**TODO** example
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
Tags can be copied with standard Proxmark3 commands.
2020-01-16 18:11:14 +08:00
2020-04-04 19:55:26 +08:00
**TODO** example