From 38034480ca3cf5627627efd323dcb8e58441f7d3 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 24 Jul 2023 01:42:24 +0200 Subject: [PATCH] text --- client/src/cmdhf14a.c | 26 ++++++++++++-------------- client/src/cmdhffudan.c | 2 +- client/src/cmdhfjooki.c | 4 ++-- client/src/cmdhfmf.c | 28 ++++++++++++++-------------- client/src/cmdhfmfu.c | 8 ++++---- client/src/mifare/mifarehost.c | 14 ++++++++++---- 6 files changed, 43 insertions(+), 39 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index f2ca64076..ac94d8d0c 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -418,11 +418,10 @@ static int CmdHf14AConfig(const char *Cmd) { } int Hf14443_4aGetCardData(iso14a_card_select_t *card) { - SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); + SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; WaitForResponse(CMD_ACK, &resp); - memcpy(card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t)); uint64_t select_status = resp.oldarg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision @@ -548,16 +547,17 @@ static int CmdHF14AReader(const char *Cmd) { } bool continuous = arg_get_lit(ctx, 7); - CLIParserFree(ctx); - int res = PM3_SUCCESS; - - if (!disconnectAfter) + if (!disconnectAfter == false) { cm |= ISO14A_NO_DISCONNECT; + } + if (continuous) { PrintAndLogEx(INFO, "Press " _GREEN_("Enter") " to exit"); } + + int res = PM3_SUCCESS; do { clearCommandBuffer(); @@ -570,8 +570,7 @@ static int CmdHF14AReader(const char *Cmd) { if (ISO14A_CONNECT & cm) { PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { - if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed"); + if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) { DropField(); res = PM3_ESOFT; goto plot; @@ -589,7 +588,6 @@ static int CmdHF14AReader(const char *Cmd) { uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed"); DropField(); res = PM3_ESOFT; goto plot; @@ -625,8 +623,8 @@ static int CmdHF14AReader(const char *Cmd) { } PrintAndLogEx(NORMAL, ""); } - if (!disconnectAfter) { - if (!silent) PrintAndLogEx(SUCCESS, "Card is selected. You can now start sending commands"); + if ((disconnectAfter == false) && (silent == false)) { + PrintAndLogEx(SUCCESS, "Card is selected. You can now start sending commands"); } } plot: @@ -1865,8 +1863,8 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { clearCommandBuffer(); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { - if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed"); + if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) { + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); DropField(); return 0; } @@ -1883,7 +1881,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); DropField(); return select_status; } diff --git a/client/src/cmdhffudan.c b/client/src/cmdhffudan.c index 38ef8eef5..53e580e1b 100644 --- a/client/src/cmdhffudan.c +++ b/client/src/cmdhffudan.c @@ -110,7 +110,7 @@ static int fudan_get_type(iso14a_card_select_t *card, bool verbose) { SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) { - PrintAndLogEx(DEBUG, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ESOFT; } diff --git a/client/src/cmdhfjooki.c b/client/src/cmdhfjooki.c index 93ca6a00a..025fdf5c4 100644 --- a/client/src/cmdhfjooki.c +++ b/client/src/cmdhfjooki.c @@ -200,7 +200,7 @@ static int jooki_create_ndef(uint8_t *b64ndef, uint8_t *ndefrecord) { static void jooki_printEx(uint8_t *b64, uint8_t *iv, uint8_t tid, uint8_t fid, uint8_t *uid, bool verbose) { int idx = jooki_lookup(tid, fid); - PrintAndLogEx(INFO, "Encoded URL.. %s ( %s )", sprint_hex(b64, 12), b64); + PrintAndLogEx(INFO, "Encoded URL.. %s ( " _YELLOW_("%s") " )", sprint_hex(b64, 12), b64); PrintAndLogEx(INFO, "Figurine..... %02x %02x - " _GREEN_("%s, %s") , tid , fid @@ -574,7 +574,7 @@ static int CmdHF14AJookiSim(const char *Cmd) { break; } - if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0) + if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == false) continue; if (resp.status != PM3_SUCCESS) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index a02026b06..8c03888f0 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -101,8 +101,8 @@ static int GetHFMF14AUID(uint8_t *uid, int *uidlen) { clearCommandBuffer(); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) { + PrintAndLogEx(DEBUG, "iso14443a card select failed"); DropField(); return PM3_ERFTRANS; } @@ -551,13 +551,13 @@ static int mfc_read_tag(iso14a_card_select_t *card, uint8_t *carddata, uint8_t n SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "iso14443a card select timeout"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ETIMEOUT; } uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_SUCCESS; } @@ -2487,13 +2487,13 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "iso14443a card select timeout"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ETIMEOUT; } uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_ECARDEXCHANGE; } @@ -5248,7 +5248,7 @@ static int CmdHF14AMfCSave(const char *Cmd) { SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "iso14443a card select timeout"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ETIMEOUT; } @@ -5260,7 +5260,7 @@ static int CmdHF14AMfCSave(const char *Cmd) { */ uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_SUCCESS; } @@ -5398,7 +5398,7 @@ static int CmdHF14AMfCView(const char *Cmd) { SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "iso14443a card select timeout"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ETIMEOUT; } @@ -5411,7 +5411,7 @@ static int CmdHF14AMfCView(const char *Cmd) { uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_ERFTRANS; } @@ -6231,13 +6231,13 @@ int CmdHFMFNDEFFormat(const char *Cmd) { SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "iso14443a card select timeout"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ETIMEOUT; } uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_SUCCESS; } @@ -7933,7 +7933,7 @@ static int CmdHF14AGen4Save(const char *Cmd) { SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "iso14443a card select timeout"); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); return PM3_ETIMEOUT; } @@ -7945,7 +7945,7 @@ static int CmdHF14AGen4Save(const char *Cmd) { */ uint64_t select_status = resp.oldarg[0]; if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_SUCCESS; } diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 9f7f54c53..6762d0b1c 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -190,7 +190,7 @@ int ul_read_uid(uint8_t *uid) { // 2: OK, no ATS // 3: proprietary Anticollision if (select_status == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); return PM3_ESOFT; } if (card.uidlen != 7) { @@ -224,14 +224,14 @@ static bool ul_select(iso14a_card_select_t *card) { PacketResponseNG resp; if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { - PrintAndLogEx(WARNING, "timeout while waiting for reply."); + PrintAndLogEx(DEBUG, "iso14443a card select timeout"); DropField(); return false; } else { uint16_t len = (resp.oldarg[1] & 0xFFFF); if (len == 0) { - PrintAndLogEx(WARNING, "iso14443a card select failed"); + PrintAndLogEx(DEBUG, "iso14443a card select failed"); DropField(); return false; } @@ -1351,7 +1351,7 @@ static mfu_identify_t mfu_ident_table[] = { "Jooki", "0004040201000F03", 12, 32, "E11012000103A00C340329D101255504732E6A6F6F6B692E726F636B732F732F", ul_ev1_pwdgen_def, ul_ev1_packgen_def, - "hf jooki decode -r" + "hf mfu ndefread" }, { "Lego Dimensions", "0004040201000F03", diff --git a/client/src/mifare/mifarehost.c b/client/src/mifare/mifarehost.c index 6c9d8caa2..bdf4ec7f1 100644 --- a/client/src/mifare/mifarehost.c +++ b/client/src/mifare/mifarehost.c @@ -195,15 +195,22 @@ int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keyc SendCommandNG(CMD_HF_MIFARE_CHKKEYS, data, (5 + 6 * keycnt)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_HF_MIFARE_CHKKEYS, &resp, 2500)) return PM3_ETIMEOUT; - if (resp.status != PM3_SUCCESS) return resp.status; + if (!WaitForResponseTimeout(CMD_HF_MIFARE_CHKKEYS, &resp, 2500)) { + return PM3_ETIMEOUT; + } + if (resp.status != PM3_SUCCESS) { + return resp.status; + } struct kr { uint8_t key[6]; bool found; } PACKED; struct kr *keyresult = (struct kr *)&resp.data.asBytes; - if (!keyresult->found) return PM3_ESOFT; + if (!keyresult->found) { + return PM3_ESOFT; + } + *key = bytes_to_num(keyresult->key, sizeof(keyresult->key)); return PM3_SUCCESS; } @@ -585,7 +592,6 @@ out: return PM3_ESOFT; } - int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t *resultKey) { uint32_t uid;