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) {
|
||||
char c = param_getchar(cmd, cmdp);
|
||||
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':
|
||||
return usage_hf_14a_apdu();
|
||||
case 's':
|
||||
case 'S':
|
||||
activateField = true;
|
||||
break;
|
||||
case 'k':
|
||||
case 'K':
|
||||
leaveSignalON = true;
|
||||
break;
|
||||
case 't':
|
||||
case 'T':
|
||||
decodeTLV = true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -17,6 +17,7 @@ int usage_sm_raw(void) {
|
|||
PrintAndLogEx(NORMAL, " r : do not read response");
|
||||
PrintAndLogEx(NORMAL, " a : active signal field ON without 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, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
|
@ -67,7 +68,7 @@ int CmdSmartRaw(const char *Cmd) {
|
|||
bool active = false;
|
||||
bool active_select = false;
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false, reply = true;
|
||||
bool errors = false, reply = true, decodeTLV = false;
|
||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
|
@ -85,6 +86,10 @@ int CmdSmartRaw(const char *Cmd) {
|
|||
active_select = true;
|
||||
cmdp++;
|
||||
break;
|
||||
case 't':
|
||||
decodeTLV = true;
|
||||
cmdp++;
|
||||
break;
|
||||
case 'd': {
|
||||
switch (param_gethex_to_eol(Cmd, cmdp+1, data, sizeof(data), &hexlen)) {
|
||||
case 1:
|
||||
|
@ -135,19 +140,27 @@ int CmdSmartRaw(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "smart card response failed");
|
||||
return 1;
|
||||
}
|
||||
uint32_t len = resp.arg[0];
|
||||
uint32_t datalen = resp.arg[0];
|
||||
|
||||
if ( !len ) {
|
||||
if ( !datalen ) {
|
||||
PrintAndLogEx(WARNING, "smart card response failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "received %i bytes", len);
|
||||
PrintAndLogEx(INFO, "received %i bytes", datalen);
|
||||
|
||||
if (!len)
|
||||
if (!datalen)
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "util.h"
|
||||
#include "loclass/fileutils.h" // saveFile
|
||||
#include "cmdmain.h" // getfromdevice
|
||||
#include "emv/emvcore.h" // decodeTVL
|
||||
#include "emv/apduinfo.h" // APDUcode description
|
||||
|
||||
extern int CmdSmartcard(const char *Cmd);
|
||||
|
||||
|
|
|
@ -154,13 +154,14 @@ bool I2C_Start(void) {
|
|||
}
|
||||
|
||||
bool I2C_WaitForSim() {
|
||||
// variable delay here.
|
||||
// variable delay here.
|
||||
if (!WaitSCL_L_300ms())
|
||||
return false;
|
||||
|
||||
// 8051 speaks with smart card.
|
||||
// 1000*50*3.07 = 153.5ms
|
||||
if (!WaitSCL_H_delay(1000*50) )
|
||||
// 1byte transfer == 1ms
|
||||
if (!WaitSCL_H_delay(2000*50) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -526,7 +527,7 @@ void I2C_print_status(void) {
|
|||
I2C_Reset_EnterMainProgram();
|
||||
uint8_t len = I2C_BufferRead(resp, sizeof(resp), I2C_DEVICE_CMD_GETVERSION, I2C_DEVICE_ADDRESS_MAIN);
|
||||
if ( len > 0 )
|
||||
Dbprintf(" version. ................v%x.%02x", resp[0], resp[1]);
|
||||
Dbprintf(" version.................v%x.%02x", resp[0], resp[1]);
|
||||
else
|
||||
DbpString(" version.................FAILED");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue