RfidResearchGroup / proxmark3

Iceman Fork - Proxmark3
http://www.icedev.se
GNU General Public License v3.0
3.65k stars 981 forks source link

Misleading error message in hf mf ndefread or a bug in the code #2252

Closed phaseloop closed 5 months ago

phaseloop commented 6 months ago

Describe the bug

I'm running hf mf ndefread on a card which probably does not have MAD or is using non-standard key.

I'm getting an error:

error, read sector 0. card doesn't have MAD or doesn't have MAD on default keys [?] Try hf mf ndefread -k with your custom key

The problem is - MAD sector 0 is being read always using hardcoded MAD key and not key being provided by user and stored in ndefkey variable. Provided key is used to read only subsequent sectors (1..n).

Either there should be an option to provide additional MAD sector key or this error message should not suggest using -k switch.

I can fix this - I only need confirmation my thinking is right.

Relevant code part:

https://github.com/RfidResearchGroup/proxmark3/blob/master/client/src/cmdhfmf.c#L6014

This is output of reading my card using hf mf mad -k A8844B0BCA06 (yes I paste here my key, I don't care, lol).

[=] ------------ MAD v1 details -------------
[!!] 🚨 DA = 0! MAD not available
[!] ⚠️  Invalid Info byte (MAD1) value 0x10
[!] ⚠️  Card publisher not present 0xfffffff6

[=] ---------------- Listing ----------------
[=]  00 MAD v1
[=]  01 [2439] (unknown)
[=]  02 [0173] (unknown)
[=]  03 [0000] free
[=]  04 [0000] free
[=]  05 [0000] free
[=]  06 [0000] free
[=]  07 [C200] (unknown)
[=]  08 [0000] free
[=]  09 [0000] free
[=]  10 [0000] free
[=]  11 [0000] free
[=]  12 [0000] free
[=]  13 [0000] free
[=]  14 [0000] free
[=]  15 [B100] (unknown)
iceman1001 commented 6 months ago

Not a bug in that sense, it works on the assumption that S0 key must be the default mad key, if its not then they are breaking the ndef standard. I would say your tag is from a system that made a mistake or they actually want to break the standard and only their app can read the ndef records out of the box.

Wouldn't be too hard to override the first checks using user supplied key

phaseloop commented 5 months ago

Makes sense, thank you :)