From 8293b8121708ae8a55b6221faa523386b2d9ad08 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 12 Oct 2024 13:56:17 +0200 Subject: [PATCH] style --- client/pyscripts/mf_backdoor_dump.py | 10 ++++----- client/src/cmdhf14b.c | 10 ++++----- client/src/cmdlfem410x.c | 2 +- client/src/cmdlfhitaghts.c | 28 +++++++++++------------ client/src/fileutils.c | 4 ++-- client/src/fileutils.h | 2 +- client/src/pm3line_vocabulary.h | 1 + doc/commands.json | 33 +++++++++++++++++++++------- doc/commands.md | 5 +++-- 9 files changed, 57 insertions(+), 38 deletions(-) diff --git a/client/pyscripts/mf_backdoor_dump.py b/client/pyscripts/mf_backdoor_dump.py index c018a87db..768622bae 100644 --- a/client/pyscripts/mf_backdoor_dump.py +++ b/client/pyscripts/mf_backdoor_dump.py @@ -24,7 +24,7 @@ p = pm3.pm3() for bk in BACKDOOR_KEYS: p.console(f"hf mf rdbl -c 4 --blk 0 --key {bk}") output = p.grabbed_output.split('\n') - + if "auth error" in output[0].lower(): continue elif "can't select card" in output[0].lower(): @@ -37,7 +37,7 @@ for bk in BACKDOOR_KEYS: else: WORKING_KEY = bk break - + if not WORKING_KEY: print("None of the backdoor keys seem to work with this tag.") exit() @@ -52,7 +52,7 @@ header = False # Read every sector for i in range(TOTAL_SECTORS): p.console(f"hf mf rdsc -c 4 --key {WORKING_KEY} -s {i}") - + start = False for line in p.grabbed_output.split('\n'): if not header: @@ -60,11 +60,11 @@ for i in range(TOTAL_SECTORS): elif start and len(line) > 0: print(line) continue - + if "----------" in line: start = True header = True continue else: continue - + diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 5fa9037b9..43eeff9fc 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -465,10 +465,10 @@ static int print_atqb_resp(uint8_t *data, uint8_t cid) { PrintAndLogEx(SUCCESS, "Tag :"); PrintAndLogEx(SUCCESS, " Max Buf Length: %u (MBLI) %s", cid >> 4, (cid & 0xF0) ? "" : "chained frames not supported"); PrintAndLogEx(SUCCESS, " CID : %u", cid & 0x0f); - PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "--- " _CYAN_("Fingerprint")); - if (memcmp(data, "\x54\x43\x4F\x53",4) == 0) { + if (memcmp(data, "\x54\x43\x4F\x53", 4) == 0) { int outlen = 0; uint8_t out[PM3_CMD_DATA_SIZE] = {0}; @@ -479,7 +479,7 @@ static int print_atqb_resp(uint8_t *data, uint8_t cid) { } else { PrintAndLogEx(SUCCESS, "Tiananxin TCOS CPU card... " _RED_("n/a")); } - PrintAndLogEx(SUCCESS, "Magic capabilities........ most likely"); + PrintAndLogEx(SUCCESS, "Magic capabilities........ most likely"); } } else { @@ -2935,8 +2935,8 @@ static int CmdHF14BSetUID(const char *Cmd) { return switch_off_field_14b(); } - iso14b_card_select_t *card = (iso14b_card_select_t*)select; - if (memcmp(card->atqb, "\x54\x43\x4F\x53", 4) ) { + iso14b_card_select_t *card = (iso14b_card_select_t *)select; + if (memcmp(card->atqb, "\x54\x43\x4F\x53", 4)) { PrintAndLogEx(FAILED, "None supported tag"); PrintAndLogEx(NORMAL, ""); return switch_off_field_14b(); diff --git a/client/src/cmdlfem410x.c b/client/src/cmdlfem410x.c index 891773d4e..1acebd6ab 100644 --- a/client/src/cmdlfem410x.c +++ b/client/src/cmdlfem410x.c @@ -529,7 +529,7 @@ static int CmdEM410xBrute(const char *Cmd) { // load keys uint8_t *uidblock = NULL; uint32_t uidcount = 0; - int res = loadFileDICTIONARY_safe_ex(filename, suffix, (void**)&uidblock, 5, &uidcount, false); + int res = loadFileDICTIONARY_safe_ex(filename, suffix, (void **)&uidblock, 5, &uidcount, false); if (res != PM3_SUCCESS) { free(uidblock); return res; diff --git a/client/src/cmdlfhitaghts.c b/client/src/cmdlfhitaghts.c index 147f5989f..12a80dc62 100644 --- a/client/src/cmdlfhitaghts.c +++ b/client/src/cmdlfhitaghts.c @@ -210,8 +210,8 @@ static void print_error(int8_t reason) { PrintAndLogEx(FAILED, "Write to page failed!"); break; default: - // PM3_REASON_UNKNOWN - PrintAndLogEx(DEBUG, "DEBUG: Error - Hitag S failed"); + // PM3_REASON_UNKNOWN + PrintAndLogEx(DEBUG, "DEBUG: Error - Hitag S failed"); } } @@ -296,7 +296,7 @@ static int CmdLFHitagSRead(const char *Cmd) { PrintAndLogEx(INFO, "---+-------------+-------"); const int hts_mem_sizes[] = {1, 8, 64, 64}; - + if (count == 0) { count = hts_mem_sizes[config.MEMT] - page; } @@ -458,7 +458,7 @@ void hitags_config_print(hitags_config_t config) { PrintAndLogEx(INFO, " Authenticaion.... %s", config.auth ? _YELLOW_("Yes") : "No"); PrintAndLogEx(INFO, " TTF coding....... %s", - config.RES3 ? "FSK 0=RF/10 1=RF/8" : (const char *[]){"Manchester", "Biphase"}[config.TTFC]); + config.RES3 ? "FSK 0=RF/10 1=RF/8" : (const char *[]) {"Manchester", "Biphase"}[config.TTFC]); PrintAndLogEx(INFO, " TTF data rate.... %s", (const char *[]) { @@ -467,16 +467,16 @@ void hitags_config_print(hitags_config_t config) { }[config.TTFDR]); PrintAndLogEx(INFO, " TTF mode......... %s", - (const char *[]){ - "TTF Mode disabled (= RTF Mode)", - "Page 4, Page 5", - "Page 4, Page 5, Page 6, Page 7", - "Page 4", - "TTF Mode disabled (= RTF Mode)", - "Page 4, Page 5, Page 6", - "Page 4, Page 5, Page 6, Page 7, Page 8", - "Page 4, Page 5, Page 6, Page 7, Page 8, Page 9, Page 10, Page 11", - }[config.RES0 << 2 | config.TTFM]); + (const char *[]) { + "TTF Mode disabled (= RTF Mode)", + "Page 4, Page 5", + "Page 4, Page 5, Page 6, Page 7", + "Page 4", + "TTF Mode disabled (= RTF Mode)", + "Page 4, Page 5, Page 6", + "Page 4, Page 5, Page 6, Page 7, Page 8", + "Page 4, Page 5, Page 6, Page 7, Page 8, Page 9, Page 10, Page 11", + }[config.RES0 << 2 | config.TTFM]); PrintAndLogEx(INFO, " Config locked.... %s", config.LCON ? _RED_("Yes") : _GREEN_("No")); PrintAndLogEx(INFO, " Key/PWD locked... %s", config.LKP ? _RED_("Yes") : _GREEN_("No")); diff --git a/client/src/fileutils.c b/client/src/fileutils.c index ece462f9e..b193eb2b2 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -717,7 +717,7 @@ int saveFileJSONex(const char *preferredName, JSONFileType ftype, uint8_t *data, if (datalen != sizeof(iso14a_fm11rf08s_nonces_with_data_t)) { return PM3_EINVARG; } - iso14a_fm11rf08s_nonces_with_data_t * p = (iso14a_fm11rf08s_nonces_with_data_t *)data; + iso14a_fm11rf08s_nonces_with_data_t *p = (iso14a_fm11rf08s_nonces_with_data_t *)data; if (ftype == jsfFM11RF08SNoncesWithData) { JsonSaveStr(root, "FileType", "fm11rf08s_nonces_with_data"); } else { @@ -2317,7 +2317,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key return loadFileDICTIONARY_safe_ex(preferredName, ".dic", pdata, keylen, keycnt, true); } -int loadFileDICTIONARY_safe_ex(const char *preferredName, const char* suffix, void **pdata, uint8_t keylen, uint32_t *keycnt, bool verbose) { +int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, void **pdata, uint8_t keylen, uint32_t *keycnt, bool verbose) { int retval = PM3_SUCCESS; diff --git a/client/src/fileutils.h b/client/src/fileutils.h index 876bff44e..c4d7d082f 100644 --- a/client/src/fileutils.h +++ b/client/src/fileutils.h @@ -279,7 +279,7 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale */ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t keylen, uint32_t *keycnt); -int loadFileDICTIONARY_safe_ex(const char *preferredName, const char* suffix, void **pdata, uint8_t keylen, uint32_t *keycnt, bool verbose); +int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, void **pdata, uint8_t keylen, uint32_t *keycnt, bool verbose); int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya, void **keyb, size_t *alen, size_t *blen); diff --git a/client/src/pm3line_vocabulary.h b/client/src/pm3line_vocabulary.h index f57138920..4c67baf01 100644 --- a/client/src/pm3line_vocabulary.h +++ b/client/src/pm3line_vocabulary.h @@ -176,6 +176,7 @@ const static vocabulary_t vocabulary[] = { { 1, "hf 14b valid" }, { 0, "hf 14b calypso" }, { 0, "hf 14b mobib" }, + { 0, "hf 14b setuid" }, { 1, "hf 15 help" }, { 1, "hf 15 list" }, { 1, "hf 15 demod" }, diff --git a/doc/commands.json b/doc/commands.json index 7641f4e04..5a629a810 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1613,6 +1613,19 @@ ], "usage": "hf 14b restore [-h] [-f ] [--512] [--4k]" }, + "hf 14b setuid": { + "command": "hf 14b setuid", + "description": "Set UID for magic card (only works with such cards)", + "notes": [ + "hf 14b setuid -u 11223344" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-u, --uid UID, 4 hex bytes" + ], + "usage": "hf 14b setuid [-h] -u " + }, "hf 14b sim": { "command": "hf 14b sim", "description": "Simulate a ISO/IEC 14443 type B tag with 4 byte UID / PUPI", @@ -3221,12 +3234,14 @@ "options": [ "-h, --help This help", "--ci use config slot at index", - "--ki Key index to select key from memory 'hf iclass managekeys'", + "--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'", + "--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 ]" + "usage": "hf iclass configcard [-hglp] [--ci ] [--ki ] [--krki ] [--elite]" }, "hf iclass creditepurse": { "command": "hf iclass creditepurse", @@ -5111,9 +5126,10 @@ "", "FM11RF08S specific options: Incompatible with above options, except -k; output in JSON", "--collect_fm11rf08s collect all nT/{nT}/par_err.", - "--collect_fm11rf08s_with_data collect all nT/{nT}/par_err and data blocks." + "--collect_fm11rf08s_with_data collect all nT/{nT}/par_err and data blocks.", + "-f, --file Specify a filename for collected data" ], - "usage": "hf mf isen [-hab] [--blk ] [-c ] [-k ] [--blk2 ] [--a2] [--b2] [--c2 ] [--key2 ] [-n ] [--reset] [--hardreset] [--addread] [--addauth] [--incblk2] [--corruptnrar] [--corruptnrarparity] FM11RF08S specific options: [--collect_fm11rf08s] [--collect_fm11rf08s_with_data]" + "usage": "hf mf isen [-hab] [--blk ] [-c ] [-k ] [--blk2 ] [--a2] [--b2] [--c2 ] [--key2 ] [-n ] [--reset] [--hardreset] [--addread] [--addauth] [--incblk2] [--corruptnrar] [--corruptnrarparity] FM11RF08S specific options: [--collect_fm11rf08s] [--collect_fm11rf08s_with_data] [-f ]" }, "hf mf mad": { "command": "hf mf mad", @@ -9793,9 +9809,10 @@ "--nrar nonce / answer writer, 8 hex bytes", "--crypto crypto mode", "-k, --key pwd or key, 4 or 6 hex bytes", - "-p, --page page address to read from" + "-p, --page page address to read from", + "-c, --count how many pages to read. '0' reads all pages up to the end page (default: 1)" ], - "usage": "lf hitag hts rdbl [-h8] [--nrar ] [--crypto] [-k ] -p " + "usage": "lf hitag hts rdbl [-h8] [--nrar ] [--crypto] [-k ] [-p ] [-c ]" }, "lf hitag hts reader": { "command": "lf hitag hts reader", @@ -12954,8 +12971,8 @@ } }, "metadata": { - "commands_extracted": 747, + "commands_extracted": 748, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2024-10-04T07:43:15" + "extracted_on": "2024-10-12T11:55:26" } } diff --git a/doc/commands.md b/doc/commands.md index 1b859017e..717b659aa 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -227,6 +227,7 @@ Check column "offline" for their availability. |`hf 14b valid `|Y |`SRIX4 checksum test` |`hf 14b calypso `|N |`Read contents of a Calypso card` |`hf 14b mobib `|N |`Read contents of a Mobib card` +|`hf 14b setuid `|N |`Set UID for magic card` ### hf 15 @@ -1078,9 +1079,9 @@ Check column "offline" for their availability. |`lf hitag hts help `|Y |`This help` |`lf hitag hts list `|Y |`List Hitag S trace history` |`lf hitag hts reader `|N |`Act like a Hitag S reader` -|`lf hitag hts rdbl `|N |`Read Hitag S memory` +|`lf hitag hts rdbl `|N |`Read Hitag S page` |`lf hitag hts wrbl `|N |`Write Hitag S page` -|`lf hitag hts sim `|N |`Simulate Hitag transponder` +|`lf hitag hts sim `|N |`Simulate Hitag S transponder` ### lf idteck