fixed the magic detection , and improved the hints reporting MF Classic tags

This commit is contained in:
iceman1001 2024-02-21 23:23:54 +01:00
commit 490111ee47
3 changed files with 30 additions and 31 deletions

View file

@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Fixed `hf 14a info` - magic detection works again and better hint detection (@iceman1001)
- Added `hf 14b restore` - new command to restore dump files to a SR512/4k card (@Sonic803)
- Changed led show / leds detection for PM3 Easy devices (@francesco-scar)
## [DEFCON is Cancelled.4.18218][2024-02-18]
- Changed `hf fudan dump --ns` - now supports nosave flag (@iceman1001)

View file

@ -2030,7 +2030,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
isSEOS = ((nxptype & HID_SEOS) == HID_SEOS);
// generic catch, we assume MIFARE Classic for all unknown ISO14443a tags
isMifareClassic = ((nxptype & MTOTHER) == MTOTHER);
isMifareClassic |= ((nxptype & MTOTHER) == MTOTHER);
} else {
@ -2272,10 +2272,11 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
} else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
if ((card.atqa[0] & 0x02) == 0x02)
if ((card.atqa[0] & 0x02) == 0x02) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus S 2K (SL3)");
else if ((card.atqa[0] & 0x04) == 0x04)
} else if ((card.atqa[0] & 0x04) == 0x04) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus S 4K (SL3)");
}
} else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x00\xF6\xD1", 7) == 0) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus SE 1K (17pF)");
@ -2288,7 +2289,6 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
if ((card.sak & 0x20) == 0x20) { // and no GetVersion()..
if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) {
snprintf(tip + strlen(tip), sizeof(tip) - strlen(tip), _GREEN_("%s"), "MIFARE Plus X 2K (SL1)");
} else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) {
@ -2480,8 +2480,10 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
PrintAndLogEx(INFO, "--> SAK incorrectly claims that card supports RATS <--");
}
}
if (select_status == 1)
if (select_status == 1) {
select_status = 2;
}
}
if (setDeviceDebugLevel(verbose ? DBG_INFO : DBG_NONE, false) != PM3_SUCCESS) {
@ -2489,6 +2491,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
}
uint16_t isMagic = 0;
if (isMifareClassic) {
isMagic = detect_mf_magic(true, MF_KEY_B, 0xFFFFFFFFFFFF);
}
@ -2529,7 +2532,6 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
if (res == PM3_SUCCESS) {
mfc_ev1_print_signature(card.uid, card.uidlen, signature, sizeof(signature));
}
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`hf mf`") " commands");
}
if (setDeviceDebugLevel(dbg_curr, false) != PM3_SUCCESS) {
@ -2580,34 +2582,28 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
PrintAndLogEx(HINT, "Hint: try `" _YELLOW_("hf ntag424 info") "`");
}
if (isMifareClassic &&
(((isMagic & MAGIC_FLAG_GEN_1A) == MAGIC_FLAG_GEN_1A) || ((isMagic & MAGIC_FLAG_GEN_1B) == MAGIC_FLAG_GEN_1B))
) {
PrintAndLogEx(HINT, "Hint: use `" _YELLOW_("hf mf c*") "` commands when interacting");
}
if (isMifareClassic) {
if (((isMagic & MAGIC_FLAG_GEN_1A) == MAGIC_FLAG_GEN_1A) || ((isMagic & MAGIC_FLAG_GEN_1B) == MAGIC_FLAG_GEN_1B)) {
PrintAndLogEx(HINT, "Hint: use `" _YELLOW_("hf mf c*") "` commands when interacting");
}
if (isMifareClassic &&
((isMagic & MAGIC_FLAG_GEN_2) == MAGIC_FLAG_GEN_2)
) {
PrintAndLogEx(HINT, "Hint: Use normal `" _YELLOW_("hf mf") "` commands when interacting");
}
if ((isMagic & MAGIC_FLAG_GEN_3) == MAGIC_FLAG_GEN_3) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf gen3*") "` commands when interacting");
}
if (isMifareClassic &&
((isMagic & MAGIC_FLAG_GEN_3) == MAGIC_FLAG_GEN_3)
) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf gen3*") "` commands when interacting");
}
if ((isMagic & MAGIC_FLAG_GEN_4GTU) == MAGIC_FLAG_GEN_4GTU) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf g*") "` commands when interacting");
}
if (isMifareClassic &&
((isMagic & MAGIC_FLAG_GEN_4GTU) == MAGIC_FLAG_GEN_4GTU)
) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf g*") "` commands when interacting");
}
if ((isMagic & MAGIC_FLAG_GDM_AUTH) == MAGIC_FLAG_GDM_AUTH) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf gdm*") "` commands when interacting");
}
if (isMifareClassic &&
((isMagic & MAGIC_FLAG_GDM_AUTH) == MAGIC_FLAG_GDM_AUTH)
) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf gdm*") "` commands when interacting");
if ((isMagic & MAGIC_FLAG_GEN_2) == MAGIC_FLAG_GEN_2) {
PrintAndLogEx(HINT, "Hint: Use `" _YELLOW_("hf mf") "` commands when interacting");
} else {
PrintAndLogEx(HINT, "Hint: try " _YELLOW_("`hf mf`") " commands");
}
}
PrintAndLogEx(NORMAL, "");

View file

@ -1407,7 +1407,7 @@ uint16_t detect_mf_magic(bool is_mfc, uint8_t key_type, uint64_t key) {
uint16_t isMagic = MAGIC_FLAG_NONE;
if ((resp.status == PM3_SUCCESS) && resp.length == sizeof(uint16_t)) {
isMagic = resp.data.asDwords[0] & 0xFFFF;
isMagic = MemLeToUint2byte(resp.data.asBytes);
}
if ((isMagic & MAGIC_FLAG_GEN_1A) == MAGIC_FLAG_GEN_1A) {