mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
chg: 'sc raw' added 't' param, for decoding apdu response
chg: i2c, max timeout fitting for 256bytes frames
This commit is contained in:
parent
684a692bb0
commit
4a8e048694
4 changed files with 26 additions and 14 deletions
|
@ -758,20 +758,16 @@ int CmdHF14AAPDU(const char *cmd) {
|
||||||
while(param_getchar(cmd, cmdp) != 0x00) {
|
while(param_getchar(cmd, cmdp) != 0x00) {
|
||||||
char c = param_getchar(cmd, cmdp);
|
char c = param_getchar(cmd, cmdp);
|
||||||
if ((c == '-') && (param_getlength(cmd, cmdp) == 2))
|
if ((c == '-') && (param_getlength(cmd, cmdp) == 2))
|
||||||
switch (param_getchar_indx(cmd, 1, cmdp)) {
|
switch (tolower(param_getchar_indx(cmd, 1, cmdp))) {
|
||||||
case 'h':
|
case 'h':
|
||||||
case 'H':
|
|
||||||
return usage_hf_14a_apdu();
|
return usage_hf_14a_apdu();
|
||||||
case 's':
|
case 's':
|
||||||
case 'S':
|
|
||||||
activateField = true;
|
activateField = true;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'K':
|
|
||||||
leaveSignalON = true;
|
leaveSignalON = true;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
case 'T':
|
|
||||||
decodeTLV = true;
|
decodeTLV = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -17,6 +17,7 @@ int usage_sm_raw(void) {
|
||||||
PrintAndLogEx(NORMAL, " r : do not read response");
|
PrintAndLogEx(NORMAL, " r : do not read response");
|
||||||
PrintAndLogEx(NORMAL, " a : active signal field ON without select");
|
PrintAndLogEx(NORMAL, " a : active signal field ON without select");
|
||||||
PrintAndLogEx(NORMAL, " s : active signal field ON with select");
|
PrintAndLogEx(NORMAL, " s : active signal field ON with select");
|
||||||
|
PrintAndLogEx(NORMAL, " t : executes TLV decoder if it possible");
|
||||||
PrintAndLogEx(NORMAL, " d <bytes> : bytes to send");
|
PrintAndLogEx(NORMAL, " d <bytes> : bytes to send");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
|
@ -67,7 +68,7 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
bool active = false;
|
bool active = false;
|
||||||
bool active_select = false;
|
bool active_select = false;
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false, reply = true;
|
bool errors = false, reply = true, decodeTLV = false;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
|
@ -85,6 +86,10 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
active_select = true;
|
active_select = true;
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
decodeTLV = true;
|
||||||
|
cmdp++;
|
||||||
|
break;
|
||||||
case 'd': {
|
case 'd': {
|
||||||
switch (param_gethex_to_eol(Cmd, cmdp+1, data, sizeof(data), &hexlen)) {
|
switch (param_gethex_to_eol(Cmd, cmdp+1, data, sizeof(data), &hexlen)) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -135,19 +140,27 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
PrintAndLogEx(WARNING, "smart card response failed");
|
PrintAndLogEx(WARNING, "smart card response failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
uint32_t len = resp.arg[0];
|
uint32_t datalen = resp.arg[0];
|
||||||
|
|
||||||
if ( !len ) {
|
if ( !datalen ) {
|
||||||
PrintAndLogEx(WARNING, "smart card response failed");
|
PrintAndLogEx(WARNING, "smart card response failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "received %i bytes", len);
|
PrintAndLogEx(INFO, "received %i bytes", datalen);
|
||||||
|
|
||||||
if (!len)
|
if (!datalen)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "%s", sprint_hex(resp.d.asBytes, len) );
|
uint8_t *data = resp.d.asBytes;
|
||||||
|
|
||||||
|
// TLV decoder
|
||||||
|
if (decodeTLV && datalen > 4) {
|
||||||
|
PrintAndLogEx(SUCCESS, "APDU response: %02x %02x - %s", data[datalen - 2], data[datalen - 1], GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1]));
|
||||||
|
TLVPrintFromBuffer(data, datalen - 2);
|
||||||
|
} else {
|
||||||
|
PrintAndLogEx(SUCCESS, "%s", sprint_hex(data, datalen));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "loclass/fileutils.h" // saveFile
|
#include "loclass/fileutils.h" // saveFile
|
||||||
#include "cmdmain.h" // getfromdevice
|
#include "cmdmain.h" // getfromdevice
|
||||||
|
#include "emv/emvcore.h" // decodeTVL
|
||||||
|
#include "emv/apduinfo.h" // APDUcode description
|
||||||
|
|
||||||
extern int CmdSmartcard(const char *Cmd);
|
extern int CmdSmartcard(const char *Cmd);
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,8 @@ bool I2C_WaitForSim() {
|
||||||
|
|
||||||
// 8051 speaks with smart card.
|
// 8051 speaks with smart card.
|
||||||
// 1000*50*3.07 = 153.5ms
|
// 1000*50*3.07 = 153.5ms
|
||||||
if (!WaitSCL_H_delay(1000*50) )
|
// 1byte transfer == 1ms
|
||||||
|
if (!WaitSCL_H_delay(2000*50) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue