From 3a3ea75d1273a1cf8725211527c211c5668c3b64 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 15 Nov 2024 14:28:14 +0100 Subject: [PATCH] style --- armsrc/appmain.c | 6 +- armsrc/iclass.c | 2 +- armsrc/iso14443a.c | 6 +- armsrc/iso14443a.h | 2 +- armsrc/mifarecmd.c | 130 +++++++++++++++--------------- client/pyscripts/fm11rf08_full.py | 2 +- client/src/cmdhficlass.c | 16 ++-- client/src/cmdhfmf.c | 60 +++++++------- client/src/cmdpiv.c | 2 +- doc/commands.json | 22 +++-- doc/commands.md | 2 +- 11 files changed, 124 insertions(+), 126 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index f6e78e747..e019f14a5 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1656,9 +1656,9 @@ static void PacketReceived(PacketCommandNG *packet) { bool enumerate; } PACKED; struct p *payload = (struct p *) packet->data.asBytes; - SimulateIso14443aTagAID(payload->tagtype, payload->flags, payload->uid, - payload->rats, sizeof(payload->rats), payload->aid, payload->response, - payload->apdu, payload->aid_len, payload->respond_len, + SimulateIso14443aTagAID(payload->tagtype, payload->flags, payload->uid, + payload->rats, sizeof(payload->rats), payload->aid, payload->response, + payload->apdu, payload->aid_len, payload->respond_len, payload->apdu_len, payload->enumerate); // ## Simulate iso14443a tag - pass tag type, UID, rats, aid, resp, apdu break; } diff --git a/armsrc/iclass.c b/armsrc/iclass.c index 94a4746ea..ec6578ded 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -2168,7 +2168,7 @@ static void generate_single_key_block_inverted_opt(const uint8_t *startingKey, u 0x95, 0x96, 0x99, 0x9A, 0x9C, 0xA3, 0xA5, 0xA6, 0xA9, 0xAA, 0xAC, 0xB1, 0xB2, 0xB4, 0xB8, 0xC3, 0xC5, 0xC6, 0xC9, 0xCA, 0xCC, 0xD1, 0xD2, 0xD4, 0xD8, 0xE1, 0xE2, 0xE4, 0xE8, 0xF0 - }; + }; uint8_t binary_endings[8]; // Array to store binary values for each ending bit // Extract each bit from the ending_bits[k] and store it in binary_endings diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 6993fe2fd..d02055b0d 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1108,7 +1108,7 @@ bool prepare_allocated_tag_modulation(tag_response_info_t *response_info, uint8_ } } -bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, +bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, uint8_t *iRATs, size_t irats_len, tag_response_info_t **responses, uint32_t *cuid, uint32_t counters[3], uint8_t tearings[3], uint8_t *pages) { uint8_t sak = 0; @@ -1272,7 +1272,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, } } - // copy the iRATs if supplied. + // copy the iRATs if supplied. // iRATs is a pointer to 20 byte array // rRATS is a 40 byte array if ((flags & FLAG_RATS_IN_DATA) == FLAG_RATS_IN_DATA) { @@ -1283,7 +1283,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, // Even if RATS protocol defined as max 40 bytes doesn't mean people try stuff if (rRATS_len > sizeof(rRATS)) { if (g_dbglevel >= DBG_ERROR) Dbprintf("[-] ERROR: iRATS overflow. Max %zu, got %zu", sizeof(rRATS), rRATS_len); - return false; + return false; } } diff --git a/armsrc/iso14443a.h b/armsrc/iso14443a.h index e50e0face..24b388252 100644 --- a/armsrc/iso14443a.h +++ b/armsrc/iso14443a.h @@ -149,7 +149,7 @@ void SimulateIso14443aTagAID(uint8_t tagType, uint16_t flags, uint8_t *data, uint8_t *iRATs, size_t irats_len, uint8_t *aid, uint8_t *resp, uint8_t *apdu, int aid_len, int respond_len, int apdu_len, bool enumerate); -bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, +bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, uint8_t *iRATs, size_t irats_len, tag_response_info_t **responses, uint32_t *cuid, uint32_t counters[3], uint8_t tearings[3], uint8_t *pages); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 5ebc43acd..715b69132 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -3128,82 +3128,82 @@ void MifareHasStaticEncryptedNonce(uint8_t block_no, uint8_t key_type, uint8_t * }; first_nt_counter++; } else for (uint8_t i = 0; i < nr_nested; i++) { - if (need_first_auth) { - cuid = 0; + if (need_first_auth) { + cuid = 0; - if (hardreset) { - if (g_dbglevel >= DBG_EXTENDED) { - Dbprintf("RF reset"); + if (hardreset) { + if (g_dbglevel >= DBG_EXTENDED) { + Dbprintf("RF reset"); + } + // some cards need longer than mf_reset_card() to see effect on nT + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + SpinDelay(150); + iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); } - // some cards need longer than mf_reset_card() to see effect on nT - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - SpinDelay(150); - iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); - } - if (g_dbglevel >= DBG_EXTENDED) { - Dbprintf("select"); - } - if (iso14443a_select_card(NULL, NULL, &cuid, true, 0, true) == false) { - retval = PM3_ESOFT; - goto OUT; - } - if (mifare_classic_authex_cmd(pcs, cuid, block_no, key_auth_cmd, ui64key, AUTH_FIRST, &nt_first, NULL, NULL, NULL, corruptnrar, corruptnrarparity)) { - if (g_dbglevel >= DBG_ERROR) Dbprintf("Auth error"); - retval = PM3_ESOFT; - goto OUT; - }; - is_last_auth_first_auth = true; - first_nt_counter++; - if ((first_nt_counter > 1) && (old_nt_first == nt_first)) { - first_nt_repetition_counter++; - } - old_nt_first = nt_first; - if (!reset && !hardreset) { - need_first_auth = false; - } - if (addread) { - uint8_t dataread[16] = {0x00}; - mifare_classic_readblock(pcs, block_no, dataread); - } - if (addauth) { - if (mifare_classic_authex_cmd(pcs, cuid, block_no, key_auth_cmd, ui64key, AUTH_NESTED, &nt, NULL, NULL, NULL, false, false)) { + if (g_dbglevel >= DBG_EXTENDED) { + Dbprintf("select"); + } + if (iso14443a_select_card(NULL, NULL, &cuid, true, 0, true) == false) { + retval = PM3_ESOFT; + goto OUT; + } + if (mifare_classic_authex_cmd(pcs, cuid, block_no, key_auth_cmd, ui64key, AUTH_FIRST, &nt_first, NULL, NULL, NULL, corruptnrar, corruptnrarparity)) { if (g_dbglevel >= DBG_ERROR) Dbprintf("Auth error"); retval = PM3_ESOFT; goto OUT; - } else if (g_dbglevel >= DBG_EXTENDED) { - Dbprintf("Nonce distance: %5i (first nonce <> nested nonce)", nonce_distance(nt_first, nt)); + }; + is_last_auth_first_auth = true; + first_nt_counter++; + if ((first_nt_counter > 1) && (old_nt_first == nt_first)) { + first_nt_repetition_counter++; } - is_last_auth_first_auth = false; - if (nt == nt_first) { - first_and_nested_nt_repetition_counter++; + old_nt_first = nt_first; + if (!reset && !hardreset) { + need_first_auth = false; + } + if (addread) { + uint8_t dataread[16] = {0x00}; + mifare_classic_readblock(pcs, block_no, dataread); + } + if (addauth) { + if (mifare_classic_authex_cmd(pcs, cuid, block_no, key_auth_cmd, ui64key, AUTH_NESTED, &nt, NULL, NULL, NULL, false, false)) { + if (g_dbglevel >= DBG_ERROR) Dbprintf("Auth error"); + retval = PM3_ESOFT; + goto OUT; + } else if (g_dbglevel >= DBG_EXTENDED) { + Dbprintf("Nonce distance: %5i (first nonce <> nested nonce)", nonce_distance(nt_first, nt)); + } + is_last_auth_first_auth = false; + if (nt == nt_first) { + first_and_nested_nt_repetition_counter++; + } + old_nt = nt; } - old_nt = nt; } - } - nt = 0; - ntenc = 0; - if (mifare_classic_authex_cmd(pcs, cuid, incblk2 ? block_no_nested + (i * 4) : block_no_nested, key_auth_cmd_nested, ui64key_nested, AUTH_NESTED, &nt, &ntenc, &ntencpar, NULL, false, false)) { - if (g_dbglevel >= DBG_ERROR) Dbprintf("Nested auth error"); - need_first_auth = true; - } else if (g_dbglevel >= DBG_EXTENDED) { - if (is_last_auth_first_auth) { - Dbprintf("Nonce distance: %5i (first nonce <> nested nonce)", nonce_distance(nt_first, nt)); - } else { - Dbprintf("Nonce distance: %5i", nonce_distance(old_nt, nt)); + nt = 0; + ntenc = 0; + if (mifare_classic_authex_cmd(pcs, cuid, incblk2 ? block_no_nested + (i * 4) : block_no_nested, key_auth_cmd_nested, ui64key_nested, AUTH_NESTED, &nt, &ntenc, &ntencpar, NULL, false, false)) { + if (g_dbglevel >= DBG_ERROR) Dbprintf("Nested auth error"); + need_first_auth = true; + } else if (g_dbglevel >= DBG_EXTENDED) { + if (is_last_auth_first_auth) { + Dbprintf("Nonce distance: %5i (first nonce <> nested nonce)", nonce_distance(nt_first, nt)); + } else { + Dbprintf("Nonce distance: %5i", nonce_distance(old_nt, nt)); + } } + nested_nt_session_counter++; + is_last_auth_first_auth = false; + old_nt = nt; + if (nt == nt_first) { + first_and_nested_nt_repetition_counter++; + } + if ((nested_nt_session_counter > 1) && (oldntenc == ntenc)) { + nested_nt_repetition_counter++; + } + oldntenc = ntenc; } - nested_nt_session_counter++; - is_last_auth_first_auth = false; - old_nt = nt; - if (nt == nt_first) { - first_and_nested_nt_repetition_counter++; - } - if ((nested_nt_session_counter > 1) && (oldntenc == ntenc)) { - nested_nt_repetition_counter++; - } - oldntenc = ntenc; - } data[1] = (cuid >> 24) & 0xFF; data[2] = (cuid >> 16) & 0xFF; diff --git a/client/pyscripts/fm11rf08_full.py b/client/pyscripts/fm11rf08_full.py index 7fbb0511a..e684f904d 100644 --- a/client/pyscripts/fm11rf08_full.py +++ b/client/pyscripts/fm11rf08_full.py @@ -162,7 +162,7 @@ globals: dumpData(data, blkn) - # FIXME: nr of blocks depend on the tag. RF32 is 256, RF08 is 64, RF08S is 64+8, + # FIXME: nr of blocks depend on the tag. RF32 is 256, RF08 is 64, RF08S is 64+8, # Currently dumpAcl is hardcoded for RF08S dumpAcl(data) diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 775610e4f..bb95d9a4b 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -483,7 +483,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )"); //Block 13 (This is needed for Rev.C readers!) - uint8_t block_0x13[PICOPASS_BLOCK_SIZE] = {0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x1C}; + uint8_t block_0x13[PICOPASS_BLOCK_SIZE] = {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C}; memcpy(data + (0x13 * 8), block_0x13, sizeof(block_0x13)); // encrypted partial keyroll key 14 @@ -536,7 +536,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke } else { memcpy(data, cc, sizeof(picopass_hdr_t)); memcpy(data + (6 * 8), o->data, sizeof(o->data)); - if (strstr(o->desc, "Custom") != NULL){ + if (strstr(o->desc, "Custom") != NULL) { if (got_mk == false) { PrintAndLogEx(ERR, "please specify New Master Key!"); free(data); @@ -5066,16 +5066,16 @@ static int CmdHFiClassConfigCard(const char *Cmd) { if (ccidx > -1 && ccidx < ARRAYLEN(iclass_config_options)) { const iclass_config_card_item_t *item = get_config_card_item(ccidx); if (strstr(item->desc, "ELITE") != NULL && got_kr == false) { - PrintAndLogEx(ERR, "please specify ELITE Key (--eki) !"); - return PM3_EINVARG; + PrintAndLogEx(ERR, "please specify ELITE Key (--eki) !"); + return PM3_EINVARG; } if (strstr(item->desc, "Custom") != NULL && got_mk == false) { - PrintAndLogEx(ERR, "please specify New Standard Master Key (--mrki) !"); - return PM3_EINVARG; + PrintAndLogEx(ERR, "please specify New Standard Master Key (--mrki) !"); + return PM3_EINVARG; } if (strstr(item->desc, "Restore") != NULL && card_kidx == -1) { - PrintAndLogEx(ERR, "please specify the Current Reader's Key (--ki) !"); - return PM3_EINVARG; + PrintAndLogEx(ERR, "please specify the Current Reader's Key (--ki) !"); + return PM3_EINVARG; } generate_config_card(item, keyroll_key, got_kr, card_key, got_eki, elite, got_mk, master_key); } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index c9bef038b..fdbd2ffb7 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -250,9 +250,9 @@ bool mfc_value(const uint8_t *d, int32_t *val) { uint32_t b = MemLeToUint4byte(d + 8); int val_checks = ( - (a == b) && (a == ~a_inv) && - (d[12] == (~d[13] & 0xFF)) && - (d[14] == (~d[15] & 0xFF)) + (a == b) && (a == ~a_inv) && + (d[12] == (~d[13] & 0xFF)) && + (d[14] == (~d[15] & 0xFF)) ); if (val) { @@ -1602,7 +1602,7 @@ static int CmdHF14AMfRestore(const char *Cmd) { PrintAndLogEx(INFO, " %3d | %s| ( " _RED_("fail") " ) key " _YELLOW_("%c"), blockno, sprint_hex(bldata, sizeof(bldata)), - (kt == MF_KEY_A) ? 'A' : 'B' + (kt == MF_KEY_A) ? 'A' : 'B' ); } // end loop key types } // end loop B @@ -2963,7 +2963,7 @@ noValidKeyFound: PrintAndLogEx(INFO, "======================= " _YELLOW_("START READ B KEY ATTACK") " ======================="); PrintAndLogEx(INFO, "reading B key of sector %3d with key type %c", current_sector_i, - (current_key_type_i == MF_KEY_B) ? 'B' : 'A'); + (current_key_type_i == MF_KEY_B) ? 'B' : 'A'); } uint8_t sectrail = (mfFirstBlockOfSector(current_sector_i) + mfNumBlocksPerSector(current_sector_i) - 1); @@ -2995,7 +2995,7 @@ noValidKeyFound: if (verbose) { PrintAndLogEx(WARNING, "unknown B key: sector: %3d key type: %c", current_sector_i, - (current_key_type_i == MF_KEY_B) ? 'B' : 'A' + (current_key_type_i == MF_KEY_B) ? 'B' : 'A' ); PrintAndLogEx(INFO, " -- reading the B key was not possible, maybe due to access rights?"); @@ -3018,7 +3018,7 @@ skipReadBKey: PrintAndLogEx(INFO, "======================= " _YELLOW_("START NESTED ATTACK") " ======================="); PrintAndLogEx(INFO, "sector no %3d, target key type %c", current_sector_i, - (current_key_type_i == MF_KEY_B) ? 'B' : 'A'); + (current_key_type_i == MF_KEY_B) ? 'B' : 'A'); } tryNested: isOK = mf_nested(mfFirstBlockOfSector(sectorno), keytype, key, mfFirstBlockOfSector(current_sector_i), current_key_type_i, tmp_key, calibrate); @@ -3144,7 +3144,7 @@ tryStaticnested: PrintAndLogEx(INFO, "======================= " _YELLOW_("START STATIC NESTED ATTACK") " ======================="); PrintAndLogEx(INFO, "sector no %3d, target key type %c", current_sector_i, - (current_key_type_i == MF_KEY_B) ? 'B' : 'A'); + (current_key_type_i == MF_KEY_B) ? 'B' : 'A'); } isOK = mf_static_nested(mfFirstBlockOfSector(sectorno), keytype, key, mfFirstBlockOfSector(current_sector_i), current_key_type_i, tmp_key); @@ -4424,7 +4424,7 @@ void printKeyTableEx(size_t sectorscnt, sector_t *e_sector, uint8_t start_sector _YELLOW_("H") ":Hardnested / " _YELLOW_("C") ":statiCnested / " _YELLOW_("A") ":keyA " - " )" + " )" ); if (sectorscnt == 18) { PrintAndLogEx(INFO, "( " _MAGENTA_("*") " ) These sectors used for signature. Lays outside of user memory"); @@ -5212,7 +5212,7 @@ static int CmdHF14AMfCSetUID(const char *Cmd) { PrintAndLogEx(SUCCESS, "Old UID... %s", sprint_hex(old_uid, uidlen)); PrintAndLogEx(SUCCESS, "New UID... %s ( %s )", sprint_hex(verify_uid, uidlen), - (res == 0) ? _GREEN_("verified") : _RED_("fail") + (res == 0) ? _GREEN_("verified") : _RED_("fail") ); return PM3_SUCCESS; } @@ -6603,10 +6603,10 @@ int CmdHFMFNDEFFormat(const char *Cmd) { "If not, it will try finding a key file based on your UID. ie, if you ran autopwn before", "hf mf ndefformat\n" // "hf mf ndefformat --mini --> MIFARE Mini\n" - "hf mf ndefformat --1k --> MIFARE Classic 1k\n" + "hf mf ndefformat --1k --> MIFARE Classic 1k\n" // "hf mf ndefformat --2k --> MIFARE 2k\n" // "hf mf ndefformat --4k --> MIFARE 4k\n" - "hf mf ndefformat --keys hf-mf-01020304-key.bin --> MIFARE 1k with keys from specified file\n" + "hf mf ndefformat --keys hf-mf-01020304-key.bin --> MIFARE 1k with keys from specified file\n" ); void *argtable[] = { @@ -9258,7 +9258,7 @@ static int CmdHF14AMfValue(const char *Cmd) { // don't want to write value data and break something if ((blockno == 0) || (mfIsSectorTrailer(blockno)) || - (trnval == 0) || + (trnval == 0) || (trnval != -1 && mfIsSectorTrailer(trnval))) { PrintAndLogEx(WARNING, "invalid block number, should be a data block"); return PM3_EINVARG; @@ -9695,47 +9695,47 @@ static int CmdHF14AMfInfo(const char *Cmd) { // backdoor might be present, or just a clone reusing Fudan MF data... PrintAndLogEx(SUCCESS, "Fudan based card"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08s, sizeof(fkey)) == 0 - && card.sak == 0x08 && memcmp(blockdata + 5, "\x08\x04\x00", 3) == 0 - && (blockdata[8] == 0x03 || blockdata[8] == 0x04) && blockdata[15] == 0x90) { + && card.sak == 0x08 && memcmp(blockdata + 5, "\x08\x04\x00", 3) == 0 + && (blockdata[8] == 0x03 || blockdata[8] == 0x04) && blockdata[15] == 0x90) { PrintAndLogEx(SUCCESS, "Fudan FM11RF08S"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08s, sizeof(fkey)) == 0 - && card.sak == 0x08 && memcmp(blockdata + 5, "\x00\x03\x00\x10", 4) == 0 - && blockdata[15] == 0x90) { + && card.sak == 0x08 && memcmp(blockdata + 5, "\x00\x03\x00\x10", 4) == 0 + && blockdata[15] == 0x90) { PrintAndLogEx(SUCCESS, "Fudan FM11RF08S-7B"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x08 && memcmp(blockdata + 5, "\x08\x04\x00", 3) == 0 - && blockdata[15] == 0x98) { + && card.sak == 0x08 && memcmp(blockdata + 5, "\x08\x04\x00", 3) == 0 + && blockdata[15] == 0x98) { PrintAndLogEx(SUCCESS, "Fudan FM11RF08S **98"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x08 && memcmp(blockdata + 5, "\x08\x04\x00", 3) == 0 - && (blockdata[8] >= 0x01 && blockdata[8] <= 0x03) && blockdata[15] == 0x1D) { + && card.sak == 0x08 && memcmp(blockdata + 5, "\x08\x04\x00", 3) == 0 + && (blockdata[8] >= 0x01 && blockdata[8] <= 0x03) && blockdata[15] == 0x1D) { PrintAndLogEx(SUCCESS, "Fudan FM11RF08"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k32, sizeof(fkey)) == 0 - && card.sak == 0x18 && memcmp(blockdata + 5, "\x18\x02\x00\x46\x44\x53\x37\x30\x56\x30\x31", 11) == 0) { + && card.sak == 0x18 && memcmp(blockdata + 5, "\x18\x02\x00\x46\x44\x53\x37\x30\x56\x30\x31", 11) == 0) { PrintAndLogEx(SUCCESS, "Fudan FM11RF32"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x20 && memcmp(blockdata + 8, "\x62\x63\x64\x65\x66\x67\x68\x69", 8) == 0) { + && card.sak == 0x20 && memcmp(blockdata + 8, "\x62\x63\x64\x65\x66\x67\x68\x69", 8) == 0) { PrintAndLogEx(SUCCESS, "Fudan FM11RF32 (SAK=20)"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x28 && ( - (memcmp(blockdata + 5, "\x28\x04\x00\x90\x10\x15\x01\x00\x00\x00\x00", 11) == 0) || - (memcmp(blockdata + 5, "\x28\x04\x00\x90\x11\x15\x01\x00\x00\x00\x00", 11) == 0))) { + && card.sak == 0x28 && ( + (memcmp(blockdata + 5, "\x28\x04\x00\x90\x10\x15\x01\x00\x00\x00\x00", 11) == 0) || + (memcmp(blockdata + 5, "\x28\x04\x00\x90\x11\x15\x01\x00\x00\x00\x00", 11) == 0))) { // Note: it also has ATS = // 10 78 80 90 02 20 90 00 00 00 00 00 + UID + CRC PrintAndLogEx(SUCCESS, "Fudan FM1208-10"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x28 && memcmp(blockdata + 5, "\x28\x04\x00\x90\x53\xB7\x0C\x00\x00\x00\x00", 11) == 0) { + && card.sak == 0x28 && memcmp(blockdata + 5, "\x28\x04\x00\x90\x53\xB7\x0C\x00\x00\x00\x00", 11) == 0) { // Note: it also has ATS = // 10 78 80 B0 02 20 90 00 00 00 00 00 + UID + CRC PrintAndLogEx(SUCCESS, "Fudan FM1216-137"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x88 && memcmp(blockdata + 5, "\x88\x04\x00\x43", 4) == 0) { + && card.sak == 0x88 && memcmp(blockdata + 5, "\x88\x04\x00\x43", 4) == 0) { PrintAndLogEx(SUCCESS, "Infineon SLE66R35"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x44", 4) == 0) { + && card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x44", 4) == 0) { PrintAndLogEx(SUCCESS, "NXP MF1ICS5003"); } else if (fKeyType == MF_KEY_BD && memcmp(fkey, k08, sizeof(fkey)) == 0 - && card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x45", 4) == 0) { + && card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x45", 4) == 0) { PrintAndLogEx(SUCCESS, "NXP MF1ICS5004"); } else if (fKeyType == MF_KEY_BD) { PrintAndLogEx(SUCCESS, _RED_("Unknown card with backdoor, please report details!")); diff --git a/client/src/cmdpiv.c b/client/src/cmdpiv.c index abd464045..4c297124b 100644 --- a/client/src/cmdpiv.c +++ b/client/src/cmdpiv.c @@ -466,7 +466,7 @@ static void piv_print_fascn(const uint8_t *buf, const size_t len, int level) { PrintAndLogEx(NORMAL, "%s" NOLF, encoded[tmp & 0x1f]); } uint8_t lrc = buf[24] & 0x1f; - PrintAndLogEx(NORMAL, " LRC=[" _YELLOW_("%02" PRIx8 ) "]", lrc); + PrintAndLogEx(NORMAL, " LRC=[" _YELLOW_("%02" PRIx8) "]", lrc); } static bool piv_tag_dump(const struct tlv *tlv, int level) { diff --git a/doc/commands.json b/doc/commands.json index 1e9a8909a..d4c4bcd5b 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -3242,23 +3242,20 @@ "command": "hf iclass configcard", "description": "Manage reader configuration card via Cardhelper or internal database, The generated config card will be uploaded to device emulator memory. You can start simulating `hf iclass sim -t 3` or use the emul commands", "notes": [ - "hf iclass configcard -l -> download config card settings from cardhelper", "hf iclass configcard -p -> print all config cards in the database", - "hf iclass configcard --ci 1 -> view config card setting in slot 1", - "hf iclass configcard -g --ci 0 -> generate config file from slot 0" + "hf iclass configcard --g 0 -> generate config file with option 0" ], "offline": false, "options": [ "-h, --help This help", - "--ci use config slot at index", + "--g use config option", "--ki Card Key - index to select key from memory 'hf iclass managekeys'", - "--krki Elite Keyroll Key - index to select key from memory 'hf iclass managekeys'", + "--eki Elite Key - index to select key from memory 'hf iclass managekeys'", + "--mrki Standard Master Key - index to select key from memory 'hf iclass managekeys'", "--elite Use elite key for the the Card Key ki", - "-g generate card dump file", - "-l load available cards", "-p print available cards" ], - "usage": "hf iclass configcard [-hglp] [--ci ] [--ki ] [--krki ] [--elite]" + "usage": "hf iclass configcard [-hp] [--g ] [--ki ] [--eki ] [--mrki ] [--elite]" }, "hf iclass creditepurse": { "command": "hf iclass creditepurse", @@ -5175,9 +5172,10 @@ "-b, --keyb use key B for access printing sectors (by default: key A)", "--be (optional, BigEndian)", "--dch decode Card Holder information", - "-f, --file load dump file and decode MAD" + "-f, --file load dump file and decode MAD", + "--force force decode (skip key check)" ], - "usage": "hf mf mad [-hvb] [--aid ] [-k ] [--be] [--dch] [-f ]" + "usage": "hf mf mad [-hvb] [--aid ] [-k ] [--be] [--dch] [-f ] [--force]" }, "hf mf nack": { "command": "hf mf nack", @@ -12244,7 +12242,7 @@ "--aid Applet ID to select. By default A0000003080000100 will be used", "--nonce Nonce to sign.", "--slot Slot number. Default will be 0x9E (card auth cert).", - "--alg Algorithm to use to sign. Example values: 06=RSA-1024, 07=RSA-2048, 11=ECC-P256 (default), 14=ECC-P384" + "--alg Algorithm to use to sign. Example values: 06=RSA-1024, 07=RSA-2048, 17=ECC-P256 (default), 20=ECC-P384" ], "usage": "piv sign [-hskatw] [--aid ] --nonce [--slot ] [--alg ]" }, @@ -13005,6 +13003,6 @@ "metadata": { "commands_extracted": 749, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2024-11-02T14:09:48" + "extracted_on": "2024-11-15T13:26:34" } } diff --git a/doc/commands.md b/doc/commands.md index c78c4aea1..bf9b82edc 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -413,7 +413,7 @@ Check column "offline" for their availability. |`hf iclass esave `|N |`Save emulator memory to file` |`hf iclass esetblk `|N |`Set emulator memory block data` |`hf iclass eview `|N |`View emulator memory` -|`hf iclass configcard `|N |`Reader configuration card` +|`hf iclass configcard `|N |`Reader configuration card generator` |`hf iclass calcnewkey `|Y |`Calc diversified keys (blocks 3 & 4) to write new keys` |`hf iclass encode `|Y |`Encode binary wiegand to block 7` |`hf iclass encrypt `|Y |`Encrypt given block data`