mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Better Reply structs
This commit is contained in:
parent
64eb93c9c4
commit
533667ea6d
57 changed files with 725 additions and 718 deletions
|
@ -108,14 +108,14 @@ static int usage_hf_14b_dump(void) {
|
|||
|
||||
/*
|
||||
static void switch_on_field_14b(void) {
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
}
|
||||
*/
|
||||
|
||||
static int switch_off_field_14b(void) {
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -128,11 +128,11 @@ static bool waitCmd14b(bool verbose) {
|
|||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
|
||||
if ((resp.core.old.arg[0] & 0xFF) > 0) return false;
|
||||
if ((resp.oldarg[0] & 0xFF) > 0) return false;
|
||||
|
||||
uint16_t len = (resp.core.old.arg[1] & 0xFFFF);
|
||||
uint16_t len = (resp.oldarg[1] & 0xFFFF);
|
||||
|
||||
memcpy(data, resp.core.old.d.asBytes, len);
|
||||
memcpy(data, resp.data.asBytes, len);
|
||||
|
||||
if (verbose) {
|
||||
if (len >= 3) {
|
||||
|
@ -171,7 +171,7 @@ static int CmdHF14BSim(const char *Cmd) {
|
|||
pupi = param_get32ex(Cmd, 1, 0, 16);
|
||||
}
|
||||
|
||||
UsbCommand c = {CMD_SIMULATE_TAG_ISO_14443B, {pupi, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_ISO_14443B, {pupi, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -182,7 +182,7 @@ static int CmdHF14BSniff(const char *Cmd) {
|
|||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_hf_14b_sniff();
|
||||
|
||||
UsbCommand c = {CMD_SNIFF_ISO_14443B, {0, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_SNIFF_ISO_14443B, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -277,7 +277,7 @@ static int CmdHF14BCmdRaw(const char *Cmd) {
|
|||
// Max buffer is USB_CMD_DATA_SIZE
|
||||
datalen = (datalen > USB_CMD_DATA_SIZE) ? USB_CMD_DATA_SIZE : datalen;
|
||||
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {flags, datalen, time_wait}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {flags, datalen, time_wait}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, datalen);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -302,7 +302,7 @@ static bool get_14b_UID(iso14b_card_select_t *card) {
|
|||
|
||||
int8_t retry = 3;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
|
||||
// test for 14b SR
|
||||
while (retry--) {
|
||||
|
@ -311,9 +311,9 @@ static bool get_14b_UID(iso14b_card_select_t *card) {
|
|||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
|
||||
uint8_t status = resp.core.old.arg[0];
|
||||
uint8_t status = resp.oldarg[0];
|
||||
if (status == 0) {
|
||||
memcpy(card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -329,9 +329,9 @@ static bool get_14b_UID(iso14b_card_select_t *card) {
|
|||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
|
||||
uint8_t status = resp.core.old.arg[0];
|
||||
uint8_t status = resp.oldarg[0];
|
||||
if (status == 0) {
|
||||
memcpy(card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ static bool HF14B_Std_Info(bool verbose) {
|
|||
bool isSuccess = false;
|
||||
|
||||
// 14b get and print UID only (general info)
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
|
@ -521,9 +521,9 @@ static bool HF14B_Std_Info(bool verbose) {
|
|||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
uint64_t status = resp.oldarg[0];
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
|
@ -550,7 +550,7 @@ static bool HF14B_Std_Info(bool verbose) {
|
|||
// SRx get and print full info (needs more info...)
|
||||
static bool HF14B_ST_Info(bool verbose) {
|
||||
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
|
@ -561,9 +561,9 @@ static bool HF14B_ST_Info(bool verbose) {
|
|||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
uint64_t status = resp.oldarg[0];
|
||||
if (status > 0)
|
||||
return false;
|
||||
|
||||
|
@ -607,7 +607,7 @@ static bool HF14B_ST_Reader(bool verbose) {
|
|||
bool isSuccess = false;
|
||||
|
||||
// SRx get and print general info about SRx chip from UID
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
|
@ -617,9 +617,9 @@ static bool HF14B_ST_Reader(bool verbose) {
|
|||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
uint64_t status = resp.oldarg[0];
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
|
@ -647,7 +647,7 @@ static bool HF14B_Std_Reader(bool verbose) {
|
|||
bool isSuccess = false;
|
||||
|
||||
// 14b get and print UID only (general info)
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
|
@ -658,9 +658,9 @@ static bool HF14B_Std_Reader(bool verbose) {
|
|||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.data.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
uint64_t status = resp.oldarg[0];
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
|
@ -692,7 +692,7 @@ static bool HF14B_Other_Reader() {
|
|||
// // 14b get and print UID only (general info)
|
||||
// uint32_t flags = ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_RAW | ISO14B_APPEND_CRC;
|
||||
|
||||
// UsbCommand c = {CMD_ISO_14443B_COMMAND, {flags, datalen, 0}, {{0}}};
|
||||
// UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {flags, datalen, 0}, {{0}}};
|
||||
// memcpy(c.d.asBytes, data, datalen);
|
||||
|
||||
// clearCommandBuffer();
|
||||
|
@ -762,7 +762,7 @@ static int CmdHF14BReadSri(const char *Cmd) {
|
|||
uint8_t tagtype = param_get8(Cmd, 0);
|
||||
uint8_t blocks = (tagtype == 1) ? 0x7F : 0x0F;
|
||||
|
||||
UsbCommand c = {CMD_READ_SRI_TAG, {blocks, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_READ_SRI_TAG, {blocks, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -902,14 +902,14 @@ static int CmdHF14BDump(const char *Cmd) {
|
|||
uint8_t *recv = NULL;
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, { ISO14B_CONNECT | ISO14B_SELECT_SR, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, { ISO14B_CONNECT | ISO14B_SELECT_SR, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
//select
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
if (resp.core.old.arg[0]) {
|
||||
PrintAndLogEx(INFO, "failed to select %d | %d", resp.core.old.arg[0], resp.core.old.arg[1]);
|
||||
if (resp.oldarg[0]) {
|
||||
PrintAndLogEx(INFO, "failed to select %d | %d", resp.oldarg[0], resp.oldarg[1]);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -929,20 +929,20 @@ static int CmdHF14BDump(const char *Cmd) {
|
|||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
||||
uint8_t status = resp.core.old.arg[0] & 0xFF;
|
||||
uint8_t status = resp.oldarg[0] & 0xFF;
|
||||
if (status > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint16_t len = (resp.core.old.arg[1] & 0xFFFF);
|
||||
recv = resp.core.old.d.asBytes;
|
||||
uint16_t len = (resp.oldarg[1] & 0xFFFF);
|
||||
recv = resp.data.asBytes;
|
||||
|
||||
if (!check_crc(CRC_14443_B, recv, len)) {
|
||||
PrintAndLogEx(FAILED, "crc fail, retrying one more time");
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(data + (blocknum * 4), resp.core.old.d.asBytes, 4);
|
||||
memcpy(data + (blocknum * 4), resp.data.asBytes, 4);
|
||||
|
||||
if (blocknum == 0xFF) {
|
||||
//last read.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue