Better Reply structs

This commit is contained in:
Philippe Teuwen 2019-04-17 23:44:48 +02:00
parent 64eb93c9c4
commit 533667ea6d
57 changed files with 725 additions and 718 deletions

View file

@ -363,7 +363,7 @@ void SendVersion(void) {
}
// measure the USB Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time.
// Note: this mimics GetFromBigbuf(), i.e. we have the overhead of the UsbCommand structure included.
// Note: this mimics GetFromBigbuf(), i.e. we have the overhead of the UsbCommandOLD structure included.
void printUSBSpeed(void) {
Dbprintf("USB Speed");
Dbprintf(" Sending USB packets to client...");
@ -378,9 +378,9 @@ void printUSBSpeed(void) {
LED_B_ON();
while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) {
reply_ng(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, PM3_SUCCESS, test_data, USB_DATANG_SIZE);
reply_ng(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, PM3_SUCCESS, test_data, USB_CMD_DATA_SIZE);
end_time = GetTickCount();
bytes_transferred += USB_DATANG_SIZE;
bytes_transferred += USB_CMD_DATA_SIZE;
}
LED_B_OFF();
@ -1142,13 +1142,13 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
LED_A_OFF();
/*
uint8_t my_rx[sizeof(UsbCommand)];
uint8_t my_rx[sizeof(UsbCommandOLD)];
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
LED_B_INV();
if (usart_readbuffer(my_rx) ) {
//UsbPacketReceived(my_rx, sizeof(my_rx));
UsbCommand *my = (UsbCommand *)my_rx;
UsbCommandOLD *my = (UsbCommandOLD *)my_rx;
if (my->cmd > 0 ) {
Dbprintf("received command: 0x%04x and args: %d %d %d", my->cmd, my->arg[0], my->arg[1], my->arg[2]);
}
@ -1577,13 +1577,13 @@ void __attribute__((noreturn)) AppMain(void) {
size_t bytes = usb_read_ng((uint8_t *)&rx, sizeof(UsbCommandNGPreamble));
if (bytes == sizeof(UsbCommandNGPreamble)) {
if (rx.magic == USB_COMMANDNG_PREAMBLE_MAGIC) { // New style NG command
if (rx.length > USB_DATANG_SIZE) {
if (rx.length > USB_CMD_DATA_SIZE) {
Dbprintf("Packet frame with incompatible length: 0x%04x", rx.length);
error = true;
}
if (!error) { // Get the core and variable length payload
bytes = usb_read_ng(((uint8_t *)&rx.core), sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + rx.length);
if (bytes != sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + rx.length) {
bytes = usb_read_ng(((uint8_t *)&rx.core), sizeof(UsbPacketNGCore) - USB_CMD_DATA_SIZE + rx.length);
if (bytes != sizeof(UsbPacketNGCore) - USB_CMD_DATA_SIZE + rx.length) {
Dbprintf("Packet frame error variable part too short? %d/%d", bytes, rx.length);
error = true;
}
@ -1595,7 +1595,7 @@ void __attribute__((noreturn)) AppMain(void) {
error = true;
}
uint8_t first, second;
compute_crc(CRC_14443_A, (uint8_t *)&rx, sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + rx.length, &first, &second);
compute_crc(CRC_14443_A, (uint8_t *)&rx, sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_CMD_DATA_SIZE + rx.length, &first, &second);
if ((first << 8) + second != rx.crc) {
Dbprintf("Packet frame CRC error %02X%02X <> %04X", first, second, rx.crc);
error = true;
@ -1615,9 +1615,9 @@ void __attribute__((noreturn)) AppMain(void) {
bytes = usb_read_ng(((uint8_t *)&rx.core.old) + sizeof(UsbCommandNGPreamble), sizeof(UsbCommand) - sizeof(UsbCommandNGPreamble));
if (bytes != sizeof(UsbCommand) - sizeof(UsbCommandNGPreamble)) {
Dbprintf("Packet frame error var part too short? %d/%d", bytes, sizeof(UsbCommand) - sizeof(UsbCommandNGPreamble));
bytes = usb_read_ng(((uint8_t *)&rx.core.old) + sizeof(UsbCommandNGPreamble), sizeof(UsbCommandOLD) - sizeof(UsbCommandNGPreamble));
if (bytes != sizeof(UsbCommandOLD) - sizeof(UsbCommandNGPreamble)) {
Dbprintf("Packet frame error var part too short? %d/%d", bytes, sizeof(UsbCommandOLD) - sizeof(UsbCommandNGPreamble));
error = true;
}
if (!error) {

View file

@ -222,7 +222,7 @@ void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data);
void iClass_ReadCheck(uint8_t blockno, uint8_t keytype);
// cmd.h
uint8_t cmd_receive(UsbCommand *cmd);
uint8_t cmd_receive(UsbCommandOLD *cmd);
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
// util.h

View file

@ -37,7 +37,7 @@ int main(int argc, char **argv) {
while (1) {
while (!OpenProxmark()) { sleep(1); }
while (1) {
UsbCommand cmdbuf;
UsbCommandOLD cmdbuf;
CommandReceived(argv[1]);
HANDLE_ERROR;
ReceiveCommand(&cmdbuf);

View file

@ -512,7 +512,7 @@ static int CmdAnalyseA(const char *Cmd) {
if (errors || cmdp == 0) return usage_analyse_a();
UsbCommand c = {CMD_FPC_SEND, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FPC_SEND, {0, 0, 0}, {{0}}};
memcpy(c.d.asBytes, data, USB_CMD_DATA_SIZE);
clearCommandBuffer();
SendCommand(&c);
@ -521,7 +521,7 @@ static int CmdAnalyseA(const char *Cmd) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
return 1;
}
PrintAndLogEx(NORMAL, "got ack. Status %d", resp.core.old.arg[0]);
PrintAndLogEx(NORMAL, "got ack. Status %d", resp.oldarg[0]);
return 0;
/*
PrintAndLogEx(NORMAL, "-- " _BLUE_("its my message") "\n");

View file

@ -874,7 +874,7 @@ static int CmdBuffClear(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_data_buffclear();
UsbCommand c = {CMD_BUFF_CLEAR, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_BUFF_CLEAR, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
ClearGraph(true);
@ -1468,8 +1468,8 @@ int getSamples(uint32_t n, bool silent) {
uint8_t bits_per_sample = 8;
//Old devices without this feature would send 0 at arg[0]
if (response.core.old.arg[0] > 0) {
sample_config *sc = (sample_config *) response.core.old.d.asBytes;
if (response.oldarg[0] > 0) {
sample_config *sc = (sample_config *) response.data.asBytes;
if (!silent) PrintAndLogEx(NORMAL, "Samples @ %d bits/smpl, decimation 1:%d ", sc->bits_per_sample, sc->decimation);
bits_per_sample = sc->bits_per_sample;
}
@ -1529,7 +1529,7 @@ int CmdTuneSamples(const char *Cmd) {
int timeout = 0;
PrintAndLogEx(INFO, "\nMeasuring antenna characteristics, please wait...");
UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -1544,12 +1544,12 @@ int CmdTuneSamples(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "\n");
uint32_t v_lf125 = resp.core.old.arg[0];
uint32_t v_lf134 = resp.core.old.arg[0] >> 32;
uint32_t v_lf125 = resp.oldarg[0];
uint32_t v_lf134 = resp.oldarg[0] >> 32;
uint32_t v_hf = resp.core.old.arg[1];
uint32_t peakf = resp.core.old.arg[2];
uint32_t peakv = resp.core.old.arg[2] >> 32;
uint32_t v_hf = resp.oldarg[1];
uint32_t peakf = resp.oldarg[2];
uint32_t peakv = resp.oldarg[2] >> 32;
if (v_lf125 > NON_VOLTAGE)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - 125.00 kHz", (v_lf125 * ANTENNA_ERROR) / 1000.0);
@ -1595,8 +1595,8 @@ int CmdTuneSamples(const char *Cmd) {
// even here, these values has 3% error.
uint16_t test1 = 0;
for (int i = 0; i < 256; i++) {
GraphBuffer[i] = resp.core.old.d.asBytes[i] - 128;
test1 += resp.core.old.d.asBytes[i];
GraphBuffer[i] = resp.data.asBytes[i] - 128;
test1 += resp.data.asBytes[i];
}
if (test1 > 0) {

View file

@ -140,7 +140,7 @@ static int CmdFlashMemRead(const char *Cmd) {
return 1;
}
UsbCommand c = {CMD_FLASHMEM_READ, {start_index, len, 0}, {{0}}};
UsbCommandOLD c = {CMD_FLASHMEM_READ, {start_index, len, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -153,7 +153,7 @@ static int CmdFlashmemSpiBaudrate(const char *Cmd) {
uint32_t baudrate = param_get32ex(Cmd, 0, 0, 10);
baudrate = baudrate * 1000000;
if (baudrate != FLASH_BAUD && baudrate != FLASH_MINBAUD) return usage_flashmem_spibaud();
UsbCommand c = {CMD_FLASHMEM_SET_SPIBAUDRATE, {baudrate, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FLASHMEM_SET_SPIBAUDRATE, {baudrate, 0, 0}, {{0}}};
SendCommand(&c);
return 0;
}
@ -274,7 +274,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
while (bytes_remaining > 0) {
uint32_t bytes_in_packet = MIN(FLASH_MEM_BLOCK_SIZE, bytes_remaining);
UsbCommand c = {CMD_FLASHMEM_WRITE, {start_index + bytes_sent, bytes_in_packet, 0}, {{0}}};
UsbCommandOLD c = {CMD_FLASHMEM_WRITE, {start_index + bytes_sent, bytes_in_packet, 0}, {{0}}};
memcpy(c.d.asBytes, data + bytes_sent, bytes_in_packet);
clearCommandBuffer();
@ -290,7 +290,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
return 1;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (!isok)
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
@ -389,7 +389,7 @@ static int CmdFlashMemWipe(const char *Cmd) {
//Validations
if (errors || cmdp == 0) return usage_flashmem_wipe();
UsbCommand c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
UsbCommandOLD c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -397,7 +397,7 @@ static int CmdFlashMemWipe(const char *Cmd) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return 1;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (isok)
PrintAndLogEx(SUCCESS, "Flash WIPE ok");
else
@ -435,7 +435,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
//Validations
if (errors) return usage_flashmem_info();
UsbCommand c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -444,7 +444,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
return 1;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (!isok) {
PrintAndLogEx(FAILED, "failed");
return 1;
@ -452,7 +452,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
// validate signature here
rdv40_validation_t mem;
memcpy(&mem, (rdv40_validation_t *)resp.core.old.d.asBytes, sizeof(rdv40_validation_t));
memcpy(&mem, (rdv40_validation_t *)resp.data.asBytes, sizeof(rdv40_validation_t));
// Flash ID hash (sha1)
mbedtls_sha1(mem.flashid, sizeof(mem.flashid), sha_hash);
@ -564,7 +564,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
if (shall_write) {
// save to mem
c = (UsbCommand) {CMD_FLASHMEM_WRITE, {FLASH_MEM_SIGNATURE_OFFSET, FLASH_MEM_SIGNATURE_LEN, 0}, {{0}}};
c = (UsbCommandOLD) {CMD_FLASHMEM_WRITE, {FLASH_MEM_SIGNATURE_OFFSET, FLASH_MEM_SIGNATURE_LEN, 0}, {{0}}};
memcpy(c.d.asBytes, sign, sizeof(sign));
clearCommandBuffer();
SendCommand(&c);
@ -572,7 +572,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
} else {
if (!resp.core.old.arg[0])
if (!resp.oldarg[0])
PrintAndLogEx(FAILED, "Writing signature failed");
else
PrintAndLogEx(SUCCESS, "Writing signature ok [offset: %u]", FLASH_MEM_SIGNATURE_OFFSET);

View file

@ -84,7 +84,7 @@ int CmdHFSearch(const char *Cmd) {
int CmdHFTune(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
PrintAndLogEx(SUCCESS, "Measuring HF antenna, press button to exit");
UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING_HF, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MEASURE_ANTENNA_TUNING_HF, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -97,7 +97,7 @@ int CmdHFSniff(const char *Cmd) {
int skippairs = param_get32ex(Cmd, 0, 0, 10);
int skiptriggers = param_get32ex(Cmd, 1, 0, 10);
UsbCommand c = {CMD_HF_SNIFFER, {skippairs, skiptriggers, 0}, {{0}}};
UsbCommandOLD c = {CMD_HF_SNIFFER, {skippairs, skiptriggers, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;

View file

@ -228,15 +228,15 @@ static int CmdHF14AList(const char *Cmd) {
}
int Hf14443_4aGetCardData(iso14a_card_select_t *card) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
memcpy(card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
uint64_t select_status = resp.core.old.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
uint64_t select_status = resp.oldarg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
if (select_status == 0) {
PrintAndLogEx(ERR, "E->iso14443a card select failed");
@ -256,7 +256,7 @@ int Hf14443_4aGetCardData(iso14a_card_select_t *card) {
PrintAndLogEx(NORMAL, " UID: %s", sprint_hex(card->uid, card->uidlen));
PrintAndLogEx(NORMAL, "ATQA: %02x %02x", card->atqa[1], card->atqa[0]);
PrintAndLogEx(NORMAL, " SAK: %02x [%" PRIu64 "]", card->sak, resp.core.old.arg[0]);
PrintAndLogEx(NORMAL, " SAK: %02x [%" PRIu64 "]", card->sak, resp.oldarg[0]);
if (card->ats_len < 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
PrintAndLogEx(NORMAL, "E-> Error ATS length(%d) : %s", card->ats_len, sprint_hex(card->ats, card->ats_len));
return 1;
@ -298,7 +298,7 @@ static int CmdHF14AReader(const char *Cmd) {
if (!disconnectAfter)
cm |= ISO14A_NO_DISCONNECT;
UsbCommand c = {CMD_READER_ISO_14443a, {cm, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {cm, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -311,7 +311,7 @@ static int CmdHF14AReader(const char *Cmd) {
}
iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
/*
0: couldn't read
@ -319,7 +319,7 @@ static int CmdHF14AReader(const char *Cmd) {
2: OK, no ATS
3: proprietary Anticollision
*/
uint64_t select_status = resp.core.old.arg[0];
uint64_t select_status = resp.oldarg[0];
if (select_status == 0) {
if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed");
@ -336,7 +336,7 @@ static int CmdHF14AReader(const char *Cmd) {
PrintAndLogEx(NORMAL, " UID : %s", sprint_hex(card.uid, card.uidlen));
PrintAndLogEx(NORMAL, "ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
PrintAndLogEx(NORMAL, " SAK : %02x [%" PRIu64 "]", card.sak, resp.core.old.arg[0]);
PrintAndLogEx(NORMAL, " SAK : %02x [%" PRIu64 "]", card.sak, resp.oldarg[0]);
if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
PrintAndLogEx(NORMAL, " ATS : %s", sprint_hex(card.ats, card.ats_len));
@ -385,16 +385,16 @@ static int CmdHF14ACUIDs(const char *Cmd) {
}
// execute anticollision procedure
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
iso14a_card_select_t *card = (iso14a_card_select_t *) resp.core.old.d.asBytes;
iso14a_card_select_t *card = (iso14a_card_select_t *) resp.data.asBytes;
// check if command failed
if (resp.core.old.arg[0] == 0) {
if (resp.oldarg[0] == 0) {
PrintAndLogEx(WARNING, "card select failed.");
} else {
char uid_string[20];
@ -483,7 +483,7 @@ int CmdHF14ASim(const char *Cmd) {
if (useUIDfromEML)
flags |= FLAG_UID_IN_EMUL;
UsbCommand c = {CMD_SIMULATE_TAG_ISO_14443a, { tagtype, flags, 0 }, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_TAG_ISO_14443a, { tagtype, flags, 0 }, {{0}}};
memcpy(c.d.asBytes, uid, uidlen >> 1);
clearCommandBuffer();
SendCommand(&c);
@ -494,9 +494,9 @@ int CmdHF14ASim(const char *Cmd) {
while (!ukbhit()) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
if (!(flags & FLAG_NR_AR_ATTACK)) break;
if ((resp.core.old.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
if ((resp.oldarg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
memcpy(data, resp.core.old.d.asBytes, sizeof(data));
memcpy(data, resp.data.asBytes, sizeof(data));
readerAttack(data[0], setEmulatorMem, verbose);
}
showSectorTable();
@ -512,7 +512,7 @@ int CmdHF14ASniff(const char *Cmd) {
if (ctmp == 'c') param |= 0x01;
if (ctmp == 'r') param |= 0x02;
}
UsbCommand c = {CMD_SNIFF_ISO_14443a, {param, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SNIFF_ISO_14443a, {param, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -528,7 +528,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
UsbReplyNG resp;
// Anticollision + SELECT card
UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
UsbCommandOLD ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
SendCommand(&ca);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
@ -536,19 +536,19 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
}
// check result
if (resp.core.old.arg[0] == 0) {
if (resp.oldarg[0] == 0) {
PrintAndLogEx(ERR, "No card in field.");
return 1;
}
if (resp.core.old.arg[0] != 1 && resp.core.old.arg[0] != 2) {
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.core.old.arg[0]);
if (resp.oldarg[0] != 1 && resp.oldarg[0] != 2) {
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.oldarg[0]);
return 1;
}
if (resp.core.old.arg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
if (resp.oldarg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
// get ATS
UsbCommand cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
UsbCommandOLD 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);
@ -557,7 +557,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
return 1;
}
if (resp.core.old.arg[0] == 0) { // ats_len
if (resp.oldarg[0] == 0) { // ats_len
PrintAndLogEx(ERR, "Can't get ATS.");
return 1;
}
@ -567,7 +567,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
if (leaveSignalON)
cmdc |= ISO14A_NO_DISCONNECT;
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0}, {{0}}};
uint8_t header[] = { 0x0a | responseNum, 0x00};
responseNum ^= 1;
memcpy(c.d.asBytes, header, 2);
@ -578,8 +578,8 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
recv = resp.core.old.d.asBytes;
int iLen = resp.core.old.arg[0];
recv = resp.data.asBytes;
int iLen = resp.oldarg[0];
if (!iLen) {
PrintAndLogEx(ERR, "No card response.");
@ -627,7 +627,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
DropField();
// Anticollision + SELECT card
UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
UsbCommandOLD ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
SendCommand(&ca);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
PrintAndLogEx(ERR, "Proxmark3 connection timeout.");
@ -635,19 +635,19 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
}
// check result
if (resp.core.old.arg[0] == 0) {
if (resp.oldarg[0] == 0) {
PrintAndLogEx(ERR, "No card in field.");
return 1;
}
if (resp.core.old.arg[0] != 1 && resp.core.old.arg[0] != 2) {
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.core.old.arg[0]);
if (resp.oldarg[0] != 1 && resp.oldarg[0] != 2) {
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.oldarg[0]);
return 1;
}
if (resp.core.old.arg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
if (resp.oldarg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
// get ATS
UsbCommand cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
UsbCommandOLD 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);
@ -656,20 +656,20 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
return 1;
}
if (resp.core.old.arg[0] == 0) { // ats_len
if (resp.oldarg[0] == 0) { // ats_len
PrintAndLogEx(ERR, "Can't get ATS.");
return 1;
}
// get frame length from ATS in data field
if (resp.core.old.arg[0] > 1) {
uint8_t fsci = resp.core.old.d.asBytes[1] & 0x0f;
if (resp.oldarg[0] > 1) {
uint8_t fsci = resp.data.asBytes[1] & 0x0f;
if (fsci < sizeof(atsFSC) / sizeof(atsFSC[0]))
frameLength = atsFSC[fsci];
}
} else {
// get frame length from ATS in card data structure
iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.core.old.d.asBytes;
iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.data.asBytes;
if (vcard->ats_len > 1) {
uint8_t fsci = vcard->ats[1] & 0x0f;
if (fsci < sizeof(atsFSC) / sizeof(atsFSC[0]))
@ -704,7 +704,7 @@ 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"
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}, {{0}}};
if (datain)
memcpy(c.d.asBytes, datain, datainlen);
@ -715,9 +715,9 @@ static int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
recv = resp.core.old.d.asBytes;
int iLen = resp.core.old.arg[0];
uint8_t res = resp.core.old.arg[1];
recv = resp.data.asBytes;
int iLen = resp.oldarg[0];
uint8_t res = resp.oldarg[1];
int dlen = iLen - 2;
if (dlen < 0)
@ -891,7 +891,7 @@ static int CmdHF14AAPDU(const char *Cmd) {
}
static int CmdHF14ACmdRaw(const char *Cmd) {
UsbCommand c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
bool reply = 1;
bool crc = false;
bool power = false;
@ -1050,9 +1050,9 @@ static int waitCmd(uint8_t iSelect) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint16_t len = (resp.core.old.arg[0] & 0xFFFF);
uint16_t len = (resp.oldarg[0] & 0xFFFF);
if (iSelect) {
len = (resp.core.old.arg[1] & 0xFFFF);
len = (resp.oldarg[1] & 0xFFFF);
if (len) {
PrintAndLogEx(NORMAL, "Card selected. UID[%i]:", len);
} else {
@ -1065,7 +1065,7 @@ static int waitCmd(uint8_t iSelect) {
if (!len)
return 1;
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
} else {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return 3;
@ -1096,7 +1096,7 @@ static int CmdHF14AAntiFuzz(const char *Cmd) {
arg0 = FLAG_10B_UID_IN_DATA;
CLIParserFree();
UsbCommand c = {CMD_ANTIFUZZ_ISO_14443a, {arg0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_ANTIFUZZ_ISO_14443a, {arg0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -1161,7 +1161,7 @@ int CmdHF14A(const char *Cmd) {
}
int infoHF14A(bool verbose, bool do_nack_test) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -1172,7 +1172,7 @@ int infoHF14A(bool verbose, bool do_nack_test) {
}
iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
/*
0: couldn't read
@ -1180,7 +1180,7 @@ int infoHF14A(bool verbose, bool do_nack_test) {
2: OK, no ATS
3: proprietary Anticollision
*/
uint64_t select_status = resp.core.old.arg[0];
uint64_t select_status = resp.oldarg[0];
if (select_status == 0) {
if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed");
@ -1197,7 +1197,7 @@ int infoHF14A(bool verbose, bool do_nack_test) {
PrintAndLogEx(NORMAL, " UID : %s", sprint_hex(card.uid, card.uidlen));
PrintAndLogEx(NORMAL, "ATQA : %02x %02x", card.atqa[1], card.atqa[0]);
PrintAndLogEx(NORMAL, " SAK : %02x [%" PRIu64 "]", card.sak, resp.core.old.arg[0]);
PrintAndLogEx(NORMAL, " SAK : %02x [%" PRIu64 "]", card.sak, resp.oldarg[0]);
bool isMifareClassic = true;
switch (card.sak) {
@ -1221,9 +1221,9 @@ int infoHF14A(bool verbose, bool do_nack_test) {
SendCommand(&c);
WaitForResponse(CMD_ACK, &resp);
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
select_status = resp.core.old.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
select_status = resp.oldarg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
if (select_status == 0) {
DropField();
@ -1295,8 +1295,8 @@ int infoHF14A(bool verbose, bool do_nack_test) {
SendCommand(&c);
WaitForResponse(CMD_ACK, &resp);
memcpy(card.ats, resp.core.old.d.asBytes, resp.core.old.arg[0]);
card.ats_len = resp.core.old.arg[0]; // note: ats_len includes CRC Bytes
memcpy(card.ats, resp.data.asBytes, resp.oldarg[0]);
card.ats_len = resp.oldarg[0]; // note: ats_len includes CRC Bytes
}
if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes

View file

@ -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.

View file

@ -199,7 +199,7 @@ const productName uidmapping[] = {
static int getUID(uint8_t *buf) {
UsbReplyNG resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
c.d.asBytes[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_INVENTORY | ISO15_REQINV_SLOT1;
c.d.asBytes[1] = ISO15_CMD_INVENTORY;
@ -218,9 +218,9 @@ static int getUID(uint8_t *buf) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint8_t resplen = resp.core.old.arg[0];
if (resplen >= 12 && CheckCrc15(resp.core.old.d.asBytes, 12)) {
memcpy(buf, resp.core.old.d.asBytes + 2, 8);
uint8_t resplen = resp.oldarg[0];
if (resplen >= 12 && CheckCrc15(resp.data.asBytes, 12)) {
memcpy(buf, resp.data.asBytes + 2, 8);
return 1;
}
}
@ -418,7 +418,7 @@ static int usage_15_readmulti(void) {
* Parameters:
* **cmd command line
*/
static int prepareHF15Cmd(char **cmd, UsbCommand *c, uint8_t iso15cmd) {
static int prepareHF15Cmd(char **cmd, UsbCommandOLD *c, uint8_t iso15cmd) {
int temp;
uint8_t *req = c->d.asBytes;
uint8_t uid[8] = {0x00};
@ -577,7 +577,7 @@ static int CmdHF15Samples(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_15_samples();
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -596,7 +596,7 @@ static int CmdHF15Info(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
char cmdbuf[100] = {0};
char *cmd = cmdbuf;
@ -619,14 +619,14 @@ static int CmdHF15Info(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(WARNING, "iso15693 card doesn't answer to systeminfo command");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (recv[0] & ISO15_RES_ERROR) {
PrintAndLogEx(WARNING, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
@ -674,7 +674,7 @@ static int CmdHF15Record(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_15_record();
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -702,7 +702,7 @@ static int CmdHF15Sim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Starting simulating UID %s", sprint_hex(uid, sizeof(uid)));
UsbCommand c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}, {{0}}};
memcpy(c.d.asBytes, uid, 8);
clearCommandBuffer();
SendCommand(&c);
@ -718,7 +718,7 @@ static int CmdHF15Afi(const char *Cmd) {
PrintAndLogEx(SUCCESS, "press pm3-button to cancel");
UsbCommand c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -784,7 +784,7 @@ static int CmdHF15Dump(const char *Cmd) {
memset(data, 0, sizeof(data));
UsbReplyNG resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
req[0] = ISO15_REQ_SUBCARRIER_SINGLE | ISO15_REQ_DATARATE_HIGH | ISO15_REQ_NONINVENTORY | ISO15_REQ_ADDRESS;
req[1] = ISO15_CMD_READ;
@ -803,13 +803,13 @@ static int CmdHF15Dump(const char *Cmd) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint8_t len = resp.core.old.arg[0];
uint8_t len = resp.oldarg[0];
if (len < 2) {
PrintAndLogEx(FAILED, "iso15693 card select failed");
continue;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, len)) {
PrintAndLogEx(FAILED, "crc fail");
@ -821,9 +821,9 @@ static int CmdHF15Dump(const char *Cmd) {
break;
}
mem[blocknum].lock = resp.core.old.d.asBytes[0];
memcpy(mem[blocknum].block, resp.core.old.d.asBytes + 1, 4);
memcpy(data + (blocknum * 4), resp.core.old.d.asBytes + 1, 4);
mem[blocknum].lock = resp.data.asBytes[0];
memcpy(mem[blocknum].block, resp.data.asBytes + 1, 4);
memcpy(data + (blocknum * 4), resp.data.asBytes + 1, 4);
retry = 0;
blocknum++;
@ -860,7 +860,7 @@ static int CmdHF15Raw(const char *Cmd) {
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_raw();
UsbReplyNG resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
int reply = 1, fast = 1, i = 0;
bool crc = false;
char buf[5] = "";
@ -926,9 +926,9 @@ static int CmdHF15Raw(const char *Cmd) {
if (reply) {
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint8_t len = resp.core.old.arg[0];
uint8_t len = resp.oldarg[0];
PrintAndLogEx(NORMAL, "received %i octets", len);
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
} else {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
}
@ -947,7 +947,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0;
uint8_t pagenum, pagecount;
@ -986,13 +986,13 @@ static int CmdHF15Readmulti(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(FAILED, "iso15693 card select failed");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, status)) {
PrintAndLogEx(FAILED, "CRC failed");
@ -1031,11 +1031,11 @@ static int CmdHF15Read(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
// UsbCommand arg: len, speed, recv?
// UsbCommandOLD arg: len, speed, recv?
// arg0 (datalen, cmd len? .arg0 == crc?)
// arg1 (speed == 0 == 1 of 256, == 1 == 1 of 4 )
// arg2 (recv == 1 == expect a response)
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}};
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}};
uint8_t *req = c.d.asBytes;
int reqlen = 0, blocknum;
char cmdbuf[100] = {0};
@ -1066,13 +1066,13 @@ static int CmdHF15Read(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(NORMAL, "iso15693 card select failed");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, status)) {
PrintAndLogEx(NORMAL, "CRC failed");
@ -1104,7 +1104,7 @@ static int CmdHF15Write(const char *Cmd) {
UsbReplyNG resp;
uint8_t *recv;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
uint8_t *req = c.d.asBytes;
int reqlen = 0, pagenum, temp;
char cmdbuf[100] = {0};
@ -1150,13 +1150,13 @@ static int CmdHF15Write(const char *Cmd) {
return 1;
}
uint32_t status = resp.core.old.arg[0];
uint32_t status = resp.oldarg[0];
if (status < 2) {
PrintAndLogEx(FAILED, "iso15693 card select failed");
return 1;
}
recv = resp.core.old.d.asBytes;
recv = resp.data.asBytes;
if (!CheckCrc15(recv, status)) {
PrintAndLogEx(FAILED, "CRC failed");

View file

@ -31,20 +31,20 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
// repeat n times
for (uint32_t i = 0; i < n; i++) {
// execute PACE
UsbCommand c = {CMD_EPA_PACE_COLLECT_NONCE, {(int)m, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_EPA_PACE_COLLECT_NONCE, {(int)m, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
// check if command failed
if (resp.core.old.arg[0] != 0) {
PrintAndLogEx(FAILED, "Error in step %d, Return code: %d", resp.core.old.arg[0], (int)resp.core.old.arg[1]);
if (resp.oldarg[0] != 0) {
PrintAndLogEx(FAILED, "Error in step %d, Return code: %d", resp.oldarg[0], (int)resp.oldarg[1]);
} else {
size_t nonce_length = resp.core.old.arg[1];
size_t nonce_length = resp.oldarg[1];
char *nonce = (char *) calloc(2 * nonce_length + 1, sizeof(uint8_t));
for (int j = 0; j < nonce_length; j++) {
sprintf(nonce + (2 * j), "%02X", resp.core.old.d.asBytes[j]);
sprintf(nonce + (2 * j), "%02X", resp.data.asBytes[j]);
}
// print nonce
PrintAndLogEx(NORMAL, "Length: %d, Nonce: %s", nonce_length, nonce);
@ -109,7 +109,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
}
// transfer the APDUs to the Proxmark
UsbCommand usb_cmd;
UsbCommandOLD usb_cmd;
usb_cmd.cmd = CMD_EPA_PACE_REPLAY;
for (int i = 0; i < sizeof(apdu_lengths); i++) {
// APDU number
@ -132,7 +132,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
clearCommandBuffer();
SendCommand(&usb_cmd);
WaitForResponse(CMD_ACK, &resp);
if (resp.core.old.arg[0] != 0) {
if (resp.oldarg[0] != 0) {
PrintAndLogEx(WARNING, "Transfer of APDU #%d Part %d failed!", i, j);
return 0;
}
@ -144,21 +144,21 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
clearCommandBuffer();
SendCommand(&usb_cmd);
WaitForResponse(CMD_ACK, &resp);
if (resp.core.old.arg[0] != 0) {
PrintAndLogEx(NORMAL, "\nPACE replay failed in step %u!", (uint32_t)resp.core.old.arg[0]);
if (resp.oldarg[0] != 0) {
PrintAndLogEx(NORMAL, "\nPACE replay failed in step %u!", (uint32_t)resp.oldarg[0]);
PrintAndLogEx(NORMAL, "Measured times:");
PrintAndLogEx(NORMAL, "MSE Set AT: %u us", resp.core.old.d.asDwords[0]);
PrintAndLogEx(NORMAL, "GA Get Nonce: %u us", resp.core.old.d.asDwords[1]);
PrintAndLogEx(NORMAL, "GA Map Nonce: %u us", resp.core.old.d.asDwords[2]);
PrintAndLogEx(NORMAL, "GA Perform Key Agreement: %u us", resp.core.old.d.asDwords[3]);
PrintAndLogEx(NORMAL, "GA Mutual Authenticate: %u us", resp.core.old.d.asDwords[4]);
PrintAndLogEx(NORMAL, "MSE Set AT: %u us", resp.data.asDwords[0]);
PrintAndLogEx(NORMAL, "GA Get Nonce: %u us", resp.data.asDwords[1]);
PrintAndLogEx(NORMAL, "GA Map Nonce: %u us", resp.data.asDwords[2]);
PrintAndLogEx(NORMAL, "GA Perform Key Agreement: %u us", resp.data.asDwords[3]);
PrintAndLogEx(NORMAL, "GA Mutual Authenticate: %u us", resp.data.asDwords[4]);
} else {
PrintAndLogEx(NORMAL, "PACE replay successfull!");
PrintAndLogEx(NORMAL, "MSE Set AT: %u us", resp.core.old.d.asDwords[0]);
PrintAndLogEx(NORMAL, "GA Get Nonce: %u us", resp.core.old.d.asDwords[1]);
PrintAndLogEx(NORMAL, "GA Map Nonce: %u us", resp.core.old.d.asDwords[2]);
PrintAndLogEx(NORMAL, "GA Perform Key Agreement: %u us", resp.core.old.d.asDwords[3]);
PrintAndLogEx(NORMAL, "GA Mutual Authenticate: %u us", resp.core.old.d.asDwords[4]);
PrintAndLogEx(NORMAL, "MSE Set AT: %u us", resp.data.asDwords[0]);
PrintAndLogEx(NORMAL, "GA Get Nonce: %u us", resp.data.asDwords[1]);
PrintAndLogEx(NORMAL, "GA Map Nonce: %u us", resp.data.asDwords[2]);
PrintAndLogEx(NORMAL, "GA Perform Key Agreement: %u us", resp.data.asDwords[3]);
PrintAndLogEx(NORMAL, "GA Mutual Authenticate: %u us", resp.data.asDwords[4]);
}
return 1;
}

View file

@ -128,7 +128,7 @@ static int CmdHFFelicaSim(const char *Cmd) {
//Validations
if (errors || cmdp == 0) return usage_hf_felica_sim();
UsbCommand c = {CMD_FELICA_SIMULATE_TAG, { tagtype, flags, 0 }, {{0}}};
UsbCommandOLD c = {CMD_FELICA_SIMULATE_TAG, { tagtype, flags, 0 }, {{0}}};
memcpy(c.d.asBytes, uid, uidlen >> 1);
clearCommandBuffer();
SendCommand(&c);
@ -174,7 +174,7 @@ static int CmdHFFelicaSniff(const char *Cmd) {
//Validations
if (errors || cmdp == 0) return usage_hf_felica_sniff();
UsbCommand c = {CMD_FELICA_SNIFF, {samples2skip, triggers2skip, 0}, {{0}}};
UsbCommandOLD c = {CMD_FELICA_SNIFF, {samples2skip, triggers2skip, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -188,7 +188,7 @@ static int CmdHFFelicaSimLite(const char *Cmd) {
if (!uid)
return usage_hf_felica_simlite();
UsbCommand c = {CMD_FELICA_LITE_SIM, {uid, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FELICA_LITE_SIM, {uid, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -352,7 +352,7 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
PrintAndLogEx(SUCCESS, "FeliCa lite - dump started");
PrintAndLogEx(SUCCESS, "press pm3-button to cancel");
UsbCommand c = {CMD_FELICA_LITE_DUMP, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FELICA_LITE_DUMP, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -375,12 +375,12 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
return 1;
}
}
if (resp.core.old.arg[0] == 0) {
if (resp.oldarg[0] == 0) {
PrintAndLogEx(WARNING, "\nButton pressed. Aborted.");
return 1;
}
uint64_t tracelen = resp.core.old.arg[1];
uint64_t tracelen = resp.oldarg[1];
if (tracelen == 0)
return 1;
@ -415,18 +415,18 @@ static void waitCmdFelica(uint8_t iSelect) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
uint16_t len = iSelect ? (resp.core.old.arg[1] & 0xffff) : (resp.core.old.arg[0] & 0xffff);
uint16_t len = iSelect ? (resp.oldarg[1] & 0xffff) : (resp.oldarg[0] & 0xffff);
PrintAndLogEx(NORMAL, "received %i octets", len);
if (!len)
return;
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.data.asBytes, len));
} else {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
}
}
static int CmdHFFelicaCmdRaw(const char *Cmd) {
UsbCommand c = {CMD_FELICA_COMMAND, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FELICA_COMMAND, {0, 0, 0}, {{0}}};
bool reply = 1;
bool crc = false;
bool power = false;
@ -568,8 +568,8 @@ int CmdHFFelica(const char *Cmd) {
int readFelicaUid(bool verbose) {
//UsbCommand cDisconnect = {CMD_FELICA_COMMAND, {0,0,0}, {{0}}};
UsbCommand c = {CMD_FELICA_COMMAND, {FELICA_CONNECT, 0, 0}, {{0}}};
//UsbCommandOLD cDisconnect = {CMD_FELICA_COMMAND, {0,0,0}, {{0}}};
UsbCommandOLD c = {CMD_FELICA_COMMAND, {FELICA_CONNECT, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -580,8 +580,8 @@ int readFelicaUid(bool verbose) {
}
felica_card_select_t card;
memcpy(&card, (felica_card_select_t *)resp.core.old.d.asBytes, sizeof(felica_card_select_t));
uint64_t status = resp.core.old.arg[0];
memcpy(&card, (felica_card_select_t *)resp.data.asBytes, sizeof(felica_card_select_t));
uint64_t status = resp.oldarg[0];
switch (status) {
case 1: {

View file

@ -281,7 +281,7 @@ static int CmdHFiClassList(const char *Cmd) {
static int CmdHFiClassSniff(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_hf_iclass_sniff();
UsbCommand c = {CMD_SNIFF_ICLASS, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SNIFF_ICLASS, {0, 0, 0}, {{0}}};
SendCommand(&c);
return 0;
}
@ -380,7 +380,7 @@ static int CmdHFiClassSim(const char *Cmd) {
case 2: {
PrintAndLogEx(INFO, "Starting iCLASS sim 2 attack (elite mode)");
PrintAndLogEx(INFO, "press keyboard to cancel");
UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
UsbReplyNG resp;
memcpy(c.d.asBytes, csns, 8 * NUM_CSNS);
clearCommandBuffer();
@ -399,7 +399,7 @@ static int CmdHFiClassSim(const char *Cmd) {
return 0;
}
}
uint8_t num_mac = resp.core.old.arg[1];
uint8_t num_mac = resp.oldarg[1];
bool success = (NUM_CSNS == num_mac);
PrintAndLogEx(NORMAL, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS, (success) ? "OK" : "FAIL");
@ -420,9 +420,9 @@ static int CmdHFiClassSim(const char *Cmd) {
//copy CSN
memcpy(dump + i * 24, csns + i * 8, 8);
//copy epurse
memcpy(dump + i * 24 + 8, resp.core.old.d.asBytes + i * 16, 8);
memcpy(dump + i * 24 + 8, resp.data.asBytes + i * 16, 8);
// NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
memcpy(dump + i * 24 + 16, resp.core.old.d.asBytes + i * 16 + 8, 8);
memcpy(dump + i * 24 + 16, resp.data.asBytes + i * 16 + 8, 8);
}
/** Now, save to dumpfile **/
saveFile("iclass_mac_attack", "bin", dump, datalen);
@ -433,7 +433,7 @@ static int CmdHFiClassSim(const char *Cmd) {
// reader in key roll mode, when it has two keys it alternates when trying to verify.
PrintAndLogEx(INFO, "Starting iCLASS sim 4 attack (elite mode, reader in key roll mode)");
PrintAndLogEx(INFO, "press keyboard to cancel");
UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
UsbReplyNG resp;
memcpy(c.d.asBytes, csns, 8 * NUM_CSNS);
clearCommandBuffer();
@ -452,7 +452,7 @@ static int CmdHFiClassSim(const char *Cmd) {
return 0;
}
}
uint8_t num_mac = resp.core.old.arg[1];
uint8_t num_mac = resp.oldarg[1];
bool success = ((NUM_CSNS * 2) == num_mac);
PrintAndLogEx(NORMAL, "[%c] %d out of %d MAC obtained [%s]", (success) ? '+' : '!', num_mac, NUM_CSNS * 2, (success) ? "OK" : "FAIL");
@ -475,9 +475,9 @@ static int CmdHFiClassSim(const char *Cmd) {
// copy CSN
memcpy(dump + i * MAC_ITEM_SIZE, csns + i * 8, 8); //CSN
// copy EPURSE
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.core.old.d.asBytes + i * 16, 8);
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.data.asBytes + i * 16, 8);
// copy NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.core.old.d.asBytes + i * 16 + 8, 8);
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.data.asBytes + i * 16 + 8, 8);
}
saveFile("iclass_mac_attack_keyroll_A", "bin", dump, datalen);
@ -489,9 +489,9 @@ static int CmdHFiClassSim(const char *Cmd) {
// Copy CSN
memcpy(dump + i * MAC_ITEM_SIZE, csns + i * 8, 8);
// copy EPURSE
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.core.old.d.asBytes + resp_index, 8);
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.data.asBytes + resp_index, 8);
// copy NR_MAC (eight bytes from the response) ( 8b csn + 8 epurse == 16)
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.core.old.d.asBytes + resp_index + 8, 8);
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.data.asBytes + resp_index + 8, 8);
resp_index++;
}
saveFile("iclass_mac_attack_keyroll_B", "bin", dump, datalen);
@ -501,7 +501,7 @@ static int CmdHFiClassSim(const char *Cmd) {
case 1:
case 3:
default: {
UsbCommand c = {CMD_SIMULATE_TAG_ICLASS, {simType, numberOfCSNs}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, numberOfCSNs}, {{0}}};
memcpy(c.d.asBytes, CSN, 8);
clearCommandBuffer();
SendCommand(&c);
@ -531,7 +531,7 @@ static int CmdHFiClassReader_Replay(const char *Cmd) {
return 1;
}
UsbCommand c = {CMD_READER_ICLASS_REPLAY, {readerType}, {{0}}};
UsbCommandOLD c = {CMD_READER_ICLASS_REPLAY, {readerType}, {{0}}};
memcpy(c.d.asBytes, MAC, 4);
clearCommandBuffer();
SendCommand(&c);
@ -540,7 +540,7 @@ static int CmdHFiClassReader_Replay(const char *Cmd) {
/*
static int iclassEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
UsbCommand c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, 0}, {{0}}};
memcpy(c.d.asBytes, data, blocksCount * 16);
clearCommandBuffer();
SendCommand(&c);
@ -603,7 +603,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
while (bytes_remaining > 0) {
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
UsbCommand c = {CMD_ICLASS_EML_MEMSET, {bytes_sent, bytes_in_packet, 0}, {{0}}};
UsbCommandOLD c = {CMD_ICLASS_EML_MEMSET, {bytes_sent, bytes_in_packet, 0}, {{0}}};
memcpy(c.d.asBytes, dump + bytes_sent, bytes_in_packet);
clearCommandBuffer();
SendCommand(&c);
@ -768,7 +768,7 @@ static void Calc_wb_mac(uint8_t blockno, uint8_t *data, uint8_t *div_key, uint8_
static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool use_credit_key, bool verbose) {
UsbReplyNG resp;
UsbCommand c = {CMD_READER_ICLASS, {0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ICLASS, {0}, {{0}}};
c.arg[0] = FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_CC | FLAG_ICLASS_READER_ONE_TRY;
if (use_credit_key)
@ -781,8 +781,8 @@ static bool select_only(uint8_t *CSN, uint8_t *CCNR, bool use_credit_key, bool v
return false;
}
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t isOK = resp.oldarg[0] & 0xff;
uint8_t *data = resp.data.asBytes;
memcpy(CSN, data, 8);
@ -819,7 +819,7 @@ static bool select_and_auth(uint8_t *KEY, uint8_t *MAC, uint8_t *div_key, bool u
doMAC(CCNR, div_key, MAC);
UsbReplyNG resp;
UsbCommand d = {CMD_ICLASS_AUTHENTICATION, {0, 0, 0}, {{0}}};
UsbCommandOLD d = {CMD_ICLASS_AUTHENTICATION, {0, 0, 0}, {{0}}};
memcpy(d.d.asBytes, MAC, 4);
clearCommandBuffer();
SendCommand(&d);
@ -827,7 +827,7 @@ static bool select_and_auth(uint8_t *KEY, uint8_t *MAC, uint8_t *div_key, bool u
if (verbose) PrintAndLogEx(FAILED, "auth command execute timeout");
return false;
}
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
if (!isOK) {
if (verbose) PrintAndLogEx(FAILED, "authentication error");
return false;
@ -939,7 +939,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
FLAG_ICLASS_READER_ONE_TRY;
//get config and first 3 blocks
UsbCommand c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
UsbReplyNG resp;
uint8_t tag_data[255 * 8];
@ -952,8 +952,8 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
}
DropField();
uint8_t readStatus = resp.core.old.arg[0] & 0xff;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t readStatus = resp.oldarg[0] & 0xff;
uint8_t *data = resp.data.asBytes;
if (readStatus == 0) {
PrintAndLogEx(FAILED, "no tag found");
@ -981,7 +981,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
}
// begin dump
UsbCommand w = {CMD_ICLASS_DUMP, {blockno, numblks - blockno + 1}, {{0}}};
UsbCommandOLD w = {CMD_ICLASS_DUMP, {blockno, numblks - blockno + 1}, {{0}}};
clearCommandBuffer();
SendCommand(&w);
while (true) {
@ -1000,14 +1000,14 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
}
// dump cmd switch off at device when finised.
uint32_t blocksRead = resp.core.old.arg[1];
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint32_t blocksRead = resp.oldarg[1];
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK && !blocksRead) {
PrintAndLogEx(WARNING, "read block failed");
return 0;
}
uint32_t startindex = resp.core.old.arg[2];
uint32_t startindex = resp.oldarg[2];
if (blocksRead * 8 > sizeof(tag_data) - (blockno * 8)) {
PrintAndLogEx(FAILED, "data exceeded buffer size!");
blocksRead = (sizeof(tag_data) / 8) - blockno;
@ -1046,14 +1046,14 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
PrintAndLogEx(WARNING, "command execute timeout 2");
return 0;
}
isOK = resp.core.old.arg[0] & 0xff;
blocksRead = resp.core.old.arg[1];
isOK = resp.oldarg[0] & 0xff;
blocksRead = resp.oldarg[1];
if (!isOK && !blocksRead) {
PrintAndLogEx(WARNING, "read block failed 2");
return 0;
}
startindex = resp.core.old.arg[2];
startindex = resp.oldarg[2];
if (blocksRead * 8 > sizeof(tag_data) - gotBytes) {
PrintAndLogEx(FAILED, "data exceeded buffer size!");
blocksRead = (sizeof(tag_data) - gotBytes) / 8;
@ -1100,7 +1100,7 @@ static int WriteBlock(uint8_t blockno, uint8_t *bldata, uint8_t *KEY, bool use_c
UsbReplyNG resp;
Calc_wb_mac(blockno, bldata, div_key, MAC);
UsbCommand w = {CMD_ICLASS_WRITEBLOCK, {blockno}, {{0}}};
UsbCommandOLD w = {CMD_ICLASS_WRITEBLOCK, {blockno}, {{0}}};
memcpy(w.d.asBytes, bldata, 8);
memcpy(w.d.asBytes + 8, MAC, 4);
@ -1110,7 +1110,7 @@ static int WriteBlock(uint8_t blockno, uint8_t *bldata, uint8_t *KEY, bool use_c
if (verbose) PrintAndLogEx(WARNING, "Write Command execute timeout");
return 0;
}
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (isOK)
PrintAndLogEx(SUCCESS, "Write block successful");
else
@ -1321,7 +1321,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
return 0;
}
UsbCommand w = {CMD_ICLASS_CLONE, {startblock, endblock}, {{0}}};
UsbCommandOLD w = {CMD_ICLASS_CLONE, {startblock, endblock}, {{0}}};
uint8_t *ptr;
// calculate all mac for every the block we will write
for (i = startblock; i <= endblock; i++) {
@ -1368,7 +1368,7 @@ static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite,
}
UsbReplyNG resp;
UsbCommand c = {CMD_ICLASS_READBLOCK, {blockno}, {{0}}};
UsbCommandOLD c = {CMD_ICLASS_READBLOCK, {blockno}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
@ -1376,13 +1376,13 @@ static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite,
return 0;
}
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, "read block failed");
return 0;
}
//data read is stored in: resp.core.old.d.asBytes[0-15]
PrintAndLogEx(NORMAL, "block %02X: %s\n", blockno, sprint_hex(resp.core.old.d.asBytes, 8));
//data read is stored in: resp.data.asBytes[0-15]
PrintAndLogEx(NORMAL, "block %02X: %s\n", blockno, sprint_hex(resp.data.asBytes, 8));
return 1;
}
@ -1977,7 +1977,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
if (keys == keycnt - i)
lastChunk = true;
UsbCommand c = {CMD_ICLASS_CHECK_KEYS, { (lastChunk << 8), keys, 0}, {{0}}};
UsbCommandOLD c = {CMD_ICLASS_CHECK_KEYS, { (lastChunk << 8), keys, 0}, {{0}}};
// bit 16
// - 1 indicates credit key
@ -1999,8 +1999,8 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
}
}
uint8_t found = resp.core.old.arg[1] & 0xFF;
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t found = resp.oldarg[1] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
t2 = msclock() - t2;
switch (isOK) {
@ -2465,7 +2465,7 @@ int readIclass(bool loop, bool verbose) {
FLAG_ICLASS_READER_CONF | FLAG_ICLASS_READER_ONLY_ONCE |
FLAG_ICLASS_READER_ONE_TRY;
UsbCommand c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
// loop in client not device - else on windows have a communication error
UsbReplyNG resp;
while (!ukbhit()) {
@ -2473,8 +2473,8 @@ int readIclass(bool loop, bool verbose) {
clearCommandBuffer();
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
uint8_t readStatus = resp.core.old.arg[0] & 0xff;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t readStatus = resp.oldarg[0] & 0xff;
uint8_t *data = resp.data.asBytes;
if (verbose) PrintAndLogEx(NORMAL, "Readstatus:%02x", readStatus);
// no tag found or button pressed

View file

@ -524,7 +524,7 @@ static int CmdLegicRfSim(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_legic_sim();
UsbCommand c = {CMD_SIMULATE_TAG_LEGIC_RF, {1}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_TAG_LEGIC_RF, {1}, {{0}}};
sscanf(Cmd, " %" SCNi64, &c.arg[0]);
clearCommandBuffer();
SendCommand(&c);
@ -642,7 +642,7 @@ static int CmdLegicRfWrite(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Writing to tag");
UsbCommand c = {CMD_WRITER_LEGIC_RF, {offset, len, IV}, {{0}}};
UsbCommandOLD c = {CMD_WRITER_LEGIC_RF, {offset, len, IV}, {{0}}};
memcpy(c.d.asBytes, data, len);
UsbReplyNG resp;
clearCommandBuffer();
@ -661,7 +661,7 @@ static int CmdLegicRfWrite(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "\n");
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
if (!isOK) {
PrintAndLogEx(WARNING, "Failed writing tag");
return 1;
@ -756,7 +756,7 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
legic_chk_iv(&iv);
UsbCommand c = {CMD_READER_LEGIC_RF, {offset, len, iv}, {{0}}};
UsbCommandOLD c = {CMD_READER_LEGIC_RF, {offset, len, iv}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -773,8 +773,8 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
}
PrintAndLogEx(NORMAL, "\n");
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
*outlen = resp.core.old.arg[1];
uint8_t isOK = resp.oldarg[0] & 0xFF;
*outlen = resp.oldarg[1];
if (!isOK) {
PrintAndLogEx(WARNING, "Failed reading tag");
return 2;
@ -810,18 +810,18 @@ int legic_get_type(legic_card_select_t *card) {
if (card == NULL) return 1;
UsbCommand c = {CMD_LEGIC_INFO, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_LEGIC_INFO, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500))
return 2;
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
if (!isOK)
return 3;
memcpy(card, (legic_card_select_t *)resp.core.old.d.asBytes, sizeof(legic_card_select_t));
memcpy(card, (legic_card_select_t *)resp.data.asBytes, sizeof(legic_card_select_t));
return 0;
}
void legic_chk_iv(uint32_t *iv) {
@ -837,7 +837,7 @@ void legic_chk_iv(uint32_t *iv) {
}
void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
UsbCommand c = {CMD_LEGIC_ESET, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_LEGIC_ESET, {0, 0, 0}, {{0}}};
for (size_t i = offset; i < numofbytes; i += USB_CMD_DATA_SIZE) {
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
@ -900,7 +900,7 @@ static int CmdLegicDump(const char *Cmd) {
legic_print_type(dumplen, 0);
PrintAndLogEx(SUCCESS, "Reading tag memory %d b...", dumplen);
UsbCommand c = {CMD_READER_LEGIC_RF, {0x00, dumplen, 0x55}, {{0}}};
UsbCommandOLD c = {CMD_READER_LEGIC_RF, {0x00, dumplen, 0x55}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -917,13 +917,13 @@ static int CmdLegicDump(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "\n");
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
if (!isOK) {
PrintAndLogEx(WARNING, "Failed dumping tag data");
return 2;
}
uint16_t readlen = resp.core.old.arg[1];
uint16_t readlen = resp.oldarg[1];
uint8_t *data = calloc(readlen, sizeof(uint8_t));
if (!data) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
@ -1049,7 +1049,7 @@ static int CmdLegicRestore(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Restoring to card");
// transfer to device
UsbCommand c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
UsbCommandOLD c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
UsbReplyNG resp;
for (size_t i = 7; i < numofbytes; i += USB_CMD_DATA_SIZE) {
@ -1073,9 +1073,9 @@ static int CmdLegicRestore(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "\n");
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
if (!isOK) {
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.core.old.arg[1] & 0xFF);
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.oldarg[1] & 0xFF);
free(data);
return 1;
}
@ -1242,7 +1242,7 @@ static int CmdLegicWipe(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Erasing");
// transfer to device
UsbCommand c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
UsbCommandOLD c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
UsbReplyNG resp;
for (size_t i = 7; i < card.cardsize; i += USB_CMD_DATA_SIZE) {
@ -1268,9 +1268,9 @@ static int CmdLegicWipe(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "\n");
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
uint8_t isOK = resp.oldarg[0] & 0xFF;
if (!isOK) {
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.core.old.arg[1] & 0xFF);
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.oldarg[1] & 0xFF);
free(data);
return 4;
}

View file

@ -411,7 +411,7 @@ static int usage_hf14_nack(void) {
}
static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -422,7 +422,7 @@ static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
}
iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
memcpy(uid, card.uid, card.uidlen * sizeof(uint8_t));
*uidlen = card.uidlen;
return 1;
@ -522,7 +522,7 @@ static int CmdHF14AMfWrBl(const char *Cmd) {
PrintAndLogEx(NORMAL, "--block no:%d, key type:%c, key:%s", blockNo, keyType ? 'B' : 'A', sprint_hex(key, 6));
PrintAndLogEx(NORMAL, "--data: %s", sprint_hex(bldata, 16));
UsbCommand c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
memcpy(c.d.asBytes + 10, bldata, 16);
clearCommandBuffer();
@ -530,7 +530,7 @@ static int CmdHF14AMfWrBl(const char *Cmd) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
} else {
PrintAndLogEx(NORMAL, "Command execute timeout");
@ -568,15 +568,15 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "--block no:%d, key type:%c, key:%s ", blockNo, keyType ? 'B' : 'A', sprint_hex(key, 6));
UsbCommand c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t isOK = resp.oldarg[0] & 0xff;
uint8_t *data = resp.data.asBytes;
if (isOK) {
PrintAndLogEx(NORMAL, "isOk:%02x data:%s", isOK, sprint_hex(data, 16));
@ -638,7 +638,7 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "--sector no:%d key type:%c key:%s ", sectorNo, keyType ? 'B' : 'A', sprint_hex(key, 6));
UsbCommand c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
clearCommandBuffer();
SendCommand(&c);
@ -646,8 +646,8 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
isOK = resp.core.old.arg[0] & 0xff;
data = resp.core.old.d.asBytes;
isOK = resp.oldarg[0] & 0xff;
data = resp.data.asBytes;
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
if (isOK) {
@ -803,14 +803,14 @@ static int CmdHF14AMfDump(const char *Cmd) {
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) {
UsbCommand c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1, 0, 0}, {{0}}};
memcpy(c.d.asBytes, keyA[sectorNo], 6);
clearCommandBuffer();
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t isOK = resp.oldarg[0] & 0xff;
uint8_t *data = resp.data.asBytes;
if (isOK) {
rights[sectorNo][0] = ((data[7] & 0x10) >> 2) | ((data[8] & 0x1) << 1) | ((data[8] & 0x10) >> 4); // C1C2C3 for data area 0
rights[sectorNo][1] = ((data[7] & 0x20) >> 3) | ((data[8] & 0x2) << 0) | ((data[8] & 0x20) >> 5); // C1C2C3 for data area 1
@ -840,7 +840,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) {
if (blockNo == NumBlocksPerSector(sectorNo) - 1) { // sector trailer. At least the Access Conditions can always be read with key A.
UsbCommand c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
memcpy(c.d.asBytes, keyA[sectorNo], 6);
clearCommandBuffer();
SendCommand(&c);
@ -848,7 +848,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
} else { // data block. Check if it can be read with key A or key B
uint8_t data_area = (sectorNo < 32) ? blockNo : blockNo / 5;
if ((rights[sectorNo][data_area] == 0x03) || (rights[sectorNo][data_area] == 0x05)) { // only key B would work
UsbCommand c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 1, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 1, 0}, {{0}}};
memcpy(c.d.asBytes, keyB[sectorNo], 6);
SendCommand(&c);
received = WaitForResponseTimeout(CMD_ACK, &resp, 1500);
@ -857,7 +857,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
PrintAndLogEx(WARNING, "access rights do not allow reading of sector %2d block %3d", sectorNo, blockNo);
tries = MIFARE_SECTOR_RETRY;
} else { // key A would work
UsbCommand c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
memcpy(c.d.asBytes, keyA[sectorNo], 6);
clearCommandBuffer();
SendCommand(&c);
@ -865,14 +865,14 @@ static int CmdHF14AMfDump(const char *Cmd) {
}
}
if (received) {
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (isOK) break;
}
}
if (received) {
isOK = resp.core.old.arg[0] & 0xff;
uint8_t *data = resp.core.old.d.asBytes;
isOK = resp.oldarg[0] & 0xff;
uint8_t *data = resp.data.asBytes;
if (blockNo == NumBlocksPerSector(sectorNo) - 1) { // sector trailer. Fill in the keys.
data[0] = (keyA[sectorNo][0]);
data[1] = (keyA[sectorNo][1]);
@ -1019,7 +1019,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
for (blockNo = 0; blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
UsbCommand c = {CMD_MIFARE_WRITEBL, {FirstBlockOfSector(sectorNo) + blockNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_WRITEBL, {FirstBlockOfSector(sectorNo) + blockNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
bytes_read = fread(bldata, 1, 16, fdump);
if (bytes_read != 16) {
@ -1052,7 +1052,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
} else {
PrintAndLogEx(WARNING, "Command execute timeout");
@ -1251,7 +1251,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
PrintAndLogEx(SUCCESS, "reading block %d", sectrail);
UsbCommand c = {CMD_MIFARE_READBL, {sectrail, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {sectrail, 0, 0}, {{0}}};
num_to_bytes(e_sector[i].Key[0], 6, c.d.asBytes); // KEY A
clearCommandBuffer();
SendCommand(&c);
@ -1259,10 +1259,10 @@ static int CmdHF14AMfNested(const char *Cmd) {
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK) continue;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t *data = resp.data.asBytes;
key64 = bytes_to_num(data + 10, 6);
if (key64) {
PrintAndLogEx(SUCCESS, "data: %s", sprint_hex(data + 10, 6));
@ -1997,7 +1997,7 @@ static int CmdHF14AMfChk(const char *Cmd) {
PrintAndLogEx(NORMAL, "Reading block %d", sectrail);
UsbCommand c = {CMD_MIFARE_READBL, {sectrail, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {sectrail, 0, 0}, {{0}}};
num_to_bytes(e_sector[i].Key[0], 6, c.d.asBytes); // KEY A
clearCommandBuffer();
SendCommand(&c);
@ -2005,10 +2005,10 @@ static int CmdHF14AMfChk(const char *Cmd) {
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK) continue;
uint8_t *data = resp.core.old.d.asBytes;
uint8_t *data = resp.data.asBytes;
key64 = bytes_to_num(data + 10, 6);
if (key64) {
PrintAndLogEx(NORMAL, "Data:%s", sprint_hex(data + 10, 6));
@ -2231,7 +2231,7 @@ static int CmdHF14AMfSim(const char *Cmd) {
, flags
, flags);
UsbCommand c = {CMD_SIMULATE_MIFARE_CARD, {flags, exitAfterNReads, 0}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_MIFARE_CARD, {flags, exitAfterNReads, 0}, {{0}}};
memcpy(c.d.asBytes, uid, sizeof(uid));
clearCommandBuffer();
SendCommand(&c);
@ -2243,9 +2243,9 @@ static int CmdHF14AMfSim(const char *Cmd) {
while (!ukbhit()) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
if (!(flags & FLAG_NR_AR_ATTACK)) break;
if ((resp.core.old.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
if ((resp.oldarg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
memcpy(data, resp.core.old.d.asBytes, sizeof(data));
memcpy(data, resp.data.asBytes, sizeof(data));
readerAttack(data[0], setEmulatorMem, verbose);
}
showSectorTable();
@ -2291,7 +2291,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
PrintAndLogEx(NORMAL, "Press the key on pc keyboard to abort the client.\n");
PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n");
UsbCommand c = {CMD_MIFARE_SNIFFER, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_SNIFFER, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -2312,9 +2312,9 @@ static int CmdHF14AMfSniff(const char *Cmd) {
continue;
}
res = resp.core.old.arg[0] & 0xff;
traceLen = resp.core.old.arg[1];
len = resp.core.old.arg[2];
res = resp.oldarg[0] & 0xff;
traceLen = resp.oldarg[1];
len = resp.oldarg[2];
if (res == 0) {
PrintAndLogEx(SUCCESS, "hf mifare sniff finished");
@ -2344,7 +2344,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
}
// what happens if LEN is bigger then TRACELEN --iceman
memcpy(bufPtr, resp.core.old.d.asBytes, len);
memcpy(bufPtr, resp.data.asBytes, len);
bufPtr += len;
pckNum++;
}
@ -2422,7 +2422,7 @@ int CmdHF14AMfDbg(const char *Cmd) {
uint8_t dbgMode = param_get8ex(Cmd, 0, 0, 10);
if (dbgMode > 4) return usage_hf14_dbg();
UsbCommand c = {CMD_MIFARE_SET_DBGMODE, {dbgMode, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_SET_DBGMODE, {dbgMode, 0, 0}, {{0}}};
SendCommand(&c);
return 0;
}
@ -2508,7 +2508,7 @@ static int CmdHF14AMfEClear(const char *Cmd) {
char c = tolower(param_getchar(Cmd, 0));
if (c == 'h') return usage_hf14_eclr();
UsbCommand cmd = {CMD_MIFARE_EML_MEMCLR, {0, 0, 0}, {{0}}};
UsbCommandOLD cmd = {CMD_MIFARE_EML_MEMCLR, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&cmd);
return 0;
@ -2693,7 +2693,7 @@ static int CmdHF14AMfECFill(const char *Cmd) {
numSectors = NumOfSectors(c);
PrintAndLogEx(NORMAL, "--params: numSectors: %d, keyType: %c\n", numSectors, (keyType == 0) ? 'A' : 'B');
UsbCommand cmd = {CMD_MIFARE_EML_CARDLOAD, {numSectors, keyType, 0}, {{0}}};
UsbCommandOLD cmd = {CMD_MIFARE_EML_CARDLOAD, {numSectors, keyType, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&cmd);
return 0;
@ -3155,14 +3155,14 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
return 1;
}
UsbCommand c = {CMD_MIFARE_SETMOD, {mod, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_SETMOD, {mod, 0, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t ok = resp.core.old.arg[0] & 0xff;
uint8_t ok = resp.oldarg[0] & 0xff;
PrintAndLogEx(SUCCESS, "isOk:%02x", ok);
if (!ok)
PrintAndLogEx(FAILED, "Failed.");
@ -3256,16 +3256,16 @@ static int CmdHF14AMfice(const char *Cmd) {
flags = 0;
flags |= initialize ? 0x0001 : 0;
flags |= slow ? 0x0002 : 0;
UsbCommand c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) goto out;
if (resp.core.old.arg[0]) goto out;
if (resp.oldarg[0]) goto out;
uint32_t items = resp.core.old.arg[2];
uint32_t items = resp.oldarg[2];
if (fnonces) {
fwrite(resp.core.old.d.asBytes, 1, items * 4, fnonces);
fwrite(resp.data.asBytes, 1, items * 4, fnonces);
fflush(fnonces);
}
@ -3289,7 +3289,7 @@ out:
fclose(fnonces);
}
UsbCommand c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;

View file

@ -51,14 +51,14 @@ static int CmdHF14ADesWb(const char *Cmd) {
PrintAndLogEx(NORMAL, "--block no:%02x key type:%02x key:%s", blockNo, keyType, sprint_hex(key, 6));
PrintAndLogEx(NORMAL, "--data: %s", sprint_hex(bldata, 16));
UsbCommand c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
memcpy(c.d.asBytes + 10, bldata, 16);
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
} else {
PrintAndLogEx(NORMAL, "Command execute timeout");
@ -93,14 +93,14 @@ static int CmdHF14ADesRb(const char *Cmd) {
}
PrintAndLogEx(NORMAL, "--block no:%02x key type:%02x key:%s ", blockNo, keyType, sprint_hex(key, 6));
UsbCommand c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t * data = resp.core.old.d.asBytes;
uint8_t isOK = resp.oldarg[0] & 0xff;
uint8_t * data = resp.data.asBytes;
if (isOK)
PrintAndLogEx(NORMAL, "isOk:%02x data:%s", isOK, sprint_hex(data, 16));
@ -116,7 +116,7 @@ static int CmdHF14ADesRb(const char *Cmd) {
static int CmdHF14ADesInfo(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_MIFARE_DESFIRE_INFO, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_DESFIRE_INFO, {0, 0, 0}, {{0}}};
SendCommand(&c);
UsbReplyNG resp;
@ -124,9 +124,9 @@ static int CmdHF14ADesInfo(const char *Cmd) {
PrintAndLogEx(WARNING, "Command execute timeout");
return 0;
}
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
switch (resp.core.old.arg[1]) {
switch (resp.oldarg[1]) {
case 1:
PrintAndLogEx(WARNING, "Can't select card");
break;
@ -143,25 +143,25 @@ static int CmdHF14ADesInfo(const char *Cmd) {
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "-- Desfire Information --------------------------------------");
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
PrintAndLogEx(NORMAL, " UID : %s", sprint_hex(resp.core.old.d.asBytes, 7));
PrintAndLogEx(NORMAL, " Batch number : %s", sprint_hex(resp.core.old.d.asBytes + 28, 5));
PrintAndLogEx(NORMAL, " Production date : week %02x, 20%02x", resp.core.old.d.asBytes[33], resp.core.old.d.asBytes[34]);
PrintAndLogEx(NORMAL, " UID : %s", sprint_hex(resp.data.asBytes, 7));
PrintAndLogEx(NORMAL, " Batch number : %s", sprint_hex(resp.data.asBytes + 28, 5));
PrintAndLogEx(NORMAL, " Production date : week %02x, 20%02x", resp.data.asBytes[33], resp.data.asBytes[34]);
PrintAndLogEx(NORMAL, " -----------------------------------------------------------");
PrintAndLogEx(NORMAL, " Hardware Information");
PrintAndLogEx(NORMAL, " Vendor Id : %s", getTagInfo(resp.core.old.d.asBytes[7]));
PrintAndLogEx(NORMAL, " Type : 0x%02X", resp.core.old.d.asBytes[8]);
PrintAndLogEx(NORMAL, " Subtype : 0x%02X", resp.core.old.d.asBytes[9]);
PrintAndLogEx(NORMAL, " Version : %s", getVersionStr(resp.core.old.d.asBytes[10], resp.core.old.d.asBytes[11]));
PrintAndLogEx(NORMAL, " Storage size : %s", getCardSizeStr(resp.core.old.d.asBytes[12]));
PrintAndLogEx(NORMAL, " Protocol : %s", getProtocolStr(resp.core.old.d.asBytes[13]));
PrintAndLogEx(NORMAL, " Vendor Id : %s", getTagInfo(resp.data.asBytes[7]));
PrintAndLogEx(NORMAL, " Type : 0x%02X", resp.data.asBytes[8]);
PrintAndLogEx(NORMAL, " Subtype : 0x%02X", resp.data.asBytes[9]);
PrintAndLogEx(NORMAL, " Version : %s", getVersionStr(resp.data.asBytes[10], resp.data.asBytes[11]));
PrintAndLogEx(NORMAL, " Storage size : %s", getCardSizeStr(resp.data.asBytes[12]));
PrintAndLogEx(NORMAL, " Protocol : %s", getProtocolStr(resp.data.asBytes[13]));
PrintAndLogEx(NORMAL, " -----------------------------------------------------------");
PrintAndLogEx(NORMAL, " Software Information");
PrintAndLogEx(NORMAL, " Vendor Id : %s", getTagInfo(resp.core.old.d.asBytes[14]));
PrintAndLogEx(NORMAL, " Type : 0x%02X", resp.core.old.d.asBytes[15]);
PrintAndLogEx(NORMAL, " Subtype : 0x%02X", resp.core.old.d.asBytes[16]);
PrintAndLogEx(NORMAL, " Version : %d.%d", resp.core.old.d.asBytes[17], resp.core.old.d.asBytes[18]);
PrintAndLogEx(NORMAL, " storage size : %s", getCardSizeStr(resp.core.old.d.asBytes[19]));
PrintAndLogEx(NORMAL, " Protocol : %s", getProtocolStr(resp.core.old.d.asBytes[20]));
PrintAndLogEx(NORMAL, " Vendor Id : %s", getTagInfo(resp.data.asBytes[14]));
PrintAndLogEx(NORMAL, " Type : 0x%02X", resp.data.asBytes[15]);
PrintAndLogEx(NORMAL, " Subtype : 0x%02X", resp.data.asBytes[16]);
PrintAndLogEx(NORMAL, " Version : %d.%d", resp.data.asBytes[17], resp.data.asBytes[18]);
PrintAndLogEx(NORMAL, " storage size : %s", getCardSizeStr(resp.data.asBytes[19]));
PrintAndLogEx(NORMAL, " Protocol : %s", getProtocolStr(resp.data.asBytes[20]));
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
// Master Key settings
@ -177,7 +177,7 @@ static int CmdHF14ADesInfo(const char *Cmd) {
return 0;
uint8_t tmp[3];
memcpy(tmp, resp.core.old.d.asBytes + 3, 3);
memcpy(tmp, resp.data.asBytes + 3, 3);
PrintAndLogEx(NORMAL, " Available free memory on card : %d bytes", le24toh(tmp));
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
@ -256,7 +256,7 @@ void getKeySettings(uint8_t *aid) {
const char *str = messStr;
uint8_t isOK = 0;
uint32_t options;
UsbCommand c = {CMD_MIFARE_DESFIRE, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_DESFIRE, {0, 0, 0}, {{0}}};
UsbReplyNG resp;
//memset(messStr, 0x00, 512);
@ -269,19 +269,19 @@ void getKeySettings(uint8_t *aid) {
c.d.asBytes[0] = GET_KEY_SETTINGS; // 0x45
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {return;}
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, " Can't select master application");
return;
}
str = (resp.core.old.d.asBytes[3] & (1 << 3)) ? "YES" : "NO";
str = (resp.data.asBytes[3] & (1 << 3)) ? "YES" : "NO";
PrintAndLogEx(NORMAL, " [0x08] Configuration changeable : %s", str);
str = (resp.core.old.d.asBytes[3] & (1 << 2)) ? "NO" : "YES";
str = (resp.data.asBytes[3] & (1 << 2)) ? "NO" : "YES";
PrintAndLogEx(NORMAL, " [0x04] CMK required for create/delete : %s", str);
str = (resp.core.old.d.asBytes[3] & (1 << 1)) ? "NO" : "YES";
str = (resp.data.asBytes[3] & (1 << 1)) ? "NO" : "YES";
PrintAndLogEx(NORMAL, " [0x02] Directory list access with CMK : %s", str);
str = (resp.core.old.d.asBytes[3] & (1 << 0)) ? "YES" : "NO";
str = (resp.data.asBytes[3] & (1 << 0)) ? "YES" : "NO";
PrintAndLogEx(NORMAL, " [0x01] CMK is changeable : %s", str);
c.arg[LENPOS] = 0x02; //LEN
@ -289,14 +289,14 @@ void getKeySettings(uint8_t *aid) {
c.d.asBytes[1] = 0x00;
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { return; }
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, " Can't read key-version");
return;
}
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, " Max number of keys : %d", resp.core.old.d.asBytes[4]);
PrintAndLogEx(NORMAL, " Master key Version : %d (0x%02x)", resp.core.old.d.asBytes[3], resp.core.old.d.asBytes[3]);
PrintAndLogEx(NORMAL, " Max number of keys : %d", resp.data.asBytes[4]);
PrintAndLogEx(NORMAL, " Master key Version : %d (0x%02x)", resp.data.asBytes[3], resp.data.asBytes[3]);
PrintAndLogEx(NORMAL, " ----------------------------------------------------------");
c.arg[LENPOS] = 0x02; //LEN
@ -304,19 +304,19 @@ void getKeySettings(uint8_t *aid) {
c.d.asBytes[1] = 0x00; // KEY 0
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {return;}
isOK = resp.core.old.d.asBytes[2] & 0xff;
isOK = resp.data.asBytes[2] & 0xff;
PrintAndLogEx(NORMAL, " [0x0A] Authenticate : %s", (isOK == 0xAE) ? "NO" : "YES");
c.d.asBytes[0] = AUTHENTICATE_ISO; //0x1A
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {return;}
isOK = resp.core.old.d.asBytes[2] & 0xff;
isOK = resp.data.asBytes[2] & 0xff;
PrintAndLogEx(NORMAL, " [0x1A] Authenticate ISO : %s", (isOK == 0xAE) ? "NO" : "YES");
c.d.asBytes[0] = AUTHENTICATE_AES; //0xAA
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {return;}
isOK = resp.core.old.d.asBytes[2] & 0xff;
isOK = resp.data.asBytes[2] & 0xff;
PrintAndLogEx(NORMAL, " [0xAA] Authenticate AES : %s", (isOK == 0xAE) ? "NO" : "YES");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, " ----------------------------------------------------------");
@ -335,7 +335,7 @@ void getKeySettings(uint8_t *aid) {
PrintAndLogEx(WARNING, " Timed-out");
return;
}
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, " Can't select AID: %s", sprint_hex(aid, 3));
return;
@ -350,12 +350,12 @@ void getKeySettings(uint8_t *aid) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
return;
}
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, " Can't read Application Master key settings");
} else {
// Access rights.
uint8_t rights = (resp.core.old.d.asBytes[3] >> 4 & 0xff);
uint8_t rights = (resp.data.asBytes[3] >> 4 & 0xff);
switch (rights) {
case 0x00:
str = "AMK authentication is necessary to change any key (default)";
@ -374,13 +374,13 @@ void getKeySettings(uint8_t *aid) {
PrintAndLogEx(NORMAL, "-- %s", str);
PrintAndLogEx(NORMAL, "");
// same as CMK
str = (resp.core.old.d.asBytes[3] & (1 << 3)) ? "YES" : "NO";
str = (resp.data.asBytes[3] & (1 << 3)) ? "YES" : "NO";
PrintAndLogEx(NORMAL, " 0x08 Configuration changeable : %s", str);
str = (resp.core.old.d.asBytes[3] & (1 << 2)) ? "NO" : "YES";
str = (resp.data.asBytes[3] & (1 << 2)) ? "NO" : "YES";
PrintAndLogEx(NORMAL, " 0x04 AMK required for create/delete : %s", str);
str = (resp.core.old.d.asBytes[3] & (1 << 1)) ? "NO" : "YES";
str = (resp.data.asBytes[3] & (1 << 1)) ? "NO" : "YES";
PrintAndLogEx(NORMAL, " 0x02 Directory list access with AMK : %s", str);
str = (resp.core.old.d.asBytes[3] & (1 << 0)) ? "YES" : "NO";
str = (resp.data.asBytes[3] & (1 << 0)) ? "YES" : "NO";
PrintAndLogEx(NORMAL, " 0x01 AMK is changeable : %s", str);
}
@ -397,15 +397,15 @@ void getKeySettings(uint8_t *aid) {
int numOfKeys;
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (isOK == false) {
PrintAndLogEx(WARNING, " Can't read Application Master key version. Trying all keys");
//numOfKeys = MAX_NUM_KEYS;
} else {
numOfKeys = resp.core.old.d.asBytes[4];
numOfKeys = resp.data.asBytes[4];
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, " Max number of keys : %d", numOfKeys);
PrintAndLogEx(NORMAL, " Application Master key Version : %d (0x%02x)", resp.core.old.d.asBytes[3], resp.core.old.d.asBytes[3]);
PrintAndLogEx(NORMAL, " Application Master key Version : %d (0x%02x)", resp.data.asBytes[3], resp.data.asBytes[3]);
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
}
@ -427,7 +427,7 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
uint8_t aid[3];
uint32_t options = (INIT | DISCONNECT);
UsbCommand c = {CMD_MIFARE_DESFIRE, {options, 0x01 }, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_DESFIRE, {options, 0x01 }, {{0}}};
c.d.asBytes[0] = GET_APPLICATION_IDS; //0x6a
SendCommand(&c);
@ -436,7 +436,7 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
return 0;
}
isOK = resp.core.old.arg[0] & 0xff;
isOK = resp.oldarg[0] & 0xff;
if (!isOK) {
PrintAndLogEx(NORMAL, "Command unsuccessful");
return 0;
@ -449,33 +449,33 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
UsbReplyNG respFiles;
uint8_t num = 0;
int max = resp.core.old.arg[1] - 3 - 2;
int max = resp.oldarg[1] - 3 - 2;
for (int i = 3; i <= max; i += 3) {
PrintAndLogEx(NORMAL, " Aid %d : %02X %02X %02X ", num, resp.core.old.d.asBytes[i], resp.core.old.d.asBytes[i + 1], resp.core.old.d.asBytes[i + 2]);
PrintAndLogEx(NORMAL, " Aid %d : %02X %02X %02X ", num, resp.data.asBytes[i], resp.data.asBytes[i + 1], resp.data.asBytes[i + 2]);
num++;
aid[0] = resp.core.old.d.asBytes[i];
aid[1] = resp.core.old.d.asBytes[i + 1];
aid[2] = resp.core.old.d.asBytes[i + 2];
aid[0] = resp.data.asBytes[i];
aid[1] = resp.data.asBytes[i + 1];
aid[2] = resp.data.asBytes[i + 2];
getKeySettings(aid);
// Select Application
c.arg[CMDPOS] = INIT;
c.arg[LENPOS] = 0x04;
c.d.asBytes[0] = SELECT_APPLICATION; // 0x5a
c.d.asBytes[1] = resp.core.old.d.asBytes[i];
c.d.asBytes[2] = resp.core.old.d.asBytes[i + 1];
c.d.asBytes[3] = resp.core.old.d.asBytes[i + 2];
c.d.asBytes[1] = resp.data.asBytes[i];
c.d.asBytes[2] = resp.data.asBytes[i + 1];
c.d.asBytes[3] = resp.data.asBytes[i + 2];
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &respAid, 1500)) {
PrintAndLogEx(WARNING, " Timed-out");
continue;
}
isOK = respAid.core.old.d.asBytes[2] & 0xff;
isOK = respAid.data.asBytes[2] & 0xff;
if (isOK != 0x00) {
PrintAndLogEx(WARNING, " Can't select AID: %s", sprint_hex(resp.core.old.d.asBytes + i, 3));
PrintAndLogEx(WARNING, " Can't select AID: %s", sprint_hex(resp.data.asBytes + i, 3));
continue;
}
@ -489,13 +489,13 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
PrintAndLogEx(WARNING, " Timed-out");
continue;
} else {
isOK = respFiles.core.old.d.asBytes[2] & 0xff;
isOK = respFiles.data.asBytes[2] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, " Can't get file ids ");
} else {
int respfileLen = resp.core.old.arg[1] - 3 - 2;
int respfileLen = resp.oldarg[1] - 3 - 2;
for (int j = 0; j < respfileLen; ++j) {
PrintAndLogEx(NORMAL, " Fileid %d :", resp.core.old.d.asBytes[j + 3]);
PrintAndLogEx(NORMAL, " Fileid %d :", resp.data.asBytes[j + 3]);
}
}
}
@ -510,13 +510,13 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
PrintAndLogEx(WARNING, " Timed-out");
continue;
} else {
isOK = respFiles.core.old.d.asBytes[2] & 0xff;
isOK = respFiles.data.asBytes[2] & 0xff;
if (!isOK) {
PrintAndLogEx(WARNING, " Can't get ISO file ids ");
} else {
int respfileLen = resp.core.old.arg[1] - 3 - 2;
int respfileLen = resp.oldarg[1] - 3 - 2;
for (int j = 0; j < respfileLen; ++j) {
PrintAndLogEx(NORMAL, " ISO Fileid %d :", resp.core.old.d.asBytes[j + 3]);
PrintAndLogEx(NORMAL, " ISO Fileid %d :", resp.data.asBytes[j + 3]);
}
}
}
@ -611,7 +611,7 @@ static int CmdHF14ADesAuth(const char *Cmd) {
return 1;
}
// algo, nyckell<6C>ngd,
UsbCommand c = {CMD_MIFARE_DESFIRE_AUTH1, { cmdAuthMode, cmdAuthAlgo, cmdKeyNo }, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_DESFIRE_AUTH1, { cmdAuthMode, cmdAuthAlgo, cmdKeyNo }, {{0}}};
c.d.asBytes[0] = keylength;
memcpy(c.d.asBytes + 1, key, keylength);
@ -624,9 +624,9 @@ static int CmdHF14ADesAuth(const char *Cmd) {
return 0;
}
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (isOK) {
uint8_t *data = resp.core.old.d.asBytes;
uint8_t *data = resp.data.asBytes;
PrintAndLogEx(NORMAL, " Key :%s", sprint_hex(key, keylength));
PrintAndLogEx(NORMAL, " SESSION :%s", sprint_hex(data, keylength));

View file

@ -58,13 +58,13 @@ static int CmdHF14AMfDESAuth(const char *Cmd) {
//DES_set_key((DES_cblock *)key2,&ks2);
//Auth1
UsbCommand c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
UsbCommandOLD c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
cuid = resp.core.old.arg[1];
uint8_t *data = resp.core.old.d.asBytes;
uint8_t isOK = resp.oldarg[0] & 0xff;
cuid = resp.oldarg[1];
uint8_t *data = resp.data.asBytes;
if (isOK) {
PrintAndLogEx(NORMAL, "enc(nc)/b0:%s", sprint_hex(data + 2, 8));
@ -94,7 +94,7 @@ static int CmdHF14AMfDESAuth(const char *Cmd) {
PrintAndLogEx(NORMAL, "b2:%s", sprint_hex(b2, 8));
//Auth2
UsbCommand d = {CMD_MIFARE_DES_AUTH2, {cuid}};
UsbCommandOLD d = {CMD_MIFARE_DES_AUTH2, {cuid}};
memcpy(reply, b1, 8);
memcpy(reply + 8, b2, 8);
memcpy(d.d.asBytes, reply, 16);
@ -158,13 +158,13 @@ static int CmdHF14AMfAESAuth(const char *Cmd) {
AES_set_decrypt_key(key, 128, &key_d);
//Auth1
UsbCommand c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
UsbCommandOLD c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
cuid = resp.core.old.arg[1];
uint8_t *data = resp.core.old.d.asBytes;
uint8_t isOK = resp.oldarg[0] & 0xff;
cuid = resp.oldarg[1];
uint8_t *data = resp.data.asBytes;
if (isOK) {
PrintAndLogEx(NORMAL, "enc(nc)/b0:%s", sprint_hex(data + 2, 16));
@ -201,7 +201,7 @@ static int CmdHF14AMfAESAuth(const char *Cmd) {
PrintAndLogEx(NORMAL, "b2:%s", sprint_hex(b2, 16));
//Auth2
UsbCommand d = {CMD_MIFARE_DES_AUTH2, {cuid}};
UsbCommandOLD d = {CMD_MIFARE_DES_AUTH2, {cuid}};
memcpy(reply, b1, 16);
memcpy(reply + 16, b2, 16);
memcpy(d.d.asBytes, reply, 32);

View file

@ -1383,7 +1383,7 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
flags |= initialize ? 0x0001 : 0;
flags |= slow ? 0x0002 : 0;
flags |= field_off ? 0x0004 : 0;
UsbCommand c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
memcpy(c.d.asBytes, key, 6);
clearCommandBuffer();
@ -1394,14 +1394,14 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
if (initialize) {
if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) {
//strange second call (iceman)
UsbCommand c1 = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
UsbCommandOLD c1 = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
clearCommandBuffer();
SendCommand(&c1);
return 1;
}
if (resp.core.old.arg[0]) return resp.core.old.arg[0]; // error during nested_hard
if (resp.oldarg[0]) return resp.oldarg[0]; // error during nested_hard
cuid = resp.core.old.arg[1];
cuid = resp.oldarg[1];
if (nonce_file_write && fnonces == NULL) {
if ((fnonces = fopen(filename, "wb")) == NULL) {
PrintAndLogEx(WARNING, "Could not create file %s", filename);
@ -1420,8 +1420,8 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
if (!initialize) {
uint32_t nt_enc1, nt_enc2;
uint8_t par_enc;
uint16_t num_sampled_nonces = resp.core.old.arg[2];
uint8_t *bufp = resp.core.old.d.asBytes;
uint16_t num_sampled_nonces = resp.oldarg[2];
uint8_t *bufp = resp.data.asBytes;
for (uint16_t i = 0; i < num_sampled_nonces; i += 2) {
nt_enc1 = bytes_to_num(bufp, 4);
nt_enc2 = bytes_to_num(bufp + 4, 4);
@ -1479,11 +1479,11 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
}
return 1;
}
if (resp.core.old.arg[0]) {
if (resp.oldarg[0]) {
if (nonce_file_write) {
fclose(fnonces);
}
return resp.core.old.arg[0]; // error during nested_hard
return resp.oldarg[0]; // error during nested_hard
}
}

View file

@ -42,16 +42,16 @@ static int CmdHFMFPInfo(const char *cmd) {
infoHF14A(false, false);
// Mifare Plus info
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
uint64_t select_status = resp.core.old.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
uint64_t select_status = resp.oldarg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
if (select_status == 1 || select_status == 2) {
PrintAndLogEx(NORMAL, "----------------------------------------------");

View file

@ -458,22 +458,22 @@ static char *getUlev1CardSizeStr(uint8_t fsize) {
}
static void ul_switch_on_field(void) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
}
static int ul_send_cmd_raw(uint8_t *cmd, uint8_t cmdlen, uint8_t *response, uint16_t responseLength) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_APPEND_CRC | ISO14A_NO_RATS, cmdlen, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_APPEND_CRC | ISO14A_NO_RATS, cmdlen, 0}, {{0}}};
memcpy(c.d.asBytes, cmd, cmdlen);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return -1;
if (!resp.core.old.arg[0] && responseLength) return -1;
if (!resp.oldarg[0] && responseLength) return -1;
uint16_t resplen = (resp.core.old.arg[0] < responseLength) ? resp.core.old.arg[0] : responseLength;
memcpy(response, resp.core.old.d.asBytes, resplen);
uint16_t resplen = (resp.oldarg[0] < responseLength) ? resp.oldarg[0] : responseLength;
memcpy(response, resp.data.asBytes, resplen);
return resplen;
}
@ -485,13 +485,13 @@ static int ul_select(iso14a_card_select_t *card) {
bool ans = false;
ans = WaitForResponseTimeout(CMD_ACK, &resp, 1500);
if (!ans || resp.core.old.arg[0] < 1) {
if (!ans || resp.oldarg[0] < 1) {
PrintAndLogEx(WARNING, "iso14443a card select failed");
DropField();
return 0;
}
memcpy(card, resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(card, resp.data.asBytes, sizeof(iso14a_card_select_t));
return 1;
}
@ -533,13 +533,13 @@ static int ulc_requestAuthentication(uint8_t *nonce, uint16_t nonceLength) {
static int ulc_authentication(uint8_t *key, bool switch_off_field) {
UsbCommand c = {CMD_MIFAREUC_AUTH, {switch_off_field}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREUC_AUTH, {switch_off_field}, {{0}}};
memcpy(c.d.asBytes, key, 16);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return 0;
if (resp.core.old.arg[0] == 1) return 1;
if (resp.oldarg[0] == 1) return 1;
return 0;
}
@ -621,7 +621,7 @@ static int ul_fudan_check(void) {
if (!ul_select(&card))
return UL_ERROR;
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 4, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 4, 0}, {{0}}};
uint8_t cmd[4] = {0x30, 0x00, 0x02, 0xa7}; //wrong crc on purpose should be 0xa8
memcpy(c.d.asBytes, cmd, 4);
@ -629,9 +629,9 @@ static int ul_fudan_check(void) {
SendCommand(&c);
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return UL_ERROR;
if (resp.core.old.arg[0] != 1) return UL_ERROR;
if (resp.oldarg[0] != 1) return UL_ERROR;
return (!resp.core.old.d.asBytes[0]) ? FUDAN_UL : UL; //if response == 0x00 then Fudan, else Genuine NXP
return (!resp.data.asBytes[0]) ? FUDAN_UL : UL; //if response == 0x00 then Fudan, else Genuine NXP
}
static int ul_print_default(uint8_t *data) {
@ -1475,7 +1475,7 @@ static int CmdHF14AMfUWrBl(const char *Cmd) {
PrintAndLogEx(NORMAL, "Block: %0d (0x%02X) [ %s]", blockNo, blockNo, sprint_hex(blockdata, 4));
//Send write Block
UsbCommand c = {CMD_MIFAREU_WRITEBL, {blockNo}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREU_WRITEBL, {blockNo}, {{0}}};
memcpy(c.d.asBytes, blockdata, 4);
if (hasAuthKey) {
@ -1490,7 +1490,7 @@ static int CmdHF14AMfUWrBl(const char *Cmd) {
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
} else {
PrintAndLogEx(WARNING, "Command execute timeout");
@ -1581,7 +1581,7 @@ static int CmdHF14AMfURdBl(const char *Cmd) {
if (swapEndian && hasPwdKey) authKeyPtr = SwapEndian64(authenticationkey, 4, 4);
//Read Block
UsbCommand c = {CMD_MIFAREU_READBL, {blockNo}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREU_READBL, {blockNo}, {{0}}};
if (hasAuthKey) {
c.arg[1] = 1;
memcpy(c.d.asBytes, authKeyPtr, 16);
@ -1594,9 +1594,9 @@ static int CmdHF14AMfURdBl(const char *Cmd) {
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (isOK) {
uint8_t *d = resp.core.old.d.asBytes;
uint8_t *d = resp.data.asBytes;
PrintAndLogEx(NORMAL, "\nBlock# | Data | Ascii");
PrintAndLogEx(NORMAL, "-----------------------------");
PrintAndLogEx(NORMAL, "%02d/0x%02X | %s| %s\n", blockNo, blockNo, sprint_hex(d, 4), sprint_ascii(d, 4));
@ -1846,7 +1846,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
}
ul_print_type(tagtype, 0);
PrintAndLogEx(SUCCESS, "Reading tag memory...");
UsbCommand c = {CMD_MIFAREU_READCARD, {startPage, pages}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREU_READCARD, {startPage, pages}, {{0}}};
if (hasAuthKey) {
if (tagtype & UL_C)
c.arg[2] = 1; //UL_C auth
@ -1864,13 +1864,13 @@ static int CmdHF14AMfUDump(const char *Cmd) {
return 1;
}
if (resp.core.old.arg[0] != 1) {
if (resp.oldarg[0] != 1) {
PrintAndLogEx(WARNING, "Failed dumping card");
return 1;
}
uint32_t startindex = resp.core.old.arg[2];
uint32_t bufferSize = resp.core.old.arg[1];
uint32_t startindex = resp.oldarg[2];
uint32_t bufferSize = resp.oldarg[1];
if (bufferSize > sizeof(data)) {
PrintAndLogEx(FAILED, "Data exceeded Buffer size!");
bufferSize = sizeof(data);
@ -1984,7 +1984,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
static void wait4response(uint8_t b) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK)
PrintAndLogEx(WARNING, "failed to write block %d", b);
} else {
@ -2010,7 +2010,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
bool read_key = false;
size_t filelen = 0;
FILE *f;
UsbCommand c = {CMD_MIFAREU_WRITEBL, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREU_WRITEBL, {0, 0, 0}, {{0}}};
memset(authkey, 0x00, sizeof(authkey));
@ -2387,17 +2387,17 @@ static int CmdHF14AMfUCSetPwd(const char *Cmd) {
return 1;
}
UsbCommand c = {CMD_MIFAREUC_SETPWD, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREUC_SETPWD, {0, 0, 0}, {{0}}};
memcpy(c.d.asBytes, pwd, 16);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
if ((resp.core.old.arg[0] & 0xff) == 1) {
if ((resp.oldarg[0] & 0xff) == 1) {
PrintAndLogEx(INFO, "Ultralight-C new password: %s", sprint_hex(pwd, 16));
} else {
PrintAndLogEx(WARNING, "Failed writing at block %d", resp.core.old.arg[1] & 0xff);
PrintAndLogEx(WARNING, "Failed writing at block %d", resp.oldarg[1] & 0xff);
return 1;
}
} else {
@ -2412,7 +2412,7 @@ static int CmdHF14AMfUCSetPwd(const char *Cmd) {
//
static int CmdHF14AMfUCSetUid(const char *Cmd) {
UsbCommand c = {CMD_MIFAREU_READBL, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFAREU_READBL, {0, 0, 0}, {{0}}};
UsbReplyNG resp;
uint8_t uid[7] = {0x00};
char cmdp = tolower(param_getchar(Cmd, 0));
@ -2435,7 +2435,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) {
// save old block2.
uint8_t oldblock2[4] = {0x00};
memcpy(resp.core.old.d.asBytes, oldblock2, 4);
memcpy(resp.data.asBytes, oldblock2, 4);
// block 0.
c.cmd = CMD_MIFAREU_WRITEBL;
@ -2487,15 +2487,15 @@ static int CmdHF14AMfUGenDiverseKeys(const char *Cmd) {
if (cmdp == 'r') {
// read uid from tag
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
uint64_t select_status = resp.core.old.arg[0];
uint64_t select_status = resp.oldarg[0];
// 0: couldn't read,
// 1: OK, with ATS
// 2: OK, no ATS
@ -2602,15 +2602,15 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) {
if (cmdp == 'r') {
// read uid from tag
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
iso14a_card_select_t card;
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
uint64_t select_status = resp.core.old.arg[0];
uint64_t select_status = resp.oldarg[0];
// 0: couldn't read
// 1: OK with ATS
// 2: OK, no ATS

View file

@ -31,29 +31,29 @@ static struct {
} topaz_tag;
static void topaz_switch_on_field(void) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, 0, 0}, {{0}}};
SendCommand(&c);
}
static void topaz_switch_off_field(void) {
UsbCommand c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
SendCommand(&c);
}
// send a raw topaz command, returns the length of the response (0 in case of error)
static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0}, {{0}}};
memcpy(c.d.asBytes, cmd, len);
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_ACK, &resp);
if (resp.core.old.arg[0] > 0) {
memcpy(response, resp.core.old.d.asBytes, resp.core.old.arg[0]);
if (resp.oldarg[0] > 0) {
memcpy(response, resp.data.asBytes, resp.oldarg[0]);
}
return resp.core.old.arg[0];
return resp.oldarg[0];
}

View file

@ -308,7 +308,7 @@ static void lookupChipID(uint32_t iChipID, uint32_t mem_used) {
}
static int CmdDetectReader(const char *Cmd) {
UsbCommand c = {CMD_LISTEN_READER_FIELD, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_LISTEN_READER_FIELD, {0, 0, 0}, {{0}}};
// 'l' means LF - 125/134 kHz
if (*Cmd == 'l') {
c.arg[0] = 1;
@ -326,7 +326,7 @@ static int CmdDetectReader(const char *Cmd) {
// ## FPGA Control
static int CmdFPGAOff(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_FPGA_MAJOR_MODE_OFF, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_FPGA_MAJOR_MODE_OFF, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -336,7 +336,7 @@ static int CmdFPGAOff(const char *Cmd) {
static int CmdLCD(const char *Cmd) {
int i, j;
UsbCommand c = {CMD_LCD, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_LCD, {0, 0, 0}, {{0}}};
sscanf(Cmd, "%x %d", &i, &j);
while (j--) {
c.arg[0] = i & 0x1ff;
@ -347,7 +347,7 @@ static int CmdLCD(const char *Cmd) {
}
static int CmdLCDReset(const char *Cmd) {
UsbCommand c = {CMD_LCD_RESET, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_LCD_RESET, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -355,7 +355,7 @@ static int CmdLCDReset(const char *Cmd) {
#endif
static int CmdReadmem(const char *Cmd) {
UsbCommand c = {CMD_READ_MEM, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READ_MEM, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -363,7 +363,7 @@ static int CmdReadmem(const char *Cmd) {
static int CmdReset(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_HARDWARE_RESET, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_HARDWARE_RESET, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -374,7 +374,7 @@ static int CmdReset(const char *Cmd) {
* 600kHz.
*/
static int CmdSetDivisor(const char *Cmd) {
UsbCommand c = {CMD_SET_LF_DIVISOR, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SET_LF_DIVISOR, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
if (c.arg[0] < 19 || c.arg[0] > 255) {
PrintAndLogEx(NORMAL, "divisor must be between 19 and 255");
@ -394,7 +394,7 @@ static int CmdSetMux(const char *Cmd) {
return 1;
}
UsbCommand c = {CMD_SET_ADC_MUX, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SET_ADC_MUX, {0, 0, 0}, {{0}}};
if (strcmp(Cmd, "lopkd") == 0) c.arg[0] = 0;
else if (strcmp(Cmd, "loraw") == 0) c.arg[0] = 1;
@ -419,7 +419,7 @@ static int CmdStatus(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
UsbReplyNG resp;
UsbCommand c = {CMD_STATUS, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_STATUS, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1900))
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
@ -430,7 +430,7 @@ static int CmdPing(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
UsbReplyNG resp;
UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000))
PrintAndLogEx(NORMAL, "Ping successful");
@ -441,12 +441,12 @@ static int CmdPing(const char *Cmd) {
static int CmdPingNG(const char *Cmd) {
uint32_t len = strtol(Cmd, NULL, 0);
if (len > USB_DATANG_SIZE)
len = USB_DATANG_SIZE;
if (len > USB_CMD_DATA_SIZE)
len = USB_CMD_DATA_SIZE;
PrintAndLogEx(NORMAL, "PingNG sent with payload len=%d", len);
clearCommandBuffer();
UsbReplyNG resp;
uint8_t data[USB_DATANG_SIZE] = {0};
uint8_t data[USB_CMD_DATA_SIZE] = {0};
uint16_t cmd = CMD_PING;
for (uint16_t i = 0; i < len; i++)
data[i] = i & 0xFF;
@ -454,7 +454,7 @@ static int CmdPingNG(const char *Cmd) {
if (WaitForResponseTimeout(CMD_PING, &resp, 1000)) {
bool error = false;
if (len)
error = memcmp(data, resp.core.ng.data, len) != 0;
error = memcmp(data, resp.data.asBytes, len) != 0;
PrintAndLogEx(NORMAL, "PingNG response received, content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
} else
PrintAndLogEx(NORMAL, "PingNG response " _RED_("timeout"));
@ -496,7 +496,7 @@ int CmdHW(const char *Cmd) {
void pm3_version(bool verbose) {
if (!verbose)
return;
UsbCommand c = {CMD_VERSION, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_VERSION, {0, 0, 0}, {{0}}};
UsbReplyNG resp;
clearCommandBuffer();
SendCommand(&c);
@ -526,8 +526,8 @@ void pm3_version(bool verbose) {
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
PrintAndLogEx(NORMAL, " client: iceman %s \n", s);
PrintAndLogEx(NORMAL, (char *)resp.core.old.d.asBytes);
lookupChipID(resp.core.old.arg[0], resp.core.old.arg[1]);
PrintAndLogEx(NORMAL, (char *)resp.data.asBytes);
lookupChipID(resp.oldarg[0], resp.oldarg[1]);
}
PrintAndLogEx(NORMAL, "\n");
}

View file

@ -144,7 +144,7 @@ static int usage_lf_find(void) {
/* send a LF command before reading */
int CmdLFCommandRead(const char *Cmd) {
UsbCommand c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, {0, 0, 0}, {{0}}};
bool errors = false;
uint8_t cmdp = 0;
@ -322,7 +322,7 @@ int CmdLFSetConfig(const char *Cmd) {
sample_config config = { decimation, bps, averaging, divisor, trigger_threshold };
UsbCommand c = {CMD_SET_LF_SAMPLING_CONFIG, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SET_LF_SAMPLING_CONFIG, {0, 0, 0}, {{0}}};
memcpy(c.d.asBytes, &config, sizeof(sample_config));
clearCommandBuffer();
SendCommand(&c);
@ -331,7 +331,7 @@ int CmdLFSetConfig(const char *Cmd) {
bool lf_read(bool silent, uint32_t samples) {
if (IsOffline()) return false;
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {silent, samples, 0}, {{0}}};
UsbCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {silent, samples, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -344,8 +344,8 @@ bool lf_read(bool silent, uint32_t samples) {
return false;
}
}
// resp.core.old.arg[0] is bits read not bytes read.
getSamples(resp.core.old.arg[0] / 8, silent);
// resp.oldarg[0] is bits read not bytes read.
getSamples(resp.oldarg[0] / 8, silent);
return true;
}
@ -387,7 +387,7 @@ int CmdLFSniff(const char *Cmd) {
uint8_t cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_lf_sniff();
UsbCommand c = {CMD_LF_SNIFF_RAW_ADC_SAMPLES, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_LF_SNIFF_RAW_ADC_SAMPLES, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
WaitForResponse(CMD_ACK, NULL);
@ -420,7 +420,7 @@ int CmdLFSim(const char *Cmd) {
//can send only 512 bits at a time (1 byte sent per bit...)
for (uint16_t i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) {
UsbCommand c = {CMD_UPLOAD_SIM_SAMPLES_125K, {i, FPGA_LF, 0}, {{0}}};
UsbCommandOLD c = {CMD_UPLOAD_SIM_SAMPLES_125K, {i, FPGA_LF, 0}, {{0}}};
for (uint16_t j = 0; j < USB_CMD_DATA_SIZE; j++)
c.d.asBytes[j] = GraphBuffer[i + j];
@ -434,7 +434,7 @@ int CmdLFSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "Simulating");
UsbCommand c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -523,7 +523,7 @@ int CmdLFfskSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
size = USB_CMD_DATA_SIZE;
}
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, DemodBuffer, size);
clearCommandBuffer();
@ -619,7 +619,7 @@ int CmdLFaskSim(const char *Cmd) {
arg1 = clk << 8 | encoding;
arg2 = invert << 8 | separator;
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, DemodBuffer, size);
clearCommandBuffer();
SendCommand(&c);
@ -726,7 +726,7 @@ int CmdLFpskSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
size = USB_CMD_DATA_SIZE;
}
UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
PrintAndLogEx(DEBUG, "DEBUG: Sending DemodBuffer Length: %d", size);
memcpy(c.d.asBytes, DemodBuffer, size);
clearCommandBuffer();
@ -739,7 +739,7 @@ int CmdLFSimBidir(const char *Cmd) {
// Set ADC to twice the carrier for a slight supersampling
// HACK: not implemented in ARMSRC.
PrintAndLogEx(INFO, "Not implemented yet.");
UsbCommand c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}, {{0}}};
UsbCommandOLD c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}, {{0}}};
SendCommand(&c);
return 0;
}

View file

@ -87,7 +87,7 @@ static int usage_lf_awid_brute(void) {
}
static bool sendPing(void) {
UsbCommand ping = {CMD_PING, {1, 2, 3}, {{0}}};
UsbCommandOLD ping = {CMD_PING, {1, 2, 3}, {{0}}};
SendCommand(&ping);
SendCommand(&ping);
SendCommand(&ping);
@ -112,7 +112,7 @@ static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, ui
uint64_t arg1 = (high << 8) + low;
uint64_t arg2 = (invert << 8) + clk;
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, bs_len}, {{0}}};
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, bs_len}, {{0}}};
memcpy(c.d.asBytes, bits, bs_len);
clearCommandBuffer();
SendCommand(&c);
@ -171,7 +171,7 @@ static int CmdAWIDRead_device(const char *Cmd) {
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_awid_read();
uint8_t findone = (Cmd[0] == '1') ? 1 : 0;
UsbCommand c = {CMD_AWID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_AWID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -350,7 +350,7 @@ static int CmdAWIDSim(const char *Cmd) {
// arg1 --- fcHigh<<8 + fcLow
// arg2 --- Inversion and clk setting
// 96 --- Bitstream length: 96-bits == 12 bytes
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bits, size);
clearCommandBuffer();
SendCommand(&c);
@ -393,7 +393,7 @@ static int CmdAWIDClone(const char *Cmd) {
print_blocks(blocks, 4);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 4; i++) {
c.arg[0] = blocks[i];

View file

@ -74,7 +74,7 @@ static int CmdCOTAGRead(const char *Cmd) {
uint32_t rawsignal = 1;
sscanf(Cmd, "%u", &rawsignal);
UsbCommand c = {CMD_COTAG, {rawsignal, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_COTAG, {rawsignal, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, NULL, 7000)) {

View file

@ -389,7 +389,7 @@ int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
static int CmdEM410xRead_device(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
uint8_t findone = (cmdp == '1') ? 1 : 0;
UsbCommand c = {CMD_EM410X_DEMOD, {findone, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_EM410X_DEMOD, {findone, 0, 0}, {{0}}};
SendCommand(&c);
return 0;
}
@ -648,7 +648,7 @@ static int CmdEM410xWrite(const char *Cmd) {
return 0;
}
UsbCommand c = {CMD_EM410X_WRITE_TAG, {card, (uint32_t)(id >> 32), (uint32_t)id}, {{0}}};
UsbCommandOLD c = {CMD_EM410X_WRITE_TAG, {card, (uint32_t)(id >> 32), (uint32_t)id}, {{0}}};
SendCommand(&c);
return 0;
}
@ -1127,7 +1127,7 @@ static bool demodEM4x05resp(uint32_t *word) {
//////////////// 4205 / 4305 commands
static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
UsbCommand c = {CMD_EM4X_READ_WORD, {addr, pwd, usePwd}, {{0}}};
UsbCommandOLD c = {CMD_EM4X_READ_WORD, {addr, pwd, usePwd}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -1230,7 +1230,7 @@ static int CmdEM4x05Write(const char *Cmd) {
uint16_t flag = (addr << 8) | (usePwd);
UsbCommand c = {CMD_EM4X_WRITE_WORD, {flag, data, pwd}, {{0}}};
UsbCommandOLD c = {CMD_EM4X_WRITE_WORD, {flag, data, pwd}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;

View file

@ -282,7 +282,7 @@ static int CmdFdxClone(const char *Cmd) {
print_blocks(blocks, 5);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (int i = 4; i >= 0; --i) {
c.arg[0] = blocks[i];
@ -318,7 +318,7 @@ static int CmdFdxSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating FDX-B animal ID: %04u-%"PRIu64, countryid, animalid);
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
//getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits)
getFDXBits(animalid, countryid, 1, 0, 0, c.d.asBytes);

View file

@ -172,7 +172,7 @@ static int CmdGuardClone(const char *Cmd) {
print_blocks(blocks, 4);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (i = 0; i < 4; ++i) {
c.arg[0] = blocks[i];
@ -217,7 +217,7 @@ static int CmdGuardSim(const char *Cmd) {
arg1 = (clock1 << 8) | encoding;
arg2 = (invert << 8) | separator;
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bs, size);
clearCommandBuffer();
SendCommand(&c);

View file

@ -93,7 +93,7 @@ static int usage_lf_hid_brute(void) {
// sending three times. Didn't seem to break the previous sim?
static bool sendPing(void) {
UsbCommand ping = {CMD_PING, {1, 2, 3}, {{0}}};
UsbCommandOLD ping = {CMD_PING, {1, 2, 3}, {{0}}};
SendCommand(&ping);
SendCommand(&ping);
SendCommand(&ping);
@ -113,7 +113,7 @@ static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, ui
uint64_t arg1 = bytebits_to_byte(bits, 32);
uint64_t arg2 = bytebits_to_byte(bits + 32, 32);
UsbCommand c = {CMD_HID_SIM_TAG, {arg1, arg2, 0}, {{0}}};
UsbCommandOLD c = {CMD_HID_SIM_TAG, {arg1, arg2, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -242,7 +242,7 @@ static int CmdHIDRead_device(const char *Cmd) {
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_hid_read();
uint8_t findone = (Cmd[0] == '1') ? 1 : 0;
UsbCommand c = {CMD_HID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_HID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -263,7 +263,7 @@ static int CmdHIDSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating HID tag with ID %x%08x", hi, lo);
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation");
UsbCommand c = {CMD_HID_SIM_TAG, {hi, lo, 0}, {{0}}};
UsbCommandOLD c = {CMD_HID_SIM_TAG, {hi, lo, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -273,7 +273,7 @@ static int CmdHIDClone(const char *Cmd) {
uint32_t hi2 = 0, hi = 0, lo = 0;
uint32_t n = 0, i = 0;
UsbCommand c = {CMD_HID_CLONE_TAG, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_HID_CLONE_TAG, {0, 0, 0}, {{0}}};
uint8_t ctmp = param_getchar(Cmd, 0);
if (strlen(Cmd) == 0 || ctmp == 'H' || ctmp == 'h') return usage_lf_hid_clone();

View file

@ -260,7 +260,7 @@ static int CmdLFHitagSniff(const char *Cmd) {
char ctmp = tolower(param_getchar(Cmd, 0));
if (ctmp == 'h') return usage_hitag_sniff();
UsbCommand c = {CMD_SNIFF_HITAG, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SNIFF_HITAG, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -277,7 +277,7 @@ static int CmdLFHitagSim(const char *Cmd) {
int res = 0;
char filename[FILE_PATH_SIZE] = { 0x00 };
UsbCommand c = {CMD_SIMULATE_HITAG, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SIMULATE_HITAG, {0, 0, 0}, {{0}}};
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
switch (tolower(param_getchar(Cmd, cmdp))) {
@ -458,7 +458,7 @@ static void printHitagConfiguration(uint8_t config) {
static bool getHitagUid(uint32_t *uid) {
UsbCommand c = {CMD_READER_HITAG, {RHT2F_UID_ONLY, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_HITAG, {RHT2F_UID_ONLY, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -467,13 +467,13 @@ static bool getHitagUid(uint32_t *uid) {
return false;
}
if (resp.core.old.arg[0] == false) {
if (resp.oldarg[0] == false) {
PrintAndLogEx(DEBUG, "DEBUG: Error - failed getting UID");
return false;
}
if (uid)
*uid = bytes_to_num(resp.core.old.d.asBytes, 4);
*uid = bytes_to_num(resp.data.asBytes, 4);
return true;
}
@ -513,7 +513,7 @@ static int CmdLFHitagInfo(const char *Cmd) {
//
static int CmdLFHitagReader(const char *Cmd) {
UsbCommand c = {CMD_READER_HITAG, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_HITAG, {0, 0, 0}, {{0}}};
hitag_data *htd = (hitag_data *)c.d.asBytes;
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
@ -565,18 +565,18 @@ static int CmdLFHitagReader(const char *Cmd) {
return 1;
}
if (resp.core.old.arg[0] == false) {
if (resp.oldarg[0] == false) {
PrintAndLogEx(DEBUG, "DEBUG: Error - hitag failed");
return 1;
}
uint32_t id = bytes_to_num(resp.core.old.d.asBytes, 4);
uint32_t id = bytes_to_num(resp.data.asBytes, 4);
PrintAndLogEx(SUCCESS, "Valid Hitag2 tag found - UID: %08x", id);
if (htf != RHT2F_UID_ONLY) {
PrintAndLogEx(SUCCESS, "Dumping tag memory...");
uint8_t *data = resp.core.old.d.asBytes;
uint8_t *data = resp.data.asBytes;
char filename[FILE_PATH_SIZE];
char *fnameptr = filename;
@ -595,7 +595,7 @@ static int CmdLFHitagReader(const char *Cmd) {
static int CmdLFHitagCheckChallenges(const char *Cmd) {
UsbCommand c = { CMD_TEST_HITAGS_TRACES, {0, 0, 0}, {{0}}};
UsbCommandOLD c = { CMD_TEST_HITAGS_TRACES, {0, 0, 0}, {{0}}};
char filename[FILE_PATH_SIZE] = { 0x00 };
size_t datalen = 0;
int res = 0;
@ -644,7 +644,7 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
}
static int CmdLFHitagWriter(const char *Cmd) {
UsbCommand c = { CMD_WR_HITAG_S, {0, 0, 0}, {{0}}};
UsbCommandOLD c = { CMD_WR_HITAG_S, {0, 0, 0}, {{0}}};
hitag_data *htd = (hitag_data *)c.d.asBytes;
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
@ -682,7 +682,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
return 1;
}
if (resp.core.old.arg[0] == false) {
if (resp.oldarg[0] == false) {
PrintAndLogEx(DEBUG, "DEBUG: Error - hitag write failed");
return 1;
}

View file

@ -404,7 +404,7 @@ static int CmdIndalaSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Indala UID: %s", sprint_hex(hexuid, len));
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bits, size);
clearCommandBuffer();
SendCommand(&c);
@ -438,7 +438,7 @@ static int CmdIndalaClone(const char *Cmd) {
CLIGetHexWithReturn(2, data, &datalen);
CLIParserFree();
UsbCommand c = {0, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {0, {0, 0, 0}, {{0}}};
if (isLongUid) {
PrintAndLogEx(INFO, "Preparing to clone Indala 224bit tag with RawID %s", sprint_hex(data, datalen));

View file

@ -66,7 +66,7 @@ static int usage_lf_io_clone(void) {
static int CmdIOProxRead_device(const char *Cmd) {
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_io_read();
int findone = (Cmd[0] == '1') ? 1 : 0;
UsbCommand c = {CMD_IO_DEMOD_FSK, {findone, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_IO_DEMOD_FSK, {findone, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -215,7 +215,7 @@ static int CmdIOProxSim(const char *Cmd) {
// arg1 --- fcHigh<<8 + fcLow
// arg2 --- Invert and clk setting
// size --- 64 bits == 8 bytes
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bits, size);
clearCommandBuffer();
SendCommand(&c);
@ -258,8 +258,8 @@ static int CmdIOProxClone(const char *Cmd) {
PrintAndLogEx(INFO, "Preparing to clone IOProx to T55x7 with Version: %u FC: %u, CN: %u", version, fc, cn);
print_blocks(blocks, 3);
//UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
UsbCommand c = {CMD_IO_CLONE_TAG, {blocks[1], blocks[2], 0}, {{0}}};
//UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
UsbCommandOLD c = {CMD_IO_CLONE_TAG, {blocks[1], blocks[2], 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;

View file

@ -156,7 +156,7 @@ static int CmdJablotronClone(const char *Cmd) {
print_blocks(blocks, 3);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 3; i++) {
c.arg[0] = blocks[i];
@ -193,7 +193,7 @@ static int CmdJablotronSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Jablotron - FullCode: %"PRIx64, fullcode);
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
getJablotronBits(fullcode, c.d.asBytes);
clearCommandBuffer();
SendCommand(&c);

View file

@ -147,7 +147,7 @@ static int CmdKeriClone(const char *Cmd) {
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 3; i++) {
@ -189,7 +189,7 @@ static int CmdKeriSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id: %u", internalid);
UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bits, size);
clearCommandBuffer();
SendCommand(&c);

View file

@ -203,7 +203,7 @@ static int CmdLFNedapClone(const char *Cmd) {
print_blocks(blocks, 5);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
for (uint8_t i = 0; i<5; ++i ) {
c.arg[0] = blocks[i];
@ -248,7 +248,7 @@ static int CmdLFNedapSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "bin %s", sprint_bin_break(bs, 128, 32));
PrintAndLogEx(SUCCESS, "Simulating Nedap - CardNumber: %u", cardnumber);
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bs, size);
clearCommandBuffer();
SendCommand(&c);

View file

@ -155,7 +155,7 @@ static int CmdNoralsyClone(const char *Cmd) {
print_blocks(blocks, 4);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 4; i++) {
c.arg[0] = blocks[i];
@ -198,7 +198,7 @@ static int CmdNoralsySim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Noralsy - CardId: %u", id);
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bs, size);
clearCommandBuffer();
SendCommand(&c);

View file

@ -138,7 +138,7 @@ static int CmdParadoxSim(const char *Cmd) {
PrintAndLogEx(NORMAL, "Simulating Paradox - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bs, size);
clearCommandBuffer();
SendCommand(&c);

View file

@ -100,7 +100,7 @@ static int CmdLFPCF7931Read(const char *Cmd) {
if (ctmp == 'H' || ctmp == 'h') return usage_pcf7931_read();
UsbReplyNG resp;
UsbCommand c = {CMD_PCF7931_READ, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_PCF7931_READ, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
@ -145,7 +145,7 @@ static int CmdLFPCF7931Write(const char *Cmd) {
PrintAndLogEx(NORMAL, " pos: %d", bytepos);
PrintAndLogEx(NORMAL, " data: 0x%02X", data);
UsbCommand c = {CMD_PCF7931_WRITE, { block, bytepos, data}, {{0}}};
UsbCommandOLD c = {CMD_PCF7931_WRITE, { block, bytepos, data}, {{0}}};
memcpy(c.d.asDwords, configPcf.Pwd, sizeof(configPcf.Pwd));
c.d.asDwords[7] = (configPcf.OffsetWidth + 128);
c.d.asDwords[8] = (configPcf.OffsetPosition + 128);

View file

@ -121,7 +121,7 @@ static int CmdPrescoClone(const char *Cmd) {
print_blocks(blocks, 5);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 5; i++) {
c.arg[0] = blocks[i];
@ -152,7 +152,7 @@ static int CmdPrescoSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Presco - SiteCode: %u, UserCode: %u, FullCode: %08X", sitecode, usercode, fullcode);
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
getPrescoBits(fullcode, c.d.asBytes);
clearCommandBuffer();
SendCommand(&c);

View file

@ -233,7 +233,7 @@ static int CmdPyramidClone(const char *Cmd) {
print_blocks(blocks, 5);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 5; ++i) {
c.arg[0] = blocks[i];
@ -277,7 +277,7 @@ static int CmdPyramidSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Farpointe/Pyramid - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
UsbCommand c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
memcpy(c.d.asBytes, bs, size);
clearCommandBuffer();
SendCommand(&c);

View file

@ -1018,7 +1018,7 @@ static int CmdT55xxWakeUp(const char *Cmd) {
}
if (errors) return usage_t55xx_wakup();
UsbCommand c = {CMD_T55XX_WAKEUP, {password, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WAKEUP, {password, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
PrintAndLogEx(SUCCESS, "Wake up command sent. Try read now");
@ -1074,7 +1074,7 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
return 0;
}
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}, {{0}}};
UsbReplyNG resp;
c.d.asBytes[0] = (page1) ? 0x2 : 0;
c.d.asBytes[0] |= (testMode) ? 0x4 : 0;
@ -1515,7 +1515,7 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
// arg1: which block to read
// arg2: password
uint8_t arg0 = (page << 1 | (pwdmode));
UsbCommand c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2500)) {
@ -1775,7 +1775,7 @@ static void t55x7_create_config_block(int tagtype) {
static int CmdResetRead(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_T55XX_RESET_READ, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_RESET_READ, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2500)) {
@ -1856,7 +1856,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
uint64_t t1 = msclock();
if (cmdp == 'm') {
UsbCommand c = {CMD_T55XX_CHKPWDS, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_CHKPWDS, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -1871,13 +1871,13 @@ static int CmdT55xxChkPwds(const char *Cmd) {
}
}
if (resp.core.old.arg[0]) {
PrintAndLogEx(SUCCESS, "\nFound a candidate [ " _YELLOW_("%08X") " ]. Trying to validate", resp.core.old.arg[1]);
if (resp.oldarg[0]) {
PrintAndLogEx(SUCCESS, "\nFound a candidate [ " _YELLOW_("%08X") " ]. Trying to validate", resp.oldarg[1]);
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, resp.core.old.arg[1])) {
if (AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, true, resp.oldarg[1])) {
found = tryDetectModulation();
if (found) {
PrintAndLogEx(SUCCESS, "Found valid password: [ " _GREEN_("%08") " ]", resp.core.old.arg[1]);
PrintAndLogEx(SUCCESS, "Found valid password: [ " _GREEN_("%08") " ]", resp.oldarg[1]);
} else {
PrintAndLogEx(WARNING, "Check pwd failed");
}
@ -2299,7 +2299,7 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
t55xx_config conf = { startgap * 8, writegap * 8, write0 * 8, write1 * 8, readgap * 8 };
UsbCommand c = {CMD_SET_LF_T55XX_CONFIG, {shall_persist, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SET_LF_T55XX_CONFIG, {shall_persist, 0, 0}, {{0}}};
memcpy(c.d.asBytes, &conf, sizeof(t55xx_config));
clearCommandBuffer();
SendCommand(&c);

View file

@ -275,7 +275,7 @@ out:
// read a TI tag and return its ID
static int CmdTIRead(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_READ_TI_TYPE};
UsbCommandOLD c = {CMD_READ_TI_TYPE};
clearCommandBuffer();
SendCommand(&c);
return 0;
@ -284,7 +284,7 @@ static int CmdTIRead(const char *Cmd) {
// write new data to a r/w TI tag
static int CmdTIWrite(const char *Cmd) {
int res = 0;
UsbCommand c = {CMD_WRITE_TI_TYPE};
UsbCommandOLD c = {CMD_WRITE_TI_TYPE};
res = sscanf(Cmd, "%012" SCNx64 " %012" SCNx64 " %012" SCNx64 "", &c.arg[0], &c.arg[1], &c.arg[2]);
if (res == 2)

View file

@ -88,7 +88,7 @@ static int CmdVikingClone(const char *Cmd) {
PrintAndLogEx(INFO, "Preparing to clone Viking tag - ID: %08X, Raw: %08X%08X", id, (uint32_t)(rawID >> 32), (uint32_t)(rawID & 0xFFFFFFFF));
UsbCommand c = {CMD_VIKING_CLONE_TAG, {rawID >> 32, rawID & 0xFFFFFFFF, Q5}, {{0}}};
UsbCommandOLD c = {CMD_VIKING_CLONE_TAG, {rawID >> 32, rawID & 0xFFFFFFFF, Q5}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -119,7 +119,7 @@ static int CmdVikingSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Viking - ID: %08X, Raw: %08X%08X", id, (uint32_t)(rawID >> 32), (uint32_t)(rawID & 0xFFFFFFFF));
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
num_to_bytebits(rawID, size, c.d.asBytes);
clearCommandBuffer();
SendCommand(&c);

View file

@ -167,7 +167,7 @@ static int CmdVisa2kClone(const char *Cmd) {
print_blocks(blocks, 4);
UsbReplyNG resp;
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
for (uint8_t i = 0; i < 4; i++) {
c.arg[0] = blocks[i];
@ -198,7 +198,7 @@ static int CmdVisa2kSim(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Simulating Visa2000 - CardId: %u", id);
UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
uint32_t blocks[3] = { BL0CK1, id, (visa_parity(id) << 4) | visa_chksum(id) };

View file

@ -315,12 +315,12 @@ static int smart_wait(uint8_t *data, bool silent) {
return -1;
}
uint32_t len = resp.core.old.arg[0];
uint32_t len = resp.oldarg[0];
if (!len) {
if (!silent) PrintAndLogEx(WARNING, "smart card response failed");
return -2;
}
memcpy(data, resp.core.old.d.asBytes, len);
memcpy(data, resp.data.asBytes, len);
if (len >= 2) {
if (!silent) PrintAndLogEx(SUCCESS, "%02X%02X | %s", data[len - 2], data[len - 1], GetAPDUCodeDescription(data[len - 2], data[len - 1]));
} else {
@ -347,7 +347,7 @@ static int smart_responseEx(uint8_t *data, bool silent) {
int len = data[datalen - 1];
if (!silent) PrintAndLogEx(INFO, "Requesting 0x%02X bytes response", len);
uint8_t getstatus[] = {0x00, ISO7816_GET_RESPONSE, 0x00, 0x00, len};
UsbCommand cStatus = {CMD_SMART_RAW, {SC_RAW, sizeof(getstatus), 0}, {{0}}};
UsbCommandOLD cStatus = {CMD_SMART_RAW, {SC_RAW, sizeof(getstatus), 0}, {{0}}};
memcpy(cStatus.d.asBytes, getstatus, sizeof(getstatus));
clearCommandBuffer();
SendCommand(&cStatus);
@ -454,7 +454,7 @@ static int CmdSmartRaw(const char *Cmd) {
// arg0 = RFU flags
// arg1 = length
UsbCommand c = {CMD_SMART_RAW, {0, hexlen, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_RAW, {0, hexlen, 0}, {{0}}};
if (active || active_select) {
c.arg[0] |= SC_CONNECT;
@ -652,7 +652,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
while (bytes_remaining > 0) {
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
UsbCommand c = {CMD_SMART_UPLOAD, {index + bytes_sent, bytes_in_packet, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_UPLOAD, {index + bytes_sent, bytes_in_packet, 0}, {{0}}};
// Fill usb bytes with 0xFF
memset(c.d.asBytes, 0xFF, USB_CMD_DATA_SIZE);
@ -675,7 +675,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Sim module firmware updating, don\'t turn off your PM3!");
// trigger the firmware upgrade
UsbCommand c = {CMD_SMART_UPGRADE, {firmware_size, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_UPGRADE, {firmware_size, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -683,7 +683,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
return 1;
}
if ((resp.core.old.arg[0] & 0xFF)) {
if ((resp.oldarg[0] & 0xFF)) {
PrintAndLogEx(SUCCESS, "Sim module firmware upgrade " _GREEN_("successful"));
PrintAndLogEx(SUCCESS, "\n run " _YELLOW_("`hw status`") " to validate the fw version ");
} else {
@ -714,7 +714,7 @@ static int CmdSmartInfo(const char *Cmd) {
//Validations
if (errors) return usage_sm_info();
UsbCommand c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -723,14 +723,14 @@ static int CmdSmartInfo(const char *Cmd) {
return 1;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (!isok) {
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
return 1;
}
smart_card_atr_t card;
memcpy(&card, (smart_card_atr_t *)resp.core.old.d.asBytes, sizeof(smart_card_atr_t));
memcpy(&card, (smart_card_atr_t *)resp.data.asBytes, sizeof(smart_card_atr_t));
// print header
PrintAndLogEx(INFO, "--- Smartcard Information ---------");
@ -789,7 +789,7 @@ static int CmdSmartReader(const char *Cmd) {
//Validations
if (errors) return usage_sm_reader();
UsbCommand c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -798,13 +798,13 @@ static int CmdSmartReader(const char *Cmd) {
return 1;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (!isok) {
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
return 1;
}
smart_card_atr_t card;
memcpy(&card, (smart_card_atr_t *)resp.core.old.d.asBytes, sizeof(smart_card_atr_t));
memcpy(&card, (smart_card_atr_t *)resp.data.asBytes, sizeof(smart_card_atr_t));
PrintAndLogEx(INFO, "ISO7816-3 ATR : %s", sprint_hex(card.atr, card.atr_len));
return 0;
@ -835,7 +835,7 @@ static int CmdSmartSetClock(const char *Cmd) {
//Validations
if (errors || cmdp == 0) return usage_sm_setclock();
UsbCommand c = {CMD_SMART_SETCLOCK, {clock1, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_SETCLOCK, {clock1, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -844,7 +844,7 @@ static int CmdSmartSetClock(const char *Cmd) {
return 1;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (!isok) {
PrintAndLogEx(WARNING, "smart card set clock failed");
return 1;
@ -887,7 +887,7 @@ static void smart_brute_prim() {
PrintAndLogEx(INFO, "Reading primitives");
UsbCommand c = {CMD_SMART_RAW, {SC_RAW_T0, 5, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, 5, 0}, {{0}}};
for (int i = 0; i < sizeof(get_card_data); i += 5) {
@ -917,7 +917,7 @@ static int smart_brute_sfi(bool decodeTLV) {
int len;
// READ RECORD
uint8_t READ_RECORD[] = {0x00, 0xB2, 0x00, 0x00, 0x00};
UsbCommand c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(READ_RECORD), 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(READ_RECORD), 0}, {{0}}};
PrintAndLogEx(INFO, "Start SFI brute forcing");
@ -984,7 +984,7 @@ static void smart_brute_options(bool decodeTLV) {
uint8_t GET_PROCESSING_OPTIONS[] = {0x80, 0xA8, 0x00, 0x00, 0x02, 0x83, 0x00, 0x00};
// Get processing options command
UsbCommand c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(GET_PROCESSING_OPTIONS), 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(GET_PROCESSING_OPTIONS), 0}, {{0}}};
memcpy(c.d.asBytes, GET_PROCESSING_OPTIONS, sizeof(GET_PROCESSING_OPTIONS));
clearCommandBuffer();
SendCommand(&c);
@ -1041,7 +1041,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
// uint8_t VERIFY[] = {0x00, 0x20, 0x00, 0x80};
// Select AID command
UsbCommand cAid = {CMD_SMART_RAW, {SC_RAW_T0, 0, 0}, {{0}}};
UsbCommandOLD cAid = {CMD_SMART_RAW, {SC_RAW_T0, 0, 0}, {{0}}};
PrintAndLogEx(INFO, "Importing AID list");
json_t *root = NULL;
@ -1178,7 +1178,7 @@ int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leave
PrintAndLogEx(DEBUG, "APDU SC");
UsbCommand c = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
if (activateCard) {
c.arg[0] |= SC_SELECT | SC_CONNECT;
}
@ -1194,7 +1194,7 @@ int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leave
// retry
if (len > 1 && dataout[len - 2] == 0x6c && datainlen > 4) {
UsbCommand c2 = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
UsbCommandOLD c2 = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
memcpy(c2.d.asBytes, datain, 5);
// transfer length via T=0
@ -1214,7 +1214,7 @@ bool smart_select(bool silent, smart_card_atr_t *atr) {
if (atr)
memset(atr, 0, sizeof(smart_card_atr_t));
UsbCommand c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -1223,14 +1223,14 @@ bool smart_select(bool silent, smart_card_atr_t *atr) {
return false;
}
uint8_t isok = resp.core.old.arg[0] & 0xFF;
uint8_t isok = resp.oldarg[0] & 0xFF;
if (!isok) {
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
return false;
}
smart_card_atr_t card;
memcpy(&card, (smart_card_atr_t *)resp.core.old.d.asBytes, sizeof(smart_card_atr_t));
memcpy(&card, (smart_card_atr_t *)resp.data.asBytes, sizeof(smart_card_atr_t));
if (atr)
memcpy(atr, &card, sizeof(smart_card_atr_t));

View file

@ -678,7 +678,7 @@ int CmdTraceList(const char *Cmd) {
return 1;
}
traceLen = response.core.old.arg[2];
traceLen = response.oldarg[2];
if (traceLen > USB_CMD_DATA_SIZE) {
uint8_t *p = realloc(trace, traceLen);
if (p == NULL) {

View file

@ -25,7 +25,7 @@ static pthread_t USB_communication_thread;
//static pthread_t FPC_communication_thread;
// Transmit buffer.
static UsbCommand txBuffer;
static UsbCommandOLD txBuffer;
static UsbCommandNG txBufferNG;
size_t txBufferNGLen;
static bool txBuffer_pending = false;
@ -57,7 +57,7 @@ bool IsOffline() {
return offline;
}
void SendCommand(UsbCommand *c) {
void SendCommand(UsbCommandOLD *c) {
#ifdef COMMS_DEBUG
PrintAndLogEx(NORMAL, "Sending %d bytes | cmd %04x\n", sizeof(UsbCommand), c->cmd);
@ -99,12 +99,12 @@ void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
PrintAndLogEx(NORMAL, "Sending bytes to proxmark failed - offline");
return;
}
if (len > USB_DATANG_SIZE) {
if (len > USB_CMD_DATA_SIZE) {
PrintAndLogEx(WARNING, "Sending %d bytes of payload is too much, abort", len);
return;
}
UsbCommandNGPostamble *tx_post = (UsbCommandNGPostamble *)((uint8_t *)&txBufferNG + sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + len);
UsbCommandNGPostamble *tx_post = (UsbCommandNGPostamble *)((uint8_t *)&txBufferNG + sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_CMD_DATA_SIZE + len);
pthread_mutex_lock(&txBufferMutex);
/**
@ -121,9 +121,9 @@ void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
txBufferNG.core.ng.cmd = cmd;
memcpy(&txBufferNG.core.ng.data, data, len);
uint8_t first, second;
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + len, &first, &second);
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_CMD_DATA_SIZE + len, &first, &second);
tx_post->crc = (first << 8) + second;
txBufferNGLen = sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + len + sizeof(UsbCommandNGPostamble);
txBufferNGLen = sizeof(UsbCommandNGPreamble) + sizeof(UsbPacketNGCore) - USB_CMD_DATA_SIZE + len + sizeof(UsbCommandNGPostamble);
txBuffer_pending = true;
// tell communication thread that a new command can be send
@ -195,35 +195,19 @@ static int getReply(UsbReplyNG *packet) {
//-----------------------------------------------------------------------------
static void UsbReplyReceived(UsbReplyNG *packet) {
uint64_t cmd; // To accommodate old cmd, can be reduced to uint16_t once all old cmds are gone.
//DOEGOX
//PrintAndLogEx(NORMAL, "RECV %s magic %08x length %04x status %04x crc %04x cmd %04x",
// packet->ng ? "NG" : "OLD", packet->magic, packet->length, packet->status, packet->crc, packet->cmd);
if (packet->ng) {
// PrintAndLogEx(NORMAL, "RECV NG magic %08x length %04x status %04x crc %04x cmd %04x", packet->magic, packet->length, packet->status, packet->crc, packet->core.ng.cmd);
cmd = packet->core.ng.cmd;
} else {
// PrintAndLogEx(NORMAL, "RECV OLD magic %08x length %04x status %04x crc %04x cmd %04x", packet->magic, packet->length, packet->status, packet->crc, packet->core.old.cmd);
cmd = packet->core.old.cmd;
}
// For cmd handlers still using old cmd format:
if (packet->ng) {
cmd = packet->core.ng.cmd;
} else {
cmd = packet->core.old.cmd;
}
switch (cmd) {
switch (packet->cmd) {
// First check if we are handling a debug message
case CMD_DEBUG_PRINT_STRING: {
char s[USB_CMD_DATA_SIZE + 1];
memset(s, 0x00, sizeof(s));
size_t len = MIN(packet->core.old.arg[0], USB_CMD_DATA_SIZE);
memcpy(s, packet->core.old.d.asBytes, len);
uint64_t flag = packet->core.old.arg[1];
size_t len = MIN(packet->oldarg[0], USB_CMD_DATA_SIZE);
memcpy(s, packet->data.asBytes, len);
uint64_t flag = packet->oldarg[1];
switch (flag) {
case FLAG_RAWPRINT:
@ -246,7 +230,7 @@ static void UsbReplyReceived(UsbReplyNG *packet) {
break;
}
case CMD_DEBUG_PRINT_INTEGERS: {
PrintAndLogEx(NORMAL, "#db# %" PRIx64 ", %" PRIx64 ", %" PRIx64 "", packet->core.old.arg[0], packet->core.old.arg[1], packet->core.old.arg[2]);
PrintAndLogEx(NORMAL, "#db# %" PRIx64 ", %" PRIx64 ", %" PRIx64 "", packet->oldarg[0], packet->oldarg[1], packet->oldarg[2]);
break;
}
// iceman: hw status - down the path on device, runs printusbspeed which starts sending a lot of
@ -297,6 +281,7 @@ __attribute__((force_align_arg_pointer))
size_t rxlen;
UsbReplyNG rx;
UsbReplyNGRaw rx_raw;
//int counter_to_offline = 0;
#if defined(__MACH__) && defined(__APPLE__)
@ -307,25 +292,34 @@ __attribute__((force_align_arg_pointer))
rxlen = 0;
bool ACK_received = false;
bool error = false;
if (uart_receive(sp, (uint8_t *)&rx, sizeof(UsbReplyNGPreamble), &rxlen) && (rxlen == sizeof(UsbReplyNGPreamble))) {
if (uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(UsbReplyNGPreamble), &rxlen) && (rxlen == sizeof(UsbReplyNGPreamble))) {
rx.magic = rx_raw.pre.magic;
rx.length = rx_raw.pre.length;
rx.status = rx_raw.pre.status;
rx.cmd = rx_raw.pre.cmd;
if (rx.magic == USB_REPLYNG_PREAMBLE_MAGIC) { // New style NG reply
if (rx.length > USB_DATANG_SIZE) {
if (rx.length > USB_CMD_DATA_SIZE) {
PrintAndLogEx(WARNING, "Received packet frame with incompatible length: 0x%04x", rx.length);
error = true;
}
if (!error) { // Get the core and variable length payload
if ((!uart_receive(sp, (uint8_t *)&rx.core, sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + rx.length, &rxlen)) || (rxlen != sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + rx.length)) {
if ((!error) && (rx.length > 0)) { // Get the variable length payload
if ((!uart_receive(sp, (uint8_t *)&rx_raw.data, rx.length, &rxlen)) || (rxlen != rx.length)) {
PrintAndLogEx(WARNING, "Received packet frame error variable part too short? %d/%d", rxlen, rx.length);
error = true;
} else {
memcpy(&rx.data, &rx_raw.data, rx.length);
}
}
if (!error) { // Get the postamble
if ((!uart_receive(sp, (uint8_t *)&rx.crc, sizeof(UsbReplyNGPostamble), &rxlen)) || (rxlen != sizeof(UsbReplyNGPostamble))) {
if ((!uart_receive(sp, (uint8_t *)&rx_raw.post, sizeof(UsbReplyNGPostamble), &rxlen)) || (rxlen != sizeof(UsbReplyNGPostamble))) {
PrintAndLogEx(WARNING, "Received packet frame error fetching postamble");
error = true;
}
}
if (!error) { // Check CRC
rx.crc = rx_raw.post.crc;
uint8_t first, second;
compute_crc(CRC_14443_A, (uint8_t *)&rx, sizeof(UsbReplyNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + rx.length, &first, &second);
compute_crc(CRC_14443_A, (uint8_t *)&rx_raw, sizeof(UsbReplyNGPreamble) + rx.length, &first, &second);
if ((first << 8) + second != rx.crc) {
PrintAndLogEx(WARNING, "Received packet frame CRC error %02X%02X <> %04X", first, second, rx.crc);
error = true;
@ -336,27 +330,31 @@ __attribute__((force_align_arg_pointer))
rx.ng = true;
UsbReplyReceived(&rx);
//TODO DOEGOX NG don't send ACK anymore but reply with the corresponding cmd, still things seem to work fine...
if (rx.core.ng.cmd == CMD_ACK) {
if (rx.cmd == CMD_ACK) {
ACK_received = true;
}
}
} else { // Old style reply
uint8_t tmp[sizeof(UsbReplyNGPreamble)];
memcpy(tmp, &rx, sizeof(UsbReplyNGPreamble));
memcpy(&rx.core.old, tmp, sizeof(UsbReplyNGPreamble));
if ((!uart_receive(sp, ((uint8_t *)&rx.core.old) + sizeof(UsbReplyNGPreamble), sizeof(UsbCommand) - sizeof(UsbReplyNGPreamble), &rxlen)) || (rxlen != sizeof(UsbCommand) - sizeof(UsbReplyNGPreamble))) {
PrintAndLogEx(WARNING, "Received packet frame error var part too short? %d/%d", rxlen, sizeof(UsbCommand) - sizeof(UsbReplyNGPreamble));
UsbCommandOLD rx_old;
memcpy(&rx_old, &rx_raw.pre, sizeof(UsbReplyNGPreamble));
if ((!uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(UsbReplyNGPreamble), sizeof(UsbCommandOLD) - sizeof(UsbReplyNGPreamble), &rxlen)) || (rxlen != sizeof(UsbCommandOLD) - sizeof(UsbReplyNGPreamble))) {
PrintAndLogEx(WARNING, "Received packet frame error var part too short? %d/%d", rxlen, sizeof(UsbCommandOLD) - sizeof(UsbReplyNGPreamble));
error = true;
}
if (!error) {
// PrintAndLogEx(NORMAL, "Received reply old full !!");
rx.ng = false;
rx.magic = 0;
rx.length = USB_CMD_DATA_SIZE;
rx.status = 0;
rx.crc = 0;
rx.cmd = rx_old.cmd;
rx.oldarg[0] = rx_old.arg[0];
rx.oldarg[1] = rx_old.arg[1];
rx.oldarg[2] = rx_old.arg[2];
rx.length = USB_CMD_DATA_SIZE;
memcpy(&rx.data, &rx_old.d, rx.length);
UsbReplyReceived(&rx);
if (rx.core.old.cmd == CMD_ACK) {
if (rx.cmd == CMD_ACK) {
ACK_received = true;
}
}
@ -388,7 +386,7 @@ __attribute__((force_align_arg_pointer))
}
txBufferNGLen = 0;
} else {
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(UsbCommand))) {
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(UsbCommandOLD))) {
//counter_to_offline++;
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device" _RED_("failed"));
}
@ -462,10 +460,10 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
int TestProxmark(void) {
clearCommandBuffer();
UsbReplyNG resp;
UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 5000)) {
PrintAndLogEx(INFO, "Communicating with PM3 over %s.", resp.core.old.arg[0] == 1 ? "FPC" : "USB");
PrintAndLogEx(INFO, "Communicating with PM3 over %s.", resp.oldarg[0] == 1 ? "FPC" : "USB");
return 1;
} else {
return 0;
@ -526,9 +524,7 @@ bool WaitForResponseTimeoutW(uint32_t cmd, UsbReplyNG *response, size_t ms_timeo
while (true) {
while (getReply(response)) {
if (cmd == CMD_UNKNOWN || (response->ng && response->core.ng.cmd == cmd))
return true;
if (cmd == CMD_UNKNOWN || ((!response->ng) && response->core.old.cmd == cmd))
if (cmd == CMD_UNKNOWN || response->cmd == cmd)
return true;
}
@ -580,22 +576,22 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
switch (memtype) {
case BIG_BUF: {
UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}, {{0}}};
UsbCommandOLD c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}, {{0}}};
SendCommand(&c);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K);
}
case BIG_BUF_EML: {
UsbCommand c = {CMD_DOWNLOAD_EML_BIGBUF, {start_index, bytes, 0}, {{0}}};
UsbCommandOLD c = {CMD_DOWNLOAD_EML_BIGBUF, {start_index, bytes, 0}, {{0}}};
SendCommand(&c);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_EML_BIGBUF);
}
case FLASH_MEM: {
UsbCommand c = {CMD_FLASHMEM_DOWNLOAD, {start_index, bytes, 0}, {{0}}};
UsbCommandOLD c = {CMD_FLASHMEM_DOWNLOAD, {start_index, bytes, 0}, {{0}}};
SendCommand(&c);
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED);
}
case SIM_MEM: {
//UsbCommand c = {CMD_DOWNLOAD_SIM_MEM, {start_index, bytes, 0}, {{0}}};
//UsbCommandOLD c = {CMD_DOWNLOAD_SIM_MEM, {start_index, bytes, 0}, {{0}}};
//SendCommand(&c);
//return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM);
return false;
@ -617,11 +613,11 @@ static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbReplyN
// arg0 = offset in transfer. Startindex of this chunk
// arg1 = length bytes to transfer
// arg2 = bigbuff tracelength (?)
if (response->core.old.cmd == rec_cmd) {
if (response->cmd == rec_cmd) {
uint32_t offset = response->core.old.arg[0];
uint32_t copy_bytes = MIN(bytes - bytes_completed, response->core.old.arg[1]);
//uint32_t tracelen = response->core.old.arg[2];
uint32_t offset = response->oldarg[0];
uint32_t copy_bytes = MIN(bytes - bytes_completed, response->oldarg[1]);
//uint32_t tracelen = response->oldarg[2];
// extended bounds check1. upper limit is USB_CMD_DATA_SIZE
// shouldn't happen
@ -633,9 +629,9 @@ static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbReplyN
break;
}
memcpy(dest + offset, response->core.old.d.asBytes, copy_bytes);
memcpy(dest + offset, response->data.asBytes, copy_bytes);
bytes_completed += copy_bytes;
} else if (response->core.old.cmd == CMD_ACK) {
} else if (response->cmd == CMD_ACK) {
return true;
}
}

View file

@ -49,7 +49,7 @@ void SetOffline(bool value);
bool IsOffline(void);
void *uart_receiver(void *targ);
void SendCommand(UsbCommand *c);
void SendCommand(UsbCommandOLD *c);
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len);
void clearCommandBuffer(void);

View file

@ -259,7 +259,7 @@ fail:
// Get the state of the proxmark, backwards compatible
static int get_proxmark_state(uint32_t *state) {
UsbCommand c = {CMD_DEVICE_INFO};
UsbCommandOLD c = {CMD_DEVICE_INFO};
SendCommand(&c);
UsbReplyNG resp;
WaitForResponse(CMD_UNKNOWN, &resp); // wait for any response. No timeout.
@ -269,7 +269,7 @@ static int get_proxmark_state(uint32_t *state) {
// 2. The old os code will respond with CMD_DEBUG_PRINT_STRING and "unknown command"
// 3. The new bootrom and os codes will respond with CMD_DEVICE_INFO and flags
switch (resp.core.old.cmd) {
switch (resp.cmd) {
case CMD_ACK:
*state = DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM;
break;
@ -277,10 +277,10 @@ static int get_proxmark_state(uint32_t *state) {
*state = DEVICE_INFO_FLAG_CURRENT_MODE_OS;
break;
case CMD_DEVICE_INFO:
*state = resp.core.old.arg[0];
*state = resp.oldarg[0];
break;
default:
fprintf(stderr, _RED_("Error:") "Couldn't get Proxmark3 state, bad response type: 0x%04" PRIx64 "\n", resp.core.old.cmd);
fprintf(stderr, _RED_("Error:") "Couldn't get Proxmark3 state, bad response type: 0x%04x\n", resp.cmd);
return -1;
break;
}
@ -300,7 +300,7 @@ static int enter_bootloader(char *serial_port_name) {
if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
fprintf(stdout, _BLUE_("Entering bootloader...") "\n");
UsbCommand c;
UsbCommandOLD c;
memset(&c, 0, sizeof(c));
if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
@ -338,10 +338,10 @@ static int enter_bootloader(char *serial_port_name) {
static int wait_for_ack(UsbReplyNG *ack) {
WaitForResponse(CMD_UNKNOWN, ack);
if (ack->core.old.cmd != CMD_ACK) {
printf("Error: Unexpected reply 0x%04" PRIx64 " %s (expected ACK)\n",
ack->core.old.cmd,
(ack->core.old.cmd == CMD_NACK) ? "NACK" : ""
if (ack->cmd != CMD_ACK) {
printf("Error: Unexpected reply 0x%04x %s (expected ACK)\n",
ack->cmd,
(ack->cmd == CMD_NACK) ? "NACK" : ""
);
return -1;
}
@ -361,7 +361,7 @@ int flash_start_flashing(int enable_bl_writes, char *serial_port_name) {
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
// This command is stupid. Why the heck does it care which area we're
// flashing, as long as it's not the bootloader area? The mind boggles.
UsbCommand c = {CMD_START_FLASH};
UsbCommandOLD c = {CMD_START_FLASH};
UsbReplyNG resp;
if (enable_bl_writes) {
@ -386,16 +386,16 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
uint8_t block_buf[BLOCK_SIZE];
memset(block_buf, 0xFF, BLOCK_SIZE);
memcpy(block_buf, data, length);
UsbCommand c = {CMD_FINISH_WRITE, {address, 0, 0}};
UsbCommandOLD c = {CMD_FINISH_WRITE, {address, 0, 0}};
UsbReplyNG resp;
memcpy(c.d.asBytes, block_buf, length);
SendCommand(&c);
int ret = wait_for_ack(&resp);
if (ret && resp.core.old.arg[0]) {
uint32_t lock_bits = resp.core.old.arg[0] >> 16;
bool lock_error = resp.core.old.arg[0] & AT91C_MC_LOCKE;
bool prog_error = resp.core.old.arg[0] & AT91C_MC_PROGE;
bool security_bit = resp.core.old.arg[0] & AT91C_MC_SECURITY;
if (ret && resp.oldarg[0]) {
uint32_t lock_bits = resp.oldarg[0] >> 16;
bool lock_error = resp.oldarg[0] & AT91C_MC_LOCKE;
bool prog_error = resp.oldarg[0] & AT91C_MC_PROGE;
bool security_bit = resp.oldarg[0] & AT91C_MC_SECURITY;
printf("%s", lock_error ? " Lock Error\n" : "");
printf("%s", prog_error ? " Invalid Command or bad Keyword\n" : "");
printf("%s", security_bit ? " Security Bit is set!\n" : "");
@ -459,7 +459,7 @@ void flash_free(flash_file_t *ctx) {
// just reset the unit
int flash_stop_flashing(void) {
UsbCommand c = {CMD_HARDWARE_RESET};
UsbCommandOLD c = {CMD_HARDWARE_RESET};
SendCommand(&c);
msleep(100);
return 0;

View file

@ -20,9 +20,9 @@
#define MAX_FILES 4
void cmd_debug(UsbCommand *c) {
void cmd_debug(UsbCommandOLD *c) {
// Debug
printf("UsbCommand length[len=%zu]\n", sizeof(UsbCommand));
printf("UsbCommandOLD length[len=%zu]\n", sizeof(UsbCommandOLD));
printf(" cmd[len=%zu]: %016" PRIx64"\n", sizeof(c->cmd), c->cmd);
printf(" arg0[len=%zu]: %016" PRIx64"\n", sizeof(c->arg[0]), c->arg[0]);
printf(" arg1[len=%zu]: %016" PRIx64"\n", sizeof(c->arg[1]), c->arg[1]);

View file

@ -16,7 +16,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
uint64_t par_list = 0, ks_list = 0;
uint64_t *keylist = NULL, *last_keylist = NULL;
UsbCommand c = {CMD_READER_MIFARE, {true, blockno, key_type}, {{0}}};
UsbCommandOLD c = {CMD_READER_MIFARE, {true, blockno, key_type}, {{0}}};
// message
PrintAndLogEx(NORMAL, "--------------------------------------------------------------------------------\n");
@ -47,16 +47,16 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
int16_t isOK = resp.core.old.arg[0];
int16_t isOK = resp.oldarg[0];
if (isOK < 0)
return isOK;
uid = (uint32_t)bytes_to_num(resp.core.old.d.asBytes + 0, 4);
nt = (uint32_t)bytes_to_num(resp.core.old.d.asBytes + 4, 4);
par_list = bytes_to_num(resp.core.old.d.asBytes + 8, 8);
ks_list = bytes_to_num(resp.core.old.d.asBytes + 16, 8);
nr = (uint32_t)bytes_to_num(resp.core.old.d.asBytes + 24, 4);
ar = (uint32_t)bytes_to_num(resp.core.old.d.asBytes + 28, 4);
uid = (uint32_t)bytes_to_num(resp.data.asBytes + 0, 4);
nt = (uint32_t)bytes_to_num(resp.data.asBytes + 4, 4);
par_list = bytes_to_num(resp.data.asBytes + 8, 8);
ks_list = bytes_to_num(resp.data.asBytes + 16, 8);
nr = (uint32_t)bytes_to_num(resp.data.asBytes + 24, 4);
ar = (uint32_t)bytes_to_num(resp.data.asBytes + 28, 4);
break;
}
}
@ -123,14 +123,14 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
}
int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t *keyBlock, uint64_t *key) {
*key = -1;
UsbCommand c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), clear_trace, keycnt}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), clear_trace, keycnt}, {{0}}};
memcpy(c.d.asBytes, keyBlock, 6 * keycnt);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) return 1;
if ((resp.core.old.arg[0] & 0xff) != 0x01) return 2;
*key = bytes_to_num(resp.core.old.d.asBytes, 6);
if ((resp.oldarg[0] & 0xff) != 0x01) return 2;
*key = bytes_to_num(resp.data.asBytes, 6);
return 0;
}
@ -145,7 +145,7 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
uint32_t timeout = 0;
// send keychunk
UsbCommand c = {CMD_MIFARE_CHKKEYS_FAST, { (sectorsCnt | (firstChunk << 8) | (lastChunk << 12)), ((use_flashmemory << 8) | strategy), size}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_CHKKEYS_FAST, { (sectorsCnt | (firstChunk << 8) | (lastChunk << 12)), ((use_flashmemory << 8) | strategy), size}, {{0}}};
memcpy(c.d.asBytes, keyBlock, 6 * size);
clearCommandBuffer();
SendCommand(&c);
@ -166,7 +166,7 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
t2 = msclock() - t2;
// time to convert the returned data.
uint8_t curr_keys = resp.core.old.arg[0];
uint8_t curr_keys = resp.oldarg[0];
PrintAndLogEx(SUCCESS, "\nChunk: %.1fs | found %u/%u keys (%u)", (float)(t2 / 1000.0), curr_keys, (sectorsCnt << 1), size);
@ -177,8 +177,8 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
uint8_t arr[80];
uint64_t foo = 0;
uint16_t bar = 0;
foo = bytes_to_num(resp.core.old.d.asBytes + 480, 8);
bar = (resp.core.old.d.asBytes[489] << 8 | resp.core.old.d.asBytes[488]);
foo = bytes_to_num(resp.data.asBytes + 480, 8);
bar = (resp.data.asBytes[489] << 8 | resp.data.asBytes[488]);
for (uint8_t i = 0; i < 64; i++)
arr[i] = (foo >> i) & 0x1;
@ -190,7 +190,7 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
icesector_t *tmp = calloc(sectorsCnt, sizeof(icesector_t));
if (tmp == NULL)
return 1;
memcpy(tmp, resp.core.old.d.asBytes, sectorsCnt * sizeof(icesector_t));
memcpy(tmp, resp.data.asBytes, sectorsCnt * sizeof(icesector_t));
for (int i = 0; i < sectorsCnt; i++) {
// key A
@ -297,23 +297,23 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
StateList_t statelists[2];
struct Crypto1State *p1, *p2, *p3, *p4;
UsbCommand c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}, {{0}}};
memcpy(c.d.asBytes, key, 6);
clearCommandBuffer();
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return -1;
// error during nested
if (resp.core.old.arg[0]) return resp.core.old.arg[0];
if (resp.oldarg[0]) return resp.oldarg[0];
memcpy(&uid, resp.core.old.d.asBytes, 4);
memcpy(&uid, resp.data.asBytes, 4);
for (i = 0; i < 2; i++) {
statelists[i].blockNo = resp.core.old.arg[2] & 0xff;
statelists[i].keyType = (resp.core.old.arg[2] >> 8) & 0xff;
statelists[i].blockNo = resp.oldarg[2] & 0xff;
statelists[i].keyType = (resp.oldarg[2] >> 8) & 0xff;
statelists[i].uid = uid;
memcpy(&statelists[i].nt, (void *)(resp.core.old.d.asBytes + 4 + i * 8 + 0), 4);
memcpy(&statelists[i].ks1, (void *)(resp.core.old.d.asBytes + 4 + i * 8 + 4), 4);
memcpy(&statelists[i].nt, (void *)(resp.data.asBytes + 4 + i * 8 + 0), 4);
memcpy(&statelists[i].ks1, (void *)(resp.data.asBytes + 4 + i * 8 + 4), 4);
}
// calc keys
@ -397,8 +397,8 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
num_to_bytes(key64, 6, resultKey);
PrintAndLogEx(SUCCESS, "target block:%3u key type: %c -- found valid key [%012" PRIx64 "]",
(uint16_t)resp.core.old.arg[2] & 0xff,
(resp.core.old.arg[2] >> 8) ? 'B' : 'A',
(uint16_t)resp.oldarg[2] & 0xff,
(resp.oldarg[2] >> 8) ? 'B' : 'A',
key64
);
return -5;
@ -407,8 +407,8 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
out:
PrintAndLogEx(SUCCESS, "target block:%3u key type: %c",
(uint16_t)resp.core.old.arg[2] & 0xff,
(resp.core.old.arg[2] >> 8) ? 'B' : 'A'
(uint16_t)resp.oldarg[2] & 0xff,
(resp.oldarg[2] >> 8) ? 'B' : 'A'
);
free(statelists[0].head.slhead);
@ -419,17 +419,17 @@ out:
// MIFARE
int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data) {
UsbCommand c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
memcpy(c.d.asBytes, key, 6);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (isOK) {
memcpy(data, resp.core.old.d.asBytes, mfNumBlocksPerSector(sectorNo) * 16);
memcpy(data, resp.data.asBytes, mfNumBlocksPerSector(sectorNo) * 16);
return 0;
} else {
return 1;
@ -444,12 +444,12 @@ int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data)
// EMULATOR
int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount) {
UsbCommand c = {CMD_MIFARE_EML_MEMGET, {blockNum, blocksCount, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_EML_MEMGET, {blockNum, blocksCount, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return 1;
memcpy(data, resp.core.old.d.asBytes, blocksCount * 16);
memcpy(data, resp.data.asBytes, blocksCount * 16);
return 0;
}
@ -458,7 +458,7 @@ int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
}
int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {
UsbCommand c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, blockBtWidth}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, blockBtWidth}, {{0}}};
memcpy(c.d.asBytes, data, blocksCount * blockBtWidth);
clearCommandBuffer();
SendCommand(&c);
@ -501,15 +501,15 @@ int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params) {
UsbCommand c = {CMD_MIFARE_CSETBLOCK, {params, blockNo, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_CSETBLOCK, {params, blockNo, 0}, {{0}}};
memcpy(c.d.asBytes, data, 16);
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (uid != NULL)
memcpy(uid, resp.core.old.d.asBytes, 4);
memcpy(uid, resp.data.asBytes, 4);
if (!isOK)
return 2;
} else {
@ -520,15 +520,15 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params) {
}
int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params) {
UsbCommand c = {CMD_MIFARE_CGETBLOCK, {params, blockNo, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_CGETBLOCK, {params, blockNo, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
uint8_t isOK = resp.core.old.arg[0] & 0xff;
uint8_t isOK = resp.oldarg[0] & 0xff;
if (!isOK)
return 2;
memcpy(data, resp.core.old.d.asBytes, 16);
memcpy(data, resp.data.asBytes, 16);
} else {
PrintAndLogEx(WARNING, "command execute timeout");
return 1;
@ -873,7 +873,7 @@ int detect_classic_prng(void) {
uint8_t cmd[] = {MIFARE_AUTH_KEYA, 0x00};
uint32_t flags = ISO14A_CONNECT | ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_RATS;
UsbCommand c = {CMD_READER_ISO_14443a, {flags, sizeof(cmd), 0}, {{0}}};
UsbCommandOLD c = {CMD_READER_ISO_14443a, {flags, sizeof(cmd), 0}, {{0}}};
memcpy(c.d.asBytes, cmd, sizeof(cmd));
clearCommandBuffer();
@ -885,7 +885,7 @@ int detect_classic_prng(void) {
}
// if select tag failed.
if (resp.core.old.arg[0] == 0) {
if (resp.oldarg[0] == 0) {
PrintAndLogEx(WARNING, "error: selecting tag failed, can't detect prng\n");
return -2;
}
@ -895,12 +895,12 @@ int detect_classic_prng(void) {
}
// check respA
if (respA.core.old.arg[0] != 4) {
PrintAndLogEx(WARNING, "PRNG data error: Wrong length: %d", respA.core.old.arg[0]);
if (respA.oldarg[0] != 4) {
PrintAndLogEx(WARNING, "PRNG data error: Wrong length: %d", respA.oldarg[0]);
return -4;
}
uint32_t nonce = bytes_to_num(respA.core.old.d.asBytes, respA.core.old.arg[0]);
uint32_t nonce = bytes_to_num(respA.data.asBytes, respA.oldarg[0]);
return validate_prng_nonce(nonce);
}
/* Detect Mifare Classic NACK bug
@ -913,7 +913,7 @@ returns:
*/
int detect_classic_nackbug(bool verbose) {
UsbCommand c = {CMD_MIFARE_NACK_DETECT, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_NACK_DETECT, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
UsbReplyNG resp;
@ -949,9 +949,9 @@ int detect_classic_nackbug(bool verbose) {
}
if (WaitForResponseTimeout(CMD_ACK, &resp, 500)) {
int32_t ok = resp.core.old.arg[0];
uint32_t nacks = resp.core.old.arg[1];
uint32_t auths = resp.core.old.arg[2];
int32_t ok = resp.oldarg[0];
uint32_t nacks = resp.oldarg[1];
uint32_t auths = resp.oldarg[2];
PrintAndLogEx(NORMAL, "");
if (verbose) {
@ -999,11 +999,11 @@ void detect_classic_magic(void) {
uint8_t isGeneration = 0;
UsbReplyNG resp;
UsbCommand c = {CMD_MIFARE_CIDENT, {0, 0, 0}, {{0}}};
UsbCommandOLD c = {CMD_MIFARE_CIDENT, {0, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500))
isGeneration = resp.core.old.arg[0] & 0xff;
isGeneration = resp.oldarg[0] & 0xff;
switch (isGeneration) {
case 1:

View file

@ -12,7 +12,7 @@
/**
* The following params expected:
* UsbCommand c
* UsbCommandOLD c
*@brief l_SendCommand
* @param L
* @return
@ -29,19 +29,19 @@ static int l_SendCommand(lua_State *L) {
uint8_t asBytes[USB_CMD_DATA_SIZE]; // 1 byte * 512 = 512 bytes (OR)
uint32_t asDwords[USB_CMD_DATA_SIZE/4]; // 4 byte * 128 = 512 bytes
} d;
} PACKED UsbCommand;
} PACKED UsbCommandOLD;
==> A 544 byte buffer will do.
**/
size_t size;
const char *data = luaL_checklstring(L, 1, &size);
if (size != sizeof(UsbCommand)) {
printf("Got data size %d, expected %d", (int) size, (int) sizeof(UsbCommand));
if (size != sizeof(UsbCommandOLD)) {
printf("Got data size %d, expected %d", (int) size, (int) sizeof(UsbCommandOLD));
lua_pushstring(L, "Wrong data size");
return 1;
}
SendCommand((UsbCommand *)data);
SendCommand((UsbCommandOLD *)data);
return 0; // no return values
}
@ -262,7 +262,7 @@ static int l_foobar(lua_State *L) {
printf("Arguments discarded, stack now contains %d elements", lua_gettop(L));
// todo: this is not used, where was it intended for?
// UsbCommand response = {CMD_MIFARE_READBL, {1337, 1338, 1339}, {{0}}};
// UsbCommandOLD response = {CMD_MIFARE_READBL, {1337, 1338, 1339}, {{0}}};
printf("Now returning a uint64_t as a string");
uint64_t x = 0xDEADC0DE;

View file

@ -26,7 +26,7 @@ int main() {
while (1) {
while (!OpenProxmark()) { sleep(1); }
while (1) {
UsbCommand cmdbuf;
UsbCommandOLD cmdbuf;
CommandReceived("hf 14a sniff");
HANDLE_ERROR;
ReceiveCommand(&cmdbuf);

View file

@ -150,7 +150,7 @@
#ifndef DropField
#define DropField() { \
UsbCommand c_drop = {CMD_READER_ISO_14443a, {0,0,0}, {{0}}}; clearCommandBuffer(); SendCommand(&c_drop); \
UsbCommandOLD c_drop = {CMD_READER_ISO_14443a, {0,0,0}, {{0}}}; clearCommandBuffer(); SendCommand(&c_drop); \
}
#endif

View file

@ -44,9 +44,9 @@ extern void Dbprintf(const char *fmt, ...);
#endif
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
UsbCommand txcmd;
UsbCommandOLD txcmd;
for (size_t i = 0; i < sizeof(UsbCommand); i++)
for (size_t i = 0; i < sizeof(UsbCommandOLD); i++)
((uint8_t *)&txcmd)[i] = 0x00;
// Compose the outgoing command frame
@ -68,47 +68,48 @@ uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void
#ifdef WITH_FPC_HOST
if (reply_via_fpc) {
sendlen = usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommand));
sendlen = usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommandOLD));
// Dbprintf_usb("Sent %i bytes over usart", len);
} else {
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommand));
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommandOLD));
}
#else
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommand));
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommandOLD));
#endif
return sendlen;
}
uint8_t reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len) {
UsbReplyNG txBufferNG;
UsbReplyNGRaw txBufferNG;
size_t txBufferNGLen;
// for (size_t i = 0; i < sizeof(txBufferNG); i++)
// ((uint8_t *)&txBufferNG)[i] = 0x00;
// Compose the outgoing command frame
txBufferNG.magic = USB_REPLYNG_PREAMBLE_MAGIC;
txBufferNG.core.ng.cmd = cmd;
txBufferNG.status = status;
if (len > USB_DATANG_SIZE) {
len = USB_DATANG_SIZE;
txBufferNG.pre.magic = USB_REPLYNG_PREAMBLE_MAGIC;
txBufferNG.pre.cmd = cmd;
txBufferNG.pre.status = status;
if (len > USB_CMD_DATA_SIZE) {
len = USB_CMD_DATA_SIZE;
// overwrite status
txBufferNG.status = PM3_EOVFLOW;
txBufferNG.pre.status = PM3_EOVFLOW;
}
txBufferNG.length = len;
UsbReplyNGPostamble *tx_post = (UsbReplyNGPostamble *)((uint8_t *)&txBufferNG + sizeof(UsbReplyNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + len);
txBufferNG.pre.length = len;
// Add the (optional) content to the frame, with a maximum size of USB_DATANG_SIZE
// Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE
if (data && len) {
for (size_t i = 0; i < len; i++) {
txBufferNG.core.ng.data[i] = data[i];
txBufferNG.data[i] = data[i];
}
}
uint8_t first, second;
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(UsbReplyNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + len, &first, &second);
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(UsbReplyNGPreamble) + len, &first, &second);
UsbReplyNGPostamble *tx_post = (UsbReplyNGPostamble *)((uint8_t *)&txBufferNG + sizeof(UsbReplyNGPreamble) + len);
tx_post->crc = (first << 8) + second;
txBufferNGLen = sizeof(UsbReplyNGPreamble) + sizeof(UsbPacketNGCore) - USB_DATANG_SIZE + len + sizeof(UsbReplyNGPostamble);
txBufferNGLen = sizeof(UsbReplyNGPreamble) + len + sizeof(UsbReplyNGPostamble);
uint32_t sendlen = 0;
// Send frame and make sure all bytes are transmitted

View file

@ -38,8 +38,8 @@ void usart_close(void) {
}
*/
static uint8_t us_inbuf[sizeof(UsbCommand)];
static uint8_t us_outbuf[sizeof(UsbCommand)];
static uint8_t us_inbuf[sizeof(UsbCommandOLD)];
static uint8_t us_outbuf[sizeof(UsbCommandOLD)];
/*
// transfer from client to device
inline int16_t usart_readbuffer(uint8_t *data) {
@ -63,7 +63,7 @@ inline int16_t usart_readbuffer(uint8_t *data) {
// Check if the first PDC bank is free
if (pUS1->US_RCR == 0) {
pUS1->US_RPR = (uint32_t)data;
pUS1->US_RCR = sizeof(UsbCommand);
pUS1->US_RCR = sizeof(UsbCommandOLD);
pUS1->US_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTEN;
check = 0;
return 2;

View file

@ -25,7 +25,6 @@ typedef BYTE uint8_t;
#endif
#define USB_CMD_DATA_SIZE 512
#define USB_DATANG_SIZE 512
typedef struct {
uint64_t cmd;
@ -34,11 +33,11 @@ typedef struct {
uint8_t asBytes[USB_CMD_DATA_SIZE];
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
} d;
} PACKED UsbCommand;
} PACKED UsbCommandOLD;
typedef struct {
uint16_t cmd;
uint8_t data[USB_DATANG_SIZE];
uint8_t data[USB_CMD_DATA_SIZE];
} PACKED UsbPacketNGCore;
typedef struct {
@ -57,7 +56,7 @@ typedef struct {
uint16_t length; // length of the variable part, 0 if none.
union { // we can simplify it once we get rid of old format compatibility
UsbPacketNGCore ng;
UsbCommand old;
UsbCommandOLD old;
} core;
uint16_t crc;
bool ng;
@ -67,6 +66,7 @@ typedef struct {
uint32_t magic;
uint16_t length; // length of the variable part, 0 if none.
int16_t status;
uint16_t cmd;
} PACKED UsbReplyNGPreamble;
#define USB_REPLYNG_PREAMBLE_MAGIC 0x62334d50 // PM3b
@ -75,18 +75,28 @@ typedef struct {
uint16_t crc;
} PACKED UsbReplyNGPostamble;
// For internal usage
typedef struct {
uint32_t magic; // \ //
uint16_t length; // Preamble //
int16_t status; // / //
union { // we can simplify it once we get rid of old format compatibility
UsbPacketNGCore ng;
UsbCommand old;
} core;
uint16_t crc; // -- Postamble //
bool ng;
uint16_t cmd;
uint16_t length;
uint32_t magic; // NG
int16_t status; // NG
uint16_t crc; // NG
uint64_t oldarg[3]; // OLD
union {
uint8_t asBytes[USB_CMD_DATA_SIZE];
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
} data;
bool ng; // does it store NG data or OLD data?
} PACKED UsbReplyNG;
// For reception and CRC check
typedef struct {
UsbReplyNGPreamble pre;
uint8_t data[USB_CMD_DATA_SIZE];
UsbReplyNGPostamble post;
} PACKED UsbReplyNGRaw;
#ifdef WITH_FPC_HOST
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
extern bool reply_via_fpc;