This commit is contained in:
iceman1001 2023-07-24 01:42:24 +02:00
commit 38034480ca
6 changed files with 43 additions and 39 deletions

View file

@ -418,11 +418,10 @@ static int CmdHf14AConfig(const char *Cmd) {
} }
int Hf14443_4aGetCardData(iso14a_card_select_t *card) { 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; PacketResponseNG resp;
WaitForResponse(CMD_ACK, &resp); WaitForResponse(CMD_ACK, &resp);
memcpy(card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t)); 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 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); bool continuous = arg_get_lit(ctx, 7);
CLIParserFree(ctx); CLIParserFree(ctx);
int res = PM3_SUCCESS; if (!disconnectAfter == false) {
if (!disconnectAfter)
cm |= ISO14A_NO_DISCONNECT; cm |= ISO14A_NO_DISCONNECT;
}
if (continuous) { if (continuous) {
PrintAndLogEx(INFO, "Press " _GREEN_("Enter") " to exit"); PrintAndLogEx(INFO, "Press " _GREEN_("Enter") " to exit");
} }
int res = PM3_SUCCESS;
do { do {
clearCommandBuffer(); clearCommandBuffer();
@ -570,8 +570,7 @@ static int CmdHF14AReader(const char *Cmd) {
if (ISO14A_CONNECT & cm) { if (ISO14A_CONNECT & cm) {
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) {
if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed");
DropField(); DropField();
res = PM3_ESOFT; res = PM3_ESOFT;
goto plot; goto plot;
@ -589,7 +588,6 @@ static int CmdHF14AReader(const char *Cmd) {
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed");
DropField(); DropField();
res = PM3_ESOFT; res = PM3_ESOFT;
goto plot; goto plot;
@ -625,8 +623,8 @@ static int CmdHF14AReader(const char *Cmd) {
} }
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
} }
if (!disconnectAfter) { if ((disconnectAfter == false) && (silent == false)) {
if (!silent) PrintAndLogEx(SUCCESS, "Card is selected. You can now start sending commands"); PrintAndLogEx(SUCCESS, "Card is selected. You can now start sending commands");
} }
} }
plot: plot:
@ -1865,8 +1863,8 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) {
if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
DropField(); DropField();
return 0; 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]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
DropField(); DropField();
return select_status; return select_status;
} }

View file

@ -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); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) {
PrintAndLogEx(DEBUG, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ESOFT; return PM3_ESOFT;
} }

View file

@ -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) { 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); 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") PrintAndLogEx(INFO, "Figurine..... %02x %02x - " _GREEN_("%s, %s")
, tid , tid
, fid , fid
@ -574,7 +574,7 @@ static int CmdHF14AJookiSim(const char *Cmd) {
break; break;
} }
if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0) if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == false)
continue; continue;
if (resp.status != PM3_SUCCESS) if (resp.status != PM3_SUCCESS)

View file

@ -101,8 +101,8 @@ static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) { if (WaitForResponseTimeout(CMD_ACK, &resp, 2500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
DropField(); DropField();
return PM3_ERFTRANS; 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); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select timeout"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -2487,13 +2487,13 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select timeout"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_ECARDEXCHANGE; return PM3_ECARDEXCHANGE;
} }
@ -5248,7 +5248,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select timeout"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
@ -5260,7 +5260,7 @@ static int CmdHF14AMfCSave(const char *Cmd) {
*/ */
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -5398,7 +5398,7 @@ static int CmdHF14AMfCView(const char *Cmd) {
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select timeout"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
@ -5411,7 +5411,7 @@ static int CmdHF14AMfCView(const char *Cmd) {
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_ERFTRANS; return PM3_ERFTRANS;
} }
@ -6231,13 +6231,13 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select timeout"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -7933,7 +7933,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT, 0, 0, NULL, 0);
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "iso14443a card select timeout"); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
@ -7945,7 +7945,7 @@ static int CmdHF14AGen4Save(const char *Cmd) {
*/ */
uint64_t select_status = resp.oldarg[0]; uint64_t select_status = resp.oldarg[0];
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -190,7 +190,7 @@ int ul_read_uid(uint8_t *uid) {
// 2: OK, no ATS // 2: OK, no ATS
// 3: proprietary Anticollision // 3: proprietary Anticollision
if (select_status == 0) { if (select_status == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
return PM3_ESOFT; return PM3_ESOFT;
} }
if (card.uidlen != 7) { if (card.uidlen != 7) {
@ -224,14 +224,14 @@ static bool ul_select(iso14a_card_select_t *card) {
PacketResponseNG resp; PacketResponseNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) {
PrintAndLogEx(WARNING, "timeout while waiting for reply."); PrintAndLogEx(DEBUG, "iso14443a card select timeout");
DropField(); DropField();
return false; return false;
} else { } else {
uint16_t len = (resp.oldarg[1] & 0xFFFF); uint16_t len = (resp.oldarg[1] & 0xFFFF);
if (len == 0) { if (len == 0) {
PrintAndLogEx(WARNING, "iso14443a card select failed"); PrintAndLogEx(DEBUG, "iso14443a card select failed");
DropField(); DropField();
return false; return false;
} }
@ -1351,7 +1351,7 @@ static mfu_identify_t mfu_ident_table[] = {
"Jooki", "0004040201000F03", "Jooki", "0004040201000F03",
12, 32, "E11012000103A00C340329D101255504732E6A6F6F6B692E726F636B732F732F", 12, 32, "E11012000103A00C340329D101255504732E6A6F6F6B692E726F636B732F732F",
ul_ev1_pwdgen_def, ul_ev1_packgen_def, ul_ev1_pwdgen_def, ul_ev1_packgen_def,
"hf jooki decode -r" "hf mfu ndefread"
}, },
{ {
"Lego Dimensions", "0004040201000F03", "Lego Dimensions", "0004040201000F03",

View file

@ -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)); SendCommandNG(CMD_HF_MIFARE_CHKKEYS, data, (5 + 6 * keycnt));
PacketResponseNG resp; PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_HF_MIFARE_CHKKEYS, &resp, 2500)) return PM3_ETIMEOUT; if (!WaitForResponseTimeout(CMD_HF_MIFARE_CHKKEYS, &resp, 2500)) {
if (resp.status != PM3_SUCCESS) return resp.status; return PM3_ETIMEOUT;
}
if (resp.status != PM3_SUCCESS) {
return resp.status;
}
struct kr { struct kr {
uint8_t key[6]; uint8_t key[6];
bool found; bool found;
} PACKED; } PACKED;
struct kr *keyresult = (struct kr *)&resp.data.asBytes; 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)); *key = bytes_to_num(keyresult->key, sizeof(keyresult->key));
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -585,7 +592,6 @@ out:
return PM3_ESOFT; return PM3_ESOFT;
} }
int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t *resultKey) { int mfStaticNested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t *resultKey) {
uint32_t uid; uint32_t uid;