You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both latest release and self-compiled from latest commit
Flashing method
flash.bat
Flash memory space
4Mbit (512 kB)
Makefile configuration
Default / removed Ultralight and NTAGs on self-compiled
Bug description
Dear chameleon revE rebooted team!
After flashing the latest firmware to the device, I noticed wrong keys being calculated using mfkey32 (reader attack). Tests were done in a controlled environment with a known key by repeatedly authenticating to a single sector. This is the Arduino code:
Chameleon was fully erased with a CLEARALL command before tests, slot 1 was configured as MF_CLASSIC_DETECTION and DETECTION? command returned all FFs and a checksum on the first run. After collecting nonces, the output changed to following:
The expected key was 010203302010, as in the sketch above. I know that 4K configuration isn't available for this mode, I was just experimenting, this is why you see block 240. The following behavior applies to all slots, all keys and all sectors. Only 2 last bytes always don't differ between real and expected outputs. The same function works with the stock firmware and the same newest rebootedGUI (backwards compatibility?). Can you help me to identify the problem? Thanks in advance!
Expected function and references
Working mfkey32 (reader) attack on newest firmware
Bug
Steps to Reproduce
Flash newest firmware
Set any slot configuration to MIFARE_CLASSIC_DETECTION
Obtain enough nonces with a known key
Compare mfkey32 execution result with expected output
Resolution paths
Ideas
Please note, that the last 2 bytes are always correct! Given that, I can assume that there is some nonce saving issue, which corrupts first nonces and thus the first part of the key
Possible Implementation
The text was updated successfully, but these errors were encountered:
So, the issue first appeared in the commit 6ec88b4, which was the last one to change MF_DETECTION implementation. Looks like moving it to working memory broke something and it didn't work properly any more. I temporarily fixed it by changing
in Configuration.c and renaming all AppWorkingMemory commands related to this mode back to AppCardMemory. Just look at the diff of the commit above for better understanding. This is a temporary fix, the real problem is somewhere in working memory
Okay, found the real problem. In MifareClassic.c you save DetectionCanary into working memory after UID and then read the whole block 0 from the same memory in CommandGetDetection function of Commands.c. The problem is that the UID is stored in card memory and you try to read it from working memory, where it never existed. Thus, on clear run the GUI becomes 8 bytes of FFs instead of the real UID (and SAK, ATQA, CRC). There are 2 solutions:
Move canary into card memory. Then you can read block 0 with a single AppCardMemoryRead function and get both UID and canary
Leave locations as they are and replace single AppWorkingMemoryRead function in CommandGetDetection (Commands.c) by AppCardMemoryRead to read first 8 bytes (UID, SAK, ATQA) from card memory and then AppWorkingMemoryRead to read the rest of block 0
Environment
Bug description
Dear chameleon revE rebooted team!
After flashing the latest firmware to the device, I noticed wrong keys being calculated using mfkey32 (reader attack). Tests were done in a controlled environment with a known key by repeatedly authenticating to a single sector. This is the Arduino code:
Chameleon was fully erased with a
CLEARALL
command before tests, slot 1 was configured asMF_CLASSIC_DETECTION
andDETECTION?
command returned allFF
s and a checksum on the first run. After collecting nonces, the output changed to following:After running mfkey32 I got the following result:
The expected key was
010203302010
, as in the sketch above. I know that 4K configuration isn't available for this mode, I was just experimenting, this is why you see block 240. The following behavior applies to all slots, all keys and all sectors. Only 2 last bytes always don't differ between real and expected outputs. The same function works with the stock firmware and the same newest rebootedGUI (backwards compatibility?). Can you help me to identify the problem? Thanks in advance!Expected function and references
Working mfkey32 (reader) attack on newest firmware
Bug
Steps to Reproduce
MIFARE_CLASSIC_DETECTION
Resolution paths
Ideas
Please note, that the last 2 bytes are always correct! Given that, I can assume that there is some nonce saving issue, which corrupts first nonces and thus the first part of the key
Possible Implementation
The text was updated successfully, but these errors were encountered: