mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Viva la revolucion
This commit is contained in:
+180
-170
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -120,13 +120,13 @@ void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
|
||||
void ReadSTMemoryIso14443b(uint8_t numofblocks);
|
||||
void RAMFUNC SniffIso14443b(void);
|
||||
void SendRawCommand14443B(uint32_t, uint32_t, uint8_t, uint8_t[]);
|
||||
void SendRawCommand14443B_Ex(UsbCommand *c);
|
||||
void SendRawCommand14443B_Ex(UsbCommandNG *c);
|
||||
void ClearFpgaShiftingRegisters(void);
|
||||
|
||||
// iso14443a.h
|
||||
void RAMFUNC SniffIso14443a(uint8_t param);
|
||||
void SimulateIso14443aTag(int tagType, int flags, uint8_t *data);
|
||||
void ReaderIso14443a(UsbCommand *c);
|
||||
void ReaderIso14443a(UsbCommandNG *c);
|
||||
|
||||
// Also used in iclass.c
|
||||
//bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t len, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag);
|
||||
@@ -137,8 +137,8 @@ void iso14a_set_trigger(bool enable);
|
||||
//int GetIso14443aCommandFromReader(uint8_t *received, uint8_t *parity, int *len);
|
||||
|
||||
// epa.h
|
||||
void EPA_PACE_Collect_Nonce(UsbCommand *c);
|
||||
void EPA_PACE_Replay(UsbCommand *c);
|
||||
void EPA_PACE_Collect_Nonce(UsbCommandNG *c);
|
||||
void EPA_PACE_Replay(UsbCommandNG *c);
|
||||
|
||||
// mifarecmd.h
|
||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
@@ -229,7 +229,7 @@ uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void
|
||||
void HfSniff(int, int);
|
||||
|
||||
//felica.c
|
||||
void felica_sendraw(UsbCommand *c);
|
||||
void felica_sendraw(UsbCommandNG *c);
|
||||
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip);
|
||||
void felica_sim_lite(uint64_t uid);
|
||||
void felica_dump_lite_s();
|
||||
|
||||
+11
-11
@@ -259,7 +259,7 @@ static void EPA_PACE_Collect_Nonce_Abort(uint8_t step, int func_return) {
|
||||
//-----------------------------------------------------------------------------
|
||||
// Acquire one encrypted PACE nonce
|
||||
//-----------------------------------------------------------------------------
|
||||
void EPA_PACE_Collect_Nonce(UsbCommand *c) {
|
||||
void EPA_PACE_Collect_Nonce(UsbCommandNG *c) {
|
||||
/*
|
||||
* ack layout:
|
||||
* arg:
|
||||
@@ -313,7 +313,7 @@ void EPA_PACE_Collect_Nonce(UsbCommand *c) {
|
||||
|
||||
// now get the nonce
|
||||
uint8_t nonce[256] = {0};
|
||||
uint8_t requested_size = (uint8_t)c->arg[0];
|
||||
uint8_t requested_size = (uint8_t)c->core.old.arg[0];
|
||||
func_return = EPA_PACE_Get_Nonce(requested_size, nonce);
|
||||
// check if the command succeeded
|
||||
if (func_return < 0) {
|
||||
@@ -430,23 +430,23 @@ int EPA_PACE_MSE_Set_AT(pace_version_info_t pace_version_info, uint8_t password)
|
||||
//-----------------------------------------------------------------------------
|
||||
// Perform the PACE protocol by replaying given APDUs
|
||||
//-----------------------------------------------------------------------------
|
||||
void EPA_PACE_Replay(UsbCommand *c) {
|
||||
void EPA_PACE_Replay(UsbCommandNG *c) {
|
||||
uint32_t timings[sizeof(apdu_lengths_replay) / sizeof(apdu_lengths_replay[0])] = {0};
|
||||
|
||||
// if an APDU has been passed, save it
|
||||
if (c->arg[0] != 0) {
|
||||
if (c->core.old.arg[0] != 0) {
|
||||
// make sure it's not too big
|
||||
if (c->arg[2] > apdus_replay[c->arg[0] - 1].len) {
|
||||
if (c->core.old.arg[2] > apdus_replay[c->core.old.arg[0] - 1].len) {
|
||||
cmd_send(CMD_ACK, 1, 0, 0, NULL, 0);
|
||||
}
|
||||
memcpy(apdus_replay[c->arg[0] - 1].data + c->arg[1],
|
||||
c->d.asBytes,
|
||||
c->arg[2]);
|
||||
memcpy(apdus_replay[c->core.old.arg[0] - 1].data + c->core.old.arg[1],
|
||||
c->core.old.d.asBytes,
|
||||
c->core.old.arg[2]);
|
||||
// save/update APDU length
|
||||
if (c->arg[1] == 0) {
|
||||
apdu_lengths_replay[c->arg[0] - 1] = c->arg[2];
|
||||
if (c->core.old.arg[1] == 0) {
|
||||
apdu_lengths_replay[c->core.old.arg[0] - 1] = c->core.old.arg[2];
|
||||
} else {
|
||||
apdu_lengths_replay[c->arg[0] - 1] += c->arg[2];
|
||||
apdu_lengths_replay[c->core.old.arg[0] - 1] += c->core.old.arg[2];
|
||||
}
|
||||
cmd_send(CMD_ACK, 0, 0, 0, NULL, 0);
|
||||
return;
|
||||
|
||||
+4
-4
@@ -475,13 +475,13 @@ static void iso18092_setup(uint8_t fpga_minor_mode) {
|
||||
// arg0 FeliCa flags
|
||||
// arg1 len of commandbytes
|
||||
// d.asBytes command bytes to send
|
||||
void felica_sendraw(UsbCommand *c) {
|
||||
void felica_sendraw(UsbCommandNG *c) {
|
||||
|
||||
if (MF_DBGLEVEL > 3) Dbprintf("FeliCa_sendraw Enter");
|
||||
|
||||
felica_command_t param = c->arg[0];
|
||||
size_t len = c->arg[1] & 0xffff;
|
||||
uint8_t *cmd = c->d.asBytes;
|
||||
felica_command_t param = c->core.old.arg[0];
|
||||
size_t len = c->core.old.arg[1] & 0xffff;
|
||||
uint8_t *cmd = c->core.old.d.asBytes;
|
||||
uint32_t arg0;
|
||||
|
||||
felica_card_select_t card;
|
||||
|
||||
+6
-6
@@ -2350,12 +2350,12 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, bool send_chaining, void *data, u
|
||||
// low :: len of commandbytes
|
||||
// arg2 timeout
|
||||
// d.asBytes command bytes to send
|
||||
void ReaderIso14443a(UsbCommand *c) {
|
||||
iso14a_command_t param = c->arg[0];
|
||||
size_t len = c->arg[1] & 0xffff;
|
||||
size_t lenbits = c->arg[1] >> 16;
|
||||
uint32_t timeout = c->arg[2];
|
||||
uint8_t *cmd = c->d.asBytes;
|
||||
void ReaderIso14443a(UsbCommandNG *c) {
|
||||
iso14a_command_t param = c->core.old.arg[0];
|
||||
size_t len = c->core.old.arg[1] & 0xffff;
|
||||
size_t lenbits = c->core.old.arg[1] >> 16;
|
||||
uint32_t timeout = c->core.old.arg[2];
|
||||
uint8_t *cmd = c->core.old.d.asBytes;
|
||||
uint32_t arg0;
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
uint8_t par[MAX_PARITY_SIZE] = {0x00};
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ RAMFUNC int ManchesterDecoding(uint8_t bit, uint16_t offset, uint32_t non_real_t
|
||||
void RAMFUNC SniffIso14443a(uint8_t param);
|
||||
void SimulateIso14443aTag(int tagType, int flags, uint8_t *data);
|
||||
void iso14443a_antifuzz(uint32_t flags);
|
||||
void ReaderIso14443a(UsbCommand *c);
|
||||
void ReaderIso14443a(UsbCommandNG *c);
|
||||
void ReaderTransmit(uint8_t *frame, uint16_t len, uint32_t *timing);
|
||||
void ReaderTransmitBitsPar(uint8_t *frame, uint16_t bits, uint8_t *par, uint32_t *timing);
|
||||
void ReaderTransmitPar(uint8_t *frame, uint16_t len, uint8_t *par, uint32_t *timing);
|
||||
|
||||
+5
-5
@@ -1566,11 +1566,11 @@ void iso14b_set_trigger(bool enable) {
|
||||
* none
|
||||
*
|
||||
*/
|
||||
void SendRawCommand14443B_Ex(UsbCommand *c) {
|
||||
iso14b_command_t param = c->arg[0];
|
||||
size_t len = c->arg[1] & 0xffff;
|
||||
uint32_t timeout = c->arg[2];
|
||||
uint8_t *cmd = c->d.asBytes;
|
||||
void SendRawCommand14443B_Ex(UsbCommandNG *c) {
|
||||
iso14b_command_t param = c->core.old.arg[0];
|
||||
size_t len = c->core.old.arg[1] & 0xffff;
|
||||
uint32_t timeout = c->core.old.arg[2];
|
||||
uint8_t *cmd = c->core.old.d.asBytes;
|
||||
uint8_t status;
|
||||
uint32_t sendlen = sizeof(iso14b_card_select_t);
|
||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ extern "C" {
|
||||
# define AddCrc14B(data, len) compute_crc(CRC_14443_B, (data), (len), (data)+(len), (data)+(len)+1)
|
||||
#endif
|
||||
|
||||
void SendRawCommand14443B_Ex(UsbCommand *c);
|
||||
void SendRawCommand14443B_Ex(UsbCommandNG *c);
|
||||
void iso14443b_setup();
|
||||
uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *response);
|
||||
uint8_t iso14443b_select_card(iso14b_card_select_t *card);
|
||||
|
||||
+12
-12
@@ -84,16 +84,15 @@ static void Fatal(void) {
|
||||
for (;;) {};
|
||||
}
|
||||
|
||||
void UsbPacketReceived(uint8_t *packet, int len) {
|
||||
void UsbPacketReceived(UsbCommandNG *packet) {
|
||||
int i, dont_ack = 0;
|
||||
UsbCommand *c = (UsbCommand *)packet;
|
||||
volatile uint32_t *p;
|
||||
|
||||
//if ( len != sizeof(UsbCommand)) Fatal();
|
||||
|
||||
uint32_t arg0 = (uint32_t)c->arg[0];
|
||||
uint32_t arg0 = (uint32_t)packet->core.old.arg[0];
|
||||
|
||||
switch (c->cmd) {
|
||||
switch (packet->core.old.cmd) {
|
||||
case CMD_DEVICE_INFO: {
|
||||
dont_ack = 1;
|
||||
arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM |
|
||||
@@ -111,7 +110,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||
*/
|
||||
p = (volatile uint32_t *)&_flash_start;
|
||||
for (i = 0; i < 12; i++)
|
||||
p[i + arg0] = c->d.asDwords[i];
|
||||
p[i + arg0] = packet->core.old.d.asDwords[i];
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -119,7 +118,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||
uint32_t *flash_mem = (uint32_t *)(&_flash_start);
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (i = 0 + (64 * j); i < 64 + (64 * j); i++) {
|
||||
flash_mem[i] = c->d.asDwords[i];
|
||||
flash_mem[i] = packet->core.old.d.asDwords[i];
|
||||
}
|
||||
|
||||
uint32_t flash_address = arg0 + (0x100 * j);
|
||||
@@ -155,7 +154,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||
break;
|
||||
|
||||
case CMD_START_FLASH: {
|
||||
if (c->arg[2] == START_FLASH_MAGIC)
|
||||
if (packet->core.old.arg[2] == START_FLASH_MAGIC)
|
||||
bootrom_unlocked = 1;
|
||||
else
|
||||
bootrom_unlocked = 0;
|
||||
@@ -164,8 +163,8 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||
int prot_end = (int)&_bootrom_end;
|
||||
int allow_start = (int)&_flash_start;
|
||||
int allow_end = (int)&_flash_end;
|
||||
int cmd_start = c->arg[0];
|
||||
int cmd_end = c->arg[1];
|
||||
int cmd_start = packet->core.old.arg[0];
|
||||
int cmd_end = packet->core.old.arg[1];
|
||||
|
||||
/* Only allow command if the bootrom is unlocked, or the parameters are outside of the protected
|
||||
* bootrom area. In any case they must be within the flash area.
|
||||
@@ -197,7 +196,7 @@ static void flash_mode(int externally_entered) {
|
||||
start_addr = 0;
|
||||
end_addr = 0;
|
||||
bootrom_unlocked = 0;
|
||||
uint8_t rx[sizeof(UsbCommand)];
|
||||
UsbCommandNG rx;
|
||||
|
||||
usb_enable();
|
||||
|
||||
@@ -209,8 +208,9 @@ static void flash_mode(int externally_entered) {
|
||||
|
||||
// Check if there is a usb packet available
|
||||
if (usb_poll_validate_length()) {
|
||||
if (usb_read(rx, sizeof(rx)))
|
||||
UsbPacketReceived(rx, sizeof(rx));
|
||||
// TODO DOEGOX
|
||||
if (usb_read((uint8_t *)&rx, sizeof(rx)))
|
||||
UsbPacketReceived(&rx);
|
||||
}
|
||||
|
||||
if (!externally_entered && !BUTTON_PRESS()) {
|
||||
|
||||
+2
-2
@@ -517,11 +517,11 @@ static int CmdAnalyseA(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "got ack. Status %d", resp.arg[0]);
|
||||
PrintAndLogEx(NORMAL, "got ack. Status %d", resp.core.old.arg[0]);
|
||||
return 0;
|
||||
/*
|
||||
PrintAndLogEx(NORMAL, "-- " _BLUE_("its my message") "\n");
|
||||
|
||||
+11
-11
@@ -1457,7 +1457,7 @@ int getSamples(uint32_t n, bool silent) {
|
||||
|
||||
if (!silent) PrintAndLogEx(NORMAL, "Reading %d bytes from device memory\n", n);
|
||||
|
||||
UsbCommand response;
|
||||
UsbReplyNG response;
|
||||
if (!GetFromDevice(BIG_BUF, got, n, 0, &response, 10000, true)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
@@ -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.arg[0] > 0) {
|
||||
sample_config *sc = (sample_config *) response.d.asBytes;
|
||||
if (response.core.old.arg[0] > 0) {
|
||||
sample_config *sc = (sample_config *) response.core.old.d.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;
|
||||
}
|
||||
@@ -1532,7 +1532,7 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
while (!WaitForResponseTimeout(CMD_MEASURED_ANTENNA_TUNING, &resp, 2000)) {
|
||||
timeout++;
|
||||
printf(".");
|
||||
@@ -1544,12 +1544,12 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint32_t v_lf125 = resp.arg[0];
|
||||
uint32_t v_lf134 = resp.arg[0] >> 32;
|
||||
uint32_t v_lf125 = resp.core.old.arg[0];
|
||||
uint32_t v_lf134 = resp.core.old.arg[0] >> 32;
|
||||
|
||||
uint32_t v_hf = resp.arg[1];
|
||||
uint32_t peakf = resp.arg[2];
|
||||
uint32_t peakv = resp.arg[2] >> 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;
|
||||
|
||||
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.d.asBytes[i] - 128;
|
||||
test1 += resp.d.asBytes[i];
|
||||
GraphBuffer[i] = resp.core.old.d.asBytes[i] - 128;
|
||||
test1 += resp.core.old.d.asBytes[i];
|
||||
}
|
||||
|
||||
if (test1 > 0) {
|
||||
|
||||
@@ -283,14 +283,14 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
||||
bytes_remaining -= bytes_in_packet;
|
||||
bytes_sent += bytes_in_packet;
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t isok = resp.arg[0] & 0xFF;
|
||||
uint8_t isok = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isok)
|
||||
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
|
||||
|
||||
@@ -392,12 +392,12 @@ static int CmdFlashMemWipe(const char *Cmd) {
|
||||
UsbCommand c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 8000)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
}
|
||||
uint8_t isok = resp.arg[0] & 0xFF;
|
||||
uint8_t isok = resp.core.old.arg[0] & 0xFF;
|
||||
if (isok)
|
||||
PrintAndLogEx(SUCCESS, "Flash WIPE ok");
|
||||
else
|
||||
@@ -438,13 +438,13 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
||||
UsbCommand c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t isok = resp.arg[0] & 0xFF;
|
||||
uint8_t isok = resp.core.old.arg[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.d.asBytes, sizeof(rdv40_validation_t));
|
||||
memcpy(&mem, (rdv40_validation_t *)resp.core.old.d.asBytes, sizeof(rdv40_validation_t));
|
||||
|
||||
// Flash ID hash (sha1)
|
||||
mbedtls_sha1(mem.flashid, sizeof(mem.flashid), sha_hash);
|
||||
@@ -572,7 +572,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
} else {
|
||||
|
||||
if (!resp.arg[0])
|
||||
if (!resp.core.old.arg[0])
|
||||
PrintAndLogEx(FAILED, "Writing signature failed");
|
||||
else
|
||||
PrintAndLogEx(SUCCESS, "Writing signature ok [offset: %u]", FLASH_MEM_SIGNATURE_OFFSET);
|
||||
|
||||
+48
-48
@@ -231,12 +231,12 @@ int Hf14443_4aGetCardData(iso14a_card_select_t *card) {
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
memcpy(card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
|
||||
uint64_t select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
uint64_t select_status = resp.core.old.arg[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.arg[0]);
|
||||
PrintAndLogEx(NORMAL, " SAK: %02x [%" PRIu64 "]", card->sak, resp.core.old.arg[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;
|
||||
@@ -303,7 +303,7 @@ static int CmdHF14AReader(const char *Cmd) {
|
||||
SendCommand(&c);
|
||||
|
||||
if (ISO14A_CONNECT & cm) {
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
DropField();
|
||||
@@ -311,7 +311,7 @@ static int CmdHF14AReader(const char *Cmd) {
|
||||
}
|
||||
|
||||
iso14a_card_select_t card;
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.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.arg[0];
|
||||
uint64_t select_status = resp.core.old.arg[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.arg[0]);
|
||||
PrintAndLogEx(NORMAL, " SAK : %02x [%" PRIu64 "]", card.sak, resp.core.old.arg[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));
|
||||
@@ -388,13 +388,13 @@ static int CmdHF14ACUIDs(const char *Cmd) {
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
iso14a_card_select_t *card = (iso14a_card_select_t *) resp.d.asBytes;
|
||||
iso14a_card_select_t *card = (iso14a_card_select_t *) resp.core.old.d.asBytes;
|
||||
|
||||
// check if command failed
|
||||
if (resp.arg[0] == 0) {
|
||||
if (resp.core.old.arg[0] == 0) {
|
||||
PrintAndLogEx(WARNING, "card select failed.");
|
||||
} else {
|
||||
char uid_string[20];
|
||||
@@ -487,16 +487,16 @@ int CmdHF14ASim(const char *Cmd) {
|
||||
memcpy(c.d.asBytes, uid, uidlen >> 1);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
||||
|
||||
while (!ukbhit()) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
if (!(flags & FLAG_NR_AR_ATTACK)) break;
|
||||
if ((resp.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
|
||||
if ((resp.core.old.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
|
||||
|
||||
memcpy(data, resp.d.asBytes, sizeof(data));
|
||||
memcpy(data, resp.core.old.d.asBytes, sizeof(data));
|
||||
readerAttack(data[0], setEmulatorMem, verbose);
|
||||
}
|
||||
showSectorTable();
|
||||
@@ -525,7 +525,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
|
||||
if (activateField) {
|
||||
responseNum = 1;
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
// Anticollision + SELECT card
|
||||
UsbCommand ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
@@ -536,17 +536,17 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
}
|
||||
|
||||
// check result
|
||||
if (resp.arg[0] == 0) {
|
||||
if (resp.core.old.arg[0] == 0) {
|
||||
PrintAndLogEx(ERR, "No card in field.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] != 1 && resp.arg[0] != 2) {
|
||||
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.arg[0]);
|
||||
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]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
if (resp.core.old.arg[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}}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
@@ -557,7 +557,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] == 0) { // ats_len
|
||||
if (resp.core.old.arg[0] == 0) { // ats_len
|
||||
PrintAndLogEx(ERR, "Can't get ATS.");
|
||||
return 1;
|
||||
}
|
||||
@@ -575,11 +575,11 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
SendCommand(&c);
|
||||
|
||||
uint8_t *recv;
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
recv = resp.d.asBytes;
|
||||
int iLen = resp.arg[0];
|
||||
recv = resp.core.old.d.asBytes;
|
||||
int iLen = resp.core.old.arg[0];
|
||||
|
||||
if (!iLen) {
|
||||
PrintAndLogEx(ERR, "No card response.");
|
||||
@@ -617,7 +617,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||
}
|
||||
|
||||
static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
frameLength = 0;
|
||||
|
||||
@@ -635,17 +635,17 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
||||
}
|
||||
|
||||
// check result
|
||||
if (resp.arg[0] == 0) {
|
||||
if (resp.core.old.arg[0] == 0) {
|
||||
PrintAndLogEx(ERR, "No card in field.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] != 1 && resp.arg[0] != 2) {
|
||||
PrintAndLogEx(ERR, "Card not in iso14443-4. res=%d.", resp.arg[0]);
|
||||
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]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
if (resp.core.old.arg[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}}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
@@ -656,20 +656,20 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (resp.arg[0] == 0) { // ats_len
|
||||
if (resp.core.old.arg[0] == 0) { // ats_len
|
||||
PrintAndLogEx(ERR, "Can't get ATS.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get frame length from ATS in data field
|
||||
if (resp.arg[0] > 1) {
|
||||
uint8_t fsci = resp.d.asBytes[1] & 0x0f;
|
||||
if (resp.core.old.arg[0] > 1) {
|
||||
uint8_t fsci = resp.core.old.d.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.d.asBytes;
|
||||
iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.core.old.d.asBytes;
|
||||
if (vcard->ats_len > 1) {
|
||||
uint8_t fsci = vcard->ats[1] & 0x0f;
|
||||
if (fsci < sizeof(atsFSC) / sizeof(atsFSC[0]))
|
||||
@@ -712,12 +712,12 @@ static int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool
|
||||
SendCommand(&c);
|
||||
|
||||
uint8_t *recv;
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
recv = resp.d.asBytes;
|
||||
int iLen = resp.arg[0];
|
||||
uint8_t res = resp.arg[1];
|
||||
recv = resp.core.old.d.asBytes;
|
||||
int iLen = resp.core.old.arg[0];
|
||||
uint8_t res = resp.core.old.arg[1];
|
||||
|
||||
int dlen = iLen - 2;
|
||||
if (dlen < 0)
|
||||
@@ -1047,12 +1047,12 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
|
||||
}
|
||||
|
||||
static int waitCmd(uint8_t iSelect) {
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint16_t len = (resp.arg[0] & 0xFFFF);
|
||||
uint16_t len = (resp.core.old.arg[0] & 0xFFFF);
|
||||
if (iSelect) {
|
||||
len = (resp.arg[1] & 0xFFFF);
|
||||
len = (resp.core.old.arg[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.d.asBytes, len));
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 3;
|
||||
@@ -1164,7 +1164,7 @@ int infoHF14A(bool verbose, bool do_nack_test) {
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
DropField();
|
||||
@@ -1172,7 +1172,7 @@ int infoHF14A(bool verbose, bool do_nack_test) {
|
||||
}
|
||||
|
||||
iso14a_card_select_t card;
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.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.arg[0];
|
||||
uint64_t select_status = resp.core.old.arg[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.arg[0]);
|
||||
PrintAndLogEx(NORMAL, " SAK : %02x [%" PRIu64 "]", card.sak, resp.core.old.arg[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.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
|
||||
select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
|
||||
select_status = resp.core.old.arg[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.d.asBytes, resp.arg[0]);
|
||||
card.ats_len = resp.arg[0]; // note: ats_len includes CRC Bytes
|
||||
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
|
||||
}
|
||||
|
||||
if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes
|
||||
|
||||
+31
-31
@@ -124,15 +124,15 @@ static int switch_off_field_14b(void) {
|
||||
static bool waitCmd14b(bool verbose) {
|
||||
|
||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
|
||||
if ((resp.arg[0] & 0xFF) > 0) return false;
|
||||
if ((resp.core.old.arg[0] & 0xFF) > 0) return false;
|
||||
|
||||
uint16_t len = (resp.arg[1] & 0xFFFF);
|
||||
uint16_t len = (resp.core.old.arg[1] & 0xFFFF);
|
||||
|
||||
memcpy(data, resp.d.asBytes, len);
|
||||
memcpy(data, resp.core.old.d.asBytes, len);
|
||||
|
||||
if (verbose) {
|
||||
if (len >= 3) {
|
||||
@@ -301,7 +301,7 @@ static bool get_14b_UID(iso14b_card_select_t *card) {
|
||||
return false;
|
||||
|
||||
int8_t retry = 3;
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
|
||||
// test for 14b SR
|
||||
@@ -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.arg[0];
|
||||
uint8_t status = resp.core.old.arg[0];
|
||||
if (status == 0) {
|
||||
memcpy(card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(card, (iso14b_card_select_t *)resp.core.old.d.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.arg[0];
|
||||
uint8_t status = resp.core.old.arg[0];
|
||||
if (status == 0) {
|
||||
memcpy(card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ static bool HF14B_Std_Info(bool verbose) {
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
@@ -521,9 +521,9 @@ static bool HF14B_Std_Info(bool verbose) {
|
||||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.arg[0];
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
@@ -553,7 +553,7 @@ static bool HF14B_ST_Info(bool verbose) {
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
@@ -561,9 +561,9 @@ static bool HF14B_ST_Info(bool verbose) {
|
||||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.arg[0];
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
if (status > 0)
|
||||
return false;
|
||||
|
||||
@@ -610,16 +610,16 @@ static bool HF14B_ST_Reader(bool verbose) {
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
return false;
|
||||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.arg[0];
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
@@ -650,7 +650,7 @@ static bool HF14B_Std_Reader(bool verbose) {
|
||||
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
@@ -658,9 +658,9 @@ static bool HF14B_Std_Reader(bool verbose) {
|
||||
}
|
||||
|
||||
iso14b_card_select_t card;
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
memcpy(&card, (iso14b_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14b_card_select_t));
|
||||
|
||||
uint64_t status = resp.arg[0];
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
|
||||
switch (status) {
|
||||
case 0:
|
||||
@@ -697,7 +697,7 @@ static bool HF14B_Other_Reader() {
|
||||
|
||||
// clearCommandBuffer();
|
||||
// SendCommand(&c);
|
||||
// UsbCommand resp;
|
||||
// UsbReplyNG resp;
|
||||
// WaitForResponse(CMD_ACK,&resp);
|
||||
|
||||
// if (datalen > 2 ) {
|
||||
@@ -712,7 +712,7 @@ static bool HF14B_Other_Reader() {
|
||||
// c.d.asBytes[0] = ISO14443B_AUTHENTICATE;
|
||||
// clearCommandBuffer();
|
||||
// SendCommand(&c);
|
||||
// UsbCommand resp;
|
||||
// UsbReplyNG resp;
|
||||
// WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
// if (datalen > 0) {
|
||||
@@ -727,7 +727,7 @@ static bool HF14B_Other_Reader() {
|
||||
// c.d.asBytes[0] = ISO14443B_RESET;
|
||||
// clearCommandBuffer();
|
||||
// SendCommand(&c);
|
||||
// UsbCommand resp;
|
||||
// UsbReplyNG resp;
|
||||
// WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
// if (datalen > 0) {
|
||||
@@ -901,15 +901,15 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||
int blocknum = 0;
|
||||
uint8_t *recv = NULL;
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand 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.arg[0]) {
|
||||
PrintAndLogEx(INFO, "failed to select %d | %d", resp.arg[0], resp.arg[1]);
|
||||
if (resp.core.old.arg[0]) {
|
||||
PrintAndLogEx(INFO, "failed to select %d | %d", resp.core.old.arg[0], resp.core.old.arg[1]);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -929,20 +929,20 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
||||
uint8_t status = resp.arg[0] & 0xFF;
|
||||
uint8_t status = resp.core.old.arg[0] & 0xFF;
|
||||
if (status > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint16_t len = (resp.arg[1] & 0xFFFF);
|
||||
recv = resp.d.asBytes;
|
||||
uint16_t len = (resp.core.old.arg[1] & 0xFFFF);
|
||||
recv = resp.core.old.d.asBytes;
|
||||
|
||||
if (!check_crc(CRC_14443_B, recv, len)) {
|
||||
PrintAndLogEx(FAILED, "crc fail, retrying one more time");
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(data + (blocknum * 4), resp.d.asBytes, 4);
|
||||
memcpy(data + (blocknum * 4), resp.core.old.d.asBytes, 4);
|
||||
|
||||
if (blocknum == 0xFF) {
|
||||
//last read.
|
||||
|
||||
+25
-25
@@ -198,7 +198,7 @@ const productName uidmapping[] = {
|
||||
// returns 1 if suceeded
|
||||
static int getUID(uint8_t *buf) {
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand 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;
|
||||
@@ -218,9 +218,9 @@ static int getUID(uint8_t *buf) {
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
||||
uint8_t resplen = resp.arg[0];
|
||||
if (resplen >= 12 && CheckCrc15(resp.d.asBytes, 12)) {
|
||||
memcpy(buf, resp.d.asBytes + 2, 8);
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -594,7 +594,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') return usage_15_info();
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
uint8_t *recv;
|
||||
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
uint8_t *req = c.d.asBytes;
|
||||
@@ -619,14 +619,14 @@ static int CmdHF15Info(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t status = resp.arg[0];
|
||||
uint32_t status = resp.core.old.arg[0];
|
||||
|
||||
if (status < 2) {
|
||||
PrintAndLogEx(WARNING, "iso15693 card doesn't answer to systeminfo command");
|
||||
return 1;
|
||||
}
|
||||
|
||||
recv = resp.d.asBytes;
|
||||
recv = resp.core.old.d.asBytes;
|
||||
|
||||
if (recv[0] & ISO15_RES_ERROR) {
|
||||
PrintAndLogEx(WARNING, "iso15693 card returned error %i: %s", recv[0], TagErrorStr(recv[0]));
|
||||
@@ -783,7 +783,7 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
uint8_t data[256 * 4] = {0};
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand 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;
|
||||
@@ -803,13 +803,13 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
||||
uint8_t len = resp.arg[0];
|
||||
uint8_t len = resp.core.old.arg[0];
|
||||
if (len < 2) {
|
||||
PrintAndLogEx(FAILED, "iso15693 card select failed");
|
||||
continue;
|
||||
}
|
||||
|
||||
recv = resp.d.asBytes;
|
||||
recv = resp.core.old.d.asBytes;
|
||||
|
||||
if (!CheckCrc15(recv, len)) {
|
||||
PrintAndLogEx(FAILED, "crc fail");
|
||||
@@ -821,9 +821,9 @@ static int CmdHF15Dump(const char *Cmd) {
|
||||
break;
|
||||
}
|
||||
|
||||
mem[blocknum].lock = resp.d.asBytes[0];
|
||||
memcpy(mem[blocknum].block, resp.d.asBytes + 1, 4);
|
||||
memcpy(data + (blocknum * 4), resp.d.asBytes + 1, 4);
|
||||
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);
|
||||
|
||||
retry = 0;
|
||||
blocknum++;
|
||||
@@ -859,7 +859,7 @@ static int CmdHF15Raw(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_raw();
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
int reply = 1, fast = 1, i = 0;
|
||||
bool crc = false;
|
||||
@@ -926,9 +926,9 @@ static int CmdHF15Raw(const char *Cmd) {
|
||||
|
||||
if (reply) {
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
uint8_t len = resp.arg[0];
|
||||
uint8_t len = resp.core.old.arg[0];
|
||||
PrintAndLogEx(NORMAL, "received %i octets", len);
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.d.asBytes, len));
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
}
|
||||
@@ -945,7 +945,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_readmulti();
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
uint8_t *recv;
|
||||
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
uint8_t *req = c.d.asBytes;
|
||||
@@ -986,13 +986,13 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t status = resp.arg[0];
|
||||
uint32_t status = resp.core.old.arg[0];
|
||||
if (status < 2) {
|
||||
PrintAndLogEx(FAILED, "iso15693 card select failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
recv = resp.d.asBytes;
|
||||
recv = resp.core.old.d.asBytes;
|
||||
|
||||
if (!CheckCrc15(recv, status)) {
|
||||
PrintAndLogEx(FAILED, "CRC failed");
|
||||
@@ -1028,7 +1028,7 @@ static int CmdHF15Read(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_read();
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
uint8_t *recv;
|
||||
|
||||
// UsbCommand arg: len, speed, recv?
|
||||
@@ -1066,13 +1066,13 @@ static int CmdHF15Read(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t status = resp.arg[0];
|
||||
uint32_t status = resp.core.old.arg[0];
|
||||
if (status < 2) {
|
||||
PrintAndLogEx(NORMAL, "iso15693 card select failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
recv = resp.d.asBytes;
|
||||
recv = resp.core.old.d.asBytes;
|
||||
|
||||
if (!CheckCrc15(recv, status)) {
|
||||
PrintAndLogEx(NORMAL, "CRC failed");
|
||||
@@ -1102,7 +1102,7 @@ static int CmdHF15Write(const char *Cmd) {
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_write();
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
uint8_t *recv;
|
||||
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
uint8_t *req = c.d.asBytes;
|
||||
@@ -1150,13 +1150,13 @@ static int CmdHF15Write(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t status = resp.arg[0];
|
||||
uint32_t status = resp.core.old.arg[0];
|
||||
if (status < 2) {
|
||||
PrintAndLogEx(FAILED, "iso15693 card select failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
recv = resp.d.asBytes;
|
||||
recv = resp.core.old.d.asBytes;
|
||||
|
||||
if (!CheckCrc15(recv, status)) {
|
||||
PrintAndLogEx(FAILED, "CRC failed");
|
||||
|
||||
+19
-19
@@ -34,17 +34,17 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
|
||||
UsbCommand c = {CMD_EPA_PACE_COLLECT_NONCE, {(int)m, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
// check if command failed
|
||||
if (resp.arg[0] != 0) {
|
||||
PrintAndLogEx(FAILED, "Error in step %d, Return code: %d", resp.arg[0], (int)resp.arg[1]);
|
||||
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]);
|
||||
} else {
|
||||
size_t nonce_length = resp.arg[1];
|
||||
size_t nonce_length = resp.core.old.arg[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.d.asBytes[j]);
|
||||
sprintf(nonce + (2 * j), "%02X", resp.core.old.d.asBytes[j]);
|
||||
}
|
||||
// print nonce
|
||||
PrintAndLogEx(NORMAL, "Length: %d, Nonce: %s", nonce_length, nonce);
|
||||
@@ -72,7 +72,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
||||
"Example:\n preplay 0022C1A4 1068000000 1086000002 1234ABCDEF 1A2B3C4D";
|
||||
|
||||
// Proxmark response
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
int skip = 0, skip_add = 0, scan_return;
|
||||
// for each APDU
|
||||
@@ -132,7 +132,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&usb_cmd);
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
if (resp.arg[0] != 0) {
|
||||
if (resp.core.old.arg[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.arg[0] != 0) {
|
||||
PrintAndLogEx(NORMAL, "\nPACE replay failed in step %u!", (uint32_t)resp.arg[0]);
|
||||
if (resp.core.old.arg[0] != 0) {
|
||||
PrintAndLogEx(NORMAL, "\nPACE replay failed in step %u!", (uint32_t)resp.core.old.arg[0]);
|
||||
PrintAndLogEx(NORMAL, "Measured times:");
|
||||
PrintAndLogEx(NORMAL, "MSE Set AT: %u us", resp.d.asDwords[0]);
|
||||
PrintAndLogEx(NORMAL, "GA Get Nonce: %u us", resp.d.asDwords[1]);
|
||||
PrintAndLogEx(NORMAL, "GA Map Nonce: %u us", resp.d.asDwords[2]);
|
||||
PrintAndLogEx(NORMAL, "GA Perform Key Agreement: %u us", resp.d.asDwords[3]);
|
||||
PrintAndLogEx(NORMAL, "GA Mutual Authenticate: %u us", resp.d.asDwords[4]);
|
||||
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]);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "PACE replay successfull!");
|
||||
PrintAndLogEx(NORMAL, "MSE Set AT: %u us", resp.d.asDwords[0]);
|
||||
PrintAndLogEx(NORMAL, "GA Get Nonce: %u us", resp.d.asDwords[1]);
|
||||
PrintAndLogEx(NORMAL, "GA Map Nonce: %u us", resp.d.asDwords[2]);
|
||||
PrintAndLogEx(NORMAL, "GA Perform Key Agreement: %u us", resp.d.asDwords[3]);
|
||||
PrintAndLogEx(NORMAL, "GA Mutual Authenticate: %u us", resp.d.asDwords[4]);
|
||||
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]);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
+10
-10
@@ -132,7 +132,7 @@ static int CmdHFFelicaSim(const char *Cmd) {
|
||||
memcpy(c.d.asBytes, uid, uidlen >> 1);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "Press pm3-button to abort simulation");
|
||||
@@ -355,7 +355,7 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
||||
UsbCommand c = {CMD_FELICA_LITE_DUMP, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
@@ -375,12 +375,12 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (resp.arg[0] == 0) {
|
||||
if (resp.core.old.arg[0] == 0) {
|
||||
PrintAndLogEx(WARNING, "\nButton pressed. Aborted.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint64_t tracelen = resp.arg[1];
|
||||
uint64_t tracelen = resp.core.old.arg[1];
|
||||
if (tracelen == 0)
|
||||
return 1;
|
||||
|
||||
@@ -412,14 +412,14 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
||||
}
|
||||
|
||||
static void waitCmdFelica(uint8_t iSelect) {
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
uint16_t len = iSelect ? (resp.arg[1] & 0xffff) : (resp.arg[0] & 0xffff);
|
||||
uint16_t len = iSelect ? (resp.core.old.arg[1] & 0xffff) : (resp.core.old.arg[0] & 0xffff);
|
||||
PrintAndLogEx(NORMAL, "received %i octets", len);
|
||||
if (!len)
|
||||
return;
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.d.asBytes, len));
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex(resp.core.old.d.asBytes, len));
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
}
|
||||
@@ -572,7 +572,7 @@ int readFelicaUid(bool verbose) {
|
||||
UsbCommand c = {CMD_FELICA_COMMAND, {FELICA_CONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "FeliCa card select failed");
|
||||
//SendCommand(&cDisconnect);
|
||||
@@ -580,8 +580,8 @@ int readFelicaUid(bool verbose) {
|
||||
}
|
||||
|
||||
felica_card_select_t card;
|
||||
memcpy(&card, (felica_card_select_t *)resp.d.asBytes, sizeof(felica_card_select_t));
|
||||
uint64_t status = resp.arg[0];
|
||||
memcpy(&card, (felica_card_select_t *)resp.core.old.d.asBytes, sizeof(felica_card_select_t));
|
||||
uint64_t status = resp.core.old.arg[0];
|
||||
|
||||
switch (status) {
|
||||
case 1: {
|
||||
|
||||
+37
-37
@@ -381,7 +381,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
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}}};
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
memcpy(c.d.asBytes, csns, 8 * NUM_CSNS);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
@@ -399,7 +399,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
uint8_t num_mac = resp.arg[1];
|
||||
uint8_t num_mac = resp.core.old.arg[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.d.asBytes + i * 16, 8);
|
||||
memcpy(dump + i * 24 + 8, resp.core.old.d.asBytes + i * 16, 8);
|
||||
// NR_MAC (eight bytes from the response) ( 8b csn + 8b epurse == 16)
|
||||
memcpy(dump + i * 24 + 16, resp.d.asBytes + i * 16 + 8, 8);
|
||||
memcpy(dump + i * 24 + 16, resp.core.old.d.asBytes + i * 16 + 8, 8);
|
||||
}
|
||||
/** Now, save to dumpfile **/
|
||||
saveFile("iclass_mac_attack", "bin", dump, datalen);
|
||||
@@ -434,7 +434,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
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}}};
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
memcpy(c.d.asBytes, csns, 8 * NUM_CSNS);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
@@ -452,7 +452,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
uint8_t num_mac = resp.arg[1];
|
||||
uint8_t num_mac = resp.core.old.arg[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.d.asBytes + i * 16, 8);
|
||||
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.core.old.d.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.d.asBytes + i * 16 + 8, 8);
|
||||
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.core.old.d.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.d.asBytes + resp_index, 8);
|
||||
memcpy(dump + i * MAC_ITEM_SIZE + 8, resp.core.old.d.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.d.asBytes + resp_index + 8, 8);
|
||||
memcpy(dump + i * MAC_ITEM_SIZE + 16, resp.core.old.d.asBytes + resp_index + 8, 8);
|
||||
resp_index++;
|
||||
}
|
||||
saveFile("iclass_mac_attack_keyroll_B", "bin", dump, datalen);
|
||||
@@ -767,7 +767,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) {
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand c = {CMD_READER_ICLASS, {0}, {{0}}};
|
||||
c.arg[0] = FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_CC | FLAG_ICLASS_READER_ONE_TRY;
|
||||
|
||||
@@ -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.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
uint8_t *data = resp.core.old.d.asBytes;
|
||||
|
||||
memcpy(CSN, data, 8);
|
||||
|
||||
@@ -818,7 +818,7 @@ static bool select_and_auth(uint8_t *KEY, uint8_t *MAC, uint8_t *div_key, bool u
|
||||
if (verbose) PrintAndLogEx(SUCCESS, "authing with %s: %s", rawkey ? "raw key" : "diversified key", sprint_hex(div_key, 8));
|
||||
|
||||
doMAC(CCNR, div_key, MAC);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand d = {CMD_ICLASS_AUTHENTICATION, {0, 0, 0}, {{0}}};
|
||||
memcpy(d.d.asBytes, MAC, 4);
|
||||
clearCommandBuffer();
|
||||
@@ -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.arg[0] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isOK) {
|
||||
if (verbose) PrintAndLogEx(FAILED, "authentication error");
|
||||
return false;
|
||||
@@ -940,7 +940,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
||||
|
||||
//get config and first 3 blocks
|
||||
UsbCommand c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
uint8_t tag_data[255 * 8];
|
||||
|
||||
clearCommandBuffer();
|
||||
@@ -952,8 +952,8 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
||||
}
|
||||
DropField();
|
||||
|
||||
uint8_t readStatus = resp.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t readStatus = resp.core.old.arg[0] & 0xff;
|
||||
uint8_t *data = resp.core.old.d.asBytes;
|
||||
|
||||
if (readStatus == 0) {
|
||||
PrintAndLogEx(FAILED, "no tag found");
|
||||
@@ -1000,14 +1000,14 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
||||
}
|
||||
// dump cmd switch off at device when finised.
|
||||
|
||||
uint32_t blocksRead = resp.arg[1];
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint32_t blocksRead = resp.core.old.arg[1];
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
if (!isOK && !blocksRead) {
|
||||
PrintAndLogEx(WARNING, "read block failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t startindex = resp.arg[2];
|
||||
uint32_t startindex = resp.core.old.arg[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.arg[0] & 0xff;
|
||||
blocksRead = resp.arg[1];
|
||||
isOK = resp.core.old.arg[0] & 0xff;
|
||||
blocksRead = resp.core.old.arg[1];
|
||||
if (!isOK && !blocksRead) {
|
||||
PrintAndLogEx(WARNING, "read block failed 2");
|
||||
return 0;
|
||||
}
|
||||
|
||||
startindex = resp.arg[2];
|
||||
startindex = resp.core.old.arg[2];
|
||||
if (blocksRead * 8 > sizeof(tag_data) - gotBytes) {
|
||||
PrintAndLogEx(FAILED, "data exceeded buffer size!");
|
||||
blocksRead = (sizeof(tag_data) - gotBytes) / 8;
|
||||
@@ -1097,7 +1097,7 @@ static int WriteBlock(uint8_t blockno, uint8_t *bldata, uint8_t *KEY, bool use_c
|
||||
if (!select_and_auth(KEY, MAC, div_key, use_credit_key, elite, rawkey, verbose))
|
||||
return 0;
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
Calc_wb_mac(blockno, bldata, div_key, MAC);
|
||||
UsbCommand w = {CMD_ICLASS_WRITEBLOCK, {blockno}, {{0}}};
|
||||
@@ -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.arg[0] & 0xff;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
if (isOK)
|
||||
PrintAndLogEx(SUCCESS, "Write block successful");
|
||||
else
|
||||
@@ -1342,7 +1342,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
||||
PrintAndLogEx(NORMAL, " MAC |%02x%02x%02x%02x|\n", p[8], p[9], p[10], p[11]);
|
||||
}
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&w);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
|
||||
@@ -1367,7 +1367,7 @@ static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite,
|
||||
return 0;
|
||||
}
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
UsbCommand c = {CMD_ICLASS_READBLOCK, {blockno}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
@@ -1376,13 +1376,13 @@ static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite,
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
if (!isOK) {
|
||||
PrintAndLogEx(WARNING, "read block failed");
|
||||
return 0;
|
||||
}
|
||||
//data read is stored in: resp.d.asBytes[0-15]
|
||||
PrintAndLogEx(NORMAL, "block %02X: %s\n", blockno, sprint_hex(resp.d.asBytes, 8));
|
||||
//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));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1987,7 +1987,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
memcpy(c.d.asBytes, pre + i, 4 * keys);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
timeout++;
|
||||
@@ -1999,8 +1999,8 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t found = resp.arg[1] & 0xFF;
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
uint8_t found = resp.core.old.arg[1] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
|
||||
t2 = msclock() - t2;
|
||||
switch (isOK) {
|
||||
@@ -2467,14 +2467,14 @@ int readIclass(bool loop, bool verbose) {
|
||||
|
||||
UsbCommand c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
|
||||
// loop in client not device - else on windows have a communication error
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
while (!ukbhit()) {
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
|
||||
uint8_t readStatus = resp.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t readStatus = resp.core.old.arg[0] & 0xff;
|
||||
uint8_t *data = resp.core.old.d.asBytes;
|
||||
|
||||
if (verbose) PrintAndLogEx(NORMAL, "Readstatus:%02x", readStatus);
|
||||
// no tag found or button pressed
|
||||
|
||||
+17
-17
@@ -644,7 +644,7 @@ static int CmdLegicRfWrite(const char *Cmd) {
|
||||
|
||||
UsbCommand c = {CMD_WRITER_LEGIC_RF, {offset, len, IV}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, len);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
@@ -661,7 +661,7 @@ static int CmdLegicRfWrite(const char *Cmd) {
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isOK) {
|
||||
PrintAndLogEx(WARNING, "Failed writing tag");
|
||||
return 1;
|
||||
@@ -759,7 +759,7 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
|
||||
UsbCommand c = {CMD_READER_LEGIC_RF, {offset, len, iv}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
@@ -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.arg[0] & 0xFF;
|
||||
*outlen = resp.arg[1];
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
*outlen = resp.core.old.arg[1];
|
||||
if (!isOK) {
|
||||
PrintAndLogEx(WARNING, "Failed reading tag");
|
||||
return 2;
|
||||
@@ -813,15 +813,15 @@ int legic_get_type(legic_card_select_t *card) {
|
||||
UsbCommand c = {CMD_LEGIC_INFO, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500))
|
||||
return 2;
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isOK)
|
||||
return 3;
|
||||
|
||||
memcpy(card, (legic_card_select_t *)resp.d.asBytes, sizeof(legic_card_select_t));
|
||||
memcpy(card, (legic_card_select_t *)resp.core.old.d.asBytes, sizeof(legic_card_select_t));
|
||||
return 0;
|
||||
}
|
||||
void legic_chk_iv(uint32_t *iv) {
|
||||
@@ -903,7 +903,7 @@ static int CmdLegicDump(const char *Cmd) {
|
||||
UsbCommand c = {CMD_READER_LEGIC_RF, {0x00, dumplen, 0x55}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
@@ -917,13 +917,13 @@ static int CmdLegicDump(const char *Cmd) {
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isOK) {
|
||||
PrintAndLogEx(WARNING, "Failed dumping tag data");
|
||||
return 2;
|
||||
}
|
||||
|
||||
uint16_t readlen = resp.arg[1];
|
||||
uint16_t readlen = resp.core.old.arg[1];
|
||||
uint8_t *data = calloc(readlen, sizeof(uint8_t));
|
||||
if (!data) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
@@ -1050,7 +1050,7 @@ static int CmdLegicRestore(const char *Cmd) {
|
||||
|
||||
// transfer to device
|
||||
UsbCommand c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
for (size_t i = 7; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
|
||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
@@ -1073,9 +1073,9 @@ static int CmdLegicRestore(const char *Cmd) {
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isOK) {
|
||||
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.arg[1] & 0xFF);
|
||||
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.core.old.arg[1] & 0xFF);
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
@@ -1243,7 +1243,7 @@ static int CmdLegicWipe(const char *Cmd) {
|
||||
|
||||
// transfer to device
|
||||
UsbCommand c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
for (size_t i = 7; i < card.cardsize; i += USB_CMD_DATA_SIZE) {
|
||||
|
||||
printf(".");
|
||||
@@ -1268,9 +1268,9 @@ static int CmdLegicWipe(const char *Cmd) {
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "\n");
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xFF;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xFF;
|
||||
if (!isOK) {
|
||||
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.arg[1] & 0xFF);
|
||||
PrintAndLogEx(WARNING, "Failed writing tag [msg = %u]", resp.core.old.arg[1] & 0xFF);
|
||||
free(data);
|
||||
return 4;
|
||||
}
|
||||
|
||||
+38
-38
@@ -414,7 +414,7 @@ static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
DropField();
|
||||
@@ -422,7 +422,7 @@ static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
|
||||
}
|
||||
|
||||
iso14a_card_select_t card;
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.core.old.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
memcpy(uid, card.uid, card.uidlen * sizeof(uint8_t));
|
||||
*uidlen = card.uidlen;
|
||||
return 1;
|
||||
@@ -528,9 +528,9 @@ static int CmdHF14AMfWrBl(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "Command execute timeout");
|
||||
@@ -573,10 +573,10 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
uint8_t *data = resp.core.old.d.asBytes;
|
||||
|
||||
if (isOK) {
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x data:%s", isOK, sprint_hex(data, 16));
|
||||
@@ -644,10 +644,10 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
|
||||
SendCommand(&c);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
isOK = resp.arg[0] & 0xff;
|
||||
data = resp.d.asBytes;
|
||||
isOK = resp.core.old.arg[0] & 0xff;
|
||||
data = resp.core.old.d.asBytes;
|
||||
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||
if (isOK) {
|
||||
@@ -736,7 +736,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
||||
memset(dataFilename, 0, sizeof(dataFilename));
|
||||
|
||||
FILE *f;
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
@@ -809,8 +809,8 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
||||
SendCommand(&c);
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
uint8_t *data = resp.core.old.d.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
|
||||
@@ -865,14 +865,14 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
if (received) {
|
||||
isOK = resp.arg[0] & 0xff;
|
||||
isOK = resp.core.old.arg[0] & 0xff;
|
||||
if (isOK) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (received) {
|
||||
isOK = resp.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
isOK = resp.core.old.arg[0] & 0xff;
|
||||
uint8_t *data = resp.core.old.d.asBytes;
|
||||
if (blockNo == NumBlocksPerSector(sectorNo) - 1) { // sector trailer. Fill in the keys.
|
||||
data[0] = (keyA[sectorNo][0]);
|
||||
data[1] = (keyA[sectorNo][1]);
|
||||
@@ -1050,9 +1050,9 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
@@ -1256,13 +1256,13 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
if (!isOK) continue;
|
||||
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t *data = resp.core.old.d.asBytes;
|
||||
key64 = bytes_to_num(data + 10, 6);
|
||||
if (key64) {
|
||||
PrintAndLogEx(SUCCESS, "data: %s", sprint_hex(data + 10, 6));
|
||||
@@ -2002,13 +2002,13 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t isOK = resp.core.old.arg[0] & 0xff;
|
||||
if (!isOK) continue;
|
||||
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
uint8_t *data = resp.core.old.d.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 CmdHF14AMf1kSim(const char *Cmd) {
|
||||
memcpy(c.d.asBytes, uid, sizeof(uid));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
if (flags & FLAG_INTERACTIVE) {
|
||||
PrintAndLogEx(INFO, "Press pm3-button or send another cmd to abort simulation");
|
||||
@@ -2239,9 +2239,9 @@ static int CmdHF14AMf1kSim(const char *Cmd) {
|
||||
while (!ukbhit()) {
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
if (!(flags & FLAG_NR_AR_ATTACK)) break;
|
||||
if ((resp.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
|
||||
if ((resp.core.old.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
|
||||
|
||||
memcpy(data, resp.d.asBytes, sizeof(data));
|
||||
memcpy(data, resp.core.old.d.asBytes, sizeof(data));
|
||||
readerAttack(data[0], setEmulatorMem, verbose);
|
||||
}
|
||||
showSectorTable();
|
||||
@@ -2291,7 +2291,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
// wait cycle
|
||||
while (true) {
|
||||
@@ -2308,9 +2308,9 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
||||
continue;
|
||||
}
|
||||
|
||||
res = resp.arg[0] & 0xff;
|
||||
traceLen = resp.arg[1];
|
||||
len = resp.arg[2];
|
||||
res = resp.core.old.arg[0] & 0xff;
|
||||
traceLen = resp.core.old.arg[1];
|
||||
len = resp.core.old.arg[2];
|
||||
|
||||
if (res == 0) {
|
||||
PrintAndLogEx(SUCCESS, "hf mifare sniff finished");
|
||||
@@ -2340,7 +2340,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
||||
}
|
||||
|
||||
// what happens if LEN is bigger then TRACELEN --iceman
|
||||
memcpy(bufPtr, resp.d.asBytes, len);
|
||||
memcpy(bufPtr, resp.core.old.d.asBytes, len);
|
||||
bufPtr += len;
|
||||
pckNum++;
|
||||
}
|
||||
@@ -3156,9 +3156,9 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t ok = resp.arg[0] & 0xff;
|
||||
uint8_t ok = resp.core.old.arg[0] & 0xff;
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", ok);
|
||||
if (!ok)
|
||||
PrintAndLogEx(FAILED, "Failed.");
|
||||
@@ -3198,7 +3198,7 @@ static int CmdHF14AMfice(const char *Cmd) {
|
||||
char ctmp;
|
||||
char filename[FILE_PATH_SIZE], *fptr;
|
||||
FILE *fnonces = NULL;
|
||||
UsbCommand resp;
|
||||
UsbReplyNG resp;
|
||||
|
||||
uint32_t part_limit = 3000;
|
||||
uint32_t limit = 50000;
|
||||
@@ -3257,11 +3257,11 @@ static int CmdHF14AMfice(const char *Cmd) {
|
||||
SendCommand(&c);
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) goto out;
|
||||
if (resp.arg[0]) goto out;
|
||||
if (resp.core.old.arg[0]) goto out;
|
||||
|
||||
uint32_t items = resp.arg[2];
|
||||
uint32_t items = resp.core.old.arg[2];
|
||||
if (fnonces) {
|
||||
fwrite(resp.d.asBytes, 1, items * 4, fnonces);
|
||||
fwrite(resp.core.old.d.asBytes, 1, items * 4, fnonces);
|
||||
fflush(fnonces);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user