Semi-Automated SendCommand -> SendCommandOLD
This commit is contained in:
@@ -228,8 +228,7 @@ static int CmdHF14AList(const char *Cmd) {
|
||||
}
|
||||
|
||||
int Hf14443_4aGetCardData(iso14a_card_select_t *card) {
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_CONNECT, 0, 0, NULL, 0);
|
||||
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
@@ -298,9 +297,8 @@ static int CmdHF14AReader(const char *Cmd) {
|
||||
if (!disconnectAfter)
|
||||
cm |= ISO14A_NO_DISCONNECT;
|
||||
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {cm, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, cm, 0, 0, NULL, 0);
|
||||
|
||||
if (ISO14A_CONNECT & cm) {
|
||||
PacketResponseNG resp;
|
||||
@@ -385,8 +383,7 @@ static int CmdHF14ACUIDs(const char *Cmd) {
|
||||
}
|
||||
|
||||
// execute anticollision procedure
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0, NULL, 0);
|
||||
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
@@ -483,10 +480,8 @@ int CmdHF14ASim(const char *Cmd) {
|
||||
if (useUIDfromEML)
|
||||
flags |= FLAG_UID_IN_EMUL;
|
||||
|
||||
PacketCommandOLD c = {CMD_SIMULATE_TAG_ISO_14443a, { tagtype, flags, 0 }, {{0}}};
|
||||
memcpy(c.d.asBytes, uid, uidlen >> 1);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_SIMULATE_TAG_ISO_14443a, tagtype, flags, 0 , uid, uidlen >> 1);
|
||||
PacketResponseNG resp;
|
||||
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
||||
@@ -512,9 +507,8 @@ int CmdHF14ASniff(const char *Cmd) {
|
||||
if (ctmp == 'c') param |= 0x01;
|
||||
if (ctmp == 'r') param |= 0x02;
|
||||
}
|
||||
PacketCommandOLD c = {CMD_SNIFF_ISO_14443a, {param, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_SNIFF_ISO_14443a, param, 0, 0, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -528,8 +522,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
PacketResponseNG resp;
|
||||
|
||||
// Anticollision + SELECT card
|
||||
PacketCommandOLD ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
SendCommand(&ca);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
|
||||
return 1;
|
||||
@@ -548,10 +541,8 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
|
||||
if (resp.oldarg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
// get ATS
|
||||
PacketCommandOLD cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
memcpy(cr.d.asBytes, rats, 2);
|
||||
SendCommand(&cr);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0, rats, 2);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
|
||||
return 1;
|
||||
@@ -567,12 +558,10 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
if (leaveSignalON)
|
||||
cmdc |= ISO14A_NO_DISCONNECT;
|
||||
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0}, {{0}}};
|
||||
uint8_t header[] = { 0x0a | responseNum, 0x00};
|
||||
uint8_t data[USB_CMD_DATA_SIZE] = { 0x0a | responseNum, 0x00};
|
||||
responseNum ^= 1;
|
||||
memcpy(c.d.asBytes, header, 2);
|
||||
memcpy(&c.d.asBytes[2], datain, datainlen);
|
||||
SendCommand(&c);
|
||||
memcpy(&data[2], datain, datainlen & 0xFFFF);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0, data, (datainlen & 0xFFFF) + 2);
|
||||
|
||||
uint8_t *recv;
|
||||
PacketResponseNG resp;
|
||||
@@ -595,8 +584,8 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (recv[0] != header[0]) {
|
||||
PrintAndLogEx(ERR, "iso14443-4 framing error. Card send %2x must be %2x", dataout[0], header[0]);
|
||||
if (recv[0] != data[0]) {
|
||||
PrintAndLogEx(ERR, "iso14443-4 framing error. Card send %2x must be %2x", dataout[0], data[0]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -627,8 +616,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
||||
DropField();
|
||||
|
||||
// Anticollision + SELECT card
|
||||
PacketCommandOLD ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
SendCommand(&ca);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
|
||||
return 1;
|
||||
@@ -647,10 +635,8 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
||||
|
||||
if (resp.oldarg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
// get ATS
|
||||
PacketCommandOLD cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
memcpy(cr.d.asBytes, rats, 2);
|
||||
SendCommand(&cr);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, sizeof(rats), 0, rats, sizeof(rats));
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
|
||||
return 1;
|
||||
@@ -704,12 +690,10 @@ static int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool
|
||||
// https://stackoverflow.com/questions/32994936/safe-max-java-card-apdu-data-command-and-respond-size
|
||||
// here length USB_CMD_DATA_SIZE=512
|
||||
// timeout must be authomatically set by "get ATS"
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}, {{0}}};
|
||||
|
||||
if (datain)
|
||||
memcpy(c.d.asBytes, datain, datainlen);
|
||||
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0, datain, datainlen & 0xFFFF);
|
||||
else
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, 0, 0, NULL, 0);
|
||||
|
||||
uint8_t *recv;
|
||||
PacketResponseNG resp;
|
||||
@@ -891,7 +875,6 @@ static int CmdHF14AAPDU(const char *Cmd) {
|
||||
}
|
||||
|
||||
static int CmdHF14ACmdRaw(const char *Cmd) {
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
|
||||
bool reply = 1;
|
||||
bool crc = false;
|
||||
bool power = false;
|
||||
@@ -996,45 +979,44 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
|
||||
data[datalen++] = second;
|
||||
}
|
||||
|
||||
uint16_t flags = 0;
|
||||
if (active || active_select) {
|
||||
c.arg[0] |= ISO14A_CONNECT;
|
||||
flags |= ISO14A_CONNECT;
|
||||
if (active)
|
||||
c.arg[0] |= ISO14A_NO_SELECT;
|
||||
flags |= ISO14A_NO_SELECT;
|
||||
}
|
||||
|
||||
uint32_t argtimeout = 0;
|
||||
if (bTimeout) {
|
||||
#define MAX_TIMEOUT 40542464 // = (2^32-1) * (8*16) / 13560000Hz * 1000ms/s
|
||||
c.arg[0] |= ISO14A_SET_TIMEOUT;
|
||||
flags |= ISO14A_SET_TIMEOUT;
|
||||
if (timeout > MAX_TIMEOUT) {
|
||||
timeout = MAX_TIMEOUT;
|
||||
PrintAndLogEx(NORMAL, "Set timeout to 40542 seconds (11.26 hours). The max we can wait for response");
|
||||
}
|
||||
c.arg[2] = 13560000 / 1000 / (8 * 16) * timeout; // timeout in ETUs (time to transfer 1 bit, approx. 9.4 us)
|
||||
argtimeout = 13560000 / 1000 / (8 * 16) * timeout; // timeout in ETUs (time to transfer 1 bit, approx. 9.4 us)
|
||||
}
|
||||
|
||||
if (power) {
|
||||
c.arg[0] |= ISO14A_NO_DISCONNECT;
|
||||
flags |= ISO14A_NO_DISCONNECT;
|
||||
}
|
||||
|
||||
if (datalen > 0) {
|
||||
c.arg[0] |= ISO14A_RAW;
|
||||
flags |= ISO14A_RAW;
|
||||
}
|
||||
|
||||
if (topazmode) {
|
||||
c.arg[0] |= ISO14A_TOPAZMODE;
|
||||
flags |= ISO14A_TOPAZMODE;
|
||||
}
|
||||
if (no_rats) {
|
||||
c.arg[0] |= ISO14A_NO_RATS;
|
||||
flags |= ISO14A_NO_RATS;
|
||||
}
|
||||
|
||||
// Max buffer is USB_CMD_DATA_SIZE
|
||||
datalen = (datalen > USB_CMD_DATA_SIZE) ? USB_CMD_DATA_SIZE : datalen;
|
||||
|
||||
c.arg[1] = (datalen & 0xFFFF) | ((uint32_t)(numbits << 16));
|
||||
memcpy(c.d.asBytes, data, datalen);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, flags, (datalen & 0xFFFF) | ((uint32_t)(numbits << 16)), argtimeout, data, datalen & 0xFFFF);
|
||||
|
||||
if (reply) {
|
||||
int res = 0;
|
||||
@@ -1096,9 +1078,8 @@ static int CmdHF14AAntiFuzz(const char *Cmd) {
|
||||
arg0 = FLAG_10B_UID_IN_DATA;
|
||||
|
||||
CLIParserFree();
|
||||
PacketCommandOLD c = {CMD_ANTIFUZZ_ISO_14443a, {arg0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_ANTIFUZZ_ISO_14443a, arg0, 0, 0, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1160,9 +1141,8 @@ int CmdHF14A(const char *Cmd) {
|
||||
}
|
||||
|
||||
int infoHF14A(bool verbose, bool do_nack_test) {
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
@@ -1213,11 +1193,8 @@ int infoHF14A(bool verbose, bool do_nack_test) {
|
||||
PrintAndLogEx(NORMAL, "TYPE: Possible AZTEK (iso14443a compliant)");
|
||||
|
||||
// reconnect for further tests
|
||||
c.arg[0] = ISO14A_CONNECT | ISO14A_NO_DISCONNECT;
|
||||
c.arg[1] = 0;
|
||||
c.arg[2] = 0;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0);
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
|
||||
@@ -1286,12 +1263,8 @@ int infoHF14A(bool verbose, bool do_nack_test) {
|
||||
// try to request ATS even if tag claims not to support it
|
||||
if (select_status == 2) {
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
c.arg[0] = ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT;
|
||||
c.arg[1] = 2;
|
||||
c.arg[2] = 0;
|
||||
memcpy(c.d.asBytes, rats, 2);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0, rats, sizeof(rats));
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
memcpy(card.ats, resp.data.asBytes, resp.oldarg[0]);
|
||||
|
||||
Reference in New Issue
Block a user