From 0c2ef9d3a8145cf2b3717dc186a6c840b9f31654 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 18 Oct 2024 17:37:52 +0200 Subject: [PATCH] style --- armsrc/mifaresim.c | 40 ++++++++++++++++++++-------------------- client/src/cmdhfmf.c | 2 +- common_arm/flashmem.c | 4 ++-- doc/commands.json | 25 +++++++++++++++---------- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/armsrc/mifaresim.c b/armsrc/mifaresim.c index 77e321a09..6fb3287fa 100644 --- a/armsrc/mifaresim.c +++ b/armsrc/mifaresim.c @@ -831,9 +831,9 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 uint8_t nt_par_err = buf[(cardAUTHKEY * 8) + 2]; uint32_t nt_enc = bytes_to_num(response, 4); response_par[0] = ((((nt_par_err >> 3) & 1) ^ oddparity8((nt_enc >> 24) & 0xFF)) << 7 | - (((nt_par_err >> 2) & 1) ^ oddparity8((nt_enc >> 16) & 0xFF)) << 6 | - (((nt_par_err >> 1) & 1) ^ oddparity8((nt_enc >> 8) & 0xFF)) << 5 | - (((nt_par_err >> 0) & 1) ^ oddparity8((nt_enc >> 0) & 0xFF)) << 4); + (((nt_par_err >> 2) & 1) ^ oddparity8((nt_enc >> 16) & 0xFF)) << 6 | + (((nt_par_err >> 1) & 1) ^ oddparity8((nt_enc >> 8) & 0xFF)) << 5 | + (((nt_par_err >> 0) & 1) ^ oddparity8((nt_enc >> 0) & 0xFF)) << 4); ar_nr_resp[0].cuid = cuid; ar_nr_resp[0].sector = cardAUTHSC; ar_nr_resp[0].keytype = cardAUTHKEY; @@ -1192,7 +1192,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 (cardAUTHSC == ar_nr_resp[i].sector) && (cardAUTHKEY == ar_nr_resp[i].keytype) ) - ) { + ) { // if first auth for sector, or matches sector and keytype of previous auth if (ar_nr_resp[i].state != SECOND) { // if we haven't already collected 2 nonces for this sector @@ -1363,15 +1363,15 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 running_nested_auth_attack = false; if (g_dbglevel >= DBG_INFO) { Dbprintf("Collected nested AR/NR which can be used to extract sector %d " _YELLOW_("%s") - , ar_nr_resp[0].sector - , (ar_nr_resp[0].keytype == AUTHKEYA) ? "key A" : "key B" + , ar_nr_resp[0].sector + , (ar_nr_resp[0].keytype == AUTHKEYA) ? "key A" : "key B" ); Dbprintf("../tools/mfc/card_reader/mfkey32nested %08x %08x %08x %08x %08x", - ar_nr_resp[0].cuid, //UID - ar_nr_resp[0].nonce, //NT - ar_nr_resp[0].nonce2,//NT_ENC - ar_nr_resp[0].nr, //NR1 - ar_nr_resp[0].ar //AR1 + ar_nr_resp[0].cuid, //UID + ar_nr_resp[0].nonce, //NT + ar_nr_resp[0].nonce2,//NT_ENC + ar_nr_resp[0].nr, //NR1 + ar_nr_resp[0].ar //AR1 ); } } @@ -1383,17 +1383,17 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1 index = i; if (g_dbglevel >= DBG_INFO) { Dbprintf("Collected two pairs of AR/NR which can be used to extract sector %d " _YELLOW_("%s") - , ar_nr_resp[i].sector - , (ar_nr_resp[i].keytype == AUTHKEYA) ? "key A" : "key B" + , ar_nr_resp[i].sector + , (ar_nr_resp[i].keytype == AUTHKEYA) ? "key A" : "key B" ); Dbprintf("../tools/mfc/card_reader/mfkey32v2 %08x %08x %08x %08x %08x %08x %08x", - ar_nr_resp[i].cuid, //UID - ar_nr_resp[i].nonce, //NT - ar_nr_resp[i].nr, //NR1 - ar_nr_resp[i].ar, //AR1 - ar_nr_resp[i].nonce2,//NT2 - ar_nr_resp[i].nr2, //NR2 - ar_nr_resp[i].ar2 //AR2 + ar_nr_resp[i].cuid, //UID + ar_nr_resp[i].nonce, //NT + ar_nr_resp[i].nr, //NR1 + ar_nr_resp[i].ar, //AR1 + ar_nr_resp[i].nonce2,//NT2 + ar_nr_resp[i].nr2, //NR2 + ar_nr_resp[i].ar2 //AR2 ); } } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 094b2a410..10c4efc00 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -4067,7 +4067,7 @@ void readerAttack(sector_t *k_sector, size_t k_sectors_cnt, nonces_t data, bool if (setEmulatorMem) { uint8_t memBlock[16]; mfEmlGetMem(memBlock, (sector * 4) + 3, 1); - if ((memBlock[6]==0) && (memBlock[7]==0) && (memBlock[8]==0)) { + if ((memBlock[6] == 0) && (memBlock[7] == 0) && (memBlock[8] == 0)) { // ACL not yet set? memBlock[6] = 0xFF; memBlock[7] = 0x07; diff --git a/common_arm/flashmem.c b/common_arm/flashmem.c index 300571df4..33d7db2ad 100644 --- a/common_arm/flashmem.c +++ b/common_arm/flashmem.c @@ -385,8 +385,8 @@ void Flashmem_print_status(void) { break; default: Dbprintf(" Device ID............... " _YELLOW_("%02X / %02X (Winbond)"), - device_type.manufacturer_id, - device_type.device_id + device_type.manufacturer_id, + device_type.device_id ); break; } diff --git a/doc/commands.json b/doc/commands.json index 5a629a810..f28a7e93b 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1355,9 +1355,10 @@ "--skip ISO14443-3 select only (skip RATS)", "--ecp Use enhanced contactless polling", "--mag Use Apple magsafe polling", - "-@ continuous reader mode" + "-@ continuous reader mode", + "-w, --wait wait for card" ], - "usage": "hf 14a reader [-hks@] [--drop] [--skip] [--ecp] [--mag]" + "usage": "hf 14a reader [-hks@w] [--drop] [--skip] [--ecp] [--mag]" }, "hf 14a sim": { "command": "hf 14a sim", @@ -4590,12 +4591,14 @@ "-h, --help This help", "-a input key type is key A(def)", "-b input key type is key B", + "-c input key type is key A + offset", + "-k, --key key, 6 hex bytes, only for option -c", "--mini MIFARE Classic Mini / S20", "--1k MIFARE Classic 1k / S50 (def)", "--2k MIFARE Classic/Plus 2k", "--4k MIFARE Classic 4k / S70" ], - "usage": "hf mf ecfill [-hab] [--mini] [--1k] [--2k] [--4k]" + "usage": "hf mf ecfill [-hab] [-c ] [-k ] [--mini] [--1k] [--2k] [--4k]" }, "hf mf eclr": { "command": "hf mf eclr", @@ -5370,7 +5373,7 @@ "hf mf sim --1k -u 11223344556677 -> MIFARE Classic 1k with 7b UID", "hf mf sim --1k -u 11223344 -i -x -> Perform reader attack in interactive mode", "hf mf sim --2k -> MIFARE 2k", - "hf mf sim --4k -> MIFARE 4k" + "hf mf sim --4k -> MIFARE 4khf mf sim --1k -x -e --> Keep simulation running and populate with found reader keys" ], "offline": false, "options": [ @@ -5384,12 +5387,13 @@ "--sak Provide explicit SAK (1 bytes, overrides option t)", "-n, --num Automatically exit simulation after blocks have been read by reader. 0 = infinite", "-i, --interactive Console will not be returned until simulation finishes or is aborted", - "-x Performs the 'reader attack', nr/ar attack against a reader", - "-e, --emukeys Fill simulator keys from found keys", + "-x Performs the 'reader attack', nr/ar attack against a reader.", + "-y Performs the nested 'reader attack'. This requires preloading nt & nt_enc in emulator memory. Implies -x.", + "-e, --emukeys Fill simulator keys from found keys. Requires -x or -y. Implies -i. Simulation will restart automatically.", "-v, --verbose verbose output", "--cve trigger CVE 2021_0430" ], - "usage": "hf mf sim [-hixev] [-u ] [--mini] [--1k] [--2k] [--4k] [--atqa ] [--sak ] [-n ] [--cve]" + "usage": "hf mf sim [-hixyev] [-u ] [--mini] [--1k] [--2k] [--4k] [--atqa ] [--sak ] [-n ] [--cve]" }, "hf mf staticnested": { "command": "hf mf staticnested", @@ -12405,9 +12409,10 @@ ], "offline": true, "options": [ - "-h, --help This help" + "-h, --help This help", + "-j, --json Dump prefs as JSON" ], - "usage": "prefs show [-h]" + "usage": "prefs show [-hj]" }, "prefs set client.debug": { "command": "prefs set client.debug", @@ -12973,6 +12978,6 @@ "metadata": { "commands_extracted": 748, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2024-10-12T11:55:26" + "extracted_on": "2024-10-18T15:36:53" } }