mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
chg: 'sm raw' - implemented 'r' don't read reply
This commit is contained in:
parent
1a2ef57c0c
commit
36d774506c
5 changed files with 23 additions and 20 deletions
|
@ -1028,7 +1028,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_SMART_RAW: {
|
case CMD_SMART_RAW: {
|
||||||
SmartCardRaw(c->arg[0], c->d.asBytes);
|
SmartCardRaw(c->arg[0], c->arg[1], c->d.asBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_SMART_UPLOAD: {
|
case CMD_SMART_UPLOAD: {
|
||||||
|
|
|
@ -15,7 +15,6 @@ int usage_sm_raw(void) {
|
||||||
PrintAndLogEx(NORMAL, "Usage: sc raw [h|r|c] d <0A 0B 0C ... hex>");
|
PrintAndLogEx(NORMAL, "Usage: sc raw [h|r|c] d <0A 0B 0C ... hex>");
|
||||||
PrintAndLogEx(NORMAL, " h : this help");
|
PrintAndLogEx(NORMAL, " h : this help");
|
||||||
PrintAndLogEx(NORMAL, " r : do not read response");
|
PrintAndLogEx(NORMAL, " r : do not read response");
|
||||||
PrintAndLogEx(NORMAL, " c : calculate and append CRC");
|
|
||||||
PrintAndLogEx(NORMAL, " d <bytes> : bytes to send");
|
PrintAndLogEx(NORMAL, " d <bytes> : bytes to send");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
|
@ -42,11 +41,16 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
|
|
||||||
int hexlen = 0;
|
int hexlen = 0;
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false, reply = true;
|
||||||
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) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
|
|
||||||
|
case 'r':
|
||||||
|
reply = false;
|
||||||
|
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:
|
||||||
|
@ -74,19 +78,20 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
//Validations
|
//Validations
|
||||||
if (errors || cmdp == 0 ) return usage_sm_raw();
|
if (errors || cmdp == 0 ) return usage_sm_raw();
|
||||||
|
|
||||||
|
UsbCommand c = {CMD_SMART_RAW, {0, hexlen, 0}};
|
||||||
UsbCommand c = {CMD_SMART_RAW, {hexlen, 0, 0}};
|
|
||||||
memcpy(c.d.asBytes, data, hexlen );
|
memcpy(c.d.asBytes, data, hexlen );
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
||||||
// reading response from smart card
|
// reading response from smart card
|
||||||
|
if ( reply ) {
|
||||||
UsbCommand resp;
|
UsbCommand resp;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||||
PrintAndLogEx(WARNING, "smart card response failed");
|
PrintAndLogEx(WARNING, "smart card response failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(SUCCESS,"resp: %s", sprint_hex(resp.d.asBytes, resp.arg[0]));
|
PrintAndLogEx(SUCCESS,"resp: %s", sprint_hex(resp.d.asBytes, resp.arg[0]));
|
||||||
|
}
|
||||||
return 0;;
|
return 0;;
|
||||||
}
|
}
|
||||||
int CmdSmartUpgrade(const char *Cmd) {
|
int CmdSmartUpgrade(const char *Cmd) {
|
||||||
|
|
|
@ -502,8 +502,7 @@ uint64_t param_get64ex(const char *line, int paramnum, int deflt, int base)
|
||||||
return deflt;
|
return deflt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt)
|
int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt) {
|
||||||
{
|
|
||||||
int bg, en, i;
|
int bg, en, i;
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
|
|
||||||
|
@ -522,8 +521,7 @@ int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt)
|
int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt) {
|
||||||
{
|
|
||||||
int bg, en, i;
|
int bg, en, i;
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
|
|
||||||
|
|
|
@ -525,7 +525,7 @@ void SmartCardAtr(void) {
|
||||||
cmd_send(CMD_ACK, len, 0, 0, resp, sizeof(smart_card_atr_t));
|
cmd_send(CMD_ACK, len, 0, 0, resp, sizeof(smart_card_atr_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmartCardRaw( uint64_t arg0, uint8_t *data ) {
|
void SmartCardRaw( uint64_t arg0, uint64_t arg1, uint8_t *data ) {
|
||||||
#define ISO7618_MAX_FRAME 255
|
#define ISO7618_MAX_FRAME 255
|
||||||
StartTicks();
|
StartTicks();
|
||||||
I2C_Reset_EnterMainProgram();
|
I2C_Reset_EnterMainProgram();
|
||||||
|
@ -550,7 +550,7 @@ void SmartCardRaw( uint64_t arg0, uint8_t *data ) {
|
||||||
// start [C0 02] A0 A4 00 00 02 stop
|
// start [C0 02] A0 A4 00 00 02 stop
|
||||||
// asBytes = A0 A4 00 00 02
|
// asBytes = A0 A4 00 00 02
|
||||||
// arg0 = len 5
|
// arg0 = len 5
|
||||||
I2C_BufferWrite(data, arg0, I2C_DEVICE_CMD_SEND, I2C_DEVICE_ADDRESS_MAIN);
|
I2C_BufferWrite(data, arg1, I2C_DEVICE_CMD_SEND, I2C_DEVICE_ADDRESS_MAIN);
|
||||||
|
|
||||||
// read response
|
// read response
|
||||||
// start [C0 03 start C1 len aa bb cc stop]
|
// start [C0 03 start C1 len aa bb cc stop]
|
||||||
|
|
|
@ -37,7 +37,7 @@ bool I2C_WriteFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t d
|
||||||
|
|
||||||
// generice functions
|
// generice functions
|
||||||
void SmartCardAtr(void);
|
void SmartCardAtr(void);
|
||||||
void SmartCardRaw(uint64_t arg0, uint8_t *data);
|
void SmartCardRaw(uint64_t arg0, uint64_t arg1, uint8_t *data);
|
||||||
void SmartCardUpgrade(uint64_t arg0);
|
void SmartCardUpgrade(uint64_t arg0);
|
||||||
|
|
||||||
void I2C_print_status(void);
|
void I2C_print_status(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue