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
+12 -12
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) {
+1 -1
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
+1 -1
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);
+2 -2
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");
+11 -11
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) {
+11 -11
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);
+2 -2
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;
+52 -52
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
+34 -34
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.
+31 -31
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");
+19 -19
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;
}
+13 -13
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: {
+43 -43
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
+19 -19
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;
}
+45 -45
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;
+67 -67
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, nyckellngd,
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));
+10 -10
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);
+8 -8
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
}
}
+3 -3
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, "----------------------------------------------");
+34 -34
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

Some files were not shown because too many files have changed in this diff Show More