From 74f02fef8ab672a2eec2be9e061d0c1848c3c837 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 24 Jun 2023 17:16:28 +0200 Subject: [PATCH] style --- armsrc/iso14443a.c | 4 +- client/src/cmdhfmf.c | 48 +++++------ client/src/cmdhfmfp.c | 62 +++++++------- client/src/cmdhfmfu.c | 4 +- client/src/cmdhftopaz.c | 14 ++-- client/src/cmdtrace.c | 14 ++-- client/src/fileutils.c | 2 +- client/src/mifare/mad.c | 46 +++++------ client/src/pm3line_vocabulory.h | 22 ++--- common/crc16.c | 2 +- doc/commands.json | 138 ++++++++++++++++++++++++-------- doc/commands.md | 24 +++--- 12 files changed, 229 insertions(+), 151 deletions(-) diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 42b42c180..9cff73f63 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -1291,7 +1291,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, tag_r { .response = rPPS, .response_n = sizeof(rPPS) }, // PPS response { .response = rPACK, .response_n = sizeof(rPACK) } // PACK response }; - + // "precompile" responses. There are 12 predefined responses with a total of 84 bytes data to transmit. // Coded responses need one byte per bit to transfer (data, parity, start, stop, correction) @@ -3105,7 +3105,7 @@ void ReaderIso14443a(PacketCommandNG *c) { FpgaDisableTracing(); reply_old(CMD_ACK, arg0, 0, 0, buf, sizeof(buf)); } - } else { + } else { arg0 = ReaderReceive(buf, par); FpgaDisableTracing(); reply_old(CMD_ACK, arg0, 0, 0, buf, sizeof(buf)); diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index c25e00cff..765c515e4 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -1395,7 +1395,7 @@ static int CmdHF14AMfRestore(const char *Cmd) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { PrintAndLogEx(WARNING, "Command execute timeout"); continue; - } + } int isOK = resp.oldarg[0] & 0xff; if (isOK == 1) { @@ -1406,14 +1406,14 @@ static int CmdHF14AMfRestore(const char *Cmd) { goto out; } else { if (b == 0) { - PrintAndLogEx(INFO, "Writing to manufacture block w key " _YELLOW_("%c") " ( " _RED_("fail") " )", - (kt == MF_KEY_A) ? 'A' : 'B' - ); + PrintAndLogEx(INFO, "Writing to manufacture block w key " _YELLOW_("%c") " ( " _RED_("fail") " )", + (kt == MF_KEY_A) ? 'A' : 'B' + ); } else { PrintAndLogEx(FAILED, "Write to block " _YELLOW_("%u") " w key " _YELLOW_("%c") " ( " _RED_("fail") " ) ", - blockno, - (kt == MF_KEY_A) ? 'A' : 'B' - ); + blockno, + (kt == MF_KEY_A) ? 'A' : 'B' + ); } } } // end loop key types @@ -1424,7 +1424,7 @@ out: free(ref_dump); free(keyA); free(keyB); - PrintAndLogEx(INFO, "-----+------------------------------------------------------------"); + PrintAndLogEx(INFO, "-----+------------------------------------------------------------"); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "Done!"); return PM3_SUCCESS; @@ -3604,7 +3604,7 @@ out: // if (singleSector) // printKeyTableEx(1, e_sector, mfSectorNum(blockNo)); // else - printKeyTable(sectors_cnt, e_sector); + printKeyTable(sectors_cnt, e_sector); if (transferToEml) { // fast push mode @@ -6273,7 +6273,7 @@ skipfile: memcpy(block, firstblocks[b], MFBLOCK_SIZE); break; default: { - if (mfIsSectorTrailerBasedOnBlocks(i,j)) { + if (mfIsSectorTrailerBasedOnBlocks(i, j)) { // ST NDEF memcpy(block, firstblocks[7], MFBLOCK_SIZE); } @@ -6787,12 +6787,12 @@ static int mfc_furui_recovery(uint8_t items, uint8_t tracedata[FURUI_MAX_TRACES] uint64_t key64 = -1; if (mfkey32_moebius(&data, &key64)) { - PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ "_GREEN_("%012" PRIX64) " ]", - sprint_hex_inrow(tracedata[i], 4), - data.sector, - (data.keytype == 0x60) ? 'A' : 'B', - key64 - ); + PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ "_GREEN_("%012" PRIX64) " ]", + sprint_hex_inrow(tracedata[i], 4), + data.sector, + (data.keytype == 0x60) ? 'A' : 'B', + key64 + ); break; } } @@ -6836,11 +6836,11 @@ static int mfc_supercard_gen2_recovery(uint8_t items, uint8_t tracedata[FURUI_MA uint64_t key64 = -1; if (mfkey32_moebius(&data, &key64)) { PrintAndLogEx(SUCCESS, "UID: %s Sector %02x key %c [ "_GREEN_("%012" PRIX64) " ]", - sprint_hex_inrow(tmp, 4), - data.sector, - (data.keytype == 0x60) ? 'A' : 'B', - key64 - ); + sprint_hex_inrow(tmp, 4), + data.sector, + (data.keytype == 0x60) ? 'A' : 'B', + key64 + ); break; } } @@ -6957,7 +6957,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { // recover key from collected traces return mfc_supercard_gen2_recovery(i, tracedata); - } + } // Super card generation 1 @@ -6978,7 +6978,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { uint8_t aCHANGE[] = {0x00, 0xa6, 0xa0, 0x00, 0x05, 0xff, 0xff, 0xff, 0xff, 0x00}; memcpy(aCHANGE + 5, uid, uidlen); res = ExchangeAPDU14a(aCHANGE, sizeof(aCHANGE), activate_field, keep_field_on, response, sizeof(response), - &resplen); + &resplen); if (res != PM3_SUCCESS) { PrintAndLogEx(FAILED, "Super card UID change [ " _RED_("fail") " ]"); DropField(); @@ -6998,7 +6998,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { // --------------- RESET CARD ---------------- uint8_t aRESET[] = {0x00, 0xa6, 0xc0, 0x00}; res = ExchangeAPDU14a(aRESET, sizeof(aRESET), activate_field, keep_field_on, response, sizeof(response), - &resplen); + &resplen); if (res != PM3_SUCCESS) { PrintAndLogEx(FAILED, "Super card reset [ " _RED_("fail") " ]"); DropField(); diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index 089e041d3..52f3da57e 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -995,8 +995,8 @@ static int CmdHFMFPWrbl(const char *Cmd) { } static int plus_key_check(uint8_t startSector, uint8_t endSector, uint8_t startKeyAB, uint8_t endKeyAB, - uint8_t keyList[MAX_AES_KEYS_LIST_LEN][AES_KEY_LEN], size_t keyListLen, uint8_t foundKeys[2][64][AES_KEY_LEN + 1], - bool verbose) { + uint8_t keyList[MAX_AES_KEYS_LIST_LEN][AES_KEY_LEN], size_t keyListLen, uint8_t foundKeys[2][64][AES_KEY_LEN + 1], + bool verbose) { int res; bool selectCard = true; uint8_t keyn[2] = {0}; @@ -1296,10 +1296,10 @@ static int CmdHFMFPChk(const char *Cmd) { for (uint8_t s = startSector; s <= endSector; s++) { if ((memcmp(&foundKeys[0][s][1], ndef_key, AES_KEY_LEN) == 0) || - (memcmp(&foundKeys[1][s][1], ndef_key, AES_KEY_LEN) == 0)) { + (memcmp(&foundKeys[1][s][1], ndef_key, AES_KEY_LEN) == 0)) { has_ndef_key = true; } - + if (printedHeader == false) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "-----+----------------------------------+----------------------------------"); @@ -1320,7 +1320,7 @@ static int CmdHFMFPChk(const char *Cmd) { snprintf(strB, sizeof(strB), _RED_("%s"), "--------------------------------"); } - PrintAndLogEx(INFO, " " _YELLOW_("%03d") " | %s | %s", s, strA, strB); + PrintAndLogEx(INFO, " " _YELLOW_("%03d") " | %s | %s", s, strA, strB); } if (printedHeader == false) @@ -1395,7 +1395,7 @@ static int CmdHFMFPDump(const char *Cmd) { arg_str0("f", "file", "", "filename of dump"), arg_str0("k", "keys", "", "filename of keys"), arg_lit0(NULL, "ns", "no save to file"), - arg_lit0("v", "verbose", "Verbose mode"), + arg_lit0("v", "verbose", "Verbose mode"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -1421,14 +1421,14 @@ static int CmdHFMFPDump(const char *Cmd) { return PM3_EMALLOC; } -/* - iso14a_card_select_t card ; - int res = mfp_read_tag(&card, mem, key_fn); - if (res != PM3_SUCCESS) { - free(mem); - return res; - } -*/ + /* + iso14a_card_select_t card ; + int res = mfp_read_tag(&card, mem, key_fn); + if (res != PM3_SUCCESS) { + free(mem); + return res; + } + */ // Skip saving card data to file if (nosave) { @@ -1436,28 +1436,28 @@ static int CmdHFMFPDump(const char *Cmd) { free(mem); return PM3_SUCCESS; } -/* - // Save to file - if (strlen(data_fn) < 1) { + /* + // Save to file + if (strlen(data_fn) < 1) { - char *fptr = calloc(sizeof(char) * (strlen("hf-mfp-") + strlen("-dump")) + card.uidlen * 2 + 1, sizeof(uint8_t)); - strcpy(fptr, "hf-mfp-"); + char *fptr = calloc(sizeof(char) * (strlen("hf-mfp-") + strlen("-dump")) + card.uidlen * 2 + 1, sizeof(uint8_t)); + strcpy(fptr, "hf-mfp-"); - FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen); + FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen); - strcpy(data_fn, fptr); - free(fptr); - } + strcpy(data_fn, fptr); + free(fptr); + } - saveFile(data_fn, ".bin", mem, MIFARE_4K_MAX_BYTES); - saveFileEML(data_fn, mem, MIFARE_4K_MAX_BYTES, MFBLOCK_SIZE); + saveFile(data_fn, ".bin", mem, MIFARE_4K_MAX_BYTES); + saveFileEML(data_fn, mem, MIFARE_4K_MAX_BYTES, MFBLOCK_SIZE); - iso14a_mf_extdump_t xdump; - xdump.card_info = card; - xdump.dump = mem; - xdump.dumplen = MIFARE_4K_MAX_BYTES; - saveFileJSON(data_fn, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL); -*/ + iso14a_mf_extdump_t xdump; + xdump.card_info = card; + xdump.dump = mem; + xdump.dumplen = MIFARE_4K_MAX_BYTES; + saveFileJSON(data_fn, jsfCardMemory, (uint8_t *)&xdump, sizeof(xdump), NULL); + */ free(mem); return PM3_SUCCESS; } diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index e17032507..9f7f54c53 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -1424,7 +1424,7 @@ static mfu_identify_t *mfu_match_fingerprint(uint8_t *version, uint8_t *data) { uint8_t mtmp[40] = {0}; param_gethex_to_eol(mfu_ident_table[i].match, 0, mtmp, sizeof(mtmp), &ml); - bool m2 = (memcmp(mtmp, data + mfu_ident_table[i].mpos, mfu_ident_table[i].mlen) == 0); + bool m2 = (memcmp(mtmp, data + mfu_ident_table[i].mpos, mfu_ident_table[i].mlen) == 0); if (m2) { PrintAndLogEx(DEBUG, "(fingerprint) found %s", mfu_ident_table[i].desc); return &mfu_ident_table[i]; @@ -3608,7 +3608,7 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) { if (ul_select(&card)) { // Philips toothbrush needs page 0x21-0x23 uint8_t data[16] = {0x00}; - int status = ul_read(0x21, data, sizeof(data)); + int status = ul_read(0x21, data, sizeof(data)); if (status == -1) { PrintAndLogEx(DEBUG, "Error: tag didn't answer to READ"); } else if (status == 16) { diff --git a/client/src/cmdhftopaz.c b/client/src/cmdhftopaz.c index 766889438..4483e3154 100644 --- a/client/src/cmdhftopaz.c +++ b/client/src/cmdhftopaz.c @@ -224,7 +224,7 @@ static int topaz_write_erase8_block(uint8_t blockno, uint8_t *block_data) { uint16_t resp_len = 11; uint8_t response[11] = {0}; - // + // if (topaz_send_cmd(wr8_cmd, sizeof(wr8_cmd), response, &resp_len, true) == PM3_ETIMEOUT) { topaz_switch_off_field(); @@ -267,12 +267,12 @@ static int topaz_write_nonerase8_block(uint8_t blockno, uint8_t *block_data) { return res; } - // ADD + // ADD // 7 6 5 4 3 2 1 0 // b b b --- Byte 0 - 7 - // B B B B --------- BLOCK + // B B B B --------- BLOCK // r ----------------- 0 - // + // uint8_t wr8_cmd[] = {TOPAZ_WRITE_NE8, blockno, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; memcpy(wr8_cmd + 10, uid_echo, 4); @@ -281,7 +281,7 @@ static int topaz_write_nonerase8_block(uint8_t blockno, uint8_t *block_data) { uint16_t resp_len = 11; uint8_t response[11] = {0}; - // + // if (topaz_send_cmd(wr8_cmd, sizeof(wr8_cmd), response, &resp_len, true) == PM3_ETIMEOUT) { topaz_switch_off_field(); return PM3_ESOFT; @@ -883,7 +883,7 @@ static int CmdHFTopazDump(const char *Cmd) { if (nosave) { PrintAndLogEx(INFO, "Called with no save option"); if (set_dynamic) { - free(topaz_tag.dynamic_memory); + free(topaz_tag.dynamic_memory); } return PM3_SUCCESS; } @@ -1034,7 +1034,7 @@ static int CmdHFTopazWrBl(const char *Cmd) { PrintAndLogEx(INFO, "Block: %0d (0x%02X) [ %s]", blockno, blockno, sprint_hex(data, dlen)); int res; - if (blockno != 13 && blockno != 14) { + if (blockno != 13 && blockno != 14) { // send write/erase block res = topaz_write_erase8_block(blockno, data); } else { diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index c2e750623..323c7ef7e 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -571,9 +571,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr //2 Not crc-command // Draw the data column - #define TRACE_MAX_LINES 36 +#define TRACE_MAX_LINES 36 // number of hex bytes to be printed per row (16 data + 2 crc) - #define TRACE_MAX_HEX_BYTES 18 +#define TRACE_MAX_HEX_BYTES 18 char line[TRACE_MAX_LINES][160] = {{0}}; @@ -700,8 +700,8 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr // mark short bytes (less than 8 Bit + Parity) if (protocol == ISO_14443A || - protocol == PROTO_MIFARE || - protocol == THINFILM) { + protocol == PROTO_MIFARE || + protocol == THINFILM) { // approximated with 128 * (9 * data_len); uint16_t bitime = 1056 + 32; @@ -874,13 +874,13 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr } else { - if (last_line && (memcmp(crc, "\x20\x20\x20\x20", 4) != 0) && g_session.supports_colors && markCRCBytes) { + if (last_line && (memcmp(crc, "\x20\x20\x20\x20", 4) != 0) && g_session.supports_colors && markCRCBytes) { str_padder = 85; // odd case of multiline, and last single byte on empty row has been colorised... if (strlen(line[j]) < 14) { str_padder = 81; } - } + } if (hdr->isResponse) { PrintAndLogEx(NORMAL, " | | |%-*s | %s| %s", @@ -909,7 +909,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr annotateIso14443a(explanation, sizeof(explanation), mfData, mfDataLen, hdr->isResponse); uint8_t crcc = iso14443A_CRC_check(hdr->isResponse, mfData, mfDataLen); - //iceman: colorise crc bytes here will need a refactor of code from above. + //iceman: colorise crc bytes here will need a refactor of code from above. PrintAndLogEx(NORMAL, " | | * |%-*s | %-4s| %s", str_padder, sprint_hex_inrow_spaces(mfData, mfDataLen, 2), diff --git a/client/src/fileutils.c b/client/src/fileutils.c index 917a7ee77..4dba2c1e4 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -1313,7 +1313,7 @@ int loadFileJSONex(const char *preferredName, void *data, size_t maxdatalen, siz // memcpy(vdata, udata.bytes + (14 + atslen), 2 * 64 * 17); for (size_t i = 0; i < 64; i++) { - + if ((sptr + (AES_KEY_LEN * 2)) > maxdatalen) { break; } diff --git a/client/src/mifare/mad.c b/client/src/mifare/mad.c index 42a05c5a2..54f67a6a4 100644 --- a/client/src/mifare/mad.c +++ b/client/src/mifare/mad.c @@ -333,19 +333,19 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMA for (int i = 1; i < 16; i++) { uint16_t aid = madGetAID(sector, swapmad, 1, i); if (aid < 6) { - PrintAndLogEx(INFO, - (ibs == i) ? _MAGENTA_(" %02d [%04X] %s") : " %02d [" _GREEN_("%04X") "] %s", - i, - aid, - aid_admin[aid] - ); + PrintAndLogEx(INFO, + (ibs == i) ? _MAGENTA_(" %02d [%04X] %s") : " %02d [" _GREEN_("%04X") "] %s", + i, + aid, + aid_admin[aid] + ); } else if (prev_aid == aid) { - PrintAndLogEx(INFO, - (ibs == i) ? _MAGENTA_(" %02d [%04X] continuation") : " %02d [" _YELLOW_("%04X") "] continuation", - i, - aid - ); + PrintAndLogEx(INFO, + (ibs == i) ? _MAGENTA_(" %02d [%04X] continuation") : " %02d [" _YELLOW_("%04X") "] continuation", + i, + aid + ); } else { char fmt[60]; snprintf(fmt, sizeof(fmt), (ibs == i) ? _MAGENTA_(" %02d [%04X]%s") : " %02d [" _GREEN_("%04X") "]%s", i, aid, "%s"); @@ -368,7 +368,7 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose) { if (res == PM3_SUCCESS) PrintAndLogEx(SUCCESS, "CRC8...... 0x%02X ( " _GREEN_("%s") " )", sector[0], "ok"); else - PrintAndLogEx(SUCCESS, "CRC8...... 0x%02X ( " _RED_("%s") " )", sector[0], "fail"); + PrintAndLogEx(SUCCESS, "CRC8...... 0x%02X ( " _RED_("%s") " )", sector[0], "fail"); } int ibs = MADInfoByteDecode(sector, swapmad, 2, verbose); @@ -387,18 +387,18 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose) { for (int i = 1; i < 8 + 8 + 7 + 1; i++) { uint16_t aid = madGetAID(sector, swapmad, 2, i); if (aid < 6) { - PrintAndLogEx(INFO, - (ibs == i) ? _MAGENTA_(" %02d [%04X] %s") : " %02d [" _GREEN_("%04X") "] %s", - i + 16, - aid, - aid_admin[aid] - ); + PrintAndLogEx(INFO, + (ibs == i) ? _MAGENTA_(" %02d [%04X] %s") : " %02d [" _GREEN_("%04X") "] %s", + i + 16, + aid, + aid_admin[aid] + ); } else if (prev_aid == aid) { - PrintAndLogEx(INFO, - (ibs == i) ? _MAGENTA_(" %02d [%04X] continuation") : " %02d [" _YELLOW_("%04X") "] continuation", - i + 16, - aid - ); + PrintAndLogEx(INFO, + (ibs == i) ? _MAGENTA_(" %02d [%04X] continuation") : " %02d [" _YELLOW_("%04X") "] continuation", + i + 16, + aid + ); } else { char fmt[60]; snprintf(fmt, sizeof(fmt), (ibs == i) ? _MAGENTA_(" %02d [%04X]%s") : " %02d [" _GREEN_("%04X") "]%s", i + 16, aid, "%s"); diff --git a/client/src/pm3line_vocabulory.h b/client/src/pm3line_vocabulory.h index ffe9c66ff..ffad57057 100644 --- a/client/src/pm3line_vocabulory.h +++ b/client/src/pm3line_vocabulory.h @@ -367,17 +367,21 @@ const static vocabulory_t vocabulory[] = { { 0, "hf mf ndefread" }, { 0, "hf mf ndefwrite" }, { 1, "hf mfp help" }, - { 0, "hf mfp info" }, - { 0, "hf mfp wrp" }, - { 0, "hf mfp initp" }, - { 0, "hf mfp commitp" }, + { 1, "hf mfp list" }, { 0, "hf mfp auth" }, + { 0, "hf mfp chk" }, + { 0, "hf mfp dump" }, + { 0, "hf mfp info" }, + { 0, "hf mfp mad" }, { 0, "hf mfp rdbl" }, { 0, "hf mfp rdsc" }, { 0, "hf mfp wrbl" }, - { 0, "hf mfp chk" }, - { 0, "hf mfp mad" }, + { 0, "hf mfp commitp" }, + { 0, "hf mfp initp" }, + { 0, "hf mfp wrp" }, + { 0, "hf mfp ndefformat" }, { 0, "hf mfp ndefread" }, + { 0, "hf mfp ndefwrite" }, { 1, "hf mfu help" }, { 1, "hf mfu keygen" }, { 1, "hf mfu pwdgen" }, @@ -461,14 +465,14 @@ const static vocabulory_t vocabulory[] = { { 1, "hf thinfilm list" }, { 0, "hf thinfilm sim" }, { 1, "hf topaz help" }, - { 0, "hf topaz dump" }, { 1, "hf topaz list" }, + { 0, "hf topaz dump" }, { 0, "hf topaz info" }, + { 0, "hf topaz raw" }, + { 0, "hf topaz rdbl" }, { 0, "hf topaz reader" }, { 0, "hf topaz sim" }, { 0, "hf topaz sniff" }, - { 0, "hf topaz raw" }, - { 0, "hf topaz rdbl" }, { 1, "hf topaz view" }, { 0, "hf topaz wrbl" }, { 1, "hf xerox help" }, diff --git a/common/crc16.c b/common/crc16.c index d402977b9..812cd3481 100644 --- a/common/crc16.c +++ b/common/crc16.c @@ -354,4 +354,4 @@ uint16_t crc16_legic(uint8_t const *d, size_t n, uint8_t uidcrc) { uint16_t crc16_philips(uint8_t const *d, size_t n) { return crc16_fast(d, n, 0x49A3, false, false); -} \ No newline at end of file +} diff --git a/doc/commands.json b/doc/commands.json index efb03edd2..7a19db4f2 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -3966,14 +3966,16 @@ "command": "hf mf auth4", "description": "Executes AES authentication command in ISO14443-4", "notes": [ - "hf mf auth4 4000 000102030405060708090a0b0c0d0e0f -> executes authentication", - "hf mf auth4 9003 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> executes authentication" + "hf mf auth4 -n 4000 -k 000102030405060708090a0b0c0d0e0f -> executes authentication", + "hf mf auth4 -n 9003 -k FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> executes authentication" ], "offline": false, "options": [ - "-h, --help This help" + "-h, --help This help", + "-n key num, 2 hex bytes", + "-k, --key key, 16 hex bytes" ], - "usage": "hf mf auth4 [-h] " + "usage": "hf mf auth4 [-h] -n -k " }, "hf mf autopwn": { "command": "hf mf autopwn", @@ -4655,14 +4657,14 @@ "options": [ "-h, --help This help", "-v, --verbose show technical data", - "--aid print all sectors with specified aid", - "-k, --key key for printing sectors", + "--aid print all sectors with specified aid", + "-k, --key key for printing sectors", "-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" ], - "usage": "hf mf mad [-hvb] [--aid ] [-k ] [--be] [--dch] [-f ]" + "usage": "hf mf mad [-hvb] [--aid ] [-k ] [--be] [--dch] [-f ]" }, "hf mf nack": { "command": "hf mf nack", @@ -4784,7 +4786,8 @@ "command": "hf mf rdbl", "description": "Read MIFARE Classic block", "notes": [ - "hf mf rdbl --blk 0 -k FFFFFFFFFFFF", + "hf mf rdbl --blk 0", + "hf mf rdbl --blk 0 -k A0A1A2A3A4A5", "hf mf rdbl --blk 3 -v -> get block 3, decode sector trailer" ], "offline": false, @@ -4802,7 +4805,8 @@ "command": "hf mf rdsc", "description": "Read MIFARE Classic sector", "notes": [ - "hf mf rdsc -s 0 -k FFFFFFFFFFFF" + "hf mf rdsc -s 0", + "hf mf rdsc -s 0 -k A0A1A2A3A4A5" ], "offline": false, "options": [ @@ -4906,9 +4910,10 @@ "options": [ "-h, --help This help", "-r, --reset Reset card", - "-u, --uid New UID (4 hex bytes)" + "-u, --uid New UID (4 hex bytes)", + "--furui Furui detection card" ], - "usage": "hf mf supercard [-hr] [-u ]" + "usage": "hf mf supercard [-hr] [-u ] [--furui]" }, "hf mf value": { "command": "hf mf value", @@ -4976,7 +4981,8 @@ "command": "hf mf wrbl", "description": "Write MIFARE Classic block with 16 hex bytes of data Sector 0 / Block 0 - Manufacturer block When writing to block 0 you must use a VALID block 0 data (UID, BCC, SAK, ATQA) Writing an invalid block 0 means rendering your Magic GEN2 card undetectable. Look in the magic_cards_notes.md file for help to resolve it. `--force` param is used to override warnings like bad ACL and BLOCK 0 writes. if not specified, it will exit if detected", "notes": [ - "hf mf wrbl --blk 1 -k FFFFFFFFFFFF -d 000102030405060708090a0b0c0d0e0f" + "hf mf wrbl --blk 1 -d 000102030405060708090a0b0c0d0e0f", + "hf mf wrbl --blk 1 -k A0A1A2A3A4A5 -d 000102030405060708090a0b0c0d0e0f" ], "offline": false, "options": [ @@ -6126,7 +6132,7 @@ }, "hf mfp auth": { "command": "hf mfp auth", - "description": "Executes AES authentication command for Mifare Plus card", + "description": "Executes AES authentication command for MIFARE Plus card", "notes": [ "hf mfp auth --ki 4000 --key 000102030405060708090a0b0c0d0e0f -> executes authentication", "hf mfp auth --ki 9003 --key FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -v -> executes authentication and shows all the system data" @@ -6145,9 +6151,9 @@ "description": "Checks keys on MIFARE Plus card", "notes": [ "hf mfp chk -k 000102030405060708090a0b0c0d0e0f -> check key on sector 0 as key A and B", - "hf mfp chk -s 2 -a -> check default key list on sector 2, key A", + "hf mfp chk -s 2 -a -> check default key list on sector 2, only key A", "hf mfp chk -d mfp_default_keys -s0 -e6 -> check keys from dictionary against sectors 0-6", - "hf mfp chk --pattern1b -j keys -> check all 1-byte keys pattern and save found keys to json", + "hf mfp chk --pattern1b --dump -> check all 1-byte keys pattern and save found keys to file", "hf mfp chk --pattern2b --startp2b FA00 -> check all 2-byte keys pattern. Start from key FA00FA00...FA00" ], "offline": false, @@ -6162,10 +6168,10 @@ "--pattern1b Check all 1-byte combinations of key (0000...0000, 0101...0101, 0202...0202, ...)", "--pattern2b Check all 2-byte combinations of key (0000...0000, 0001...0001, 0002...0002, ...)", "--startp2b Start key (2-byte HEX) for 2-byte search (use with `--pattern2b`)", - "-j, --json Json filename to save keys", + "--dump Dump found keys to JSON file", "-v, --verbose Verbose mode" ], - "usage": "hf mfp chk [-habv] [-s <0..255>] [-e <0..255>] [-k ] [-d ] [--pattern1b] [--pattern2b] [--startp2b ] [-j ]" + "usage": "hf mfp chk [-habv] [-s <0..255>] [-e <0..255>] [-k ] [-d ] [--pattern1b] [--pattern2b] [--startp2b ] [--dump]" }, "hf mfp commitp": { "command": "hf mfp commitp", @@ -6180,9 +6186,26 @@ ], "usage": "hf mfp commitp [-hv]" }, + "hf mfp dump": { + "command": "hf mfp dump", + "description": "Dump MIFARE Plus tag to binary file If no given, UID will be used as filename", + "notes": [ + "hf mfp dump", + "hf mfp dump --keys hf-mf-066C8B78-key.bin -> MIFARE Plus with keys from specified file" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-f, --file filename of dump", + "-k, --keys filename of keys", + "--ns no save to file", + "-v, --verbose Verbose mode" + ], + "usage": "hf mfp dump [-hv] [-f ] [-k ] [--ns]" + }, "hf mfp help": { "command": "hf mfp help", - "description": "help This help", + "description": "help This help list List MIFARE Plus history", "notes": [], "offline": true, "options": [], @@ -6215,9 +6238,30 @@ ], "usage": "hf mfp initp [-hv] [-k ]" }, + "hf mfp list": { + "command": "hf mfp list", + "description": "Alias of `trace list -t mf` with selected protocol data to annotate trace buffer You can load a trace from file (see `trace load -h`) or it be downloaded from device by default It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol", + "notes": [ + "hf mf list --frame -> show frame delay times", + "hf mf list -1 -> use trace buffer" + ], + "offline": true, + "options": [ + "-h, --help This help", + "-1, --buffer use data from trace buffer", + "--frame show frame delay times", + "-c mark CRC bytes", + "-r show relative times (gap and duration)", + "-u display times in microseconds instead of clock cycles", + "-x show hexdump to convert to pcap(ng)", + "or to import into Wireshark using encapsulation type \"ISO 14443\"", + "-f, --file filename of dictionary" + ], + "usage": "hf mf list [-h1crux] [--frame] [-f ]" + }, "hf mfp mad": { "command": "hf mfp mad", - "description": "Checks and prints Mifare Application Directory (MAD)", + "description": "Checks and prints MIFARE Application Directory (MAD)", "notes": [ "hf mfp mad", "hf mfp mad --aid e103 -k d3f7d3f7d3f7d3f7d3f7d3f7d3f7d3f7 -> read and print NDEF data from MAD aid" @@ -6234,6 +6278,14 @@ ], "usage": "hf mfp mad [-hvb] [--aid ] [-k ] [--be] [--dch]" }, + "hf mfp ndefformat": { + "command": "hf mfp ndefformat", + "description": "format MIFARE Plus Tag as a NFC tag with Data Exchange Format (NDEF) If no given, UID will be used as filename. It will try default keys and MAD keys to detect if tag is already formatted in order to write.", + "notes": [], + "offline": false, + "options": [], + "usage": "" + }, "hf mfp ndefread": { "command": "hf mfp ndefread", "description": "Prints NFC Data Exchange Format (NDEF)", @@ -6254,9 +6306,27 @@ ], "usage": "hf mfp ndefread [-hvb] [--aid ] [-k ] [-f ]" }, + "hf mfp ndefwrite": { + "command": "hf mfp ndefwrite", + "description": "Write raw NDEF hex bytes to tag. This commands assumes tag already been NFC/NDEF formatted.", + "notes": [ + "hf mfp ndefwrite -d 0300FE -> write empty record to tag", + "hf mfp ndefwrite -f myfilename", + "hf mfp ndefwrite -d 033fd1023a53709101195405656e2d55534963656d616e2054776974746572206c696e6b5101195502747769747465722e636f6d2f686572726d616e6e31303031" + ], + "offline": false, + "options": [ + "-h, --help This help", + "-d raw NDEF hex bytes", + "-f, --file write raw NDEF file to tag", + "-p fix NDEF record headers / terminator block if missing", + "-v, --verbose verbose output" + ], + "usage": "hf mfp ndefwrite [-hpv] [-d ] [-f ]" + }, "hf mfp rdbl": { "command": "hf mfp rdbl", - "description": "Reads several blocks from Mifare Plus card", + "description": "Reads blocks from MIFARE Plus card", "notes": [ "hf mfp rdbl --blk 0 --key 000102030405060708090a0b0c0d0e0f -> executes authentication and read block 0 data", "hf mfp rdbl --blk 1 -v -> executes authentication and shows sector 1 data with default key 0xFF..0xFF" @@ -6293,7 +6363,7 @@ }, "hf mfp wrbl": { "command": "hf mfp wrbl", - "description": "Writes one block to Mifare Plus card", + "description": "Writes one block to MIFARE Plus card", "notes": [ "hf mfp wrbl --blk 1 -d ff0000000000000000000000000000ff --key 000102030405060708090a0b0c0d0e0f -> write block 1 data", "hf mfp wrbl --blk 2 -d ff0000000000000000000000000000ff -v -> write block 2 data with default key 0xFF..0xFF" @@ -7024,9 +7094,10 @@ "offline": false, "options": [ "-h, --help This help", - "-f, --file filename of dump" + "-f, --file filename of dump", + "--ns no save to file" ], - "usage": "hf topaz dump [-h] [-f ]" + "usage": "hf topaz dump [-h] [-f ] [--ns]" }, "hf topaz help": { "command": "hf topaz help", @@ -7086,16 +7157,16 @@ }, "hf topaz rdbl": { "command": "hf topaz rdbl", - "description": "Read a block", + "description": "Read Topaz block", "notes": [ - "hf topaz rdbl -b 7" + "hf topaz rdbl --blk 7" ], "offline": false, "options": [ "-h, --help This help", - "-b, --block Block number to write" + "--blk Block number" ], - "usage": "hf topaz rdbl [-h] -b " + "usage": "hf topaz rdbl [-h] --blk " }, "hf topaz reader": { "command": "hf topaz reader", @@ -7151,17 +7222,17 @@ }, "hf topaz wrbl": { "command": "hf topaz wrbl", - "description": "Write a block", + "description": "Write Topaz block with 8 hex bytes of data", "notes": [ - "hf topaz wrbl -b 7 -d 1122334455667788" + "hf topaz wrbl --blk 7 -d 1122334455667788" ], "offline": false, "options": [ "-h, --help This help", - "-b, --block Block number to write", + "--blk Block number", "-d, --data Block data (8 hex bytes)" ], - "usage": "hf topaz wrbl [-h] -b -d " + "usage": "hf topaz wrbl [-h] --blk -d " }, "hf tune": { "command": "hf tune", @@ -12022,9 +12093,8 @@ } }, "metadata": { - "commands_extracted": 755, + "commands_extracted": 759, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2023-06-04T15:36:56" - + "extracted_on": "2023-06-24T15:16:04" } } \ No newline at end of file diff --git a/doc/commands.md b/doc/commands.md index 938413fa8..a27cf6964 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -538,17 +538,21 @@ Check column "offline" for their availability. |command |offline |description |------- |------- |----------- |`hf mfp help `|Y |`This help` -|`hf mfp info `|N |`Info about Mifare Plus tag` -|`hf mfp wrp `|N |`Write Perso command` -|`hf mfp initp `|N |`Fill all the card's keys in SL0 mode` -|`hf mfp commitp `|N |`Move card to SL1 or SL3 mode` +|`hf mfp list `|Y |`List MIFARE Plus history` |`hf mfp auth `|N |`Authentication` -|`hf mfp rdbl `|N |`Read blocks` -|`hf mfp rdsc `|N |`Read sectors` -|`hf mfp wrbl `|N |`Write blocks` |`hf mfp chk `|N |`Check keys` +|`hf mfp dump `|N |`Dump MIFARE Plus tag to binary file` +|`hf mfp info `|N |`Info about MIFARE Plus tag` |`hf mfp mad `|N |`Check and print MAD` +|`hf mfp rdbl `|N |`Read blocks from card` +|`hf mfp rdsc `|N |`Read sectors from card` +|`hf mfp wrbl `|N |`Write block to card` +|`hf mfp commitp `|N |`Configure security layer (SL1/SL3 mode)` +|`hf mfp initp `|N |`Fill all the card's keys in SL0 mode` +|`hf mfp wrp `|N |`Write Perso command` +|`hf mfp ndefformat `|N |`Format MIFARE Plus Tag as NFC Tag` |`hf mfp ndefread `|N |`Read and print NDEF records from card` +|`hf mfp ndefwrite `|N |`Write NDEF records to card` ### hf mfu @@ -704,14 +708,14 @@ Check column "offline" for their availability. |command |offline |description |------- |------- |----------- |`hf topaz help `|Y |`This help` -|`hf topaz dump `|N |`Dump TOPAZ family tag to file` |`hf topaz list `|Y |`List Topaz history` +|`hf topaz dump `|N |`Dump TOPAZ family tag to file` |`hf topaz info `|N |`Tag information` +|`hf topaz raw `|N |`Send raw hex data to tag` +|`hf topaz rdbl `|N |`Read block` |`hf topaz reader `|N |`Act like a Topaz reader` |`hf topaz sim `|N |`Simulate Topaz tag` |`hf topaz sniff `|N |`Sniff Topaz reader-tag communication` -|`hf topaz raw `|N |`Send raw hex data to tag` -|`hf topaz rdbl `|N |`Read block` |`hf topaz view `|Y |`Display content from tag dump file` |`hf topaz wrbl `|N |`Write block`