From 29f1147aadc64bf9bbcaf9bafcb856da4ece1e68 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 20 Oct 2020 01:00:23 +0200 Subject: [PATCH] make style --- armsrc/appmain.c | 20 ++-- armsrc/em4x50.c | 22 ++-- armsrc/iclass.c | 30 +++--- armsrc/iso14443a.c | 2 +- armsrc/iso15693.c | 12 +-- armsrc/mifarecmd.c | 18 ++-- client/deps/cliparser/cliparser.c | 16 +-- client/src/cmdhf14a.c | 22 ++-- client/src/cmdhf14b.c | 2 +- client/src/cmdhf15.c | 22 ++-- client/src/cmdhficlass.c | 70 ++++++------- client/src/cmdhfmfp.c | 4 +- client/src/cmdhfmfu.c | 80 +++++++------- client/src/cmdhfst.c | 6 +- client/src/cmdlf.c | 2 +- client/src/cmdlfdestron.c | 8 +- client/src/cmdlfem4x05.c | 168 +++++++++++++++--------------- client/src/cmdlfem4x50.c | 2 +- client/src/cmdlffdxb.c | 6 +- client/src/cmdlfindala.c | 4 +- client/src/cmdlfmotorola.c | 8 +- client/src/scripting.c | 18 ++-- doc/commands.md | 25 ++++- include/pm3_cmd.h | 2 +- 24 files changed, 292 insertions(+), 277 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 02d6f1d23..6b127c831 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1481,12 +1481,12 @@ static void PacketReceived(PacketCommandNG *packet) { MifareU_Otp_Tearoff(packet->oldarg[0], packet->oldarg[1], packet->data.asBytes); break; } - case CMD_HF_MFU_COUNTER_TEAROFF: { + case CMD_HF_MFU_COUNTER_TEAROFF: { struct p { uint8_t counter; uint32_t tearoff_time; } PACKED; - struct p *payload = (struct p *) packet->data.asBytes; + struct p *payload = (struct p *) packet->data.asBytes; MifareU_Counter_Tearoff(payload->counter, payload->tearoff_time); break; } @@ -1520,13 +1520,13 @@ static void PacketReceived(PacketCommandNG *packet) { break; } case CMD_HF_ICLASS_SIMULATE: { -/* - struct p { - uint8_t reader[4]; - uint8_t mac[4]; - } PACKED; - struct p *payload = (struct p *) packet->data.asBytes; -*/ + /* + struct p { + uint8_t reader[4]; + uint8_t mac[4]; + } PACKED; + struct p *payload = (struct p *) packet->data.asBytes; + */ SimulateIClass(packet->oldarg[0], packet->oldarg[1], packet->oldarg[2], packet->data.asBytes); break; @@ -1562,7 +1562,7 @@ static void PacketReceived(PacketCommandNG *packet) { break; } case CMD_HF_ICLASS_RESTORE: { - iClass_Restore( (iclass_restore_req_t *)packet->data.asBytes); + iClass_Restore((iclass_restore_req_t *)packet->data.asBytes); break; } #endif diff --git a/armsrc/em4x50.c b/armsrc/em4x50.c index bce422908..9ab8dcf35 100644 --- a/armsrc/em4x50.c +++ b/armsrc/em4x50.c @@ -889,18 +889,18 @@ static int write(uint8_t word[4], uint8_t address) { return PM3_ETEAROFF; } else { - // wait for T0 * EM4X50_T_TAG_TWA (write access time) - wait_timer(FPGA_TIMER_0, T0 * EM4X50_T_TAG_TWA); + // wait for T0 * EM4X50_T_TAG_TWA (write access time) + wait_timer(FPGA_TIMER_0, T0 * EM4X50_T_TAG_TWA); - // look for ACK sequence - if (check_ack(false)) { + // look for ACK sequence + if (check_ack(false)) { - // now EM4x50 needs T0 * EM4X50_T_TAG_TWEE (EEPROM write time) - // for saving data and should return with ACK - if (check_ack(false)) - return PM3_SUCCESS; + // now EM4x50 needs T0 * EM4X50_T_TAG_TWEE (EEPROM write time) + // for saving data and should return with ACK + if (check_ack(false)) + return PM3_SUCCESS; - } + } } } else { @@ -985,7 +985,7 @@ void em4x50_write(em4x50_data_t *etd) { lf_finalize(); return; } - + if (res == PM3_SUCCESS) { // to verify result reset EM4x50 if (reset()) { @@ -1033,7 +1033,7 @@ void em4x50_write_password(em4x50_data_t *etd) { // login and change password if (login(etd->password)) { - + int res = write_password(etd->password, etd->new_password); if (res == PM3_ETEAROFF) { lf_finalize(); diff --git a/armsrc/iclass.c b/armsrc/iclass.c index 204cd9ea1..03f7dcbba 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -1367,7 +1367,7 @@ static bool select_iclass_tag_ex(picopass_hdr *hdr, bool use_credit_key, uint32_ *status |= FLAG_ICLASS_CC; } else { - + // on NON_SECURE_PAGEMODE cards, AIA is on block2.. // read App Issuer Area block 2 @@ -1443,7 +1443,7 @@ void ReaderIClass(uint8_t flags) { // with 0xFF:s in block 3 and 4. LED_B_ON(); - reply_mix(CMD_ACK, result_status, 0, 0, (uint8_t*)&hdr, sizeof(hdr)); + reply_mix(CMD_ACK, result_status, 0, 0, (uint8_t *)&hdr, sizeof(hdr)); //Send back to client, but don't bother if we already sent this - // only useful if looping in arm (not try_once && not abort_after_read) @@ -1489,9 +1489,9 @@ bool authenticate_iclass_tag(iclass_auth_req_t *payload, picopass_hdr *hdr, uint memcpy(ccnr, hdr->epurse, sizeof(hdr->epurse)); - if ( payload->use_replay) { + if (payload->use_replay) { - memcpy(pmac, payload->key + 4, 4); + memcpy(pmac, payload->key + 4, 4); memcpy(cmd_check + 1, payload->key, 8); } else { @@ -1780,7 +1780,7 @@ static bool iclass_writeblock_ext(uint8_t blockno, uint8_t *data, uint8_t *mac) // write command: cmd, 1 blockno, 8 data, 4 mac uint8_t write[16] = { 0x80 | ICLASS_CMD_UPDATE, blockno }; - memcpy(write + 2, data, 8); + memcpy(write + 2, data, 8); memcpy(write + 10, mac, 4); AddCrc(write + 1, 13); @@ -1872,11 +1872,11 @@ void iClass_WriteBlock(uint8_t *msg) { iclass_send_as_reader(write, sizeof(write), &start_time, &eof_time); if (tearoff_hook() == PM3_ETEAROFF) { // tearoff occured - res = false; - switch_off(); - if (payload->req.send_reply) - reply_ng(CMD_HF_ICLASS_WRITEBL, PM3_ETEAROFF, (uint8_t *)&res, sizeof(uint8_t)); - return; + res = false; + switch_off(); + if (payload->req.send_reply) + reply_ng(CMD_HF_ICLASS_WRITEBL, PM3_ETEAROFF, (uint8_t *)&res, sizeof(uint8_t)); + return; } else { if (GetIso15693AnswerFromTag(resp, sizeof(resp), ICLASS_READER_TIMEOUT_UPDATE, &eof_time) == 10) { @@ -1885,7 +1885,7 @@ void iClass_WriteBlock(uint8_t *msg) { } } } - + if (tries == 0) { res = false; goto out; @@ -1932,7 +1932,7 @@ void iClass_Restore(iclass_restore_req_t *msg) { if (msg->req.send_reply) { reply_ng(CMD_HF_ICLASS_RESTORE, PM3_ESOFT, NULL, 0); } - return; + return; } LED_A_ON(); @@ -1942,7 +1942,7 @@ void iClass_Restore(iclass_restore_req_t *msg) { uint32_t eof_time = 0; picopass_hdr hdr = {0}; - // select + // select bool res = select_iclass_tag(&hdr, msg->req.use_credit_key, &eof_time); if (res == false) { goto out; @@ -1974,7 +1974,7 @@ void iClass_Restore(iclass_restore_req_t *msg) { doMAC_N(wb, sizeof(wb), hdr.key_c, mac); else doMAC_N(wb, sizeof(wb), hdr.key_d, mac); - + // data + mac if (iclass_writeblock_ext(item.blockno, item.data, mac)) { Dbprintf("Write block [%02x] " _GREEN_("successful"), item.blockno); @@ -1983,7 +1983,7 @@ void iClass_Restore(iclass_restore_req_t *msg) { Dbprintf("Write block [%02x] " _RED_("failed"), item.blockno); } } - + out: switch_off(); diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index d40080ae1..6e1e22738 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -2629,7 +2629,7 @@ int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32 AddCrc14A(rats, 2); ReaderTransmit(rats, sizeof(rats), NULL); int len = ReaderReceive(resp, resp_par); - if (len == 0) + if (len == 0) return 0; if (p_card) { diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index 00af14c4f..bacceb165 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -1474,13 +1474,13 @@ int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t int res = 0; tosend_t *ts = get_tosend(); TransmitTo15693Tag(ts->buf, ts->max, &start_time); - + if (tearoff_hook() == PM3_ETEAROFF) { // tearoff occured res = PM3_ETEAROFF; } else { - + *eof_time = start_time + 32 * ((8 * ts->max) - 4); // substract the 4 padding bits after EOF LogTrace_ISO15693(send, sendlen, (start_time * 4), (*eof_time * 4), NULL, true); if (recv != NULL) { @@ -1595,11 +1595,11 @@ void ReaderIso15693(uint32_t parameter) { uint32_t start_time = 0; uint32_t eof_time; int recvlen = SendDataTag(cmd, sizeof(cmd), true, true, answer, ISO15693_MAX_RESPONSE_LENGTH, start_time, ISO15693_READER_TIMEOUT, &eof_time); - + if (recvlen == PM3_ETEAROFF) { // tearoff occured reply_mix(CMD_ACK, recvlen, 0, 0, NULL, 0); } else { - + start_time = eof_time + DELAY_ISO15693_VICC_TO_VCD_READER; // we should do a better check than this @@ -1634,7 +1634,7 @@ void ReaderIso15693(uint32_t parameter) { } } else { DbpString("Failed to select card"); - reply_mix(CMD_ACK, 0, 0, 0, NULL, 0); + reply_mix(CMD_ACK, 0, 0, 0, NULL, 0); } } switch_off(); @@ -1869,7 +1869,7 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint } if (recv) { - recvlen = MIN(recvlen,ISO15693_MAX_RESPONSE_LENGTH); + recvlen = MIN(recvlen, ISO15693_MAX_RESPONSE_LENGTH); reply_mix(CMD_ACK, recvlen, 0, 0, recvbuf, recvlen); } else { reply_mix(CMD_ACK, 1, 0, 0, NULL, 0); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index f442166f4..11c89a98b 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -2752,15 +2752,15 @@ void MifareU_Counter_Tearoff(uint8_t counter, uint32_t tearoff_time) { // Send MFU counter increase cmd uint8_t cmd[] = { - MIFARE_ULEV1_INCR_CNT, - counter, - 0, // lsb - 0, - 0, // msb - 0, // rfu - 0, - 0, - }; + MIFARE_ULEV1_INCR_CNT, + counter, + 0, // lsb + 0, + 0, // msb + 0, // rfu + 0, + 0, + }; AddCrc14A(cmd, sizeof(cmd) - 2); // anticollision / select card diff --git a/client/deps/cliparser/cliparser.c b/client/deps/cliparser/cliparser.c index a601e6490..258346c00 100644 --- a/client/deps/cliparser/cliparser.c +++ b/client/deps/cliparser/cliparser.c @@ -205,9 +205,9 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int int tmplen = 0; uint8_t tmpstr[(256 * 2) + 1] = {0}; - + // concat all strings in argstr into tmpstr[] - // + // int res = CLIParamStrToBuf(argstr, tmpstr, sizeof(tmpstr), &tmplen); if (res) { return res; @@ -216,7 +216,7 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int return res; } - res = param_gethex_to_eol((char*)tmpstr, 0, data, maxdatalen, datalen); + res = param_gethex_to_eol((char *)tmpstr, 0, data, maxdatalen, datalen); switch (res) { case 1: printf("Parameter error: Invalid HEX value\n"); @@ -241,20 +241,20 @@ int CLIParamStrToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int int ibuf = 0; for (int i = 0; i < argstr->count; i++) { - + int len = strlen(argstr->sval[i]); - - if (len > ( (sizeof(tmpstr) / 2 ) - ibuf)) { + + if (len > ((sizeof(tmpstr) / 2) - ibuf)) { printf("Parameter error: string too long (%i chars), expect MAX %zu chars\n", len + ibuf, (sizeof(tmpstr) / 2)); fflush(stdout); return 2; } - + memcpy(&tmpstr[ibuf], argstr->sval[i], len); ibuf += len; } - + ibuf = MIN(ibuf, (sizeof(tmpstr) / 2)); tmpstr[ibuf] = 0; diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 837311062..dac2193c6 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1843,30 +1843,30 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) { tip = "-> MIFARE Plus X 2K/4K (SL3)"; } else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) { - + if ((card.atqa[0] & 0x02) == 0x02) tip = "-> MIFARE Plus S 2K (SL3)"; else if ((card.atqa[0] & 0x04) == 0x04) tip = "-> MIFARE Plus S 4K (SL3)"; - + } else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x00\xF6\xD1", 7) == 0) { tip = "-> MIFARE Plus SE 1K (17pF)"; - } else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) { + } else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) { tip = "-> MIFARE Plus SE 1K (70pF)"; } - - } else { //SAK B4,5,6 - - if ((card.sak & 0x20) == 0x20) { // and no GetVersion().. - - + + } else { //SAK B4,5,6 + + if ((card.sak & 0x20) == 0x20) { // and no GetVersion().. + + if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x01\xBC\xD6", 7) == 0) { tip = "-> MIFARE Plus X 2K (SL1)"; } else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) { tip = "-> MIFARE Plus S 2K (SL1)"; } else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x00\xF6\xD1", 7) == 0) { tip = "-> MIFARE Plus SE 1K (17pF)"; - } else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) { + } else if (memcmp(card.ats + pos, "\xC1\x05\x21\x30\x10\xF6\xD1", 7) == 0) { tip = "-> MIFARE Plus SE 1K (70pF)"; } } else { @@ -1874,7 +1874,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { tip = "-> MIFARE Plus X 4K (SL1)"; } else if (memcmp(card.ats + pos, "\xC1\x05\x2F\x2F\x00\x35\xC7", 7) == 0) { tip = "-> MIFARE Plus S 4K (SL1)"; - } + } } } diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 85898fe04..73f8c2a8f 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -149,7 +149,7 @@ static int CmdHF14BSim(const char *Cmd) { PrintAndLogEx(FAILED, "failed to read pupi"); return PM3_EINVARG; } - + PrintAndLogEx(INFO, "Simulate with PUPI : " _GREEN_("%s"), sprint_hex_inrow(pupi, sizeof(pupi))); PrintAndLogEx(INFO, "Press pm3-button to abort simulation"); clearCommandBuffer(); diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index b4cde234f..6d276617c 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -656,13 +656,13 @@ static int CmdHF15Demod(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - + // The sampling rate is 106.353 ksps/s, for T = 18.8 us int i, j; int max = 0, maxPos = 0; int skip = 4; - if (GraphTraceLen < 1000) { + if (GraphTraceLen < 1000) { PrintAndLogEx(FAILED, "Too few samples in GraphBuffer. Need more than 1000"); PrintAndLogEx(HINT, "Run " _YELLOW_("`hf 15 samples`") " to collect and download data"); return PM3_ESOFT; @@ -733,8 +733,8 @@ static int CmdHF15Demod(const char *Cmd) { PrintAndLogEx(WARNING, "Warning, uneven octet! (discard extra bits!)"); PrintAndLogEx(INFO, " mask = %02x", mask); } - - if ( k == 0 ) { + + if (k == 0) { return PM3_SUCCESS; } @@ -744,7 +744,7 @@ static int CmdHF15Demod(const char *Cmd) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, " idx | data"); PrintAndLogEx(SUCCESS, "-----+-------------------------------------------------"); - if ( k / 16 > 0) { + if (k / 16 > 0) { for (; i < k; i += 16) { PrintAndLogEx(SUCCESS, " %3i | %s", i, sprint_hex(outBuf + i, 16)); } @@ -824,7 +824,7 @@ static int NxpSysInfo(uint8_t *uid) { if (status == PM3_ETEAROFF) { return status; } - + if (status < 2) { PrintAndLogEx(WARNING, "iso15693 card doesn't answer to NXP systeminfo command"); return PM3_EWRONGANSWER; @@ -1058,7 +1058,7 @@ static int CmdHF15Sniff(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - + PacketResponseNG resp; clearCommandBuffer(); SendCommandNG(CMD_HF_ISO15693_SNIFF, NULL, 0); @@ -1111,7 +1111,7 @@ static int CmdHF15Sim(const char *Cmd) { struct { uint8_t uid[8]; } PACKED payload; - + int uidlen = 0; CLIGetHexWithReturn(ctx, 1, payload.uid, &uidlen); CLIParserFree(ctx); @@ -1904,11 +1904,11 @@ static int CmdHF15CSetUID(const char *Cmd) { struct { uint8_t uid[8]; } PACKED payload; - + int uidlen = 0; CLIGetHexWithReturn(ctx, 1, payload.uid, &uidlen); CLIParserFree(ctx); - + if (uidlen != 8) { PrintAndLogEx(WARNING, "UID must include 16 HEX symbols got "); return PM3_EINVARG; @@ -1936,7 +1936,7 @@ static int CmdHF15CSetUID(const char *Cmd) { if (WaitForResponseTimeout(CMD_HF_ISO15693_CSETUID, &resp, 2000) == false) { PrintAndLogEx(WARNING, "timeout while waiting for reply"); DropField(); - return PM3_ESOFT; + return PM3_ESOFT; } PrintAndLogEx(INFO, "getting updated card details..."); diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index e9aaa1880..782e782eb 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -427,7 +427,7 @@ static void fuse_config(const picopass_hdr *hdr) { uint16_t otp = (hdr->conf.otp[1] << 8 | hdr->conf.otp[0]); - PrintAndLogEx(INFO, " Raw: " _YELLOW_("%s"), sprint_hex((uint8_t*)&hdr->conf, 8)); + PrintAndLogEx(INFO, " Raw: " _YELLOW_("%s"), sprint_hex((uint8_t *)&hdr->conf, 8)); PrintAndLogEx(INFO, " " _YELLOW_("%02X") "..................... app limit", hdr->conf.app_limit); PrintAndLogEx(INFO, " " _YELLOW_("%04X") " ( %5u )...... OTP", otp, otp); PrintAndLogEx(INFO, " " _YELLOW_("%02X") "............ block write lock", hdr->conf.block_writelock); @@ -1540,7 +1540,7 @@ static int CmdHFiClassDump(const char *Cmd) { PrintAndLogEx(SUCCESS, "Using " _YELLOW_("replay NR/MAC mode")); use_replay = true; cmdp++; - break; + break; default: PrintAndLogEx(WARNING, "Unknown parameter '%c'\n", param_getchar(Cmd, cmdp)); errors = true; @@ -1552,7 +1552,7 @@ static int CmdHFiClassDump(const char *Cmd) { PrintAndLogEx(FAILED, "Can not use a combo of 'e', 'r', 'n'"); errors = true; } - + if (errors) return usage_hf_iclass_dump(); uint32_t flags = (FLAG_ICLASS_READER_INIT | FLAG_ICLASS_READER_CLEARTRACE); @@ -1788,7 +1788,7 @@ write_dump: } static int iclass_write_block(uint8_t blockno, uint8_t *bldata, uint8_t *KEY, bool use_credit_key, bool elite, bool rawkey, bool replay, bool verbose) { - + iclass_writeblock_req_t payload = { .req.use_raw = rawkey, .req.use_elite = elite, @@ -1882,13 +1882,13 @@ static int CmdHFiClass_WriteBlock(const char *Cmd) { rawkey = true; cmdp++; break; -/* - case 'n': - PrintAndLogEx(SUCCESS, "Using " _YELLOW_("replay NR/MAC mode")); - use_replay = true; - cmdp++; - break; -*/ + /* + case 'n': + PrintAndLogEx(SUCCESS, "Using " _YELLOW_("replay NR/MAC mode")); + use_replay = true; + cmdp++; + break; + */ case 'v': verbose = true; cmdp++; @@ -1910,7 +1910,7 @@ static int CmdHFiClass_WriteBlock(const char *Cmd) { if (errors || cmdp < 6) return usage_hf_iclass_writeblock(); int isok = iclass_write_block(blockno, bldata, KEY, use_credit_key, elite, rawkey, use_replay, verbose); - switch(isok) { + switch (isok) { case PM3_SUCCESS: PrintAndLogEx(SUCCESS, "Wrote block %02X successful", blockno); break; @@ -2043,24 +2043,24 @@ static int CmdHFiClassRestore(const char *Cmd) { return PM3_EFILE; } - if (bytes_read < ((endblock - startblock + 1) * 8 )) { + if (bytes_read < ((endblock - startblock + 1) * 8)) { PrintAndLogEx(ERR, "file is smaller than your suggested block range ( " _RED_("0x%02x..0x%02x")" )", - startblock, endblock - ); + startblock, endblock + ); free(dump); return PM3_EFILE; } iclass_restore_req_t *payload = calloc(1, payload_size); payload->req.use_raw = rawkey, - payload->req.use_elite = elite, - payload->req.use_credit_key = use_credit_key, - payload->req.use_replay = false, - payload->req.blockno = startblock, - payload->req.send_reply = true, - payload->req.do_auth = true, - memcpy(payload->req.key, KEY, 8); - + payload->req.use_elite = elite, + payload->req.use_credit_key = use_credit_key, + payload->req.use_replay = false, + payload->req.blockno = startblock, + payload->req.send_reply = true, + payload->req.do_auth = true, + memcpy(payload->req.key, KEY, 8); + payload->item_cnt = (endblock - startblock + 1); // read data from file from block 6 --- 19 @@ -2068,21 +2068,21 @@ static int CmdHFiClassRestore(const char *Cmd) { // then copy to usbcommand->asbytes; // max is 32 - 6 = 28 block. 28 x 12 bytes gives 336 bytes - for (uint8_t i = 0; i < payload->item_cnt; i++) { + for (uint8_t i = 0; i < payload->item_cnt; i++) { payload->blocks[i].blockno = startblock + i; - memcpy(payload->blocks[i].data, dump + (startblock * 8) + (i * 8) , sizeof(payload->blocks[i].data)); + memcpy(payload->blocks[i].data, dump + (startblock * 8) + (i * 8), sizeof(payload->blocks[i].data)); } free(dump); if (verbose) { PrintAndLogEx(INFO, "Preparing to restore block range 0x%02x..0x%02x", startblock, endblock); - + PrintAndLogEx(INFO, "------+----------------------"); PrintAndLogEx(INFO, "block | data"); PrintAndLogEx(INFO, "------+----------------------"); - for (uint8_t i = 0; i < payload->item_cnt; i++) { + for (uint8_t i = 0; i < payload->item_cnt; i++) { iclass_restore_item_t item = payload->blocks[i]; PrintAndLogEx(INFO, " %02X | %s", item.blockno, sprint_hex_inrow(item.data, sizeof(item.data))); } @@ -2233,7 +2233,7 @@ static int CmdHFiClass_ReadBlock(const char *Cmd) { } if (got_blockno == false) errors = true; - + if ((use_replay + rawkey + elite) > 1) { PrintAndLogEx(FAILED, "Can not use a combo of 'e', 'r', 'n'"); errors = true; @@ -2405,7 +2405,7 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e PrintAndLogEx(INFO, " blk| data | ascii |lck| info"); PrintAndLogEx(INFO, "----+-------------------------+----------+---+--------------"); PrintAndLogEx(INFO, "0x00| " _GREEN_("%s") " | | CSN ", sprint_hex_ascii(iclass_dump, 8)); - + if (i != 1) PrintAndLogEx(INFO, "...."); @@ -2455,8 +2455,8 @@ void printIclassDumpContents(uint8_t *iclass_dump, uint8_t startblock, uint8_t e const char *s = info_nonks[3]; if (i < 3) { s = info_nonks[i]; - } - + } + PrintAndLogEx(INFO, "0x%02X| %s | %s | %s ", i, sprint_hex_ascii(blk, 8), lockstr, s); } else { const char *info_ks[] = {"CSN", "Config", "E-purse", "Debit", "Credit", "AIA", "User"}; @@ -2978,8 +2978,8 @@ static int CmdHFiClassCheckKeys(const char *Cmd) { free(keyBlock); return res; } - - // Get CSN / UID and CCNR + + // Get CSN / UID and CCNR PrintAndLogEx(SUCCESS, "Reading tag CSN / CCNR..."); for (uint8_t i = 0; i < ICLASS_AUTH_RETRY && !got_csn; i++) { got_csn = select_only(CSN, CCNR, false); @@ -2993,7 +2993,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) { DropField(); return PM3_ESOFT; } - + iclass_premac_t *pre = calloc(keycount, sizeof(iclass_premac_t)); if (pre == NULL) { return PM3_EMALLOC; @@ -3449,7 +3449,7 @@ static int CmdHFiClassAutopwn(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - + // Check keys. // dump diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index 7d9c077fb..fd0f6c93a 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -294,9 +294,9 @@ static int CmdHFMFPInfo(const char *Cmd) { } else { // info about 14a part infoHF14A(false, false, false); - + // Historical bytes. - + } diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index c472b8d59..55e03a848 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -242,7 +242,7 @@ static int usage_hf_mfu_otp_tearoff(void) { PrintAndLogEx(NORMAL, " s