From 238572c3374f6b4b0e9fa53aaaad0203ab18033e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 1 Jan 2024 21:52:05 +0100 Subject: [PATCH] style --- armsrc/appmain.c | 2 +- armsrc/iso14443a.c | 4 +-- armsrc/mifarecmd.c | 4 +-- client/src/cmddata.c | 4 +-- client/src/cmdhfemrtd.c | 30 ++++++++-------- client/src/cmdhfmf.c | 2 +- client/src/cmdhfmfp.c | 66 +++++++++++++++++------------------ client/src/cmdlf.c | 16 ++++----- client/src/cmdusart.c | 8 ++--- client/src/comms.c | 4 +-- client/src/proxmark3.c | 2 +- client/src/uart/uart_common.c | 2 +- client/src/uart/uart_posix.c | 3 +- doc/commands.json | 16 ++++----- 14 files changed, 81 insertions(+), 82 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index be7cb018d..1256afc9d 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1734,7 +1734,7 @@ static void PacketReceived(PacketCommandNG *packet) { case CMD_HF_MIFARE_CIDENT: { - struct p { + struct p { uint8_t is_mfc; uint8_t keytype; uint8_t key[6]; diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index b7b6d3852..c06e2af48 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -2695,7 +2695,7 @@ int iso14443a_select_cardEx(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint uint16_t UIDbit = (resp[i / 8] >> (i % 8)) & 0x01; uid_resp[uid_resp_bits / 8] |= UIDbit << (uid_resp_bits % 8); } - + uid_resp[uid_resp_bits / 8] |= 1 << (uid_resp_bits % 8); // next time select the card(s) with a 1 in the collision position uid_resp_bits++; // construct anticollision command: @@ -3516,7 +3516,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) { */ void DetectNACKbug(void) { uint8_t mf_auth[4] = { MIFARE_AUTH_KEYA, 0x00, 0xF5, 0x7B }; - uint8_t mf_nr_ar[8]= { 0x00 }; + uint8_t mf_nr_ar[8] = { 0x00 }; uint8_t uid[10] = { 0x00 }; uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = { 0x00 }; uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE] = { 0x00 }; diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 2cf2c19e0..7fd97ea80 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -2477,7 +2477,7 @@ void MifareCIdent(bool is_mfc, uint8_t keytype, uint8_t *key) { } // reset card - mf_reset_card(); + mf_reset_card(); res = iso14443a_select_card(uid, NULL, &cuid, true, 0, false); if (res) { @@ -2557,7 +2557,7 @@ void MifareCIdent(bool is_mfc, uint8_t keytype, uint8_t *key) { struct Crypto1State mpcs = {0, 0}; struct Crypto1State *pcs; pcs = &mpcs; - + // CUID (with default sector 0 B key) test // regular cards will NAK the WRITEBLOCK(0) command, while DirectWrite will ACK it // if we do get an ACK, we immediately abort to ensure nothing is ever actually written diff --git a/client/src/cmddata.c b/client/src/cmddata.c index e244a7bf5..7c0b3947e 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -870,7 +870,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG if (distance == -1) { distance = peaks[i]; continue; - } + } if (peaks[i] < distance) { distance = peaks[i]; @@ -3416,7 +3416,7 @@ static int CmdNumCon(const char *Cmd) { continue; } - switch(i) { + switch (i) { case 0: // MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod(&N, &N, &base)); break; diff --git a/client/src/cmdhfemrtd.c b/client/src/cmdhfemrtd.c index 5b9482381..0933217cd 100644 --- a/client/src/cmdhfemrtd.c +++ b/client/src/cmdhfemrtd.c @@ -1285,7 +1285,7 @@ static void emrtd_print_issuance(char *data, bool ascii) { } static void emrtd_print_personalization_timestamp(uint8_t *data, size_t datalen) { - if (datalen < 7 ) { + if (datalen < 7) { return; } @@ -1294,13 +1294,13 @@ static void emrtd_print_personalization_timestamp(uint8_t *data, size_t datalen) char final_date[20] = { 0x00 }; snprintf(final_date, sizeof(final_date), "%.4s-%.2s-%.2s %.2s:%.2s:%.2s" - , str_date - , str_date + 4 - , str_date + 6 - , str_date + 8 - , str_date + 10 - , str_date + 12 - ); + , str_date + , str_date + 4 + , str_date + 6 + , str_date + 8 + , str_date + 10 + , str_date + 12 + ); PrintAndLogEx(SUCCESS, "Personalization at....: " _YELLOW_("%s"), final_date); } @@ -1311,13 +1311,13 @@ static void emrtd_print_unknown_timestamp_5f85(uint8_t *data, size_t datalen) { } char final_date[20] = { 0x00 }; snprintf(final_date, sizeof(final_date), "%.4s-%.2s-%.2s %.2s:%.2s:%.2s" - , data - , data + 4 - , data + 6 - , data + 8 - , data + 10 - , data + 12 - ); + , data + , data + 4 + , data + 6 + , data + 8 + , data + 10 + , data + 12 + ); PrintAndLogEx(SUCCESS, "Unknown timestamp 5F85: " _YELLOW_("%s"), final_date); PrintAndLogEx(HINT, "This is very likely the personalization timestamp, but it is using an undocumented tag."); diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index f878093df..e9091b3c3 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -8965,7 +8965,7 @@ static int CmdHF14AMfInfo(const char *Cmd) { if ( (blockdata[8] == 0x03 && blockdata[15] == 0x90) || - (blockdata[9] == 0x02 && blockdata[14] == 0x1D) || + (blockdata[9] == 0x02 && blockdata[14] == 0x1D) || (memcmp(blockdata + 8, "\x62\x63\x64\x65\x66\x67\x68\x69", 8) == 0) ) { PrintAndLogEx(SUCCESS, " Fudan tag detected"); diff --git a/client/src/cmdhfmfp.c b/client/src/cmdhfmfp.c index 2a48f462a..15f244141 100644 --- a/client/src/cmdhfmfp.c +++ b/client/src/cmdhfmfp.c @@ -1682,46 +1682,46 @@ static int CmdHFMFPDump(const char *Cmd) { PrintAndLogEx(INFO, " To be implemented, feel free to contribute!"); return PM3_ENOTIMPL; -/* - mfpSetVerboseMode(verbose); + /* + mfpSetVerboseMode(verbose); - // read card - uint8_t *mem = calloc(MIFARE_4K_MAXBLOCK * MFBLOCK_SIZE, sizeof(uint8_t)); - if (mem == NULL) { - PrintAndLogEx(ERR, "failed to allocate memory"); - return PM3_EMALLOC; - } + // read card + uint8_t *mem = calloc(MIFARE_4K_MAXBLOCK * MFBLOCK_SIZE, sizeof(uint8_t)); + if (mem == NULL) { + PrintAndLogEx(ERR, "failed to allocate memory"); + 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) { - PrintAndLogEx(INFO, "Called with no save option"); + // Skip saving card data to file + if (nosave) { + PrintAndLogEx(INFO, "Called with no save option"); + free(mem); + return PM3_SUCCESS; + } + + // 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-"); + // FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen); + // strcpy(data_fn, fptr); + // free(fptr); + // } + + // pm3_save_mf_dump(filename, dump, MIFARE_4K_MAX_BYTES, jsfCardMemory); + free(mem); return PM3_SUCCESS; - } - - // 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-"); -// FillFileNameByUID(fptr, card.uid, "-dump", card.uidlen); -// strcpy(data_fn, fptr); -// free(fptr); -// } - -// pm3_save_mf_dump(filename, dump, MIFARE_4K_MAX_BYTES, jsfCardMemory); - - free(mem); - return PM3_SUCCESS; -*/ + */ } diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index a2024a60a..11b48d6b7 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -1916,13 +1916,13 @@ int CmdLFfind(const char *Cmd) { PrintAndLogEx(INFO, _CYAN_("Checking for unknown tags...") "\n"); uint8_t ones[] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - }; + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + }; // FSK PrintAndLogEx(INFO, "FSK clock.......... " NOLF); @@ -1971,7 +1971,7 @@ int CmdLFfind(const char *Cmd) { check_autocorrelate("NRZ", clock); found++; } else { - PrintAndLogEx(INFO, "NRZ ............... " _RED_("false positive")); + PrintAndLogEx(INFO, "NRZ ............... " _RED_("false positive")); PrintAndLogEx(NORMAL, ""); } } else { diff --git a/client/src/cmdusart.c b/client/src/cmdusart.c index be52aa7ca..fded09581 100644 --- a/client/src/cmdusart.c +++ b/client/src/cmdusart.c @@ -168,8 +168,8 @@ static int usart_bt_testcomm(uint32_t baudrate, uint8_t parity) { if (ret == PM3_SUCCESS) { PrintAndLogEx(SUCCESS, "RX (%3zu):%.*s", len, (int)len, data); if (str_startswith((char *)data, "hc01.comV2.0") || - str_startswith((char *)data, "www.hc01.com") || - str_startswith((char *)data, "BT SPP V4.0")) { + str_startswith((char *)data, "www.hc01.com") || + str_startswith((char *)data, "BT SPP V4.0")) { PrintAndLogEx(SUCCESS, "Add-on " _GREEN_("found!")); @@ -310,7 +310,7 @@ static int CmdUsartBtFactory(const char *Cmd) { memset(data, 0, sizeof(data)); len = 0; - + if (isBluetoothExtensionHC04 == true) { string = "AT+PIN=1234"; } else { @@ -378,7 +378,7 @@ static int CmdUsartBtFactory(const char *Cmd) { } else { memset(data, 0, sizeof(data)); - len=0; + len = 0; string = "AT+BAUD=115200,N"; PrintAndLogEx(SUCCESS, "TX (%3zu):%.*s", strlen(string), (int)strlen(string), string); diff --git a/client/src/comms.c b/client/src/comms.c index 70dbdff04..cdda2ea77 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -362,7 +362,7 @@ void *uart_reconnect(void *targ) { } if (g_session.pm3_present && (TestProxmark(g_session.current_device) != PM3_SUCCESS)) { - CloseProxmark(g_session.current_device); + CloseProxmark(g_session.current_device); } else { break; } @@ -728,7 +728,7 @@ bool OpenProxmarkSilent(pm3_device_t **dev, const char *port, uint32_t speed) { pthread_create(&communication_thread, NULL, &uart_communication, &g_conn); __atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST); __atomic_clear(&reconnect_ok, __ATOMIC_SEQ_CST); - + g_session.pm3_present = true; // TODO support for multiple devices fflush(stdout); diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index 42f1a92c1..97c82541e 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -190,7 +190,7 @@ static int check_comm(void) { CloseProxmark(g_session.current_device); StartReconnectProxmark(); c_update_reconnect_prompt = true; - } + } // its alive again if (c_update_reconnect_prompt && IsReconnectedOk() && g_session.pm3_present) { diff --git a/client/src/uart/uart_common.c b/client/src/uart/uart_common.c index 3e7fc5fb5..e10897326 100644 --- a/client/src/uart/uart_common.c +++ b/client/src/uart/uart_common.c @@ -131,4 +131,4 @@ int uart_parse_address_port(char *addrPortStr, const char **addrStr, const char } return PM3_SUCCESS; -} \ No newline at end of file +} diff --git a/client/src/uart/uart_posix.c b/client/src/uart/uart_posix.c index 5b6902a1c..0863cc9b7 100644 --- a/client/src/uart/uart_posix.c +++ b/client/src/uart/uart_posix.c @@ -108,8 +108,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed, bool slient) { bool isUDP = false; bool isBluetooth = false; bool isUnixSocket = false; - if (strlen(prefix) > 4) - { + if (strlen(prefix) > 4) { isTCP = (memcmp(prefix, "tcp:", 4) == 0); isUDP = (memcmp(prefix, "udp:", 4) == 0); } diff --git a/doc/commands.json b/doc/commands.json index edebe62b9..e35ae8855 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -4709,7 +4709,7 @@ }, "hf mf info": { "command": "hf mf info", - "description": "Information and check vulnerabilities in a MIFARE Classic card Some cards in order to extract information you need to specify key and/or specific keys in the copmmand line", + "description": "Information and check vulnerabilities in a MIFARE Classic card Some cards in order to extract information you need to specify key and/or specific keys in the command line", "notes": [ "hf mf info", "hf mf info -k FFFFFFFFFFFF -n -v" @@ -7257,7 +7257,7 @@ "offline": false, "options": [ "-h, --help This help", - "-1 Use data from Graphbuffer", + "-1 Use data from Graphbuffer (offline mode)", "-v, --verbose Verbose scan and output", "-@ optional - continuous reader mode" ], @@ -10105,16 +10105,16 @@ "description": "Read and search for valid known tag. For offline mode, you can `data load` first then search.", "notes": [ "lf search -> try reading data from tag & search for known tag", - "lf search -1 -> use data from the GraphBuffer & search for known tag", "lf search -u -> try reading data from tag & search for known and unknown tag", - "lf search -1u -> use data from the GraphBuffer & search for known and unknown tag" + "lf search -1 -> use data from the GraphBuffer & search for known tag", + "lf search -1uc -> use data from the GraphBuffer & search for known and unknown tag" ], "offline": true, "options": [ "-h, --help This help", - "-1 Use data from Graphbuffer to search", - "-c Continue searching even after a first hit", - "-u Search for unknown tags. If not set, reads only known tags" + "-1 Use data from Graphbuffer to search (offline mode)", + "-c Continue searching after successful match", + "-u Search for unknown tags" ], "usage": "lf search [-h1cu]" }, @@ -12160,6 +12160,6 @@ "metadata": { "commands_extracted": 703, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2023-12-18T09:05:00" + "extracted_on": "2024-01-01T20:49:58" } } \ No newline at end of file