X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/18b90cce48df64bf528fe358308383bf8b5fba15..517f8f84e427888dc0d6bcebeb16595ba1ad642e:/client/cmdhf14b.c?ds=sidebyside diff --git a/client/cmdhf14b.c b/client/cmdhf14b.c index cb93b1fc..a328d039 100644 --- a/client/cmdhf14b.c +++ b/client/cmdhf14b.c @@ -59,12 +59,14 @@ int usage_hf_14b_snoop(void){ return 0; } int usage_hf_14b_sim(void){ - PrintAndLog("Emulating ISO/IEC 14443 type B tag with 4 UID"); - PrintAndLog("Usage: hf 14b sim [h]"); + PrintAndLog("Emulating ISO/IEC 14443 type B tag with 4 UID / PUPI"); + PrintAndLog("Usage: hf 14b sim [h] u "); PrintAndLog("Options:"); PrintAndLog(" h this help"); + PrintAndLog(" u 4byte UID/PUPI"); PrintAndLog("sample:"); PrintAndLog(" hf 14b sim"); + PrintAndLog(" hf 14b sim u 11223344"); return 0; } int usage_hf_14b_read_srx(void){ @@ -111,10 +113,15 @@ int CmdHF14BList(const char *Cmd) { } int CmdHF14BSim(const char *Cmd) { - char cmdp = param_getchar(Cmd, 0); + char cmdp = param_getchar(Cmd, 0); if (cmdp == 'h' || cmdp == 'H') return usage_hf_14b_sim(); - UsbCommand c = {CMD_SIMULATE_TAG_ISO_14443B, {0, 0, 0}}; + uint32_t pupi = 0; + if (cmdp == 'u' || cmdp == 'U') { + pupi = param_get32ex(Cmd, 1, 0, 16); + } + + UsbCommand c = {CMD_SIMULATE_TAG_ISO_14443B, {pupi, 0, 0}}; clearCommandBuffer(); SendCommand(&c); return 0; @@ -848,24 +855,28 @@ bool waitCmd(bool verbose) { if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) { - status = (resp.arg[0] & 0xFFFF); + status = (resp.arg[0] & 0xFF); if ( status > 0 ) return FALSE; - + len = (resp.arg[1] & 0xFFFF); + memcpy(data, resp.d.asBytes, len); if (verbose) { - - ComputeCrc14443(CRC_14443_B, data, len-2, &b1, &b2); - crc = ( data[len-2] == b1 && data[len-1] == b2); - - PrintAndLog("[LEN %u] %s[%02X %02X] %s", - len, - sprint_hex(data, len-2), - data[len-2], - data[len-1], - (crc) ? "OK" : "FAIL" - ); + if ( len >= 3 ) { + ComputeCrc14443(CRC_14443_B, data, len-2, &b1, &b2); + crc = ( data[len-2] == b1 && data[len-1] == b2); + + PrintAndLog("[LEN %u] %s[%02X %02X] %s", + len, + sprint_hex(data, len-2), + data[len-2], + data[len-1], + (crc) ? "OK" : "FAIL" + ); + } else { + PrintAndLog("[LEN %u] %s", len, sprint_hex(data, len) ); + } } return TRUE; } else {