mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
Rename few stuff for consistency
This commit is contained in:
parent
15558070ad
commit
482db05741
83 changed files with 691 additions and 675 deletions
|
@ -428,12 +428,12 @@ failtag:
|
|||
err = 1;
|
||||
allKeysFound = false;
|
||||
// used in “portable” imlementation on microcontroller: it reports back the fail and open the standalone lock
|
||||
// cmd_send(CMD_CJB_FSMSTATE_MENU, 0, 0, 0, 0, 0);
|
||||
// reply_old(CMD_CJB_FSMSTATE_MENU, 0, 0, 0, 0, 0);
|
||||
break;
|
||||
} else if (key == -2) {
|
||||
err = 1; // Can't select card.
|
||||
allKeysFound = false;
|
||||
// cmd_send(CMD_CJB_FSMSTATE_MENU, 0, 0, 0, 0, 0);
|
||||
// reply_old(CMD_CJB_FSMSTATE_MENU, 0, 0, 0, 0, 0);
|
||||
break;
|
||||
} else {
|
||||
/* BRACE YOURSELF : AS LONG AS WE TRAP A KNOWN KEY, WE STOP CHECKING AND ENFORCE KNOWN SCHEMES */
|
||||
|
@ -442,7 +442,7 @@ failtag:
|
|||
num_to_bytes(key64, 6, foundKey[type][sec]);
|
||||
cjSetCursRight();
|
||||
DbprintfEx(FLAG_NOLOG, "SEC: %02x ; KEY : %012" PRIx64 " ; TYP: %i", sec, key64, type);
|
||||
/*cmd_send(CMD_CJB_INFORM_CLIENT_KEY, 12, sec, type, tosendkey, 12);*/
|
||||
/*reply_old(CMD_CJB_INFORM_CLIENT_KEY, 12, sec, type, tosendkey, 12);*/
|
||||
switch (key64) {
|
||||
/////////////////////////////////////////////////////////
|
||||
// COMMON SCHEME 1 : INFINITRON/HEXACT
|
||||
|
|
|
@ -132,12 +132,12 @@ void RunMod() {
|
|||
SpinDelay(500);
|
||||
// Begin clone function here:
|
||||
/* Example from client/mifarehost.c for commanding a block write for "magic Chinese" cards:
|
||||
UsbCommand c = {CMD_MIFARE_CSETBLOCK, {params & (0xFE | (uid == NULL ? 0:1)), blockNo, 0}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_CSETBLOCK, {params & (0xFE | (uid == NULL ? 0:1)), blockNo, 0}};
|
||||
memcpy(c.d.asBytes, data, 16);
|
||||
SendCommand(&c);
|
||||
|
||||
Block read is similar:
|
||||
UsbCommand c = {CMD_MIFARE_CGETBLOCK, {params, blockNo, 0}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_CGETBLOCK, {params, blockNo, 0}};
|
||||
We need to imitate that call with blockNo 0 to set a uid.
|
||||
|
||||
The get and set commands are handled in this file:
|
||||
|
|
|
@ -117,7 +117,7 @@ void print_result(char *name, uint8_t *buf, size_t len) {
|
|||
void DbpStringEx(char *str, uint32_t cmd) {
|
||||
#if DEBUG
|
||||
uint8_t len = strlen(str);
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING, len, cmd, 0, (uint8_t *)str, len);
|
||||
reply_old(CMD_DEBUG_PRINT_STRING, len, cmd, 0, (uint8_t *)str, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ void DbpString(char *str) {
|
|||
|
||||
#if 0
|
||||
void DbpIntegers(int x1, int x2, int x3) {
|
||||
cmd_send(CMD_DEBUG_PRINT_INTEGERS, x1, x2, x3, 0, 0);
|
||||
reply_old(CMD_DEBUG_PRINT_INTEGERS, x1, x2, x3, 0, 0);
|
||||
}
|
||||
#endif
|
||||
void DbprintfEx(uint32_t cmd, const char *fmt, ...) {
|
||||
|
@ -289,7 +289,7 @@ void MeasureAntennaTuning(void) {
|
|||
arg2 <<= 32;
|
||||
arg2 |= peakf;
|
||||
|
||||
cmd_send(CMD_MEASURED_ANTENNA_TUNING, arg0, v_hf, arg2, LF_Results, 256);
|
||||
reply_old(CMD_MEASURED_ANTENNA_TUNING, arg0, v_hf, arg2, LF_Results, 256);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
}
|
||||
|
@ -359,11 +359,11 @@ void SendVersion(void) {
|
|||
// Send Chip ID and used flash memory
|
||||
uint32_t text_and_rodata_section_size = (uint32_t)&__data_src_start__ - (uint32_t)&_flash_start;
|
||||
uint32_t compressed_data_section_size = common_area.arg1;
|
||||
cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, 0, VersionString, strlen(VersionString));
|
||||
reply_old(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, 0, VersionString, strlen(VersionString));
|
||||
}
|
||||
|
||||
// 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 UsbCommandOLD structure included.
|
||||
// Note: this mimics GetFromBigbuf(), i.e. we have the overhead of the PacketCommandOLD structure included.
|
||||
void printUSBSpeed(void) {
|
||||
Dbprintf("USB Speed");
|
||||
Dbprintf(" Sending USB packets to client...");
|
||||
|
@ -412,7 +412,7 @@ void SendStatus(void) {
|
|||
Dbprintf(" ToSendBit...............%d", ToSendBit);
|
||||
Dbprintf(" ToSend BUFFERSIZE.......%d", TOSEND_BUFFER_SIZE);
|
||||
printStandAloneModes();
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Show some leds in a pattern to identify StandAlone mod is running
|
||||
|
@ -633,7 +633,7 @@ void ListenReaderField(int limit) {
|
|||
}
|
||||
}
|
||||
|
||||
static void UsbPacketReceived(UsbCommandNG *packet) {
|
||||
static void PacketReceived(PacketCommandNG *packet) {
|
||||
/*
|
||||
if (packet->ng) {
|
||||
Dbprintf("received NG frame with %d bytes payload, with command: 0x%04x", packet->length, cmd);
|
||||
|
@ -652,7 +652,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
break;
|
||||
case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K: {
|
||||
uint32_t bits = SampleLF(packet->oldarg[0], packet->oldarg[1]);
|
||||
cmd_send(CMD_ACK, bits, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, bits, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
||||
|
@ -660,7 +660,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
break;
|
||||
case CMD_LF_SNIFF_RAW_ADC_SAMPLES: {
|
||||
uint32_t bits = SniffLF();
|
||||
cmd_send(CMD_ACK, bits, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, bits, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case CMD_HID_DEMOD_FSK: {
|
||||
|
@ -1078,7 +1078,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
// upload file from client
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, USB_CMD_DATA_SIZE);
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case CMD_SMART_UPGRADE: {
|
||||
|
@ -1136,25 +1136,25 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
|
||||
|
||||
//usb
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
reply_old(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
LED_A_OFF();
|
||||
/*
|
||||
uint8_t my_rx[sizeof(UsbCommandOLD)];
|
||||
uint8_t my_rx[sizeof(PacketCommandOLD)];
|
||||
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
|
||||
LED_B_INV();
|
||||
if (usart_readbuffer(my_rx) ) {
|
||||
//UsbPacketReceived(my_rx, sizeof(my_rx));
|
||||
//PacketReceived(my_rx, sizeof(my_rx));
|
||||
|
||||
UsbCommandOLD *my = (UsbCommandOLD *)my_rx;
|
||||
PacketCommandOLD *my = (PacketCommandOLD *)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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
//reply_old(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
StopTicks();
|
||||
break;
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
|
||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
bool isok = cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), mem + startidx + i, len);
|
||||
bool isok = reply_old(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), mem + startidx + i, len);
|
||||
if (isok != 0)
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d)", i, i + len, len);
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
// arg1 = RFU
|
||||
// arg2 = tracelen?
|
||||
// asbytes = samplingconfig array
|
||||
cmd_send(CMD_ACK, 1, 0, BigBuf_get_traceLen(), getSamplingConfig(), sizeof(sample_config));
|
||||
reply_old(CMD_ACK, 1, 0, BigBuf_get_traceLen(), getSamplingConfig(), sizeof(sample_config));
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
|
@ -1222,7 +1222,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, USB_CMD_DATA_SIZE);
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case CMD_DOWNLOAD_EML_BIGBUF: {
|
||||
|
@ -1239,12 +1239,12 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
|
||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
isok = cmd_send(CMD_DOWNLOADED_EML_BIGBUF, i, len, 0, mem + startidx + i, len);
|
||||
isok = reply_old(CMD_DOWNLOADED_EML_BIGBUF, i, len, 0, mem + startidx + i, len);
|
||||
if (isok != 0)
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d)", i, i + len, len);
|
||||
}
|
||||
// Trigger a finish downloading signal with an ACK frame
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
|
@ -1346,7 +1346,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
}
|
||||
FlashStop();
|
||||
|
||||
cmd_send(CMD_ACK, isok, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isok, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
|
@ -1357,14 +1357,14 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
bool isok = false;
|
||||
if (initalwipe) {
|
||||
isok = Flash_WipeMemory();
|
||||
cmd_send(CMD_ACK, isok, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isok, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
if (page < 3)
|
||||
isok = Flash_WipeMemoryPage(page);
|
||||
|
||||
cmd_send(CMD_ACK, isok, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isok, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
|
@ -1389,13 +1389,13 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
if (!isok)
|
||||
Dbprintf("reading flash memory failed :: | bytes between %d - %d", i, len);
|
||||
|
||||
isok = cmd_send(CMD_FLASHMEM_DOWNLOADED, i, len, 0, mem, len);
|
||||
isok = reply_old(CMD_FLASHMEM_DOWNLOADED, i, len, 0, mem, len);
|
||||
if (isok != 0)
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d", i, len);
|
||||
}
|
||||
FlashStop();
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
BigBuf_free();
|
||||
LED_B_OFF();
|
||||
break;
|
||||
|
@ -1411,7 +1411,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
Flash_UniqueID(info->flashid);
|
||||
FlashStop();
|
||||
}
|
||||
cmd_send(CMD_ACK, isok, 0, 0, info, sizeof(rdv40_validation_t));
|
||||
reply_old(CMD_ACK, isok, 0, 0, info, sizeof(rdv40_validation_t));
|
||||
BigBuf_free();
|
||||
|
||||
LED_B_OFF();
|
||||
|
@ -1453,9 +1453,9 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
reply_ng(CMD_PING, PM3_SUCCESS, packet->data.asBytes, packet->length);
|
||||
} else {
|
||||
#ifdef WITH_FPC_HOST
|
||||
cmd_send(CMD_ACK, reply_via_fpc, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, reply_via_fpc, 0, 0, 0, 0);
|
||||
#else
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
@ -1494,7 +1494,7 @@ static void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
if (common_area.flags.bootrom_present) {
|
||||
dev_info |= DEVICE_INFO_FLAG_BOOTROM_PRESENT;
|
||||
}
|
||||
cmd_send(CMD_DEVICE_INFO, dev_info, 0, 0, 0, 0);
|
||||
reply_old(CMD_DEVICE_INFO, dev_info, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1568,9 +1568,9 @@ void __attribute__((noreturn)) AppMain(void) {
|
|||
|
||||
// Check if there is a usb packet available
|
||||
if (usb_poll_validate_length()) {
|
||||
UsbCommandNG rx;
|
||||
PacketCommandNG rx;
|
||||
if (receive_ng(&rx) == PM3_SUCCESS) {
|
||||
UsbPacketReceived(&rx);
|
||||
PacketReceived(&rx);
|
||||
} else {
|
||||
Dbprintf("Error in frame reception");
|
||||
// TODO DOEGOX if error, shall we resync ?
|
||||
|
@ -1579,14 +1579,14 @@ void __attribute__((noreturn)) AppMain(void) {
|
|||
#ifdef WITH_FPC_HOST
|
||||
// Check if there is a FPC packet available
|
||||
// TODO DOEGOX NG packets support here too
|
||||
UsbCommandNG rx;
|
||||
PacketCommandNG rx;
|
||||
if (usart_readbuffer((uint8_t *)&rx)) {
|
||||
reply_via_fpc = true;
|
||||
rx.ng = false;
|
||||
rx.magic = 0;
|
||||
rx.length = USB_CMD_DATA_SIZE;
|
||||
rx.crc = 0;
|
||||
UsbPacketReceived(&rx);
|
||||
PacketReceived(&rx);
|
||||
}
|
||||
usart_readcheck((uint8_t *)&rx, sizeof(rx));
|
||||
#endif
|
||||
|
|
|
@ -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(UsbCommandNG *c);
|
||||
void SendRawCommand14443B_Ex(PacketCommandNG *c);
|
||||
void ClearFpgaShiftingRegisters(void);
|
||||
|
||||
// iso14443a.h
|
||||
void RAMFUNC SniffIso14443a(uint8_t param);
|
||||
void SimulateIso14443aTag(int tagType, int flags, uint8_t *data);
|
||||
void ReaderIso14443a(UsbCommandNG *c);
|
||||
void ReaderIso14443a(PacketCommandNG *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(UsbCommandNG *c);
|
||||
void EPA_PACE_Replay(UsbCommandNG *c);
|
||||
void EPA_PACE_Collect_Nonce(PacketCommandNG *c);
|
||||
void EPA_PACE_Replay(PacketCommandNG *c);
|
||||
|
||||
// mifarecmd.h
|
||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
|
@ -222,13 +222,13 @@ 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_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
uint8_t reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
|
||||
// util.h
|
||||
void HfSniff(int, int);
|
||||
|
||||
//felica.c
|
||||
void felica_sendraw(UsbCommandNG *c);
|
||||
void felica_sendraw(PacketCommandNG *c);
|
||||
void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip);
|
||||
void felica_sim_lite(uint64_t uid);
|
||||
void felica_dump_lite_s();
|
||||
|
|
18
armsrc/epa.c
18
armsrc/epa.c
|
@ -253,13 +253,13 @@ static void EPA_PACE_Collect_Nonce_Abort(uint8_t step, int func_return) {
|
|||
EPA_Finish();
|
||||
|
||||
// send the USB packet
|
||||
cmd_send(CMD_ACK, step, func_return, 0, 0, 0);
|
||||
reply_old(CMD_ACK, step, func_return, 0, 0, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Acquire one encrypted PACE nonce
|
||||
//-----------------------------------------------------------------------------
|
||||
void EPA_PACE_Collect_Nonce(UsbCommandNG *c) {
|
||||
void EPA_PACE_Collect_Nonce(PacketCommandNG *c) {
|
||||
/*
|
||||
* ack layout:
|
||||
* arg:
|
||||
|
@ -325,7 +325,7 @@ void EPA_PACE_Collect_Nonce(UsbCommandNG *c) {
|
|||
EPA_Finish();
|
||||
|
||||
// save received information
|
||||
cmd_send(CMD_ACK, 0, func_return, 0, nonce, func_return);
|
||||
reply_old(CMD_ACK, 0, func_return, 0, nonce, func_return);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -430,14 +430,14 @@ 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(UsbCommandNG *c) {
|
||||
void EPA_PACE_Replay(PacketCommandNG *c) {
|
||||
uint32_t timings[sizeof(apdu_lengths_replay) / sizeof(apdu_lengths_replay[0])] = {0};
|
||||
|
||||
// if an APDU has been passed, save it
|
||||
if (c->oldarg[0] != 0) {
|
||||
// make sure it's not too big
|
||||
if (c->oldarg[2] > apdus_replay[c->oldarg[0] - 1].len) {
|
||||
cmd_send(CMD_ACK, 1, 0, 0, NULL, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, NULL, 0);
|
||||
}
|
||||
memcpy(apdus_replay[c->oldarg[0] - 1].data + c->oldarg[1],
|
||||
c->data.asBytes,
|
||||
|
@ -448,7 +448,7 @@ void EPA_PACE_Replay(UsbCommandNG *c) {
|
|||
} else {
|
||||
apdu_lengths_replay[c->oldarg[0] - 1] += c->oldarg[2];
|
||||
}
|
||||
cmd_send(CMD_ACK, 0, 0, 0, NULL, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ void EPA_PACE_Replay(UsbCommandNG *c) {
|
|||
func_return = EPA_Setup();
|
||||
if (func_return != 0) {
|
||||
EPA_Finish();
|
||||
cmd_send(CMD_ACK, 2, func_return, 0, NULL, 0);
|
||||
reply_old(CMD_ACK, 2, func_return, 0, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -482,12 +482,12 @@ void EPA_PACE_Replay(UsbCommandNG *c) {
|
|||
|| response_apdu[func_return - 4] != 0x90
|
||||
|| response_apdu[func_return - 3] != 0x00)) {
|
||||
EPA_Finish();
|
||||
cmd_send(CMD_ACK, 3 + i, func_return, 0, timings, 20);
|
||||
reply_old(CMD_ACK, 3 + i, func_return, 0, timings, 20);
|
||||
return;
|
||||
}
|
||||
}
|
||||
EPA_Finish();
|
||||
cmd_send(CMD_ACK, 0, 0, 0, timings, 20);
|
||||
reply_old(CMD_ACK, 0, 0, 0, timings, 20);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ 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(UsbCommandNG *c) {
|
||||
void felica_sendraw(PacketCommandNG *c) {
|
||||
|
||||
if (MF_DBGLEVEL > 3) Dbprintf("FeliCa_sendraw Enter");
|
||||
|
||||
|
@ -498,7 +498,7 @@ void felica_sendraw(UsbCommandNG *c) {
|
|||
// if failed selecting, turn off antenna and quite.
|
||||
if (!(param & FELICA_NO_SELECT)) {
|
||||
arg0 = felica_select_card(&card);
|
||||
cmd_send(CMD_ACK, arg0, sizeof(card.uid), 0, &card, sizeof(felica_card_select_t));
|
||||
reply_old(CMD_ACK, arg0, sizeof(card.uid), 0, &card, sizeof(felica_card_select_t));
|
||||
if (arg0 > 0)
|
||||
goto OUT;
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ void felica_sendraw(UsbCommandNG *c) {
|
|||
|
||||
TransmitFor18092_AsReader(buf, buf[2] + 4, NULL, 1, 0);
|
||||
arg0 = !WaitForFelicaReply(1024);
|
||||
cmd_send(CMD_ACK, arg0, 0, 0, FelicaFrame.framebytes + 2, FelicaFrame.len - 2);
|
||||
reply_old(CMD_ACK, arg0, 0, 0, FelicaFrame.framebytes + 2, FelicaFrame.len - 2);
|
||||
}
|
||||
|
||||
if ((param & FELICA_NO_DISCONNECT))
|
||||
|
@ -603,7 +603,7 @@ void felica_sniff(uint32_t samplesToSkip, uint32_t triggersToSkip) {
|
|||
set_tracelen(numbts);
|
||||
|
||||
Dbprintf("Felica sniffing done, tracelen: %i, use hf list felica for annotations", BigBuf_get_traceLen());
|
||||
cmd_send(CMD_ACK, 1, numbts, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, numbts, 0, 0, 0);
|
||||
}
|
||||
|
||||
#define R_POLL0_LEN 0x16
|
||||
|
@ -794,5 +794,5 @@ void felica_dump_lite_s() {
|
|||
|
||||
//setting tracelen - important! it was set by buffer overflow before
|
||||
set_tracelen(cnt);
|
||||
cmd_send(CMD_ACK, isOK, cnt, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, cnt, 0, 0, 0);
|
||||
}
|
||||
|
|
|
@ -1350,9 +1350,9 @@ out:
|
|||
StartTicks();
|
||||
|
||||
if (bSuccessful)
|
||||
cmd_send(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, 48);
|
||||
reply_old(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, 48);
|
||||
else
|
||||
cmd_send(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
||||
|
@ -1613,5 +1613,5 @@ void WriterHitag(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
StartTicks();
|
||||
|
||||
cmd_send(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, 48);
|
||||
reply_old(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, 48);
|
||||
}
|
||||
|
|
|
@ -1444,7 +1444,7 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
|
|||
|
||||
StartTicks();
|
||||
|
||||
cmd_send(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1737,7 +1737,7 @@ void WritePageHitagS(hitag_function htf, hitag_data *htd, int page) {
|
|||
|
||||
StartTicks();
|
||||
|
||||
cmd_send(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2041,7 +2041,7 @@ void check_challenges(bool file_given, uint8_t *data) {
|
|||
|
||||
StartTicks();
|
||||
|
||||
cmd_send(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, bSuccessful, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1195,11 +1195,11 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
|||
|
||||
if (doIClassSimulation(MODE_EXIT_AFTER_MAC, mac_responses + i * EPURSE_MAC_SIZE)) {
|
||||
// Button pressed
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i, 0, mac_responses, i * EPURSE_MAC_SIZE);
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i, 0, mac_responses, i * EPURSE_MAC_SIZE);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i, 0, mac_responses, i * EPURSE_MAC_SIZE);
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i, 0, mac_responses, i * EPURSE_MAC_SIZE);
|
||||
|
||||
} else if (simType == 3) {
|
||||
//This is 'full sim' mode, where we use the emulator storage for data.
|
||||
|
@ -1226,20 +1226,20 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
|||
|
||||
// keyroll 1
|
||||
if (doIClassSimulation(MODE_EXIT_AFTER_MAC, mac_responses + i * EPURSE_MAC_SIZE)) {
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i * 2, 0, mac_responses, i * EPURSE_MAC_SIZE * 2);
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i * 2, 0, mac_responses, i * EPURSE_MAC_SIZE * 2);
|
||||
// Button pressed
|
||||
goto out;
|
||||
}
|
||||
|
||||
// keyroll 2
|
||||
if (doIClassSimulation(MODE_EXIT_AFTER_MAC, mac_responses + (i + numberOfCSNS) * EPURSE_MAC_SIZE)) {
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i * 2, 0, mac_responses, i * EPURSE_MAC_SIZE * 2);
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i * 2, 0, mac_responses, i * EPURSE_MAC_SIZE * 2);
|
||||
// Button pressed
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
// double the amount of collected data.
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i * 2, 0, mac_responses, i * EPURSE_MAC_SIZE * 2);
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_TAG_ICLASS, i * 2, 0, mac_responses, i * EPURSE_MAC_SIZE * 2);
|
||||
|
||||
} else {
|
||||
// We may want a mode here where we hardcode the csns to use (from proxclone).
|
||||
|
@ -2082,7 +2082,7 @@ void ReaderIClass(uint8_t arg0) {
|
|||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("SEND %c", send ? 'y' : 'n');
|
||||
|
||||
if (send) {
|
||||
cmd_send(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data));
|
||||
reply_old(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data));
|
||||
if (abort_after_read) {
|
||||
LED_B_OFF();
|
||||
return;
|
||||
|
@ -2096,10 +2096,10 @@ void ReaderIClass(uint8_t arg0) {
|
|||
}
|
||||
|
||||
if (userCancelled) {
|
||||
cmd_send(CMD_ACK, 0xFF, 0, 0, card_data, 0);
|
||||
reply_old(CMD_ACK, 0xFF, 0, 0, card_data, 0);
|
||||
switch_off();
|
||||
} else {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, card_data, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, card_data, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2180,7 +2180,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
|||
stored_data_length += 8;
|
||||
if (stored_data_length + 8 > USB_CMD_DATA_SIZE) {
|
||||
//Time to send this off and start afresh
|
||||
cmd_send(CMD_ACK,
|
||||
reply_old(CMD_ACK,
|
||||
stored_data_length,//data length
|
||||
failedRead,//Failed blocks?
|
||||
0,//Not used ATM
|
||||
|
@ -2200,7 +2200,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
|||
|
||||
//Send off any remaining data
|
||||
if (stored_data_length > 0) {
|
||||
cmd_send(CMD_ACK,
|
||||
reply_old(CMD_ACK,
|
||||
stored_data_length,//data length
|
||||
failedRead,//Failed blocks?
|
||||
0,//Not used ATM
|
||||
|
@ -2212,7 +2212,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
|||
break;
|
||||
}
|
||||
//Signal end of transmission
|
||||
cmd_send(CMD_ACK,
|
||||
reply_old(CMD_ACK,
|
||||
0,//data length
|
||||
0,//Failed blocks?
|
||||
0,//Not used ATM
|
||||
|
@ -2229,7 +2229,7 @@ void iClass_ReadCheck(uint8_t blockno, uint8_t keytype) {
|
|||
uint8_t resp[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
size_t isOK = 0;
|
||||
isOK = sendCmdGetResponseWithRetries(readcheck, sizeof(readcheck), resp, sizeof(resp), 6);
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
switch_off();
|
||||
}
|
||||
|
||||
|
@ -2248,7 +2248,7 @@ void iClass_Authentication(uint8_t *mac) {
|
|||
|
||||
// 6 retries
|
||||
bool isOK = sendCmdGetResponseWithRetries(check, sizeof(check), resp, 4, 6);
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
typedef struct iclass_premac {
|
||||
|
@ -2332,7 +2332,7 @@ void iClass_Authentication_fast(uint64_t arg0, uint64_t arg1, uint8_t *datain) {
|
|||
|
||||
out:
|
||||
// send keyindex.
|
||||
cmd_send(CMD_ACK, isOK, i, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, i, 0, 0, 0);
|
||||
|
||||
if (isOK >= 1 || lastChunk) {
|
||||
switch_off();
|
||||
|
@ -2360,7 +2360,7 @@ bool iClass_ReadBlock(uint8_t blockno, uint8_t *data, uint8_t len) {
|
|||
void iClass_ReadBlk(uint8_t blockno) {
|
||||
uint8_t data[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
bool isOK = iClass_ReadBlock(blockno, data, sizeof(data));
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, data, sizeof(data));
|
||||
reply_old(CMD_ACK, isOK, 0, 0, data, sizeof(data));
|
||||
switch_off();
|
||||
}
|
||||
|
||||
|
@ -2394,7 +2394,7 @@ void iClass_Dump(uint8_t blockno, uint8_t numblks) {
|
|||
memcpy(dataout + (blkCnt * 8), blockdata, 8);
|
||||
}
|
||||
//return pointer to dump memory in arg3
|
||||
cmd_send(CMD_ACK, isOK, blkCnt, BigBuf_max_traceLen(), 0, 0);
|
||||
reply_old(CMD_ACK, isOK, blkCnt, BigBuf_max_traceLen(), 0, 0);
|
||||
switch_off();
|
||||
BigBuf_free();
|
||||
}
|
||||
|
@ -2424,7 +2424,7 @@ bool iClass_WriteBlock_ext(uint8_t blockno, uint8_t *data) {
|
|||
// turn off afterwards
|
||||
void iClass_WriteBlock(uint8_t blockno, uint8_t *data) {
|
||||
bool isOK = iClass_WriteBlock_ext(blockno, data);
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
switch_off();
|
||||
}
|
||||
|
||||
|
@ -2451,6 +2451,6 @@ void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data) {
|
|||
else
|
||||
DbpString("Clone incomplete");
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
switch_off();
|
||||
}
|
||||
|
|
|
@ -1273,7 +1273,7 @@ void SimulateIso14443aTag(int tagType, int flags, uint8_t *data) {
|
|||
ar_nr_nonces[index].state = SECOND;
|
||||
|
||||
// send to client
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, 0, 0, &ar_nr_nonces[index], sizeof(nonces_t));
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, 0, 0, &ar_nr_nonces[index], sizeof(nonces_t));
|
||||
|
||||
ar_nr_nonces[index].state = EMPTY;
|
||||
ar_nr_nonces[index].sector = 0;
|
||||
|
@ -1392,7 +1392,7 @@ void SimulateIso14443aTag(int tagType, int flags, uint8_t *data) {
|
|||
}
|
||||
}
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
switch_off();
|
||||
|
||||
set_tracing(false);
|
||||
|
@ -1943,7 +1943,7 @@ void iso14443a_antifuzz(uint32_t flags) {
|
|||
}
|
||||
}
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
switch_off();
|
||||
BigBuf_free_keep_EM();
|
||||
}
|
||||
|
@ -2350,7 +2350,7 @@ 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(UsbCommandNG *c) {
|
||||
void ReaderIso14443a(PacketCommandNG *c) {
|
||||
iso14a_command_t param = c->oldarg[0];
|
||||
size_t len = c->oldarg[1] & 0xffff;
|
||||
size_t lenbits = c->oldarg[1] >> 16;
|
||||
|
@ -2376,7 +2376,7 @@ void ReaderIso14443a(UsbCommandNG *c) {
|
|||
if (!(param & ISO14A_NO_SELECT)) {
|
||||
iso14a_card_select_t *card = (iso14a_card_select_t *)buf;
|
||||
arg0 = iso14443a_select_card(NULL, card, NULL, true, 0, param & ISO14A_NO_RATS);
|
||||
cmd_send(CMD_ACK, arg0, card->uidlen, 0, buf, sizeof(iso14a_card_select_t));
|
||||
reply_old(CMD_ACK, arg0, card->uidlen, 0, buf, sizeof(iso14a_card_select_t));
|
||||
if (arg0 == 0)
|
||||
goto OUT;
|
||||
}
|
||||
|
@ -2388,7 +2388,7 @@ void ReaderIso14443a(UsbCommandNG *c) {
|
|||
if ((param & ISO14A_APDU)) {
|
||||
uint8_t res;
|
||||
arg0 = iso14_apdu(cmd, len, (param & ISO14A_SEND_CHAINING), buf, &res);
|
||||
cmd_send(CMD_ACK, arg0, res, 0, buf, sizeof(buf));
|
||||
reply_old(CMD_ACK, arg0, res, 0, buf, sizeof(buf));
|
||||
}
|
||||
|
||||
if ((param & ISO14A_RAW)) {
|
||||
|
@ -2432,7 +2432,7 @@ void ReaderIso14443a(UsbCommandNG *c) {
|
|||
}
|
||||
}
|
||||
arg0 = ReaderReceive(buf, par);
|
||||
cmd_send(CMD_ACK, arg0, 0, 0, buf, sizeof(buf));
|
||||
reply_old(CMD_ACK, arg0, 0, 0, buf, sizeof(buf));
|
||||
}
|
||||
|
||||
if ((param & ISO14A_REQUEST_TRIGGER))
|
||||
|
@ -2737,7 +2737,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
|||
memcpy(buf + 16, ks_list, 8);
|
||||
memcpy(buf + 24, mf_nr_ar, 8);
|
||||
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, buf, sizeof(buf));
|
||||
reply_old(CMD_ACK, isOK, 0, 0, buf, sizeof(buf));
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
@ -2963,7 +2963,7 @@ void DetectNACKbug() {
|
|||
|
||||
// num_nacks = number of nacks recieved. should be only 1. if not its a clone card which always sends NACK (parity == 0) ?
|
||||
// i = number of authentications sent. Not always 256, since we are trying to sync but close to it.
|
||||
cmd_send(CMD_ACK, isOK, num_nacks, i, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, num_nacks, i, 0, 0);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
|
|
@ -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(UsbCommandNG *c);
|
||||
void ReaderIso14443a(PacketCommandNG *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);
|
||||
|
|
|
@ -1566,7 +1566,7 @@ void iso14b_set_trigger(bool enable) {
|
|||
* none
|
||||
*
|
||||
*/
|
||||
void SendRawCommand14443B_Ex(UsbCommandNG *c) {
|
||||
void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||
iso14b_command_t param = c->oldarg[0];
|
||||
size_t len = c->oldarg[1] & 0xffff;
|
||||
uint32_t timeout = c->oldarg[2];
|
||||
|
@ -1594,7 +1594,7 @@ void SendRawCommand14443B_Ex(UsbCommandNG *c) {
|
|||
if ((param & ISO14B_SELECT_STD) == ISO14B_SELECT_STD) {
|
||||
iso14b_card_select_t *card = (iso14b_card_select_t *)buf;
|
||||
status = iso14443b_select_card(card);
|
||||
cmd_send(CMD_ACK, status, sendlen, 0, buf, sendlen);
|
||||
reply_old(CMD_ACK, status, sendlen, 0, buf, sendlen);
|
||||
// 0: OK 2: attrib fail, 3:crc fail,
|
||||
if (status > 0) goto out;
|
||||
}
|
||||
|
@ -1602,14 +1602,14 @@ void SendRawCommand14443B_Ex(UsbCommandNG *c) {
|
|||
if ((param & ISO14B_SELECT_SR) == ISO14B_SELECT_SR) {
|
||||
iso14b_card_select_t *card = (iso14b_card_select_t *)buf;
|
||||
status = iso14443b_select_srx_card(card);
|
||||
cmd_send(CMD_ACK, status, sendlen, 0, buf, sendlen);
|
||||
reply_old(CMD_ACK, status, sendlen, 0, buf, sendlen);
|
||||
// 0: OK 2: demod fail, 3:crc fail,
|
||||
if (status > 0) goto out;
|
||||
}
|
||||
|
||||
if ((param & ISO14B_APDU) == ISO14B_APDU) {
|
||||
status = iso14443b_apdu(cmd, len, buf);
|
||||
cmd_send(CMD_ACK, status, status, 0, buf, status);
|
||||
reply_old(CMD_ACK, status, status, 0, buf, status);
|
||||
}
|
||||
|
||||
if ((param & ISO14B_RAW) == ISO14B_RAW) {
|
||||
|
@ -1623,7 +1623,7 @@ void SendRawCommand14443B_Ex(UsbCommandNG *c) {
|
|||
|
||||
sendlen = MIN(Demod.len, USB_CMD_DATA_SIZE);
|
||||
status = (Demod.len > 0) ? 0 : 1;
|
||||
cmd_send(CMD_ACK, status, sendlen, 0, Demod.output, sendlen);
|
||||
reply_old(CMD_ACK, status, sendlen, 0, Demod.output, sendlen);
|
||||
}
|
||||
|
||||
out:
|
||||
|
|
|
@ -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(UsbCommandNG *c);
|
||||
void SendRawCommand14443B_Ex(PacketCommandNG *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);
|
||||
|
|
|
@ -849,7 +849,7 @@ void ReaderIso15693(uint32_t parameter) {
|
|||
// arg1 = len of response (12 bytes)
|
||||
// arg2 = rtf
|
||||
// asbytes = uid.
|
||||
cmd_send(CMD_ACK, 1, sizeof(uid), 0, uid, sizeof(uid));
|
||||
reply_old(CMD_ACK, 1, sizeof(uid), 0, uid, sizeof(uid));
|
||||
}
|
||||
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
|
||||
|
@ -989,7 +989,7 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
|
|||
buflen = (buflen > ISO15_MAX_FRAME) ? ISO15_MAX_FRAME : buflen;
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, buflen, 0, 0, buf, buflen);
|
||||
reply_old(CMD_ACK, buflen, 0, 0, buf, buflen);
|
||||
LED_B_OFF();
|
||||
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
|
||||
|
@ -998,6 +998,6 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
|
|||
Dbhexdump(buflen, buf, true);
|
||||
}
|
||||
} else {
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -402,7 +402,7 @@ void LegicRfInfo(void) {
|
|||
// establish shared secret and detect card type
|
||||
uint8_t card_type = setup_phase(0x01);
|
||||
if (init_card(card_type, &card) != 0) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ void LegicRfInfo(void) {
|
|||
for (uint8_t i = 0; i < sizeof(card.uid); ++i) {
|
||||
int16_t byte = read_byte(i, card.cmdsize);
|
||||
if (byte == -1) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
card.uid[i] = byte & 0xFF;
|
||||
|
@ -420,12 +420,12 @@ void LegicRfInfo(void) {
|
|||
int16_t mcc = read_byte(4, card.cmdsize);
|
||||
int16_t calc_mcc = CRC8Legic(card.uid, 4);;
|
||||
if (mcc != calc_mcc) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
// OK
|
||||
cmd_send(CMD_ACK, 1, 0, 0, (uint8_t *)&card, sizeof(legic_card_select_t));
|
||||
reply_old(CMD_ACK, 1, 0, 0, (uint8_t *)&card, sizeof(legic_card_select_t));
|
||||
|
||||
OUT:
|
||||
switch_off();
|
||||
|
@ -439,7 +439,7 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
|||
// establish shared secret and detect card type
|
||||
uint8_t card_type = setup_phase(iv);
|
||||
if (init_card(card_type, &card) != 0) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
@ -451,14 +451,14 @@ void LegicRfReader(uint16_t offset, uint16_t len, uint8_t iv) {
|
|||
for (uint16_t i = 0; i < len; ++i) {
|
||||
int16_t byte = read_byte(offset + i, card.cmdsize);
|
||||
if (byte == -1) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
legic_mem[i] = byte;
|
||||
}
|
||||
|
||||
// OK
|
||||
cmd_send(CMD_ACK, 1, len, 0, legic_mem, len);
|
||||
reply_old(CMD_ACK, 1, len, 0, legic_mem, len);
|
||||
|
||||
OUT:
|
||||
switch_off();
|
||||
|
@ -471,14 +471,14 @@ void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data) {
|
|||
|
||||
// uid is not writeable
|
||||
if (offset <= WRITE_LOWERLIMIT) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
// establish shared secret and detect card type
|
||||
uint8_t card_type = setup_phase(iv);
|
||||
if (init_card(card_type, &card) != 0) {
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
@ -491,13 +491,13 @@ void LegicRfWriter(uint16_t offset, uint16_t len, uint8_t iv, uint8_t *data) {
|
|||
while (len-- > 0 && !BUTTON_PRESS()) {
|
||||
if (!write_byte(len + offset, data[len], card.addrsize)) {
|
||||
Dbprintf("operation failed | %02X | %02X | %02X", len + offset, len, data[len]);
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
goto OUT;
|
||||
}
|
||||
}
|
||||
|
||||
// OK
|
||||
cmd_send(CMD_ACK, 1, len, 0, legic_mem, len);
|
||||
reply_old(CMD_ACK, 1, len, 0, legic_mem, len);
|
||||
|
||||
OUT:
|
||||
switch_off();
|
||||
|
|
|
@ -242,7 +242,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint
|
|||
// Turn off antenna
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
// tell client we are done
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* blank r/w tag data stream
|
||||
|
@ -1388,7 +1388,7 @@ void T55xxResetRead(void) {
|
|||
|
||||
// Turn the field off
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
LED_A_OFF();
|
||||
}
|
||||
|
||||
|
@ -1467,7 +1467,7 @@ void T55xxWriteBlockExt(uint32_t Data, uint8_t Block, uint32_t Pwd, uint8_t arg)
|
|||
// Write one card block in page 0, no lock
|
||||
void T55xxWriteBlock(uint32_t Data, uint8_t Block, uint32_t Pwd, uint8_t arg) {
|
||||
T55xxWriteBlockExt(Data, Block, Pwd, arg);
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Read one card block in page [page]
|
||||
|
@ -1532,7 +1532,7 @@ void T55xxReadBlock(uint16_t arg0, uint8_t Block, uint32_t Pwd) {
|
|||
// Turn the field off
|
||||
if (!brute_mem) {
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
LED_A_OFF();
|
||||
}
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ void T55xx_ChkPwds() {
|
|||
|
||||
OUT:
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
cmd_send(CMD_ACK, ret, candidate, 0, 0, 0);
|
||||
reply_old(CMD_ACK, ret, candidate, 0, 0, 0);
|
||||
LEDsoff();
|
||||
}
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) {
|
|||
// Program the data blocks for supplied ID and the block 0 config
|
||||
WriteT55xx(data, 0, 3);
|
||||
LED_D_OFF();
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Define 9bit header for EM410x tags
|
||||
|
@ -2028,7 +2028,7 @@ void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) {
|
|||
DoPartialAcquisition(20, true, 6000, 1000);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
LED_A_OFF();
|
||||
}
|
||||
|
||||
|
@ -2064,7 +2064,7 @@ void EM4xWriteWord(uint32_t flag, uint32_t data, uint32_t pwd) {
|
|||
DoPartialAcquisition(20, true, 6000, 1000);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
LED_A_OFF();
|
||||
}
|
||||
|
||||
|
@ -2118,7 +2118,7 @@ void Cotag(uint32_t arg0) {
|
|||
|
||||
// Turn the field off
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
LEDsoff();
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
if (MF_DBGLEVEL >= 2) DbpString("READ BLOCK FINISHED");
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, dataoutbuf, 16);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, dataoutbuf, 16);
|
||||
LED_B_OFF();
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
@ -129,7 +129,7 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes) {
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
}
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Arg0 = BlockNo,
|
||||
|
@ -189,7 +189,7 @@ void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain) {
|
|||
return;
|
||||
}
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, dataout, 16);
|
||||
reply_old(CMD_ACK, 1, 0, 0, dataout, 16);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
crypto1_destroy(pcs);
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, dataoutbuf, 16 * NumBlocksPerSector(sectorNo));
|
||||
reply_old(CMD_ACK, isOK, 0, 0, dataoutbuf, 16 * NumBlocksPerSector(sectorNo));
|
||||
LED_B_OFF();
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
@ -352,7 +352,7 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
|
||||
countblocks *= 4;
|
||||
|
||||
cmd_send(CMD_ACK, 1, countblocks, BigBuf_max_traceLen(), 0, 0);
|
||||
reply_old(CMD_ACK, 1, countblocks, BigBuf_max_traceLen(), 0, 0);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
BigBuf_free();
|
||||
|
@ -419,7 +419,7 @@ void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
|
||||
if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
|
||||
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
@ -461,7 +461,7 @@ void MifareUWriteBlockCompat(uint8_t arg0, uint8_t *datain)
|
|||
|
||||
if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
|
||||
|
||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||
reply_old(CMD_ACK,1,0,0,0,0);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain) {
|
|||
|
||||
if (MF_DBGLEVEL >= 2) DbpString("WRITE BLOCK FINISHED");
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
set_tracing(false);
|
||||
|
@ -603,7 +603,7 @@ void MifareUSetPwd(uint8_t arg0, uint8_t *datain) {
|
|||
return;
|
||||
};
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
set_tracing(false);
|
||||
|
@ -706,7 +706,7 @@ void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *
|
|||
|
||||
LED_C_OFF();
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, cuid, num_nonces - 1, buf, sizeof(buf));
|
||||
reply_old(CMD_ACK, isOK, cuid, num_nonces - 1, buf, sizeof(buf));
|
||||
LED_B_OFF();
|
||||
|
||||
if (MF_DBGLEVEL >= 3) DbpString("AcquireNonces finished");
|
||||
|
@ -834,7 +834,7 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
|||
LED_C_OFF();
|
||||
crypto1_destroy(pcs);
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, cuid, num_nonces, buf, sizeof(buf));
|
||||
reply_old(CMD_ACK, isOK, cuid, num_nonces, buf, sizeof(buf));
|
||||
LED_B_OFF();
|
||||
|
||||
if (MF_DBGLEVEL >= 3) DbpString("AcquireEncryptedNonces finished");
|
||||
|
@ -1054,7 +1054,7 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
|||
memcpy(buf + 16, &target_ks[1], 4);
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, 0, targetBlockNo + (targetKeyType * 0x100), buf, sizeof(buf));
|
||||
reply_old(CMD_ACK, isOK, 0, targetBlockNo + (targetKeyType * 0x100), buf, sizeof(buf));
|
||||
LED_B_OFF();
|
||||
|
||||
if (MF_DBGLEVEL >= 3) DbpString("NESTED FINISHED");
|
||||
|
@ -1504,7 +1504,7 @@ OUT:
|
|||
tmp[488] = bar & 0xFF;
|
||||
tmp[489] = bar >> 8 & 0xFF;
|
||||
|
||||
cmd_send(CMD_ACK, foundkeys, 0, 0, tmp, 480 + 10);
|
||||
reply_old(CMD_ACK, foundkeys, 0, 0, tmp, 480 + 10);
|
||||
|
||||
set_tracing(false);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
@ -1512,7 +1512,7 @@ OUT:
|
|||
BigBuf_Clear_ext(false);
|
||||
} else {
|
||||
// partial/none keys found
|
||||
cmd_send(CMD_ACK, foundkeys, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, foundkeys, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1592,7 +1592,7 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) {
|
|||
}
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, datain + i * 6, 6);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, datain + i * 6, 6);
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
|
@ -1635,7 +1635,7 @@ void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
|||
emlGetMem(buf, arg0, arg1); // data, block num, blocks count (max 4)
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, arg0, arg1, 0, buf, USB_CMD_DATA_SIZE);
|
||||
reply_old(CMD_ACK, arg0, arg1, 0, buf, USB_CMD_DATA_SIZE);
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
|
@ -1841,7 +1841,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) {
|
|||
} // end while
|
||||
|
||||
if (isOK)
|
||||
cmd_send(CMD_ACK, 1, 0, 0, uid, sizeof(uid));
|
||||
reply_old(CMD_ACK, 1, 0, 0, uid, sizeof(uid));
|
||||
else
|
||||
OnErrorMagic(errormsg);
|
||||
|
||||
|
@ -1916,7 +1916,7 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain) {
|
|||
memcpy(datain, data, sizeof(data));
|
||||
} else {
|
||||
if (isOK)
|
||||
cmd_send(CMD_ACK, 1, 0, 0, data, sizeof(data));
|
||||
reply_old(CMD_ACK, 1, 0, 0, data, sizeof(data));
|
||||
else
|
||||
OnErrorMagic(errormsg);
|
||||
}
|
||||
|
@ -1975,7 +1975,7 @@ TEST2:
|
|||
};
|
||||
|
||||
OUT:
|
||||
cmd_send(CMD_ACK, isGen, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isGen, 0, 0, 0, 0);
|
||||
// turns off
|
||||
OnSuccessMagic();
|
||||
BigBuf_free();
|
||||
|
@ -1988,7 +1988,7 @@ void OnSuccessMagic() {
|
|||
}
|
||||
void OnErrorMagic(uint8_t reason) {
|
||||
// ACK, ISOK, reason,0,0,0
|
||||
cmd_send(CMD_ACK, 0, reason, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, reason, 0, 0, 0);
|
||||
OnSuccessMagic();
|
||||
}
|
||||
|
||||
|
@ -2042,7 +2042,7 @@ void MifareSetMod(uint8_t mod, uint8_t *key) {
|
|||
crypto1_destroy(pcs);
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
@ -2075,7 +2075,7 @@ void Mifare_DES_Auth1(uint8_t arg0, uint8_t *datain) {
|
|||
}
|
||||
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 1 FINISHED");
|
||||
cmd_send(CMD_ACK, 1, cuid, 0, dataout, sizeof(dataout));
|
||||
reply_old(CMD_ACK, 1, cuid, 0, dataout, sizeof(dataout));
|
||||
}
|
||||
|
||||
void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain) {
|
||||
|
@ -2096,7 +2096,7 @@ void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain) {
|
|||
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) DbpString("AUTH 2 FINISHED");
|
||||
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, dataout, sizeof(dataout));
|
||||
reply_old(CMD_ACK, isOK, 0, 0, dataout, sizeof(dataout));
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
set_tracing(false);
|
||||
|
|
|
@ -81,7 +81,7 @@ void MifareSendCommand(uint8_t arg0, uint8_t arg1, uint8_t *datain) {
|
|||
if (flags & DISCONNECT)
|
||||
OnSuccess();
|
||||
|
||||
cmd_send(CMD_ACK, 1, len, 0, resp, len);
|
||||
reply_old(CMD_ACK, 1, len, 0, resp, len);
|
||||
}
|
||||
|
||||
void MifareDesfireGetInformation() {
|
||||
|
@ -160,7 +160,7 @@ void MifareDesfireGetInformation() {
|
|||
|
||||
memcpy(dataout + 7 + 7 + 7, resp + 3, 14);
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, dataout, sizeof(dataout));
|
||||
reply_old(CMD_ACK, 1, 0, 0, dataout, sizeof(dataout));
|
||||
|
||||
// reset the pcb_blocknum,
|
||||
pcb_blocknum = 0;
|
||||
|
@ -409,9 +409,9 @@ void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
|
||||
OnSuccess();
|
||||
if (arg1 == 2)
|
||||
cmd_send(CMD_ACK, 1, 0, 0, skey->data, 16);
|
||||
reply_old(CMD_ACK, 1, 0, 0, skey->data, 16);
|
||||
else if (arg1 == 1)
|
||||
cmd_send(CMD_ACK, 1, 0, 0, skey->data, 8);
|
||||
reply_old(CMD_ACK, 1, 0, 0, skey->data, 8);
|
||||
} else {
|
||||
DbpString("Authentication failed.");
|
||||
OnError(6);
|
||||
|
@ -494,7 +494,7 @@ void MifareDES_Auth1(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
}
|
||||
|
||||
OnSuccess();
|
||||
cmd_send(CMD_ACK, 1, len, 0, resp, len);
|
||||
reply_old(CMD_ACK, 1, len, 0, resp, len);
|
||||
}
|
||||
|
||||
// 3 different ISO ways to send data to a DESFIRE (direct, capsuled, capsuled ISO)
|
||||
|
@ -567,6 +567,6 @@ void OnSuccess() {
|
|||
}
|
||||
|
||||
void OnError(uint8_t reason) {
|
||||
cmd_send(CMD_ACK, 0, reason, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, reason, 0, 0, 0);
|
||||
OnSuccess();
|
||||
}
|
||||
|
|
|
@ -1219,7 +1219,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
|||
|
||||
if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK
|
||||
//Send the collected ar_nr in the response
|
||||
cmd_send(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp));
|
||||
reply_old(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp));
|
||||
}
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
|
|
@ -190,7 +190,7 @@ void MfSniffInit(void) {
|
|||
|
||||
void MfSniffEnd(void) {
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
|
@ -316,12 +316,12 @@ void RAMFUNC MfSniffSend() {
|
|||
while (packlen > 0) {
|
||||
LED_B_ON();
|
||||
chunksize = MIN(USB_CMD_DATA_SIZE, packlen); // chunk size 512
|
||||
cmd_send(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
||||
reply_old(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
||||
packlen -= chunksize;
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
LED_B_ON();
|
||||
cmd_send(CMD_ACK, 2, 0, 0, 0, 0); // 2 == data transfer finished.
|
||||
reply_old(CMD_ACK, 2, 0, 0, 0, 0); // 2 == data transfer finished.
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ end:
|
|||
|
||||
Dbprintf("-----------------------------------------");
|
||||
}
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void RealWritePCF7931(uint8_t *pass, uint16_t init_delay, int32_t l, int32_t p, uint8_t address, uint8_t byte, uint8_t data) {
|
||||
|
|
|
@ -20,7 +20,7 @@ void DbpString(char *str) {
|
|||
while (str[len] != 0x00)
|
||||
len++;
|
||||
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING, len, 0, 0, (uint8_t *)str, len);
|
||||
reply_old(CMD_DEBUG_PRINT_STRING, len, 0, 0, (uint8_t *)str, len);
|
||||
}
|
||||
|
||||
static void ConfigClocks(void) {
|
||||
|
@ -84,12 +84,10 @@ static void Fatal(void) {
|
|||
for (;;) {};
|
||||
}
|
||||
|
||||
void UsbPacketReceived(UsbCommandNG *packet) {
|
||||
void PacketReceived(PacketCommandNG *packet) {
|
||||
int i, dont_ack = 0;
|
||||
volatile uint32_t *p;
|
||||
|
||||
//if ( len != sizeof(UsbCommand)) Fatal();
|
||||
|
||||
uint32_t arg0 = (uint32_t)packet->oldarg[0];
|
||||
|
||||
switch (packet->cmd) {
|
||||
|
@ -100,7 +98,7 @@ void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
if (common_area.flags.osimage_present)
|
||||
arg0 |= DEVICE_INFO_FLAG_OSIMAGE_PRESENT;
|
||||
|
||||
cmd_send(CMD_DEVICE_INFO, arg0, 1, 2, 0, 0);
|
||||
reply_old(CMD_DEVICE_INFO, arg0, 1, 2, 0, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -127,7 +125,7 @@ void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
if (((flash_address + AT91C_IFLASH_PAGE_SIZE - 1) >= end_addr) || (flash_address < start_addr)) {
|
||||
/* Disallow write */
|
||||
dont_ack = 1;
|
||||
cmd_send(CMD_NACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_NACK, 0, 0, 0, 0, 0);
|
||||
} else {
|
||||
uint32_t page_n = (flash_address - ((uint32_t)flash_mem)) / AT91C_IFLASH_PAGE_SIZE;
|
||||
/* Translate address to flash page and do flash, update here for the 512k part */
|
||||
|
@ -141,7 +139,7 @@ void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
while (!((sr = AT91C_BASE_EFC0->EFC_FSR) & AT91C_MC_FRDY));
|
||||
if (sr & (AT91C_MC_LOCKE | AT91C_MC_PROGE)) {
|
||||
dont_ack = 1;
|
||||
cmd_send(CMD_NACK, sr, 0, 0, 0, 0);
|
||||
reply_old(CMD_NACK, sr, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +175,7 @@ void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
} else {
|
||||
start_addr = end_addr = 0;
|
||||
dont_ack = 1;
|
||||
cmd_send(CMD_NACK, 0, 0, 0, 0, 0);
|
||||
reply_old(CMD_NACK, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -189,14 +187,14 @@ void UsbPacketReceived(UsbCommandNG *packet) {
|
|||
}
|
||||
|
||||
if (!dont_ack)
|
||||
cmd_send(CMD_ACK, arg0, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, arg0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void flash_mode(int externally_entered) {
|
||||
start_addr = 0;
|
||||
end_addr = 0;
|
||||
bootrom_unlocked = 0;
|
||||
UsbCommandNG rx;
|
||||
PacketCommandNG rx;
|
||||
|
||||
usb_enable();
|
||||
|
||||
|
@ -210,7 +208,7 @@ static void flash_mode(int externally_entered) {
|
|||
if (usb_poll_validate_length()) {
|
||||
// TODO DOEGOX
|
||||
if (usb_read((uint8_t *)&rx, sizeof(rx)))
|
||||
UsbPacketReceived(&rx);
|
||||
PacketReceived(&rx);
|
||||
}
|
||||
|
||||
if (!externally_entered && !BUTTON_PRESS()) {
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char **argv) {
|
|||
while (1) {
|
||||
while (!OpenProxmark()) { sleep(1); }
|
||||
while (1) {
|
||||
UsbCommandOLD cmdbuf;
|
||||
PacketCommandOLD cmdbuf;
|
||||
CommandReceived(argv[1]);
|
||||
HANDLE_ERROR;
|
||||
ReceiveCommand(&cmdbuf);
|
||||
|
|
|
@ -512,12 +512,12 @@ static int CmdAnalyseA(const char *Cmd) {
|
|||
if (errors || cmdp == 0) return usage_analyse_a();
|
||||
|
||||
|
||||
UsbCommandOLD c = {CMD_FPC_SEND, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FPC_SEND, {0, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, USB_CMD_DATA_SIZE);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -874,7 +874,7 @@ static int CmdBuffClear(const char *Cmd) {
|
|||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_data_buffclear();
|
||||
|
||||
UsbCommandOLD c = {CMD_BUFF_CLEAR, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_BUFF_CLEAR, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
ClearGraph(true);
|
||||
|
@ -1457,7 +1457,7 @@ int getSamples(uint32_t n, bool silent) {
|
|||
|
||||
if (!silent) PrintAndLogEx(NORMAL, "Reading %d bytes from device memory\n", n);
|
||||
|
||||
UsbReplyNG response;
|
||||
PacketResponseNG response;
|
||||
if (!GetFromDevice(BIG_BUF, got, n, 0, &response, 10000, true)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
@ -1529,10 +1529,10 @@ int CmdTuneSamples(const char *Cmd) {
|
|||
int timeout = 0;
|
||||
PrintAndLogEx(INFO, "\nMeasuring antenna characteristics, please wait...");
|
||||
|
||||
UsbCommandOLD c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MEASURE_ANTENNA_TUNING, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
while (!WaitForResponseTimeout(CMD_MEASURED_ANTENNA_TUNING, &resp, 2000)) {
|
||||
timeout++;
|
||||
printf(".");
|
||||
|
|
|
@ -140,7 +140,7 @@ static int CmdFlashMemRead(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_READ, {start_index, len, 0}, {{0}}};
|
||||
PacketCommandOLD 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();
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_SET_SPIBAUDRATE, {baudrate, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_WRITE, {start_index + bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FLASHMEM_WRITE, {start_index + bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
|
||||
memcpy(c.d.asBytes, data + bytes_sent, bytes_in_packet);
|
||||
clearCommandBuffer();
|
||||
|
@ -283,7 +283,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
bytes_remaining -= bytes_in_packet;
|
||||
bytes_sent += bytes_in_packet;
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
free(data);
|
||||
|
@ -389,10 +389,10 @@ static int CmdFlashMemWipe(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors || cmdp == 0) return usage_flashmem_wipe();
|
||||
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 8000)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
@ -435,10 +435,10 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors) return usage_flashmem_info();
|
||||
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
@ -564,7 +564,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
|
||||
if (shall_write) {
|
||||
// save to mem
|
||||
c = (UsbCommandOLD) {CMD_FLASHMEM_WRITE, {FLASH_MEM_SIGNATURE_OFFSET, FLASH_MEM_SIGNATURE_LEN, 0}, {{0}}};
|
||||
c = (PacketCommandOLD) {CMD_FLASHMEM_WRITE, {FLASH_MEM_SIGNATURE_OFFSET, FLASH_MEM_SIGNATURE_LEN, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, sign, sizeof(sign));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -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");
|
||||
UsbCommandOLD c = {CMD_MEASURE_ANTENNA_TUNING_HF, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
|
||||
UsbCommandOLD c = {CMD_HF_SNIFFER, {skippairs, skiptriggers, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_HF_SNIFFER, {skippairs, skiptriggers, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
|
|
@ -228,10 +228,10 @@ static int CmdHF14AList(const char *Cmd) {
|
|||
}
|
||||
|
||||
int Hf14443_4aGetCardData(iso14a_card_select_t *card) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
memcpy(card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
|
||||
|
@ -298,12 +298,12 @@ static int CmdHF14AReader(const char *Cmd) {
|
|||
if (!disconnectAfter)
|
||||
cm |= ISO14A_NO_DISCONNECT;
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {cm, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {cm, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
if (ISO14A_CONNECT & cm) {
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (!silent) PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
DropField();
|
||||
|
@ -385,10 +385,10 @@ static int CmdHF14ACUIDs(const char *Cmd) {
|
|||
}
|
||||
|
||||
// execute anticollision procedure
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
iso14a_card_select_t *card = (iso14a_card_select_t *) resp.data.asBytes;
|
||||
|
@ -483,11 +483,11 @@ int CmdHF14ASim(const char *Cmd) {
|
|||
if (useUIDfromEML)
|
||||
flags |= FLAG_UID_IN_EMUL;
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_ISO_14443a, { tagtype, flags, 0 }, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SIMULATE_TAG_ISO_14443a, { tagtype, flags, 0 }, {{0}}};
|
||||
memcpy(c.d.asBytes, uid, uidlen >> 1);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
||||
|
||||
|
@ -512,7 +512,7 @@ int CmdHF14ASniff(const char *Cmd) {
|
|||
if (ctmp == 'c') param |= 0x01;
|
||||
if (ctmp == 'r') param |= 0x02;
|
||||
}
|
||||
UsbCommandOLD c = {CMD_SNIFF_ISO_14443a, {param, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SNIFF_ISO_14443a, {param, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -525,10 +525,10 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
|||
|
||||
if (activateField) {
|
||||
responseNum = 1;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
// Anticollision + SELECT card
|
||||
UsbCommandOLD ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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.");
|
||||
|
@ -548,7 +548,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
|||
|
||||
if (resp.oldarg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
// get ATS
|
||||
UsbCommandOLD cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
|
||||
PacketCommandOLD cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
memcpy(cr.d.asBytes, rats, 2);
|
||||
SendCommand(&cr);
|
||||
|
@ -567,7 +567,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
|||
if (leaveSignalON)
|
||||
cmdc |= ISO14A_NO_DISCONNECT;
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
|
@ -575,7 +575,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
|||
SendCommand(&c);
|
||||
|
||||
uint8_t *recv;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
recv = resp.data.asBytes;
|
||||
|
@ -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) {
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
frameLength = 0;
|
||||
|
||||
|
@ -627,7 +627,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
|||
DropField();
|
||||
|
||||
// Anticollision + SELECT card
|
||||
UsbCommandOLD ca = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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.");
|
||||
|
@ -647,7 +647,7 @@ static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
|
|||
|
||||
if (resp.oldarg[0] == 2) { // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS, 3: proprietary Anticollision
|
||||
// get ATS
|
||||
UsbCommandOLD cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
|
||||
PacketCommandOLD cr = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, 2, 0}, {{0}}};
|
||||
uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
|
||||
memcpy(cr.d.asBytes, rats, 2);
|
||||
SendCommand(&cr);
|
||||
|
@ -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"
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}, {{0}}};
|
||||
|
||||
if (datain)
|
||||
memcpy(c.d.asBytes, datain, datainlen);
|
||||
|
@ -712,7 +712,7 @@ static int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool
|
|||
SendCommand(&c);
|
||||
|
||||
uint8_t *recv;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
recv = resp.data.asBytes;
|
||||
|
@ -891,7 +891,7 @@ static int CmdHF14AAPDU(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdHF14ACmdRaw(const char *Cmd) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
|
||||
bool reply = 1;
|
||||
bool crc = false;
|
||||
bool power = false;
|
||||
|
@ -1047,7 +1047,7 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int waitCmd(uint8_t iSelect) {
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint16_t len = (resp.oldarg[0] & 0xFFFF);
|
||||
|
@ -1096,7 +1096,7 @@ static int CmdHF14AAntiFuzz(const char *Cmd) {
|
|||
arg0 = FLAG_10B_UID_IN_DATA;
|
||||
|
||||
CLIParserFree();
|
||||
UsbCommandOLD c = {CMD_ANTIFUZZ_ISO_14443a, {arg0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ANTIFUZZ_ISO_14443a, {arg0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -1161,10 +1161,10 @@ int CmdHF14A(const char *Cmd) {
|
|||
}
|
||||
|
||||
int infoHF14A(bool verbose, bool do_nack_test) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
DropField();
|
||||
|
|
|
@ -108,14 +108,14 @@ static int usage_hf_14b_dump(void) {
|
|||
|
||||
/*
|
||||
static void switch_on_field_14b(void) {
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
}
|
||||
*/
|
||||
|
||||
static int switch_off_field_14b(void) {
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -124,7 +124,7 @@ static int switch_off_field_14b(void) {
|
|||
static bool waitCmd14b(bool verbose) {
|
||||
|
||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
|
||||
|
@ -171,7 +171,7 @@ static int CmdHF14BSim(const char *Cmd) {
|
|||
pupi = param_get32ex(Cmd, 1, 0, 16);
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_ISO_14443B, {pupi, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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();
|
||||
|
||||
UsbCommandOLD c = {CMD_SNIFF_ISO_14443B, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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;
|
||||
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {flags, datalen, time_wait}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {flags, datalen, time_wait}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, datalen);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -301,8 +301,8 @@ static bool get_14b_UID(iso14b_card_select_t *card) {
|
|||
return false;
|
||||
|
||||
int8_t retry = 3;
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
|
||||
// test for 14b SR
|
||||
while (retry--) {
|
||||
|
@ -509,10 +509,10 @@ static bool HF14B_Std_Info(bool verbose) {
|
|||
bool isSuccess = false;
|
||||
|
||||
// 14b get and print UID only (general info)
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
|
@ -550,10 +550,10 @@ static bool HF14B_Std_Info(bool verbose) {
|
|||
// SRx get and print full info (needs more info...)
|
||||
static bool HF14B_ST_Info(bool verbose) {
|
||||
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
|
@ -607,10 +607,10 @@ static bool HF14B_ST_Reader(bool verbose) {
|
|||
bool isSuccess = false;
|
||||
|
||||
// SRx get and print general info about SRx chip from UID
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
return false;
|
||||
|
@ -647,10 +647,10 @@ static bool HF14B_Std_Reader(bool verbose) {
|
|||
bool isSuccess = false;
|
||||
|
||||
// 14b get and print UID only (general info)
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_STD | ISO14B_DISCONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "command execution timeout");
|
||||
|
@ -692,12 +692,12 @@ 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;
|
||||
|
||||
// UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, {flags, datalen, 0}, {{0}}};
|
||||
// PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, {flags, datalen, 0}, {{0}}};
|
||||
// memcpy(c.d.asBytes, data, datalen);
|
||||
|
||||
// clearCommandBuffer();
|
||||
// SendCommand(&c);
|
||||
// UsbReplyNG resp;
|
||||
// PacketResponseNG 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);
|
||||
// UsbReplyNG resp;
|
||||
// PacketResponseNG 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);
|
||||
// UsbReplyNG resp;
|
||||
// PacketResponseNG resp;
|
||||
// WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
// if (datalen > 0) {
|
||||
|
@ -762,7 +762,7 @@ static int CmdHF14BReadSri(const char *Cmd) {
|
|||
uint8_t tagtype = param_get8(Cmd, 0);
|
||||
uint8_t blocks = (tagtype == 1) ? 0x7F : 0x0F;
|
||||
|
||||
UsbCommandOLD c = {CMD_READ_SRI_TAG, {blocks, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READ_SRI_TAG, {blocks, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -901,8 +901,8 @@ static int CmdHF14BDump(const char *Cmd) {
|
|||
int blocknum = 0;
|
||||
uint8_t *recv = NULL;
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_ISO_14443B_COMMAND, { ISO14B_CONNECT | ISO14B_SELECT_SR, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_ISO_14443B_COMMAND, { ISO14B_CONNECT | ISO14B_SELECT_SR, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
|
|
|
@ -198,8 +198,8 @@ const productName uidmapping[] = {
|
|||
// returns 1 if suceeded
|
||||
static int getUID(uint8_t *buf) {
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD 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;
|
||||
|
@ -418,7 +418,7 @@ static int usage_15_readmulti(void) {
|
|||
* Parameters:
|
||||
* **cmd command line
|
||||
*/
|
||||
static int prepareHF15Cmd(char **cmd, UsbCommandOLD *c, uint8_t iso15cmd) {
|
||||
static int prepareHF15Cmd(char **cmd, PacketCommandOLD *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();
|
||||
|
||||
UsbCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
|
@ -594,9 +594,9 @@ static int CmdHF15Info(const char *Cmd) {
|
|||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 1 || cmdp == 'h' || cmdp == 'H') return usage_15_info();
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
uint8_t *recv;
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
PacketCommandOLD 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;
|
||||
|
@ -674,7 +674,7 @@ static int CmdHF15Record(const char *Cmd) {
|
|||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_15_record();
|
||||
|
||||
UsbCommandOLD c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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)));
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMTAG_ISO_15693, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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");
|
||||
|
||||
UsbCommandOLD c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_15693_FIND_AFI, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -783,8 +783,8 @@ static int CmdHF15Dump(const char *Cmd) {
|
|||
uint8_t data[256 * 4] = {0};
|
||||
memset(data, 0, sizeof(data));
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD 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;
|
||||
|
@ -859,8 +859,8 @@ static int CmdHF15Raw(const char *Cmd) {
|
|||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_raw();
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD 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] = "";
|
||||
|
@ -945,9 +945,9 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
|||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_readmulti();
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
uint8_t *recv;
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
PacketCommandOLD 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;
|
||||
|
@ -1028,14 +1028,14 @@ static int CmdHF15Read(const char *Cmd) {
|
|||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_read();
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
uint8_t *recv;
|
||||
|
||||
// UsbCommandOLD arg: len, speed, recv?
|
||||
// PacketCommandOLD 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)
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}};
|
||||
uint8_t *req = c.d.asBytes;
|
||||
int reqlen = 0, blocknum;
|
||||
char cmdbuf[100] = {0};
|
||||
|
@ -1102,9 +1102,9 @@ static int CmdHF15Write(const char *Cmd) {
|
|||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) < 3 || cmdp == 'h' || cmdp == 'H') return usage_15_write();
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
uint8_t *recv;
|
||||
UsbCommandOLD c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?
|
||||
PacketCommandOLD 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};
|
||||
|
|
|
@ -31,10 +31,10 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
|
|||
// repeat n times
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
// execute PACE
|
||||
UsbCommandOLD c = {CMD_EPA_PACE_COLLECT_NONCE, {(int)m, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_EPA_PACE_COLLECT_NONCE, {(int)m, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
// check if command failed
|
||||
|
@ -72,7 +72,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
|||
"Example:\n preplay 0022C1A4 1068000000 1086000002 1234ABCDEF 1A2B3C4D";
|
||||
|
||||
// Proxmark response
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
int skip = 0, skip_add = 0, scan_return;
|
||||
// for each APDU
|
||||
|
@ -109,7 +109,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
|||
}
|
||||
|
||||
// transfer the APDUs to the Proxmark
|
||||
UsbCommandOLD usb_cmd;
|
||||
PacketCommandOLD usb_cmd;
|
||||
usb_cmd.cmd = CMD_EPA_PACE_REPLAY;
|
||||
for (int i = 0; i < sizeof(apdu_lengths); i++) {
|
||||
// APDU number
|
||||
|
|
|
@ -128,11 +128,11 @@ static int CmdHFFelicaSim(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors || cmdp == 0) return usage_hf_felica_sim();
|
||||
|
||||
UsbCommandOLD c = {CMD_FELICA_SIMULATE_TAG, { tagtype, flags, 0 }, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FELICA_SIMULATE_TAG, { tagtype, flags, 0 }, {{0}}};
|
||||
memcpy(c.d.asBytes, uid, uidlen >> 1);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(NORMAL, "Press pm3-button to abort simulation");
|
||||
|
@ -174,7 +174,7 @@ static int CmdHFFelicaSniff(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors || cmdp == 0) return usage_hf_felica_sniff();
|
||||
|
||||
UsbCommandOLD c = {CMD_FELICA_SNIFF, {samples2skip, triggers2skip, 0}, {{0}}};
|
||||
PacketCommandOLD 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();
|
||||
|
||||
UsbCommandOLD c = {CMD_FELICA_LITE_SIM, {uid, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FELICA_LITE_SIM, {uid, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -352,10 +352,10 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "FeliCa lite - dump started");
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button to cancel");
|
||||
UsbCommandOLD c = {CMD_FELICA_LITE_DUMP, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FELICA_LITE_DUMP, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
@ -412,7 +412,7 @@ static int CmdHFFelicaDumpLite(const char *Cmd) {
|
|||
}
|
||||
|
||||
static void waitCmdFelica(uint8_t iSelect) {
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
uint16_t len = iSelect ? (resp.oldarg[1] & 0xffff) : (resp.oldarg[0] & 0xffff);
|
||||
|
@ -426,7 +426,7 @@ static void waitCmdFelica(uint8_t iSelect) {
|
|||
}
|
||||
|
||||
static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||
UsbCommandOLD c = {CMD_FELICA_COMMAND, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FELICA_COMMAND, {0, 0, 0}, {{0}}};
|
||||
bool reply = 1;
|
||||
bool crc = false;
|
||||
bool power = false;
|
||||
|
@ -568,11 +568,11 @@ int CmdHFFelica(const char *Cmd) {
|
|||
|
||||
int readFelicaUid(bool verbose) {
|
||||
|
||||
//UsbCommandOLD cDisconnect = {CMD_FELICA_COMMAND, {0,0,0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_FELICA_COMMAND, {FELICA_CONNECT, 0, 0}, {{0}}};
|
||||
//PacketCommandOLD cDisconnect = {CMD_FELICA_COMMAND, {0,0,0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FELICA_COMMAND, {FELICA_CONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (verbose) PrintAndLogEx(WARNING, "FeliCa card select failed");
|
||||
//SendCommand(&cDisconnect);
|
||||
|
|
|
@ -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();
|
||||
UsbCommandOLD c = {CMD_SNIFF_ICLASS, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SNIFF_ICLASS, {0, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -380,8 +380,8 @@ static int CmdHFiClassSim(const char *Cmd) {
|
|||
case 2: {
|
||||
PrintAndLogEx(INFO, "Starting iCLASS sim 2 attack (elite mode)");
|
||||
PrintAndLogEx(INFO, "press keyboard to cancel");
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
memcpy(c.d.asBytes, csns, 8 * NUM_CSNS);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -433,8 +433,8 @@ 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");
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, NUM_CSNS}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
memcpy(c.d.asBytes, csns, 8 * NUM_CSNS);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -501,7 +501,7 @@ static int CmdHFiClassSim(const char *Cmd) {
|
|||
case 1:
|
||||
case 3:
|
||||
default: {
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_ICLASS, {simType, numberOfCSNs}, {{0}}};
|
||||
PacketCommandOLD 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;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_ICLASS_REPLAY, {readerType}, {{0}}};
|
||||
PacketCommandOLD 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) {
|
||||
UsbCommandOLD c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
UsbCommandOLD c = {CMD_ICLASS_EML_MEMSET, {bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
|
@ -767,8 +767,8 @@ 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;
|
||||
UsbCommandOLD c = {CMD_READER_ICLASS, {0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD 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)
|
||||
|
@ -818,8 +818,8 @@ 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);
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD d = {CMD_ICLASS_AUTHENTICATION, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD d = {CMD_ICLASS_AUTHENTICATION, {0, 0, 0}, {{0}}};
|
||||
memcpy(d.d.asBytes, MAC, 4);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&d);
|
||||
|
@ -939,8 +939,8 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
FLAG_ICLASS_READER_ONE_TRY;
|
||||
|
||||
//get config and first 3 blocks
|
||||
UsbCommandOLD c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
uint8_t tag_data[255 * 8];
|
||||
|
||||
clearCommandBuffer();
|
||||
|
@ -981,7 +981,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
}
|
||||
|
||||
// begin dump
|
||||
UsbCommandOLD w = {CMD_ICLASS_DUMP, {blockno, numblks - blockno + 1}, {{0}}};
|
||||
PacketCommandOLD w = {CMD_ICLASS_DUMP, {blockno, numblks - blockno + 1}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&w);
|
||||
while (true) {
|
||||
|
@ -1097,10 +1097,10 @@ 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;
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
Calc_wb_mac(blockno, bldata, div_key, MAC);
|
||||
UsbCommandOLD w = {CMD_ICLASS_WRITEBLOCK, {blockno}, {{0}}};
|
||||
PacketCommandOLD w = {CMD_ICLASS_WRITEBLOCK, {blockno}, {{0}}};
|
||||
memcpy(w.d.asBytes, bldata, 8);
|
||||
memcpy(w.d.asBytes + 8, MAC, 4);
|
||||
|
||||
|
@ -1321,7 +1321,7 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
UsbCommandOLD w = {CMD_ICLASS_CLONE, {startblock, endblock}, {{0}}};
|
||||
PacketCommandOLD 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++) {
|
||||
|
@ -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]);
|
||||
}
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&w);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
|
||||
|
@ -1367,8 +1367,8 @@ static int ReadBlock(uint8_t *KEY, uint8_t blockno, uint8_t keyType, bool elite,
|
|||
return 0;
|
||||
}
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_ICLASS_READBLOCK, {blockno}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_ICLASS_READBLOCK, {blockno}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4500)) {
|
||||
|
@ -1977,7 +1977,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
if (keys == keycnt - i)
|
||||
lastChunk = true;
|
||||
|
||||
UsbCommandOLD c = {CMD_ICLASS_CHECK_KEYS, { (lastChunk << 8), keys, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ICLASS_CHECK_KEYS, { (lastChunk << 8), keys, 0}, {{0}}};
|
||||
|
||||
// bit 16
|
||||
// - 1 indicates credit key
|
||||
|
@ -1987,7 +1987,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
memcpy(c.d.asBytes, pre + i, 4 * keys);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
timeout++;
|
||||
|
@ -2465,9 +2465,9 @@ int readIclass(bool loop, bool verbose) {
|
|||
FLAG_ICLASS_READER_CONF | FLAG_ICLASS_READER_ONLY_ONCE |
|
||||
FLAG_ICLASS_READER_ONE_TRY;
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ICLASS, {flags, 0, 0}, {{0}}};
|
||||
// loop in client not device - else on windows have a communication error
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
while (!ukbhit()) {
|
||||
|
||||
clearCommandBuffer();
|
||||
|
|
|
@ -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();
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_LEGIC_RF, {1}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SIMULATE_TAG_LEGIC_RF, {1}, {{0}}};
|
||||
sscanf(Cmd, " %" SCNi64, &c.arg[0]);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -642,9 +642,9 @@ static int CmdLegicRfWrite(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Writing to tag");
|
||||
|
||||
UsbCommandOLD c = {CMD_WRITER_LEGIC_RF, {offset, len, IV}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_WRITER_LEGIC_RF, {offset, len, IV}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, len);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
|
@ -756,10 +756,10 @@ int legic_read_mem(uint32_t offset, uint32_t len, uint32_t iv, uint8_t *out, uin
|
|||
|
||||
legic_chk_iv(&iv);
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_LEGIC_RF, {offset, len, iv}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_LEGIC_RF, {offset, len, iv}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
@ -810,10 +810,10 @@ int legic_get_type(legic_card_select_t *card) {
|
|||
|
||||
if (card == NULL) return 1;
|
||||
|
||||
UsbCommandOLD c = {CMD_LEGIC_INFO, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_LEGIC_INFO, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500))
|
||||
return 2;
|
||||
|
||||
|
@ -837,7 +837,7 @@ void legic_chk_iv(uint32_t *iv) {
|
|||
}
|
||||
void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
||||
|
||||
UsbCommandOLD c = {CMD_LEGIC_ESET, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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,10 +900,10 @@ static int CmdLegicDump(const char *Cmd) {
|
|||
legic_print_type(dumplen, 0);
|
||||
PrintAndLogEx(SUCCESS, "Reading tag memory %d b...", dumplen);
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_LEGIC_RF, {0x00, dumplen, 0x55}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_LEGIC_RF, {0x00, dumplen, 0x55}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
uint8_t timeout = 0;
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
|
@ -1049,8 +1049,8 @@ static int CmdLegicRestore(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Restoring to card");
|
||||
|
||||
// transfer to device
|
||||
UsbCommandOLD c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
for (size_t i = 7; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
|
||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
|
@ -1242,8 +1242,8 @@ static int CmdLegicWipe(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Erasing");
|
||||
|
||||
// transfer to device
|
||||
UsbCommandOLD c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_WRITER_LEGIC_RF, {0, 0, 0x55}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
for (size_t i = 7; i < card.cardsize; i += USB_CMD_DATA_SIZE) {
|
||||
|
||||
printf(".");
|
||||
|
|
|
@ -411,10 +411,10 @@ static int usage_hf14_nack(void) {
|
|||
}
|
||||
|
||||
static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "iso14443a card select failed");
|
||||
DropField();
|
||||
|
@ -522,13 +522,13 @@ 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));
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
memcpy(c.d.asBytes + 10, bldata, 16);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||
|
@ -568,12 +568,12 @@ static int CmdHF14AMfRdBl(const char *Cmd) {
|
|||
}
|
||||
PrintAndLogEx(NORMAL, "--block no:%d, key type:%c, key:%s ", blockNo, keyType ? 'B' : 'A', sprint_hex(key, 6));
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
uint8_t *data = resp.data.asBytes;
|
||||
|
@ -638,13 +638,13 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
|
|||
}
|
||||
PrintAndLogEx(NORMAL, "--sector no:%d key type:%c key:%s ", sectorNo, keyType ? 'B' : 'A', sprint_hex(key, 6));
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
isOK = resp.oldarg[0] & 0xff;
|
||||
data = resp.data.asBytes;
|
||||
|
@ -736,7 +736,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
memset(dataFilename, 0, sizeof(dataFilename));
|
||||
|
||||
FILE *f;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
|
@ -803,7 +803,7 @@ static int CmdHF14AMfDump(const char *Cmd) {
|
|||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
for (tries = 0; tries < MIFARE_SECTOR_RETRY; tries++) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + NumBlocksPerSector(sectorNo) - 1, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, keyA[sectorNo], 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -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.
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 1, 0}, {{0}}};
|
||||
PacketCommandOLD 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
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_READBL, {FirstBlockOfSector(sectorNo) + blockNo, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, keyA[sectorNo], 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -1019,7 +1019,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
|||
|
||||
for (sectorNo = 0; sectorNo < numSectors; sectorNo++) {
|
||||
for (blockNo = 0; blockNo < NumBlocksPerSector(sectorNo); blockNo++) {
|
||||
UsbCommandOLD c = {CMD_MIFARE_WRITEBL, {FirstBlockOfSector(sectorNo) + blockNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD 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) {
|
||||
|
@ -1050,7 +1050,7 @@ static int CmdHF14AMfRestore(const char *Cmd) {
|
|||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
|
||||
|
@ -1251,12 +1251,12 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "reading block %d", sectrail);
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {sectrail, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
|
@ -1997,12 +1997,12 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "Reading block %d", sectrail);
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {sectrail, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
||||
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
|
@ -2231,11 +2231,11 @@ static int CmdHF14AMfSim(const char *Cmd) {
|
|||
, flags
|
||||
, flags);
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMULATE_MIFARE_CARD, {flags, exitAfterNReads, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SIMULATE_MIFARE_CARD, {flags, exitAfterNReads, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, uid, sizeof(uid));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (flags & FLAG_INTERACTIVE) {
|
||||
PrintAndLogEx(INFO, "Press pm3-button or send another cmd to abort simulation");
|
||||
|
@ -2291,11 +2291,11 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "Press the key on pc keyboard to abort the client.\n");
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------------------\n");
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_SNIFFER, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_SNIFFER, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
// wait cycle
|
||||
while (true) {
|
||||
|
@ -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();
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_SET_DBGMODE, {dbgMode, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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();
|
||||
|
||||
UsbCommandOLD cmd = {CMD_MIFARE_EML_MEMCLR, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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');
|
||||
UsbCommandOLD cmd = {CMD_MIFARE_EML_CARDLOAD, {numSectors, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD cmd = {CMD_MIFARE_EML_CARDLOAD, {numSectors, keyType, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&cmd);
|
||||
return 0;
|
||||
|
@ -3155,12 +3155,12 @@ static int CmdHf14AMfSetMod(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_SETMOD, {mod, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_SETMOD, {mod, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t ok = resp.oldarg[0] & 0xff;
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", ok);
|
||||
|
@ -3202,7 +3202,7 @@ static int CmdHF14AMfice(const char *Cmd) {
|
|||
char ctmp;
|
||||
char filename[FILE_PATH_SIZE], *fptr;
|
||||
FILE *fnonces = NULL;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
uint32_t part_limit = 3000;
|
||||
uint32_t limit = 50000;
|
||||
|
@ -3256,7 +3256,7 @@ static int CmdHF14AMfice(const char *Cmd) {
|
|||
flags = 0;
|
||||
flags |= initialize ? 0x0001 : 0;
|
||||
flags |= slow ? 0x0002 : 0;
|
||||
UsbCommandOLD c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
|
@ -3289,7 +3289,7 @@ out:
|
|||
fclose(fnonces);
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_ACQUIRE_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
|
|
@ -51,12 +51,12 @@ 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));
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_WRITEBL, {blockNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD 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;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
PrintAndLogEx(NORMAL, "isOk:%02x", isOK);
|
||||
|
@ -93,11 +93,11 @@ static int CmdHF14ADesRb(const char *Cmd) {
|
|||
}
|
||||
PrintAndLogEx(NORMAL, "--block no:%02x key type:%02x key:%s ", blockNo, keyType, sprint_hex(key, 6));
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_READBL, {blockNo, keyType, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
uint8_t * data = resp.data.asBytes;
|
||||
|
@ -116,9 +116,9 @@ static int CmdHF14ADesRb(const char *Cmd) {
|
|||
static int CmdHF14ADesInfo(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_DESFIRE_INFO, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_DESFIRE_INFO, {0, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||
|
@ -256,8 +256,8 @@ void getKeySettings(uint8_t *aid) {
|
|||
const char *str = messStr;
|
||||
uint8_t isOK = 0;
|
||||
uint32_t options;
|
||||
UsbCommandOLD c = {CMD_MIFARE_DESFIRE, {0, 0, 0}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_MIFARE_DESFIRE, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
|
||||
//memset(messStr, 0x00, 512);
|
||||
|
||||
|
@ -427,11 +427,11 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
|
|||
uint8_t aid[3];
|
||||
uint32_t options = (INIT | DISCONNECT);
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_DESFIRE, {options, 0x01 }, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_DESFIRE, {options, 0x01 }, {{0}}};
|
||||
c.d.asBytes[0] = GET_APPLICATION_IDS; //0x6a
|
||||
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
return 0;
|
||||
|
@ -445,8 +445,8 @@ static int CmdHF14ADesEnumApplications(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "-- Desfire Enumerate Applications ---------------------------");
|
||||
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
|
||||
|
||||
UsbReplyNG respAid;
|
||||
UsbReplyNG respFiles;
|
||||
PacketResponseNG respAid;
|
||||
PacketResponseNG respFiles;
|
||||
|
||||
uint8_t num = 0;
|
||||
int max = resp.oldarg[1] - 3 - 2;
|
||||
|
@ -611,13 +611,13 @@ static int CmdHF14ADesAuth(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
// algo, nyckell<6C>ngd,
|
||||
UsbCommandOLD c = {CMD_MIFARE_DESFIRE_AUTH1, { cmdAuthMode, cmdAuthAlgo, cmdKeyNo }, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_DESFIRE_AUTH1, { cmdAuthMode, cmdAuthAlgo, cmdKeyNo }, {{0}}};
|
||||
|
||||
c.d.asBytes[0] = keylength;
|
||||
memcpy(c.d.asBytes + 1, key, keylength);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) {
|
||||
PrintAndLogEx(WARNING, "Client command execute timeout");
|
||||
|
|
|
@ -58,9 +58,9 @@ static int CmdHF14AMfDESAuth(const char *Cmd) {
|
|||
//DES_set_key((DES_cblock *)key2,&ks2);
|
||||
|
||||
//Auth1
|
||||
UsbCommandOLD c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
cuid = resp.oldarg[1];
|
||||
|
@ -94,13 +94,13 @@ static int CmdHF14AMfDESAuth(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "b2:%s", sprint_hex(b2, 8));
|
||||
|
||||
//Auth2
|
||||
UsbCommandOLD d = {CMD_MIFARE_DES_AUTH2, {cuid}};
|
||||
PacketCommandOLD d = {CMD_MIFARE_DES_AUTH2, {cuid}};
|
||||
memcpy(reply, b1, 8);
|
||||
memcpy(reply + 8, b2, 8);
|
||||
memcpy(d.d.asBytes, reply, 16);
|
||||
SendCommand(&d);
|
||||
|
||||
UsbReplyNG respb;
|
||||
PacketResponseNG respb;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &respb, 1500)) {
|
||||
uint8_t isOK = respb.arg[0] & 0xff;
|
||||
uint8_t *data2 = respb.d.asBytes;
|
||||
|
@ -158,9 +158,9 @@ static int CmdHF14AMfAESAuth(const char *Cmd) {
|
|||
AES_set_decrypt_key(key, 128, &key_d);
|
||||
|
||||
//Auth1
|
||||
UsbCommandOLD c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_DES_AUTH1, {blockNo}};
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
cuid = resp.oldarg[1];
|
||||
|
@ -201,13 +201,13 @@ static int CmdHF14AMfAESAuth(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "b2:%s", sprint_hex(b2, 16));
|
||||
|
||||
//Auth2
|
||||
UsbCommandOLD d = {CMD_MIFARE_DES_AUTH2, {cuid}};
|
||||
PacketCommandOLD d = {CMD_MIFARE_DES_AUTH2, {cuid}};
|
||||
memcpy(reply, b1, 16);
|
||||
memcpy(reply + 16, b2, 16);
|
||||
memcpy(d.d.asBytes, reply, 32);
|
||||
SendCommand(&d);
|
||||
|
||||
UsbReplyNG respb;
|
||||
PacketResponseNG respb;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &respb, 1500)) {
|
||||
uint8_t isOK = respb.arg[0] & 0xff;
|
||||
uint8_t *data2 = respb.d.asBytes;
|
||||
|
|
|
@ -1372,7 +1372,7 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
|
|||
bool reported_suma8 = false;
|
||||
char progress_text[80];
|
||||
FILE *fnonces = NULL;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
num_acquired_nonces = 0;
|
||||
|
||||
|
@ -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;
|
||||
UsbCommandOLD c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
|
||||
clearCommandBuffer();
|
||||
|
@ -1394,7 +1394,7 @@ 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)
|
||||
UsbCommandOLD c1 = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
|
||||
PacketCommandOLD c1 = {CMD_MIFARE_ACQUIRE_ENCRYPTED_NONCES, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, 4}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c1);
|
||||
return 1;
|
||||
|
|
|
@ -42,10 +42,10 @@ static int CmdHFMFPInfo(const char *cmd) {
|
|||
infoHF14A(false, false);
|
||||
|
||||
// Mifare Plus info
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
iso14a_card_select_t card;
|
||||
|
|
|
@ -458,17 +458,17 @@ static char *getUlev1CardSizeStr(uint8_t fsize) {
|
|||
}
|
||||
|
||||
static void ul_switch_on_field(void) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
PacketCommandOLD 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) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_APPEND_CRC | ISO14A_NO_RATS, cmdlen, 0}, {{0}}};
|
||||
PacketCommandOLD 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;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return -1;
|
||||
if (!resp.oldarg[0] && responseLength) return -1;
|
||||
|
||||
|
@ -481,7 +481,7 @@ static int ul_select(iso14a_card_select_t *card) {
|
|||
|
||||
ul_switch_on_field();
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
bool ans = false;
|
||||
ans = WaitForResponseTimeout(CMD_ACK, &resp, 1500);
|
||||
|
||||
|
@ -533,11 +533,11 @@ static int ulc_requestAuthentication(uint8_t *nonce, uint16_t nonceLength) {
|
|||
|
||||
static int ulc_authentication(uint8_t *key, bool switch_off_field) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFAREUC_AUTH, {switch_off_field}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFAREUC_AUTH, {switch_off_field}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 16);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return 0;
|
||||
if (resp.oldarg[0] == 1) return 1;
|
||||
|
||||
|
@ -621,13 +621,13 @@ static int ul_fudan_check(void) {
|
|||
if (!ul_select(&card))
|
||||
return UL_ERROR;
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_NO_RATS, 4, 0}, {{0}}};
|
||||
PacketCommandOLD 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);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return UL_ERROR;
|
||||
if (resp.oldarg[0] != 1) return UL_ERROR;
|
||||
|
||||
|
@ -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
|
||||
UsbCommandOLD c = {CMD_MIFAREU_WRITEBL, {blockNo}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFAREU_WRITEBL, {blockNo}, {{0}}};
|
||||
memcpy(c.d.asBytes, blockdata, 4);
|
||||
|
||||
if (hasAuthKey) {
|
||||
|
@ -1488,7 +1488,7 @@ static int CmdHF14AMfUWrBl(const char *Cmd) {
|
|||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
PrintAndLogEx(SUCCESS, "isOk:%02x", isOK);
|
||||
|
@ -1581,7 +1581,7 @@ static int CmdHF14AMfURdBl(const char *Cmd) {
|
|||
if (swapEndian && hasPwdKey) authKeyPtr = SwapEndian64(authenticationkey, 4, 4);
|
||||
|
||||
//Read Block
|
||||
UsbCommandOLD c = {CMD_MIFAREU_READBL, {blockNo}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFAREU_READBL, {blockNo}, {{0}}};
|
||||
if (hasAuthKey) {
|
||||
c.arg[1] = 1;
|
||||
memcpy(c.d.asBytes, authKeyPtr, 16);
|
||||
|
@ -1592,7 +1592,7 @@ static int CmdHF14AMfURdBl(const char *Cmd) {
|
|||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
if (isOK) {
|
||||
|
@ -1846,7 +1846,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
|
|||
}
|
||||
ul_print_type(tagtype, 0);
|
||||
PrintAndLogEx(SUCCESS, "Reading tag memory...");
|
||||
UsbCommandOLD c = {CMD_MIFAREU_READCARD, {startPage, pages}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFAREU_READCARD, {startPage, pages}, {{0}}};
|
||||
if (hasAuthKey) {
|
||||
if (tagtype & UL_C)
|
||||
c.arg[2] = 1; //UL_C auth
|
||||
|
@ -1858,7 +1858,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
|
|||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "Command execute time-out");
|
||||
return 1;
|
||||
|
@ -1982,7 +1982,7 @@ static int CmdHF14AMfUDump(const char *Cmd) {
|
|||
}
|
||||
|
||||
static void wait4response(uint8_t b) {
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
if (!isOK)
|
||||
|
@ -2010,7 +2010,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
|
|||
bool read_key = false;
|
||||
size_t filelen = 0;
|
||||
FILE *f;
|
||||
UsbCommandOLD c = {CMD_MIFAREU_WRITEBL, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFAREU_WRITEBL, {0, 0, 0}, {{0}}};
|
||||
|
||||
memset(authkey, 0x00, sizeof(authkey));
|
||||
|
||||
|
@ -2387,12 +2387,12 @@ static int CmdHF14AMfUCSetPwd(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFAREUC_SETPWD, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFAREUC_SETPWD, {0, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, pwd, 16);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
if ((resp.oldarg[0] & 0xff) == 1) {
|
||||
PrintAndLogEx(INFO, "Ultralight-C new password: %s", sprint_hex(pwd, 16));
|
||||
|
@ -2412,8 +2412,8 @@ static int CmdHF14AMfUCSetPwd(const char *Cmd) {
|
|||
//
|
||||
static int CmdHF14AMfUCSetUid(const char *Cmd) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFAREU_READBL, {0, 0, 0}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_MIFAREU_READBL, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
uint8_t uid[7] = {0x00};
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
|
||||
|
@ -2487,10 +2487,10 @@ static int CmdHF14AMfUGenDiverseKeys(const char *Cmd) {
|
|||
|
||||
if (cmdp == 'r') {
|
||||
// read uid from tag
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
iso14a_card_select_t card;
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
|
||||
|
@ -2602,10 +2602,10 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) {
|
|||
|
||||
if (cmdp == 'r') {
|
||||
// read uid from tag
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
iso14a_card_select_t card;
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.data.asBytes, sizeof(iso14a_card_select_t));
|
||||
|
|
|
@ -31,22 +31,22 @@ static struct {
|
|||
} topaz_tag;
|
||||
|
||||
static void topaz_switch_on_field(void) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT | ISO14A_NO_SELECT | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
}
|
||||
|
||||
static void topaz_switch_off_field(void) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {0, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
}
|
||||
|
||||
// send a raw topaz command, returns the length of the response (0 in case of error)
|
||||
static int topaz_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response) {
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {ISO14A_RAW | ISO14A_NO_DISCONNECT | ISO14A_TOPAZMODE | ISO14A_NO_RATS, len, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, cmd, len);
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
|
||||
if (resp.oldarg[0] > 0) {
|
||||
|
|
|
@ -308,7 +308,7 @@ static void lookupChipID(uint32_t iChipID, uint32_t mem_used) {
|
|||
}
|
||||
|
||||
static int CmdDetectReader(const char *Cmd) {
|
||||
UsbCommandOLD c = {CMD_LISTEN_READER_FIELD, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_LISTEN_READER_FIELD, {0, 0, 0}, {{0}}};
|
||||
// 'l' means LF - 125/134 kHz
|
||||
if (*Cmd == 'l') {
|
||||
c.arg[0] = 1;
|
||||
|
@ -326,7 +326,7 @@ static int CmdDetectReader(const char *Cmd) {
|
|||
// ## FPGA Control
|
||||
static int CmdFPGAOff(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
UsbCommandOLD c = {CMD_FPGA_MAJOR_MODE_OFF, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FPGA_MAJOR_MODE_OFF, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -336,7 +336,7 @@ static int CmdFPGAOff(const char *Cmd) {
|
|||
static int CmdLCD(const char *Cmd) {
|
||||
int i, j;
|
||||
|
||||
UsbCommandOLD c = {CMD_LCD, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_LCD, {0, 0, 0}, {{0}}};
|
||||
sscanf(Cmd, "%x %d", &i, &j);
|
||||
while (j--) {
|
||||
c.arg[0] = i & 0x1ff;
|
||||
|
@ -347,7 +347,7 @@ static int CmdLCD(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdLCDReset(const char *Cmd) {
|
||||
UsbCommandOLD c = {CMD_LCD_RESET, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_LCD_RESET, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -355,7 +355,7 @@ static int CmdLCDReset(const char *Cmd) {
|
|||
#endif
|
||||
|
||||
static int CmdReadmem(const char *Cmd) {
|
||||
UsbCommandOLD c = {CMD_READ_MEM, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READ_MEM, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -363,7 +363,7 @@ static int CmdReadmem(const char *Cmd) {
|
|||
|
||||
static int CmdReset(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
UsbCommandOLD c = {CMD_HARDWARE_RESET, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_HARDWARE_RESET, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -374,7 +374,7 @@ static int CmdReset(const char *Cmd) {
|
|||
* 600kHz.
|
||||
*/
|
||||
static int CmdSetDivisor(const char *Cmd) {
|
||||
UsbCommandOLD c = {CMD_SET_LF_DIVISOR, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SET_LF_DIVISOR, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
|
||||
|
||||
if (c.arg[0] < 19 || c.arg[0] > 255) {
|
||||
PrintAndLogEx(NORMAL, "divisor must be between 19 and 255");
|
||||
|
@ -394,7 +394,7 @@ static int CmdSetMux(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_SET_ADC_MUX, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SET_ADC_MUX, {0, 0, 0}, {{0}}};
|
||||
|
||||
if (strcmp(Cmd, "lopkd") == 0) c.arg[0] = 0;
|
||||
else if (strcmp(Cmd, "loraw") == 0) c.arg[0] = 1;
|
||||
|
@ -418,8 +418,8 @@ static int CmdVersion(const char *Cmd) {
|
|||
static int CmdStatus(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
clearCommandBuffer();
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_STATUS, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_STATUS, {0, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1900))
|
||||
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
|
||||
|
@ -429,8 +429,8 @@ static int CmdStatus(const char *Cmd) {
|
|||
static int CmdPing(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
clearCommandBuffer();
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000))
|
||||
PrintAndLogEx(NORMAL, "Ping successful");
|
||||
|
@ -445,7 +445,7 @@ static int CmdPingNG(const char *Cmd) {
|
|||
len = USB_CMD_DATA_SIZE;
|
||||
PrintAndLogEx(NORMAL, "PingNG sent with payload len=%d", len);
|
||||
clearCommandBuffer();
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
uint8_t data[USB_CMD_DATA_SIZE] = {0};
|
||||
uint16_t cmd = CMD_PING;
|
||||
for (uint16_t i = 0; i < len; i++)
|
||||
|
@ -496,8 +496,8 @@ int CmdHW(const char *Cmd) {
|
|||
void pm3_version(bool verbose) {
|
||||
if (!verbose)
|
||||
return;
|
||||
UsbCommandOLD c = {CMD_VERSION, {0, 0, 0}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_VERSION, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
|
||||
|
|
|
@ -144,7 +144,7 @@ static int usage_lf_find(void) {
|
|||
/* send a LF command before reading */
|
||||
int CmdLFCommandRead(const char *Cmd) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K, {0, 0, 0}, {{0}}};
|
||||
bool errors = false;
|
||||
|
||||
uint8_t cmdp = 0;
|
||||
|
@ -322,7 +322,7 @@ int CmdLFSetConfig(const char *Cmd) {
|
|||
|
||||
sample_config config = { decimation, bps, averaging, divisor, trigger_threshold };
|
||||
|
||||
UsbCommandOLD c = {CMD_SET_LF_SAMPLING_CONFIG, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SET_LF_SAMPLING_CONFIG, {0, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, &config, sizeof(sample_config));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -331,11 +331,11 @@ int CmdLFSetConfig(const char *Cmd) {
|
|||
|
||||
bool lf_read(bool silent, uint32_t samples) {
|
||||
if (IsOffline()) return false;
|
||||
UsbCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {silent, samples, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_125K, {silent, samples, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (g_lf_threshold_set) {
|
||||
WaitForResponse(CMD_ACK, &resp);
|
||||
} else {
|
||||
|
@ -387,7 +387,7 @@ int CmdLFSniff(const char *Cmd) {
|
|||
uint8_t cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (cmdp == 'h') return usage_lf_sniff();
|
||||
|
||||
UsbCommandOLD c = {CMD_LF_SNIFF_RAW_ADC_SAMPLES, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_LF_SNIFF_RAW_ADC_SAMPLES, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
WaitForResponse(CMD_ACK, NULL);
|
||||
|
@ -420,7 +420,7 @@ int CmdLFSim(const char *Cmd) {
|
|||
|
||||
//can send only 512 bits at a time (1 byte sent per bit...)
|
||||
for (uint16_t i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) {
|
||||
UsbCommandOLD c = {CMD_UPLOAD_SIM_SAMPLES_125K, {i, FPGA_LF, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_UPLOAD_SIM_SAMPLES_125K, {i, FPGA_LF, 0}, {{0}}};
|
||||
|
||||
for (uint16_t j = 0; j < USB_CMD_DATA_SIZE; j++)
|
||||
c.d.asBytes[j] = GraphBuffer[i + j];
|
||||
|
@ -434,7 +434,7 @@ int CmdLFSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "Simulating");
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SIMULATE_TAG_125K, {GraphTraceLen, gap, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -523,7 +523,7 @@ int CmdLFfskSim(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
|
||||
size = USB_CMD_DATA_SIZE;
|
||||
}
|
||||
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
|
||||
memcpy(c.d.asBytes, DemodBuffer, size);
|
||||
clearCommandBuffer();
|
||||
|
@ -619,7 +619,7 @@ int CmdLFaskSim(const char *Cmd) {
|
|||
arg1 = clk << 8 | encoding;
|
||||
arg2 = invert << 8 | separator;
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, DemodBuffer, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -726,7 +726,7 @@ int CmdLFpskSim(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
|
||||
size = USB_CMD_DATA_SIZE;
|
||||
}
|
||||
UsbCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Sending DemodBuffer Length: %d", size);
|
||||
memcpy(c.d.asBytes, DemodBuffer, size);
|
||||
clearCommandBuffer();
|
||||
|
@ -739,7 +739,7 @@ int CmdLFSimBidir(const char *Cmd) {
|
|||
// Set ADC to twice the carrier for a slight supersampling
|
||||
// HACK: not implemented in ARMSRC.
|
||||
PrintAndLogEx(INFO, "Not implemented yet.");
|
||||
UsbCommandOLD c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_LF_SIMULATE_BIDIR, {47, 384, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -87,12 +87,12 @@ static int usage_lf_awid_brute(void) {
|
|||
}
|
||||
|
||||
static bool sendPing(void) {
|
||||
UsbCommandOLD ping = {CMD_PING, {1, 2, 3}, {{0}}};
|
||||
PacketCommandOLD ping = {CMD_PING, {1, 2, 3}, {{0}}};
|
||||
SendCommand(&ping);
|
||||
SendCommand(&ping);
|
||||
SendCommand(&ping);
|
||||
clearCommandBuffer();
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -112,7 +112,7 @@ static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, ui
|
|||
uint64_t arg1 = (high << 8) + low;
|
||||
uint64_t arg2 = (invert << 8) + clk;
|
||||
|
||||
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, bs_len}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, bs_len}, {{0}}};
|
||||
memcpy(c.d.asBytes, bits, bs_len);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -171,7 +171,7 @@ static int CmdAWIDRead_device(const char *Cmd) {
|
|||
|
||||
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_awid_read();
|
||||
uint8_t findone = (Cmd[0] == '1') ? 1 : 0;
|
||||
UsbCommandOLD c = {CMD_AWID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_AWID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -350,7 +350,7 @@ static int CmdAWIDSim(const char *Cmd) {
|
|||
// arg1 --- fcHigh<<8 + fcLow
|
||||
// arg2 --- Inversion and clk setting
|
||||
// 96 --- Bitstream length: 96-bits == 12 bytes
|
||||
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bits, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -392,8 +392,8 @@ static int CmdAWIDClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone AWID %u to T55x7 with FC: %u, CN: %u", fmtlen, fc, cn);
|
||||
print_blocks(blocks, 4);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
|
|
@ -74,7 +74,7 @@ static int CmdCOTAGRead(const char *Cmd) {
|
|||
uint32_t rawsignal = 1;
|
||||
sscanf(Cmd, "%u", &rawsignal);
|
||||
|
||||
UsbCommandOLD c = {CMD_COTAG, {rawsignal, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_COTAG, {rawsignal, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, NULL, 7000)) {
|
||||
|
|
|
@ -389,7 +389,7 @@ int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo, bool verbose) {
|
|||
static int CmdEM410xRead_device(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
uint8_t findone = (cmdp == '1') ? 1 : 0;
|
||||
UsbCommandOLD c = {CMD_EM410X_DEMOD, {findone, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_EM410X_DEMOD, {findone, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -648,7 +648,7 @@ static int CmdEM410xWrite(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_EM410X_WRITE_TAG, {card, (uint32_t)(id >> 32), (uint32_t)id}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_EM410X_WRITE_TAG, {card, (uint32_t)(id >> 32), (uint32_t)id}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1127,10 +1127,10 @@ static bool demodEM4x05resp(uint32_t *word) {
|
|||
|
||||
//////////////// 4205 / 4305 commands
|
||||
static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
|
||||
UsbCommandOLD c = {CMD_EM4X_READ_WORD, {addr, pwd, usePwd}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_EM4X_READ_WORD, {addr, pwd, usePwd}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(DEBUG, "timeout while waiting for reply.");
|
||||
return -1;
|
||||
|
@ -1230,10 +1230,10 @@ static int CmdEM4x05Write(const char *Cmd) {
|
|||
|
||||
uint16_t flag = (addr << 8) | (usePwd);
|
||||
|
||||
UsbCommandOLD c = {CMD_EM4X_WRITE_WORD, {flag, data, pwd}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_EM4X_WRITE_WORD, {flag, data, pwd}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
|
|
|
@ -281,8 +281,8 @@ static int CmdFdxClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone FDX-B to T55x7 with animal ID: %04u-%"PRIu64, countryid, animalid);
|
||||
print_blocks(blocks, 5);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (int i = 4; i >= 0; --i) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -318,7 +318,7 @@ static int CmdFdxSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating FDX-B animal ID: %04u-%"PRIu64, countryid, animalid);
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
|
||||
//getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits)
|
||||
getFDXBits(animalid, countryid, 1, 0, 0, c.d.asBytes);
|
||||
|
|
|
@ -171,8 +171,8 @@ static int CmdGuardClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone Guardall to T55x7 with Facility Code: %u, Card Number: %u", facilitycode, cardnumber);
|
||||
print_blocks(blocks, 4);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -217,7 +217,7 @@ static int CmdGuardSim(const char *Cmd) {
|
|||
arg1 = (clock1 << 8) | encoding;
|
||||
arg2 = (invert << 8) | separator;
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bs, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -93,12 +93,12 @@ static int usage_lf_hid_brute(void) {
|
|||
|
||||
// sending three times. Didn't seem to break the previous sim?
|
||||
static bool sendPing(void) {
|
||||
UsbCommandOLD ping = {CMD_PING, {1, 2, 3}, {{0}}};
|
||||
PacketCommandOLD ping = {CMD_PING, {1, 2, 3}, {{0}}};
|
||||
SendCommand(&ping);
|
||||
SendCommand(&ping);
|
||||
SendCommand(&ping);
|
||||
clearCommandBuffer();
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1000))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -113,7 +113,7 @@ static bool sendTry(uint8_t fmtlen, uint32_t fc, uint32_t cn, uint32_t delay, ui
|
|||
|
||||
uint64_t arg1 = bytebits_to_byte(bits, 32);
|
||||
uint64_t arg2 = bytebits_to_byte(bits + 32, 32);
|
||||
UsbCommandOLD c = {CMD_HID_SIM_TAG, {arg1, arg2, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_HID_SIM_TAG, {arg1, arg2, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
|
@ -242,7 +242,7 @@ static int CmdHIDRead_device(const char *Cmd) {
|
|||
|
||||
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_hid_read();
|
||||
uint8_t findone = (Cmd[0] == '1') ? 1 : 0;
|
||||
UsbCommandOLD c = {CMD_HID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_HID_DEMOD_FSK, {findone, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -263,7 +263,7 @@ static int CmdHIDSim(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Simulating HID tag with ID %x%08x", hi, lo);
|
||||
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation");
|
||||
|
||||
UsbCommandOLD c = {CMD_HID_SIM_TAG, {hi, lo, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_HID_SIM_TAG, {hi, lo, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -273,7 +273,7 @@ static int CmdHIDClone(const char *Cmd) {
|
|||
|
||||
uint32_t hi2 = 0, hi = 0, lo = 0;
|
||||
uint32_t n = 0, i = 0;
|
||||
UsbCommandOLD c = {CMD_HID_CLONE_TAG, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_HID_CLONE_TAG, {0, 0, 0}, {{0}}};
|
||||
|
||||
uint8_t ctmp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) == 0 || ctmp == 'H' || ctmp == 'h') return usage_lf_hid_clone();
|
||||
|
|
|
@ -135,7 +135,7 @@ static int CmdLFHitagList(const char *Cmd) {
|
|||
}
|
||||
|
||||
// Query for the actual size of the trace
|
||||
UsbReplyNG response;
|
||||
PacketResponseNG response;
|
||||
if (!GetFromDevice(BIG_BUF, got, USB_CMD_DATA_SIZE, 0, &response, 2500, false)) {
|
||||
PrintAndLogEx(WARNING, "command execution time out");
|
||||
free(got);
|
||||
|
@ -260,7 +260,7 @@ static int CmdLFHitagSniff(const char *Cmd) {
|
|||
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||
if (ctmp == 'h') return usage_hitag_sniff();
|
||||
|
||||
UsbCommandOLD c = {CMD_SNIFF_HITAG, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SNIFF_HITAG, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -277,7 +277,7 @@ static int CmdLFHitagSim(const char *Cmd) {
|
|||
int res = 0;
|
||||
char filename[FILE_PATH_SIZE] = { 0x00 };
|
||||
|
||||
UsbCommandOLD c = {CMD_SIMULATE_HITAG, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SIMULATE_HITAG, {0, 0, 0}, {{0}}};
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
|
@ -458,10 +458,10 @@ static void printHitagConfiguration(uint8_t config) {
|
|||
|
||||
static bool getHitagUid(uint32_t *uid) {
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_HITAG, {RHT2F_UID_ONLY, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_HITAG, {RHT2F_UID_ONLY, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return false;
|
||||
|
@ -513,7 +513,7 @@ static int CmdLFHitagInfo(const char *Cmd) {
|
|||
//
|
||||
static int CmdLFHitagReader(const char *Cmd) {
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_HITAG, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_HITAG, {0, 0, 0}, {{0}}};
|
||||
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
||||
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
|
@ -559,7 +559,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
|||
c.arg[0] = htf;
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
@ -595,7 +595,7 @@ static int CmdLFHitagReader(const char *Cmd) {
|
|||
|
||||
static int CmdLFHitagCheckChallenges(const char *Cmd) {
|
||||
|
||||
UsbCommandOLD c = { CMD_TEST_HITAGS_TRACES, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = { CMD_TEST_HITAGS_TRACES, {0, 0, 0}, {{0}}};
|
||||
char filename[FILE_PATH_SIZE] = { 0x00 };
|
||||
size_t datalen = 0;
|
||||
int res = 0;
|
||||
|
@ -644,7 +644,7 @@ static int CmdLFHitagCheckChallenges(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdLFHitagWriter(const char *Cmd) {
|
||||
UsbCommandOLD c = { CMD_WR_HITAG_S, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = { CMD_WR_HITAG_S, {0, 0, 0}, {{0}}};
|
||||
hitag_data *htd = (hitag_data *)c.d.asBytes;
|
||||
hitag_function htf = param_get32ex(Cmd, 0, 0, 10);
|
||||
|
||||
|
@ -676,7 +676,7 @@ static int CmdLFHitagWriter(const char *Cmd) {
|
|||
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 4000)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
|
|
@ -404,7 +404,7 @@ static int CmdIndalaSim(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Simulating Indala UID: %s", sprint_hex(hexuid, len));
|
||||
PrintAndLogEx(SUCCESS, "Press pm3-button to abort simulation or run another command");
|
||||
|
||||
UsbCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bits, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -438,7 +438,7 @@ static int CmdIndalaClone(const char *Cmd) {
|
|||
CLIGetHexWithReturn(2, data, &datalen);
|
||||
CLIParserFree();
|
||||
|
||||
UsbCommandOLD c = {0, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {0, {0, 0, 0}, {{0}}};
|
||||
|
||||
if (isLongUid) {
|
||||
PrintAndLogEx(INFO, "Preparing to clone Indala 224bit tag with RawID %s", sprint_hex(data, datalen));
|
||||
|
|
|
@ -66,7 +66,7 @@ static int usage_lf_io_clone(void) {
|
|||
static int CmdIOProxRead_device(const char *Cmd) {
|
||||
if (Cmd[0] == 'h' || Cmd[0] == 'H') return usage_lf_io_read();
|
||||
int findone = (Cmd[0] == '1') ? 1 : 0;
|
||||
UsbCommandOLD c = {CMD_IO_DEMOD_FSK, {findone, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_IO_DEMOD_FSK, {findone, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -215,7 +215,7 @@ static int CmdIOProxSim(const char *Cmd) {
|
|||
// arg1 --- fcHigh<<8 + fcLow
|
||||
// arg2 --- Invert and clk setting
|
||||
// size --- 64 bits == 8 bytes
|
||||
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bits, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -258,8 +258,8 @@ static int CmdIOProxClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone IOProx to T55x7 with Version: %u FC: %u, CN: %u", version, fc, cn);
|
||||
print_blocks(blocks, 3);
|
||||
|
||||
//UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_IO_CLONE_TAG, {blocks[1], blocks[2], 0}, {{0}}};
|
||||
//PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_IO_CLONE_TAG, {blocks[1], blocks[2], 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
|
|
@ -155,8 +155,8 @@ static int CmdJablotronClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone Jablotron to T55x7 with FullCode: %"PRIx64, fullcode);
|
||||
print_blocks(blocks, 3);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i < 3; i++) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -193,7 +193,7 @@ static int CmdJablotronSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Jablotron - FullCode: %"PRIx64, fullcode);
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
getJablotronBits(fullcode, c.d.asBytes);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -146,8 +146,8 @@ static int CmdKeriClone(const char *Cmd) {
|
|||
print_blocks(blocks, 3);
|
||||
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < 3; i++) {
|
||||
|
@ -189,7 +189,7 @@ static int CmdKeriSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating KERI - Internal Id: %u", internalid);
|
||||
|
||||
UsbCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bits, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -202,8 +202,8 @@ static int CmdLFNedapClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone NEDAP to T55x7 with card number: %u", cardnumber);
|
||||
print_blocks(blocks, 5);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i<5; ++i ) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -248,7 +248,7 @@ static int CmdLFNedapSim(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "bin %s", sprint_bin_break(bs, 128, 32));
|
||||
PrintAndLogEx(SUCCESS, "Simulating Nedap - CardNumber: %u", cardnumber);
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bs, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -154,8 +154,8 @@ static int CmdNoralsyClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone Noralsy to T55x7 with CardId: %u", id);
|
||||
print_blocks(blocks, 4);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -198,7 +198,7 @@ static int CmdNoralsySim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Noralsy - CardId: %u", id);
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bs, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -138,7 +138,7 @@ static int CmdParadoxSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "Simulating Paradox - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
|
||||
|
||||
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bs, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -99,8 +99,8 @@ static int CmdLFPCF7931Read(const char *Cmd) {
|
|||
uint8_t ctmp = param_getchar(Cmd, 0);
|
||||
if (ctmp == 'H' || ctmp == 'h') return usage_pcf7931_read();
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_PCF7931_READ, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_PCF7931_READ, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
|
@ -145,7 +145,7 @@ static int CmdLFPCF7931Write(const char *Cmd) {
|
|||
PrintAndLogEx(NORMAL, " pos: %d", bytepos);
|
||||
PrintAndLogEx(NORMAL, " data: 0x%02X", data);
|
||||
|
||||
UsbCommandOLD c = {CMD_PCF7931_WRITE, { block, bytepos, data}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_PCF7931_WRITE, { block, bytepos, data}, {{0}}};
|
||||
memcpy(c.d.asDwords, configPcf.Pwd, sizeof(configPcf.Pwd));
|
||||
c.d.asDwords[7] = (configPcf.OffsetWidth + 128);
|
||||
c.d.asDwords[8] = (configPcf.OffsetPosition + 128);
|
||||
|
|
|
@ -120,8 +120,8 @@ static int CmdPrescoClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone Presco to T55x7 with SiteCode: %u, UserCode: %u, FullCode: %08x", sitecode, usercode, fullcode);
|
||||
print_blocks(blocks, 5);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i < 5; i++) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -152,7 +152,7 @@ static int CmdPrescoSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Presco - SiteCode: %u, UserCode: %u, FullCode: %08X", sitecode, usercode, fullcode);
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
getPrescoBits(fullcode, c.d.asBytes);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -232,8 +232,8 @@ static int CmdPyramidClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone Farpointe/Pyramid to T55x7 with Facility Code: %u, Card Number: %u", facilitycode, cardnumber);
|
||||
print_blocks(blocks, 5);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i < 5; ++i) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -277,7 +277,7 @@ static int CmdPyramidSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Farpointe/Pyramid - Facility Code: %u, CardNumber: %u", facilitycode, cardnumber);
|
||||
|
||||
UsbCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FSK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
memcpy(c.d.asBytes, bs, size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -1018,7 +1018,7 @@ static int CmdT55xxWakeUp(const char *Cmd) {
|
|||
}
|
||||
if (errors) return usage_t55xx_wakup();
|
||||
|
||||
UsbCommandOLD c = {CMD_T55XX_WAKEUP, {password, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_T55XX_WAKEUP, {password, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
PrintAndLogEx(SUCCESS, "Wake up command sent. Try read now");
|
||||
|
@ -1074,8 +1074,8 @@ static int CmdT55xxWriteBlock(const char *Cmd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}, {{0}}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
c.d.asBytes[0] = (page1) ? 0x2 : 0;
|
||||
c.d.asBytes[0] |= (testMode) ? 0x4 : 0;
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
|
|||
// arg1: which block to read
|
||||
// arg2: password
|
||||
uint8_t arg0 = (page << 1 | (pwdmode));
|
||||
UsbCommandOLD c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2500)) {
|
||||
|
@ -1775,7 +1775,7 @@ static void t55x7_create_config_block(int tagtype) {
|
|||
|
||||
static int CmdResetRead(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
UsbCommandOLD c = {CMD_T55XX_RESET_READ, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_T55XX_RESET_READ, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2500)) {
|
||||
|
@ -1856,10 +1856,10 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
|||
uint64_t t1 = msclock();
|
||||
|
||||
if (cmdp == 'm') {
|
||||
UsbCommandOLD c = {CMD_T55XX_CHKPWDS, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_T55XX_CHKPWDS, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
timeout++;
|
||||
|
@ -2299,7 +2299,7 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
|||
|
||||
t55xx_config conf = { startgap * 8, writegap * 8, write0 * 8, write1 * 8, readgap * 8 };
|
||||
|
||||
UsbCommandOLD c = {CMD_SET_LF_T55XX_CONFIG, {shall_persist, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SET_LF_T55XX_CONFIG, {shall_persist, 0, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, &conf, sizeof(t55xx_config));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -275,7 +275,7 @@ out:
|
|||
// read a TI tag and return its ID
|
||||
static int CmdTIRead(const char *Cmd) {
|
||||
(void)Cmd; // Cmd is not used so far
|
||||
UsbCommandOLD c = {CMD_READ_TI_TYPE};
|
||||
PacketCommandOLD c = {CMD_READ_TI_TYPE};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -284,7 +284,7 @@ static int CmdTIRead(const char *Cmd) {
|
|||
// write new data to a r/w TI tag
|
||||
static int CmdTIWrite(const char *Cmd) {
|
||||
int res = 0;
|
||||
UsbCommandOLD c = {CMD_WRITE_TI_TYPE};
|
||||
PacketCommandOLD c = {CMD_WRITE_TI_TYPE};
|
||||
res = sscanf(Cmd, "%012" SCNx64 " %012" SCNx64 " %012" SCNx64 "", &c.arg[0], &c.arg[1], &c.arg[2]);
|
||||
|
||||
if (res == 2)
|
||||
|
|
|
@ -88,10 +88,10 @@ static int CmdVikingClone(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(INFO, "Preparing to clone Viking tag - ID: %08X, Raw: %08X%08X", id, (uint32_t)(rawID >> 32), (uint32_t)(rawID & 0xFFFFFFFF));
|
||||
|
||||
UsbCommandOLD c = {CMD_VIKING_CLONE_TAG, {rawID >> 32, rawID & 0xFFFFFFFF, Q5}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_VIKING_CLONE_TAG, {rawID >> 32, rawID & 0xFFFFFFFF, Q5}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, T55XX_WRITE_TIMEOUT)) {
|
||||
PrintAndLogEx(WARNING, "Error occurred, device did not respond during write operation.");
|
||||
return -1;
|
||||
|
@ -119,7 +119,7 @@ static int CmdVikingSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Viking - ID: %08X, Raw: %08X%08X", id, (uint32_t)(rawID >> 32), (uint32_t)(rawID & 0xFFFFFFFF));
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
num_to_bytebits(rawID, size, c.d.asBytes);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
|
|
@ -166,8 +166,8 @@ static int CmdVisa2kClone(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Preparing to clone Visa2000 to T55x7 with CardId: %u", id);
|
||||
print_blocks(blocks, 4);
|
||||
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_T55XX_WRITE_BLOCK, {0, 0, 0}, {{0}}};
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
c.arg[0] = blocks[i];
|
||||
|
@ -198,7 +198,7 @@ static int CmdVisa2kSim(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Simulating Visa2000 - CardId: %u", id);
|
||||
|
||||
UsbCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}, {{0}}};
|
||||
|
||||
uint32_t blocks[3] = { BL0CK1, id, (visa_parity(id) << 4) | visa_chksum(id) };
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ static int PrintATR(uint8_t *atr, size_t atrlen) {
|
|||
}
|
||||
|
||||
static int smart_wait(uint8_t *data, bool silent) {
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (!silent) PrintAndLogEx(WARNING, "smart card response timeout");
|
||||
return -1;
|
||||
|
@ -347,7 +347,7 @@ static int smart_responseEx(uint8_t *data, bool silent) {
|
|||
int len = data[datalen - 1];
|
||||
if (!silent) PrintAndLogEx(INFO, "Requesting 0x%02X bytes response", len);
|
||||
uint8_t getstatus[] = {0x00, ISO7816_GET_RESPONSE, 0x00, 0x00, len};
|
||||
UsbCommandOLD cStatus = {CMD_SMART_RAW, {SC_RAW, sizeof(getstatus), 0}, {{0}}};
|
||||
PacketCommandOLD cStatus = {CMD_SMART_RAW, {SC_RAW, sizeof(getstatus), 0}, {{0}}};
|
||||
memcpy(cStatus.d.asBytes, getstatus, sizeof(getstatus));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&cStatus);
|
||||
|
@ -454,7 +454,7 @@ static int CmdSmartRaw(const char *Cmd) {
|
|||
|
||||
// arg0 = RFU flags
|
||||
// arg1 = length
|
||||
UsbCommandOLD c = {CMD_SMART_RAW, {0, hexlen, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_RAW, {0, hexlen, 0}, {{0}}};
|
||||
|
||||
if (active || active_select) {
|
||||
c.arg[0] |= SC_CONNECT;
|
||||
|
@ -652,7 +652,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
|||
|
||||
while (bytes_remaining > 0) {
|
||||
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
|
||||
UsbCommandOLD c = {CMD_SMART_UPLOAD, {index + bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_UPLOAD, {index + bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
|
||||
// Fill usb bytes with 0xFF
|
||||
memset(c.d.asBytes, 0xFF, USB_CMD_DATA_SIZE);
|
||||
|
@ -675,10 +675,10 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Sim module firmware updating, don\'t turn off your PM3!");
|
||||
|
||||
// trigger the firmware upgrade
|
||||
UsbCommandOLD c = {CMD_SMART_UPGRADE, {firmware_size, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_UPGRADE, {firmware_size, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
@ -714,10 +714,10 @@ static int CmdSmartInfo(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors) return usage_sm_info();
|
||||
|
||||
UsbCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||
return 1;
|
||||
|
@ -789,10 +789,10 @@ static int CmdSmartReader(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors) return usage_sm_reader();
|
||||
|
||||
UsbCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||
return 1;
|
||||
|
@ -835,10 +835,10 @@ static int CmdSmartSetClock(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors || cmdp == 0) return usage_sm_setclock();
|
||||
|
||||
UsbCommandOLD c = {CMD_SMART_SETCLOCK, {clock1, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_SETCLOCK, {clock1, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
PrintAndLogEx(WARNING, "smart card select failed");
|
||||
return 1;
|
||||
|
@ -887,7 +887,7 @@ static void smart_brute_prim() {
|
|||
|
||||
PrintAndLogEx(INFO, "Reading primitives");
|
||||
|
||||
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, 5, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, 5, 0}, {{0}}};
|
||||
|
||||
for (int i = 0; i < sizeof(get_card_data); i += 5) {
|
||||
|
||||
|
@ -917,7 +917,7 @@ static int smart_brute_sfi(bool decodeTLV) {
|
|||
int len;
|
||||
// READ RECORD
|
||||
uint8_t READ_RECORD[] = {0x00, 0xB2, 0x00, 0x00, 0x00};
|
||||
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(READ_RECORD), 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(READ_RECORD), 0}, {{0}}};
|
||||
|
||||
PrintAndLogEx(INFO, "Start SFI brute forcing");
|
||||
|
||||
|
@ -984,7 +984,7 @@ static void smart_brute_options(bool decodeTLV) {
|
|||
uint8_t GET_PROCESSING_OPTIONS[] = {0x80, 0xA8, 0x00, 0x00, 0x02, 0x83, 0x00, 0x00};
|
||||
|
||||
// Get processing options command
|
||||
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(GET_PROCESSING_OPTIONS), 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, sizeof(GET_PROCESSING_OPTIONS), 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, GET_PROCESSING_OPTIONS, sizeof(GET_PROCESSING_OPTIONS));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -1041,7 +1041,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
|
|||
// uint8_t VERIFY[] = {0x00, 0x20, 0x00, 0x80};
|
||||
|
||||
// Select AID command
|
||||
UsbCommandOLD cAid = {CMD_SMART_RAW, {SC_RAW_T0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD cAid = {CMD_SMART_RAW, {SC_RAW_T0, 0, 0}, {{0}}};
|
||||
|
||||
PrintAndLogEx(INFO, "Importing AID list");
|
||||
json_t *root = NULL;
|
||||
|
@ -1178,7 +1178,7 @@ int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leave
|
|||
|
||||
PrintAndLogEx(DEBUG, "APDU SC");
|
||||
|
||||
UsbCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
|
||||
if (activateCard) {
|
||||
c.arg[0] |= SC_SELECT | SC_CONNECT;
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@ int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leave
|
|||
|
||||
// retry
|
||||
if (len > 1 && dataout[len - 2] == 0x6c && datainlen > 4) {
|
||||
UsbCommandOLD c2 = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
|
||||
PacketCommandOLD c2 = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}, {{0}}};
|
||||
memcpy(c2.d.asBytes, datain, 5);
|
||||
|
||||
// transfer length via T=0
|
||||
|
@ -1214,10 +1214,10 @@ bool smart_select(bool silent, smart_card_atr_t *atr) {
|
|||
if (atr)
|
||||
memset(atr, 0, sizeof(smart_card_atr_t));
|
||||
|
||||
UsbCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_SMART_ATR, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||
return false;
|
||||
|
|
|
@ -672,7 +672,7 @@ int CmdTraceList(const char *Cmd) {
|
|||
|
||||
if (isOnline) {
|
||||
// Query for the size of the trace, downloading USB_CMD_DATA_SIZE
|
||||
UsbReplyNG response;
|
||||
PacketResponseNG response;
|
||||
if (!GetFromDevice(BIG_BUF, trace, USB_CMD_DATA_SIZE, 0, &response, 4000, true)) {
|
||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
|
|
|
@ -25,16 +25,16 @@ static pthread_t USB_communication_thread;
|
|||
//static pthread_t FPC_communication_thread;
|
||||
|
||||
// Transmit buffer.
|
||||
static UsbCommandOLD txBuffer;
|
||||
static UsbCommandNGRaw txBufferNG;
|
||||
static PacketCommandOLD txBuffer;
|
||||
static PacketCommandNGRaw txBufferNG;
|
||||
size_t txBufferNGLen;
|
||||
static bool txBuffer_pending = false;
|
||||
static pthread_mutex_t txBufferMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t txBufferSig = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
// Used by UsbReceiveCommand as a ring buffer for messages that are yet to be
|
||||
// Used by PacketResponseReceived as a ring buffer for messages that are yet to be
|
||||
// processed by a command handler (WaitForResponse{,Timeout})
|
||||
static UsbReplyNG rxBuffer[CMD_BUFFER_SIZE];
|
||||
static PacketResponseNG rxBuffer[CMD_BUFFER_SIZE];
|
||||
|
||||
// Points to the next empty position to write to
|
||||
static int cmd_head = 0;
|
||||
|
@ -45,7 +45,7 @@ static int cmd_tail = 0;
|
|||
// to lock rxBuffer operations from different threads
|
||||
static pthread_mutex_t rxBufferMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbReplyNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
||||
|
||||
// These wrappers are required because it is not possible to access a static
|
||||
// global variable outside of the context of a single file.
|
||||
|
@ -57,10 +57,10 @@ bool IsOffline() {
|
|||
return offline;
|
||||
}
|
||||
|
||||
void SendCommand(UsbCommandOLD *c) {
|
||||
void SendCommand(PacketCommandOLD *c) {
|
||||
|
||||
#ifdef COMMS_DEBUG
|
||||
PrintAndLogEx(NORMAL, "Sending %d bytes | cmd %04x\n", sizeof(UsbCommand), c->cmd);
|
||||
PrintAndLogEx(NORMAL, "Sending %d bytes | cmd %04x\n", sizeof(PacketCommandOLD), c->cmd);
|
||||
#endif
|
||||
|
||||
if (offline) {
|
||||
|
@ -104,7 +104,7 @@ void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
|
|||
return;
|
||||
}
|
||||
|
||||
UsbCommandNGPostamble *tx_post = (UsbCommandNGPostamble *)((uint8_t *)&txBufferNG + sizeof(UsbCommandNGPreamble) + len);
|
||||
PacketCommandNGPostamble *tx_post = (PacketCommandNGPostamble *)((uint8_t *)&txBufferNG + sizeof(PacketCommandNGPreamble) + len);
|
||||
|
||||
pthread_mutex_lock(&txBufferMutex);
|
||||
/**
|
||||
|
@ -121,9 +121,9 @@ void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
|
|||
txBufferNG.pre.cmd = cmd;
|
||||
memcpy(&txBufferNG.data, data, len);
|
||||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(UsbCommandNGPreamble) + len, &first, &second);
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(PacketCommandNGPreamble) + len, &first, &second);
|
||||
tx_post->crc = (first << 8) + second;
|
||||
txBufferNGLen = sizeof(UsbCommandNGPreamble) + len + sizeof(UsbCommandNGPostamble);
|
||||
txBufferNGLen = sizeof(PacketCommandNGPreamble) + len + sizeof(PacketCommandNGPostamble);
|
||||
txBuffer_pending = true;
|
||||
|
||||
// tell communication thread that a new command can be send
|
||||
|
@ -150,7 +150,7 @@ void clearCommandBuffer() {
|
|||
* @brief storeCommand stores a USB command in a circular buffer
|
||||
* @param UC
|
||||
*/
|
||||
static void storeReply(UsbReplyNG *packet) {
|
||||
static void storeReply(PacketResponseNG *packet) {
|
||||
pthread_mutex_lock(&rxBufferMutex);
|
||||
if ((cmd_head + 1) % CMD_BUFFER_SIZE == cmd_tail) {
|
||||
//If these two are equal, we're about to overwrite in the
|
||||
|
@ -159,8 +159,8 @@ static void storeReply(UsbReplyNG *packet) {
|
|||
fflush(stdout);
|
||||
}
|
||||
//Store the command at the 'head' location
|
||||
UsbReplyNG *destination = &rxBuffer[cmd_head];
|
||||
memcpy(destination, packet, sizeof(UsbReplyNG));
|
||||
PacketResponseNG *destination = &rxBuffer[cmd_head];
|
||||
memcpy(destination, packet, sizeof(PacketResponseNG));
|
||||
|
||||
//increment head and wrap
|
||||
cmd_head = (cmd_head + 1) % CMD_BUFFER_SIZE;
|
||||
|
@ -171,7 +171,7 @@ static void storeReply(UsbReplyNG *packet) {
|
|||
* @param response location to write command
|
||||
* @return 1 if response was returned, 0 if nothing has been received
|
||||
*/
|
||||
static int getReply(UsbReplyNG *packet) {
|
||||
static int getReply(PacketResponseNG *packet) {
|
||||
pthread_mutex_lock(&rxBufferMutex);
|
||||
//If head == tail, there's nothing to read, or if we just got initialized
|
||||
if (cmd_head == cmd_tail) {
|
||||
|
@ -180,7 +180,7 @@ static int getReply(UsbReplyNG *packet) {
|
|||
}
|
||||
|
||||
//Pick out the next unread command
|
||||
memcpy(packet, &rxBuffer[cmd_tail], sizeof(UsbReplyNG));
|
||||
memcpy(packet, &rxBuffer[cmd_tail], sizeof(PacketResponseNG));
|
||||
|
||||
//Increment tail - this is a circular buffer, so modulo buffer size
|
||||
cmd_tail = (cmd_tail + 1) % CMD_BUFFER_SIZE;
|
||||
|
@ -193,7 +193,7 @@ static int getReply(UsbReplyNG *packet) {
|
|||
// Entry point into our code: called whenever we received a packet over USB
|
||||
// that we weren't necessarily expecting, for example a debug print.
|
||||
//-----------------------------------------------------------------------------
|
||||
static void UsbReplyReceived(UsbReplyNG *packet) {
|
||||
static void PacketResponseReceived(PacketResponseNG *packet) {
|
||||
|
||||
//DOEGOX
|
||||
//PrintAndLogEx(NORMAL, "RECV %s magic %08x length %04x status %04x crc %04x cmd %04x",
|
||||
|
@ -280,8 +280,8 @@ __attribute__((force_align_arg_pointer))
|
|||
communication_arg_t *connection = (communication_arg_t *)targ;
|
||||
size_t rxlen;
|
||||
|
||||
UsbReplyNG rx;
|
||||
UsbReplyNGRaw rx_raw;
|
||||
PacketResponseNG rx;
|
||||
PacketResponseNGRaw rx_raw;
|
||||
//int counter_to_offline = 0;
|
||||
|
||||
#if defined(__MACH__) && defined(__APPLE__)
|
||||
|
@ -292,7 +292,7 @@ __attribute__((force_align_arg_pointer))
|
|||
rxlen = 0;
|
||||
bool ACK_received = false;
|
||||
bool error = false;
|
||||
if (uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(UsbReplyNGPreamble), &rxlen) && (rxlen == sizeof(UsbReplyNGPreamble))) {
|
||||
if (uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(PacketResponseNGPreamble), &rxlen) && (rxlen == sizeof(PacketResponseNGPreamble))) {
|
||||
rx.magic = rx_raw.pre.magic;
|
||||
rx.length = rx_raw.pre.length;
|
||||
rx.status = rx_raw.pre.status;
|
||||
|
@ -311,7 +311,7 @@ __attribute__((force_align_arg_pointer))
|
|||
}
|
||||
}
|
||||
if (!error) { // Get the postamble
|
||||
if ((!uart_receive(sp, (uint8_t *)&rx_raw.foopost, sizeof(UsbReplyNGPostamble), &rxlen)) || (rxlen != sizeof(UsbReplyNGPostamble))) {
|
||||
if ((!uart_receive(sp, (uint8_t *)&rx_raw.foopost, sizeof(PacketResponseNGPostamble), &rxlen)) || (rxlen != sizeof(PacketResponseNGPostamble))) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame error fetching postamble");
|
||||
error = true;
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ __attribute__((force_align_arg_pointer))
|
|||
if (!error) { // Check CRC
|
||||
rx.crc = rx_raw.foopost.crc;
|
||||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&rx_raw, sizeof(UsbReplyNGPreamble) + rx.length, &first, &second);
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&rx_raw, sizeof(PacketResponseNGPreamble) + rx.length, &first, &second);
|
||||
if ((first << 8) + second != rx.crc) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame CRC error %02X%02X <> %04X", first, second, rx.crc);
|
||||
error = true;
|
||||
|
@ -328,17 +328,17 @@ __attribute__((force_align_arg_pointer))
|
|||
if (!error) {
|
||||
// PrintAndLogEx(NORMAL, "Received reply NG full !!");
|
||||
rx.ng = true;
|
||||
UsbReplyReceived(&rx);
|
||||
PacketResponseReceived(&rx);
|
||||
//TODO DOEGOX NG don't send ACK anymore but reply with the corresponding cmd, still things seem to work fine...
|
||||
if (rx.cmd == CMD_ACK) {
|
||||
ACK_received = true;
|
||||
}
|
||||
}
|
||||
} else { // Old style reply
|
||||
UsbCommandOLD rx_old;
|
||||
memcpy(&rx_old, &rx_raw.pre, sizeof(UsbReplyNGPreamble));
|
||||
if ((!uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(UsbReplyNGPreamble), sizeof(UsbCommandOLD) - sizeof(UsbReplyNGPreamble), &rxlen)) || (rxlen != sizeof(UsbCommandOLD) - sizeof(UsbReplyNGPreamble))) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame error var part too short? %d/%d", rxlen, sizeof(UsbCommandOLD) - sizeof(UsbReplyNGPreamble));
|
||||
PacketResponseOLD rx_old;
|
||||
memcpy(&rx_old, &rx_raw.pre, sizeof(PacketResponseNGPreamble));
|
||||
if ((!uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(PacketResponseNGPreamble), sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble), &rxlen)) || (rxlen != sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble))) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame error var part too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble));
|
||||
error = true;
|
||||
}
|
||||
if (!error) {
|
||||
|
@ -353,7 +353,7 @@ __attribute__((force_align_arg_pointer))
|
|||
rx.oldarg[2] = rx_old.arg[2];
|
||||
rx.length = USB_CMD_DATA_SIZE;
|
||||
memcpy(&rx.data, &rx_old.d, rx.length);
|
||||
UsbReplyReceived(&rx);
|
||||
PacketResponseReceived(&rx);
|
||||
if (rx.cmd == CMD_ACK) {
|
||||
ACK_received = true;
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ __attribute__((force_align_arg_pointer))
|
|||
}
|
||||
} else {
|
||||
if (rxlen > 0) {
|
||||
PrintAndLogEx(WARNING, "Received packet frame preamble too short: %d/%d", rxlen, sizeof(UsbReplyNGPreamble));
|
||||
PrintAndLogEx(WARNING, "Received packet frame preamble too short: %d/%d", rxlen, sizeof(PacketResponseNGPreamble));
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ __attribute__((force_align_arg_pointer))
|
|||
}
|
||||
txBufferNGLen = 0;
|
||||
} else {
|
||||
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(UsbCommandOLD))) {
|
||||
if (!uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD))) {
|
||||
//counter_to_offline++;
|
||||
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device" _RED_("failed"));
|
||||
}
|
||||
|
@ -459,8 +459,8 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
|||
// check if we can communicate with Pm3
|
||||
int TestProxmark(void) {
|
||||
clearCommandBuffer();
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_PING, {0, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 5000)) {
|
||||
PrintAndLogEx(INFO, "Communicating with PM3 over %s.", resp.oldarg[0] == 1 ? "FPC" : "USB");
|
||||
|
@ -511,9 +511,9 @@ void CloseProxmark(void) {
|
|||
* @param show_warning display message after 3 seconds
|
||||
* @return true if command was returned, otherwise false
|
||||
*/
|
||||
bool WaitForResponseTimeoutW(uint32_t cmd, UsbReplyNG *response, size_t ms_timeout, bool show_warning) {
|
||||
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning) {
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (response == NULL)
|
||||
response = &resp;
|
||||
|
@ -541,11 +541,11 @@ bool WaitForResponseTimeoutW(uint32_t cmd, UsbReplyNG *response, size_t ms_timeo
|
|||
return false;
|
||||
}
|
||||
|
||||
bool WaitForResponseTimeout(uint32_t cmd, UsbReplyNG *response, size_t ms_timeout) {
|
||||
bool WaitForResponseTimeout(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout) {
|
||||
return WaitForResponseTimeoutW(cmd, response, ms_timeout, true);
|
||||
}
|
||||
|
||||
bool WaitForResponse(uint32_t cmd, UsbReplyNG *response) {
|
||||
bool WaitForResponse(uint32_t cmd, PacketResponseNG *response) {
|
||||
return WaitForResponseTimeoutW(cmd, response, -1, true);
|
||||
}
|
||||
|
||||
|
@ -562,12 +562,12 @@ bool WaitForResponse(uint32_t cmd, UsbReplyNG *response) {
|
|||
* @param show_warning display message after 2 seconds
|
||||
* @return true if command was returned, otherwise false
|
||||
*/
|
||||
bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbReplyNG *response, size_t ms_timeout, bool show_warning) {
|
||||
bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning) {
|
||||
|
||||
if (dest == NULL) return false;
|
||||
if (bytes == 0) return true;
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (response == NULL)
|
||||
response = &resp;
|
||||
|
||||
|
@ -576,22 +576,22 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
|
|||
|
||||
switch (memtype) {
|
||||
case BIG_BUF: {
|
||||
UsbCommandOLD c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K);
|
||||
}
|
||||
case BIG_BUF_EML: {
|
||||
UsbCommandOLD c = {CMD_DOWNLOAD_EML_BIGBUF, {start_index, bytes, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_DOWNLOAD_EML_BIGBUF, {start_index, bytes, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_EML_BIGBUF);
|
||||
}
|
||||
case FLASH_MEM: {
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_DOWNLOAD, {start_index, bytes, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_FLASHMEM_DOWNLOAD, {start_index, bytes, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED);
|
||||
}
|
||||
case SIM_MEM: {
|
||||
//UsbCommandOLD c = {CMD_DOWNLOAD_SIM_MEM, {start_index, bytes, 0}, {{0}}};
|
||||
//PacketCommandOLD c = {CMD_DOWNLOAD_SIM_MEM, {start_index, bytes, 0}, {{0}}};
|
||||
//SendCommand(&c);
|
||||
//return dl_it(dest, bytes, start_index, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM);
|
||||
return false;
|
||||
|
@ -600,7 +600,7 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbReplyNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd) {
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd) {
|
||||
|
||||
uint32_t bytes_completed = 0;
|
||||
uint64_t start_time = msclock();
|
||||
|
|
|
@ -49,7 +49,7 @@ void SetOffline(bool value);
|
|||
bool IsOffline(void);
|
||||
|
||||
void *uart_receiver(void *targ);
|
||||
void SendCommand(UsbCommandOLD *c);
|
||||
void SendCommand(PacketCommandOLD *c);
|
||||
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len);
|
||||
void clearCommandBuffer(void);
|
||||
|
||||
|
@ -58,11 +58,11 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
|||
int TestProxmark(void);
|
||||
void CloseProxmark(void);
|
||||
|
||||
bool WaitForResponseTimeoutW(uint32_t cmd, UsbReplyNG *response, size_t ms_timeout, bool show_warning);
|
||||
bool WaitForResponseTimeout(uint32_t cmd, UsbReplyNG *response, size_t ms_timeout);
|
||||
bool WaitForResponse(uint32_t cmd, UsbReplyNG *response);
|
||||
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
bool WaitForResponseTimeout(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout);
|
||||
bool WaitForResponse(uint32_t cmd, PacketResponseNG *response);
|
||||
|
||||
bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, UsbReplyNG *response, size_t ms_timeout, bool show_warning);
|
||||
bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -259,9 +259,9 @@ fail:
|
|||
|
||||
// Get the state of the proxmark, backwards compatible
|
||||
static int get_proxmark_state(uint32_t *state) {
|
||||
UsbCommandOLD c = {CMD_DEVICE_INFO};
|
||||
PacketCommandOLD c = {CMD_DEVICE_INFO};
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_UNKNOWN, &resp); // wait for any response. No timeout.
|
||||
|
||||
// Three outcomes:
|
||||
|
@ -300,7 +300,7 @@ static int enter_bootloader(char *serial_port_name) {
|
|||
|
||||
if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
|
||||
fprintf(stdout, _BLUE_("Entering bootloader...") "\n");
|
||||
UsbCommandOLD c;
|
||||
PacketCommandOLD c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
|
||||
if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
|
||||
|
@ -335,7 +335,7 @@ static int enter_bootloader(char *serial_port_name) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int wait_for_ack(UsbReplyNG *ack) {
|
||||
static int wait_for_ack(PacketResponseNG *ack) {
|
||||
WaitForResponse(CMD_UNKNOWN, ack);
|
||||
|
||||
if (ack->cmd != CMD_ACK) {
|
||||
|
@ -361,8 +361,8 @@ int flash_start_flashing(int enable_bl_writes, char *serial_port_name) {
|
|||
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
|
||||
// This command is stupid. Why the heck does it care which area we're
|
||||
// flashing, as long as it's not the bootloader area? The mind boggles.
|
||||
UsbCommandOLD c = {CMD_START_FLASH};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_START_FLASH};
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (enable_bl_writes) {
|
||||
c.arg[0] = FLASH_START;
|
||||
|
@ -386,8 +386,8 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
|
|||
uint8_t block_buf[BLOCK_SIZE];
|
||||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||
memcpy(block_buf, data, length);
|
||||
UsbCommandOLD c = {CMD_FINISH_WRITE, {address, 0, 0}};
|
||||
UsbReplyNG resp;
|
||||
PacketCommandOLD c = {CMD_FINISH_WRITE, {address, 0, 0}};
|
||||
PacketResponseNG resp;
|
||||
memcpy(c.d.asBytes, block_buf, length);
|
||||
SendCommand(&c);
|
||||
int ret = wait_for_ack(&resp);
|
||||
|
@ -459,7 +459,7 @@ void flash_free(flash_file_t *ctx) {
|
|||
|
||||
// just reset the unit
|
||||
int flash_stop_flashing(void) {
|
||||
UsbCommandOLD c = {CMD_HARDWARE_RESET};
|
||||
PacketCommandOLD c = {CMD_HARDWARE_RESET};
|
||||
SendCommand(&c);
|
||||
msleep(100);
|
||||
return 0;
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
#define MAX_FILES 4
|
||||
|
||||
void cmd_debug(UsbCommandOLD *c) {
|
||||
void cmd_debug(PacketCommandOLD *c) {
|
||||
// Debug
|
||||
printf("UsbCommandOLD length[len=%zu]\n", sizeof(UsbCommandOLD));
|
||||
printf("PacketCommandOLD length[len=%zu]\n", sizeof(PacketCommandOLD));
|
||||
printf(" cmd[len=%zu]: %016" PRIx64"\n", sizeof(c->cmd), c->cmd);
|
||||
printf(" arg0[len=%zu]: %016" PRIx64"\n", sizeof(c->arg[0]), c->arg[0]);
|
||||
printf(" arg1[len=%zu]: %016" PRIx64"\n", sizeof(c->arg[1]), c->arg[1]);
|
||||
|
|
|
@ -260,9 +260,9 @@ fail:
|
|||
|
||||
// Get the state of the proxmark, backwards compatible
|
||||
static int get_proxmark_state(uint32_t *state) {
|
||||
UsbCommand c = {CMD_DEVICE_INFO};
|
||||
PacketCommandOLD c = {CMD_DEVICE_INFO};
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
PacketResponseOLD resp;
|
||||
ReceiveCommand(&resp);
|
||||
|
||||
// Three outcomes:
|
||||
|
@ -303,7 +303,7 @@ static int enter_bootloader(void) {
|
|||
|
||||
if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
|
||||
fprintf(stderr, "Entering bootloader...\n");
|
||||
UsbCommand c;
|
||||
PacketCommandOLD c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
|
||||
if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
|
||||
|
@ -338,7 +338,7 @@ static int enter_bootloader(void) {
|
|||
}
|
||||
|
||||
static int wait_for_ack(void) {
|
||||
UsbCommand ack;
|
||||
PacketResponseOLD ack;
|
||||
ReceiveCommand(&ack);
|
||||
if (ack.cmd != CMD_ACK) {
|
||||
printf("Error: Unexpected reply 0x%04x (expected ACK)\n", ack.cmd);
|
||||
|
@ -360,7 +360,7 @@ int flash_start_flashing(int enable_bl_writes) {
|
|||
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
|
||||
// This command is stupid. Why the heck does it care which area we're
|
||||
// flashing, as long as it's not the bootloader area? The mind boggles.
|
||||
UsbCommand c = {CMD_START_FLASH};
|
||||
PacketCommandOLD c = {CMD_START_FLASH};
|
||||
|
||||
if (enable_bl_writes) {
|
||||
c.arg[0] = FLASH_START;
|
||||
|
@ -387,7 +387,7 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
|
|||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||
memcpy(block_buf, data, length);
|
||||
|
||||
UsbCommand c = {CMD_SETUP_WRITE};
|
||||
PacketCommandOLD c = {CMD_SETUP_WRITE};
|
||||
for (int i = 0; i < 240; i += 48) {
|
||||
memcpy(c.d.asBytes, block_buf + i, 48);
|
||||
c.arg[0] = i / 4;
|
||||
|
@ -458,7 +458,7 @@ void flash_free(flash_file_t *ctx) {
|
|||
|
||||
// just reset the unit
|
||||
int flash_stop_flashing(void) {
|
||||
UsbCommand c = {CMD_HARDWARE_RESET};
|
||||
PacketCommandOLD c = {CMD_HARDWARE_RESET};
|
||||
SendCommand(&c);
|
||||
msleep(100);
|
||||
return 0;
|
||||
|
|
|
@ -20,14 +20,14 @@ static unsigned int claimed_iface = 0;
|
|||
unsigned char return_on_error = 0;
|
||||
unsigned char error_occured = 0;
|
||||
|
||||
void SendCommand(UsbCommand *c) {
|
||||
void SendCommand(PacketCommandOLD *c) {
|
||||
int ret;
|
||||
|
||||
#if 0
|
||||
printf("Sending %d bytes\n", sizeof(UsbCommand));
|
||||
printf("Sending %d bytes\n", sizeof(PacketCommandOLD));
|
||||
#endif
|
||||
|
||||
ret = usb_bulk_write(devh, 0x01, (char *)c, sizeof(UsbCommand), 1000);
|
||||
ret = usb_bulk_write(devh, 0x01, (char *)c, sizeof(PacketCommandOLD), 1000);
|
||||
if (ret < 0) {
|
||||
error_occured = 1;
|
||||
if (return_on_error)
|
||||
|
@ -48,11 +48,11 @@ void SendCommand(UsbCommand *c) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ReceiveCommandPoll(UsbCommand *c) {
|
||||
bool ReceiveCommandPoll(PacketResponseOLD *c) {
|
||||
int ret;
|
||||
|
||||
memset(c, 0, sizeof(UsbCommand));
|
||||
ret = usb_bulk_read(devh, 0x82, (char *)c, sizeof(UsbCommand), 500);
|
||||
memset(c, 0, sizeof(PacketResponseOLD));
|
||||
ret = usb_bulk_read(devh, 0x82, (char *)c, sizeof(PacketResponseOLD), 500);
|
||||
if (ret < 0) {
|
||||
if (ret != -ETIMEDOUT) {
|
||||
error_occured = 1;
|
||||
|
@ -73,16 +73,16 @@ bool ReceiveCommandPoll(UsbCommand *c) {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
if (ret && (ret < sizeof(UsbCommand))) {
|
||||
if (ret && (ret < sizeof(PacketResponseOLD))) {
|
||||
fprintf(stderr, "Read only %d instead of requested %d bytes!\n",
|
||||
ret, (int)sizeof(UsbCommand));
|
||||
ret, (int)sizeof(PacketResponseOLD));
|
||||
}
|
||||
}
|
||||
|
||||
return ret > 0;
|
||||
}
|
||||
|
||||
void ReceiveCommand(UsbCommand *c) {
|
||||
void ReceiveCommand(PacketResponseOLD *c) {
|
||||
// printf("%s()\n", __FUNCTION__);
|
||||
int retval = 0;
|
||||
do {
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
extern unsigned char return_on_error;
|
||||
extern unsigned char error_occured;
|
||||
|
||||
void SendCommand(UsbCommand *c);
|
||||
bool ReceiveCommandPoll(UsbCommand *c);
|
||||
void ReceiveCommand(UsbCommand *c);
|
||||
void SendCommand(PacketCommand *c);
|
||||
bool ReceiveCommandPoll(PacketCommand *c);
|
||||
void ReceiveCommand(PacketCommand *c);
|
||||
struct usb_dev_handle *FindProxmark(int verbose, unsigned int *iface);
|
||||
struct usb_dev_handle *OpenProxmark(int verbose);
|
||||
void CloseProxmark(void);
|
||||
|
|
|
@ -30,7 +30,16 @@ typedef struct {
|
|||
uint8_t asBytes[48];
|
||||
uint32_t asDwords[12];
|
||||
} d;
|
||||
} PACKED UsbCommand;
|
||||
} PACKED PacketCommandOLD;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cmd;
|
||||
uint32_t arg[3];
|
||||
union {
|
||||
uint8_t asBytes[48];
|
||||
uint32_t asDwords[12];
|
||||
} d;
|
||||
} PACKED PacketResponseOLD;
|
||||
|
||||
// For the bootloader
|
||||
#define CMD_DEVICE_INFO 0x0000
|
||||
|
|
|
@ -16,7 +16,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
|||
uint64_t par_list = 0, ks_list = 0;
|
||||
uint64_t *keylist = NULL, *last_keylist = NULL;
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_MIFARE, {true, blockno, key_type}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_MIFARE, {true, blockno, key_type}, {{0}}};
|
||||
|
||||
// message
|
||||
PrintAndLogEx(NORMAL, "--------------------------------------------------------------------------------\n");
|
||||
|
@ -45,7 +45,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
|||
return -5;
|
||||
}
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
int16_t isOK = resp.oldarg[0];
|
||||
if (isOK < 0)
|
||||
|
@ -123,11 +123,11 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
|||
}
|
||||
int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t *keyBlock, uint64_t *key) {
|
||||
*key = -1;
|
||||
UsbCommandOLD c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), clear_trace, keycnt}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_CHKKEYS, { (blockNo | (keyType << 8)), clear_trace, keycnt}, {{0}}};
|
||||
memcpy(c.d.asBytes, keyBlock, 6 * keycnt);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) return 1;
|
||||
if ((resp.oldarg[0] & 0xff) != 0x01) return 2;
|
||||
*key = bytes_to_num(resp.data.asBytes, 6);
|
||||
|
@ -145,11 +145,11 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
|
|||
uint32_t timeout = 0;
|
||||
|
||||
// send keychunk
|
||||
UsbCommandOLD c = {CMD_MIFARE_CHKKEYS_FAST, { (sectorsCnt | (firstChunk << 8) | (lastChunk << 12)), ((use_flashmemory << 8) | strategy), size}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_CHKKEYS_FAST, { (sectorsCnt | (firstChunk << 8) | (lastChunk << 12)), ((use_flashmemory << 8) | strategy), size}, {{0}}};
|
||||
memcpy(c.d.asBytes, keyBlock, 6 * size);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
while (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
|
||||
timeout++;
|
||||
|
@ -293,11 +293,11 @@ __attribute__((force_align_arg_pointer))
|
|||
int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t *resultKey, bool calibrate) {
|
||||
uint16_t i;
|
||||
uint32_t uid;
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
StateList_t statelists[2];
|
||||
struct Crypto1State *p1, *p2, *p3, *p4;
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_NESTED, {blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, calibrate}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -419,12 +419,12 @@ out:
|
|||
// MIFARE
|
||||
int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_READSC, {sectorNo, keyType, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
|
||||
|
@ -444,10 +444,10 @@ int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data)
|
|||
|
||||
// EMULATOR
|
||||
int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount) {
|
||||
UsbCommandOLD c = {CMD_MIFARE_EML_MEMGET, {blockNum, blocksCount, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_EML_MEMGET, {blockNum, blocksCount, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) return 1;
|
||||
memcpy(data, resp.data.asBytes, blocksCount * 16);
|
||||
return 0;
|
||||
|
@ -458,7 +458,7 @@ int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
|
|||
}
|
||||
|
||||
int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {
|
||||
UsbCommandOLD c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, blockBtWidth}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, blockBtWidth}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, blocksCount * blockBtWidth);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -501,11 +501,11 @@ int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_
|
|||
|
||||
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_CSETBLOCK, {params, blockNo, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_CSETBLOCK, {params, blockNo, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, data, 16);
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
if (uid != NULL)
|
||||
|
@ -520,10 +520,10 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params) {
|
|||
}
|
||||
|
||||
int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params) {
|
||||
UsbCommandOLD c = {CMD_MIFARE_CGETBLOCK, {params, blockNo, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_CGETBLOCK, {params, blockNo, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||
uint8_t isOK = resp.oldarg[0] & 0xff;
|
||||
if (!isOK)
|
||||
|
@ -869,11 +869,11 @@ int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data,
|
|||
*/
|
||||
int detect_classic_prng(void) {
|
||||
|
||||
UsbReplyNG resp, respA;
|
||||
PacketResponseNG resp, respA;
|
||||
uint8_t cmd[] = {MIFARE_AUTH_KEYA, 0x00};
|
||||
uint32_t flags = ISO14A_CONNECT | ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_RATS;
|
||||
|
||||
UsbCommandOLD c = {CMD_READER_ISO_14443a, {flags, sizeof(cmd), 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_READER_ISO_14443a, {flags, sizeof(cmd), 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, cmd, sizeof(cmd));
|
||||
|
||||
clearCommandBuffer();
|
||||
|
@ -913,10 +913,10 @@ returns:
|
|||
*/
|
||||
int detect_classic_nackbug(bool verbose) {
|
||||
|
||||
UsbCommandOLD c = {CMD_MIFARE_NACK_DETECT, {0, 0, 0}, {{0}}};
|
||||
PacketCommandOLD c = {CMD_MIFARE_NACK_DETECT, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(SUCCESS, "press pm3-button on the Proxmark3 device to abort both Proxmark3 and client.\n");
|
||||
|
@ -998,8 +998,8 @@ int detect_classic_nackbug(bool verbose) {
|
|||
void detect_classic_magic(void) {
|
||||
|
||||
uint8_t isGeneration = 0;
|
||||
UsbReplyNG resp;
|
||||
UsbCommandOLD c = {CMD_MIFARE_CIDENT, {0, 0, 0}, {{0}}};
|
||||
PacketResponseNG resp;
|
||||
PacketCommandOLD c = {CMD_MIFARE_CIDENT, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500))
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
/**
|
||||
* The following params expected:
|
||||
* UsbCommandOLD c
|
||||
* PacketCommandOLD c
|
||||
*@brief l_SendCommand
|
||||
* @param L
|
||||
* @return
|
||||
|
@ -29,19 +29,19 @@ static int l_SendCommand(lua_State *L) {
|
|||
uint8_t asBytes[USB_CMD_DATA_SIZE]; // 1 byte * 512 = 512 bytes (OR)
|
||||
uint32_t asDwords[USB_CMD_DATA_SIZE/4]; // 4 byte * 128 = 512 bytes
|
||||
} d;
|
||||
} PACKED UsbCommandOLD;
|
||||
} PACKED PacketCommandOLD;
|
||||
|
||||
==> A 544 byte buffer will do.
|
||||
**/
|
||||
size_t size;
|
||||
const char *data = luaL_checklstring(L, 1, &size);
|
||||
if (size != sizeof(UsbCommandOLD)) {
|
||||
printf("Got data size %d, expected %d", (int) size, (int) sizeof(UsbCommandOLD));
|
||||
if (size != sizeof(PacketCommandOLD)) {
|
||||
printf("Got data size %d, expected %d", (int) size, (int) sizeof(PacketCommandOLD));
|
||||
lua_pushstring(L, "Wrong data size");
|
||||
return 1;
|
||||
}
|
||||
|
||||
SendCommand((UsbCommandOLD *)data);
|
||||
SendCommand((PacketCommandOLD *)data);
|
||||
return 0; // no return values
|
||||
}
|
||||
|
||||
|
@ -184,10 +184,10 @@ static int l_WaitForResponseTimeout(lua_State *L) {
|
|||
ms_timeout = luaL_checkunsigned(L, 2);
|
||||
}
|
||||
|
||||
UsbReplyNG resp;
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(cmd, &resp, ms_timeout)) {
|
||||
//Push it as a string
|
||||
lua_pushlstring(L, (const char *)&resp, sizeof(UsbReplyNG));
|
||||
lua_pushlstring(L, (const char *)&resp, sizeof(PacketResponseNG));
|
||||
return 1;
|
||||
} else {
|
||||
//signal error by returning Nil, errorstring
|
||||
|
@ -262,7 +262,7 @@ static int l_foobar(lua_State *L) {
|
|||
printf("Arguments discarded, stack now contains %d elements", lua_gettop(L));
|
||||
|
||||
// todo: this is not used, where was it intended for?
|
||||
// UsbCommandOLD response = {CMD_MIFARE_READBL, {1337, 1338, 1339}, {{0}}};
|
||||
// PacketCommandOLD response = {CMD_MIFARE_READBL, {1337, 1338, 1339}, {{0}}};
|
||||
|
||||
printf("Now returning a uint64_t as a string");
|
||||
uint64_t x = 0xDEADC0DE;
|
||||
|
|
|
@ -26,7 +26,7 @@ int main() {
|
|||
while (1) {
|
||||
while (!OpenProxmark()) { sleep(1); }
|
||||
while (1) {
|
||||
UsbCommandOLD cmdbuf;
|
||||
PacketCommandOLD cmdbuf;
|
||||
CommandReceived("hf 14a sniff");
|
||||
HANDLE_ERROR;
|
||||
ReceiveCommand(&cmdbuf);
|
||||
|
|
|
@ -150,7 +150,7 @@
|
|||
|
||||
#ifndef DropField
|
||||
#define DropField() { \
|
||||
UsbCommandOLD c_drop = {CMD_READER_ISO_14443a, {0,0,0}, {{0}}}; clearCommandBuffer(); SendCommand(&c_drop); \
|
||||
PacketCommandOLD c_drop = {CMD_READER_ISO_14443a, {0,0,0}, {{0}}}; clearCommandBuffer(); SendCommand(&c_drop); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
42
common/cmd.c
42
common/cmd.c
|
@ -43,10 +43,10 @@ extern void Dbprintf(const char *fmt, ...);
|
|||
reply_via_fpc = true;}
|
||||
#endif
|
||||
|
||||
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||
UsbCommandOLD txcmd;
|
||||
uint8_t reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||
PacketResponseOLD txcmd;
|
||||
|
||||
for (size_t i = 0; i < sizeof(UsbCommandOLD); i++)
|
||||
for (size_t i = 0; i < sizeof(PacketResponseOLD); i++)
|
||||
((uint8_t *)&txcmd)[i] = 0x00;
|
||||
|
||||
// Compose the outgoing command frame
|
||||
|
@ -68,20 +68,20 @@ uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void
|
|||
|
||||
#ifdef WITH_FPC_HOST
|
||||
if (reply_via_fpc) {
|
||||
sendlen = usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommandOLD));
|
||||
sendlen = usart_writebuffer((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
||||
// Dbprintf_usb("Sent %i bytes over usart", len);
|
||||
} else {
|
||||
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommandOLD));
|
||||
sendlen = usb_write((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
||||
}
|
||||
#else
|
||||
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommandOLD));
|
||||
sendlen = usb_write((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
||||
#endif
|
||||
|
||||
return sendlen;
|
||||
}
|
||||
|
||||
uint8_t reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len) {
|
||||
UsbReplyNGRaw txBufferNG;
|
||||
PacketResponseNGRaw txBufferNG;
|
||||
size_t txBufferNGLen;
|
||||
// for (size_t i = 0; i < sizeof(txBufferNG); i++)
|
||||
// ((uint8_t *)&txBufferNG)[i] = 0x00;
|
||||
|
@ -105,11 +105,11 @@ uint8_t reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len) {
|
|||
}
|
||||
|
||||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(UsbReplyNGPreamble) + len, &first, &second);
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(PacketResponseNGPreamble) + len, &first, &second);
|
||||
|
||||
UsbReplyNGPostamble *tx_post = (UsbReplyNGPostamble *)((uint8_t *)&txBufferNG + sizeof(UsbReplyNGPreamble) + len);
|
||||
PacketResponseNGPostamble *tx_post = (PacketResponseNGPostamble *)((uint8_t *)&txBufferNG + sizeof(PacketResponseNGPreamble) + len);
|
||||
tx_post->crc = (first << 8) + second;
|
||||
txBufferNGLen = sizeof(UsbReplyNGPreamble) + len + sizeof(UsbReplyNGPostamble);
|
||||
txBufferNGLen = sizeof(PacketResponseNGPreamble) + len + sizeof(PacketResponseNGPostamble);
|
||||
|
||||
uint32_t sendlen = 0;
|
||||
// Send frame and make sure all bytes are transmitted
|
||||
|
@ -128,10 +128,10 @@ uint8_t reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len) {
|
|||
return sendlen;
|
||||
}
|
||||
|
||||
int16_t receive_ng(UsbCommandNG *rx) {
|
||||
UsbCommandNGRaw rx_raw;
|
||||
size_t bytes = usb_read_ng((uint8_t *)&rx_raw.pre, sizeof(UsbCommandNGPreamble));
|
||||
if (bytes != sizeof(UsbCommandNGPreamble))
|
||||
int16_t receive_ng(PacketCommandNG *rx) {
|
||||
PacketCommandNGRaw rx_raw;
|
||||
size_t bytes = usb_read_ng((uint8_t *)&rx_raw.pre, sizeof(PacketCommandNGPreamble));
|
||||
if (bytes != sizeof(PacketCommandNGPreamble))
|
||||
return PM3_EIO;
|
||||
rx->magic = rx_raw.pre.magic;
|
||||
rx->length = rx_raw.pre.length;
|
||||
|
@ -145,13 +145,13 @@ int16_t receive_ng(UsbCommandNG *rx) {
|
|||
return PM3_EIO;
|
||||
memcpy(rx->data.asBytes, rx_raw.data, rx->length);
|
||||
// Get the postamble
|
||||
bytes = usb_read_ng((uint8_t *)&rx_raw.foopost, sizeof(UsbCommandNGPostamble));
|
||||
if (bytes != sizeof(UsbCommandNGPostamble))
|
||||
bytes = usb_read_ng((uint8_t *)&rx_raw.foopost, sizeof(PacketCommandNGPostamble));
|
||||
if (bytes != sizeof(PacketCommandNGPostamble))
|
||||
return PM3_EIO;
|
||||
// Check CRC
|
||||
rx->crc = rx_raw.foopost.crc;
|
||||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&rx_raw, sizeof(UsbCommandNGPreamble) + rx->length, &first, &second);
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&rx_raw, sizeof(PacketCommandNGPreamble) + rx->length, &first, &second);
|
||||
if ((first << 8) + second != rx->crc)
|
||||
return PM3_EIO;
|
||||
#ifdef WITH_FPC_HOST
|
||||
|
@ -159,10 +159,10 @@ int16_t receive_ng(UsbCommandNG *rx) {
|
|||
#endif
|
||||
rx->ng = true;
|
||||
} else { // Old style command
|
||||
UsbCommandOLD rx_old;
|
||||
memcpy(&rx_old, &rx_raw.pre, sizeof(UsbCommandNGPreamble));
|
||||
bytes = usb_read_ng(((uint8_t *)&rx_old) + sizeof(UsbCommandNGPreamble), sizeof(UsbCommandOLD) - sizeof(UsbCommandNGPreamble));
|
||||
if (bytes != sizeof(UsbCommandOLD) - sizeof(UsbCommandNGPreamble))
|
||||
PacketCommandOLD rx_old;
|
||||
memcpy(&rx_old, &rx_raw.pre, sizeof(PacketCommandNGPreamble));
|
||||
bytes = usb_read_ng(((uint8_t *)&rx_old) + sizeof(PacketCommandNGPreamble), sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble));
|
||||
if (bytes != sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble))
|
||||
return PM3_EIO;
|
||||
#ifdef WITH_FPC_HOST
|
||||
reply_via_fpc = false;
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
#include "usart.h"
|
||||
#include "proxmark3.h"
|
||||
|
||||
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
uint8_t reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||
uint8_t reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len);
|
||||
int16_t receive_ng(UsbCommandNG *rx);
|
||||
int16_t receive_ng(PacketCommandNG *rx);
|
||||
|
||||
#endif // _PROXMARK_CMD_H_
|
||||
|
||||
|
|
10
common/i2c.c
10
common/i2c.c
|
@ -691,7 +691,7 @@ void SmartCardAtr(void) {
|
|||
set_tracing(true);
|
||||
I2C_Reset_EnterMainProgram();
|
||||
bool isOK = GetATR(&card);
|
||||
cmd_send(CMD_ACK, isOK, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
||||
reply_old(CMD_ACK, isOK, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
||||
set_tracing(false);
|
||||
LEDsoff();
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ void SmartCardRaw(uint64_t arg0, uint64_t arg1, uint8_t *data) {
|
|||
if ((flags & SC_SELECT)) {
|
||||
smart_card_atr_t card;
|
||||
bool gotATR = GetATR(&card);
|
||||
//cmd_send(CMD_ACK, gotATR, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
||||
//reply_old(CMD_ACK, gotATR, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
||||
if (!gotATR)
|
||||
goto OUT;
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ void SmartCardRaw(uint64_t arg0, uint64_t arg1, uint8_t *data) {
|
|||
}
|
||||
}
|
||||
OUT:
|
||||
cmd_send(CMD_ACK, len, 0, 0, resp, len);
|
||||
reply_old(CMD_ACK, len, 0, 0, resp, len);
|
||||
BigBuf_free();
|
||||
set_tracing(false);
|
||||
LEDsoff();
|
||||
|
@ -801,7 +801,7 @@ void SmartCardUpgrade(uint64_t arg0) {
|
|||
length -= size;
|
||||
pos += size;
|
||||
}
|
||||
cmd_send(CMD_ACK, isOK, pos, 0, 0, 0);
|
||||
reply_old(CMD_ACK, isOK, pos, 0, 0, 0);
|
||||
LED_C_OFF();
|
||||
BigBuf_free();
|
||||
}
|
||||
|
@ -818,7 +818,7 @@ void SmartCardSetClock(uint64_t arg0) {
|
|||
// start [C0 05 xx] stop
|
||||
I2C_WriteByte(arg0, I2C_DEVICE_CMD_SIM_CLC, I2C_DEVICE_ADDRESS_MAIN);
|
||||
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
set_tracing(false);
|
||||
LEDsoff();
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ void usart_close(void) {
|
|||
}
|
||||
*/
|
||||
|
||||
static uint8_t us_inbuf[sizeof(UsbCommandOLD)];
|
||||
static uint8_t us_outbuf[sizeof(UsbCommandOLD)];
|
||||
static uint8_t us_inbuf[sizeof(PacketCommandOLD)];
|
||||
static uint8_t us_outbuf[sizeof(PacketResponseOLD)];
|
||||
/*
|
||||
// transfer from client to device
|
||||
inline int16_t usart_readbuffer(uint8_t *data) {
|
||||
|
@ -63,7 +63,7 @@ inline int16_t usart_readbuffer(uint8_t *data) {
|
|||
// Check if the first PDC bank is free
|
||||
if (pUS1->US_RCR == 0) {
|
||||
pUS1->US_RPR = (uint32_t)data;
|
||||
pUS1->US_RCR = sizeof(UsbCommandOLD);
|
||||
pUS1->US_RCR = sizeof(PacketCommandOLD);
|
||||
pUS1->US_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTEN;
|
||||
check = 0;
|
||||
return 2;
|
||||
|
|
|
@ -33,19 +33,19 @@ typedef struct {
|
|||
uint8_t asBytes[USB_CMD_DATA_SIZE];
|
||||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
||||
} d;
|
||||
} PACKED UsbCommandOLD;
|
||||
} PACKED PacketCommandOLD;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint16_t length; // length of the variable part, 0 if none.
|
||||
uint16_t cmd;
|
||||
} PACKED UsbCommandNGPreamble;
|
||||
} PACKED PacketCommandNGPreamble;
|
||||
|
||||
#define USB_COMMANDNG_PREAMBLE_MAGIC 0x61334d50 // PM3a
|
||||
|
||||
typedef struct {
|
||||
uint16_t crc;
|
||||
} PACKED UsbCommandNGPostamble;
|
||||
} PACKED PacketCommandNGPostamble;
|
||||
|
||||
// For internal usage
|
||||
typedef struct {
|
||||
|
@ -59,27 +59,36 @@ typedef struct {
|
|||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
||||
} data;
|
||||
bool ng; // does it store NG data or OLD data?
|
||||
} PACKED UsbCommandNG;
|
||||
} PACKED PacketCommandNG;
|
||||
|
||||
// For reception and CRC check
|
||||
typedef struct {
|
||||
UsbCommandNGPreamble pre;
|
||||
PacketCommandNGPreamble pre;
|
||||
uint8_t data[USB_CMD_DATA_SIZE];
|
||||
UsbCommandNGPostamble foopost; // Probably not at that offset!
|
||||
} PACKED UsbCommandNGRaw;
|
||||
PacketCommandNGPostamble foopost; // Probably not at that offset!
|
||||
} PACKED PacketCommandNGRaw;
|
||||
|
||||
typedef struct {
|
||||
uint64_t cmd;
|
||||
uint64_t arg[3];
|
||||
union {
|
||||
uint8_t asBytes[USB_CMD_DATA_SIZE];
|
||||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
||||
} d;
|
||||
} PACKED PacketResponseOLD;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint16_t length; // length of the variable part, 0 if none.
|
||||
int16_t status;
|
||||
uint16_t cmd;
|
||||
} PACKED UsbReplyNGPreamble;
|
||||
} PACKED PacketResponseNGPreamble;
|
||||
|
||||
#define USB_REPLYNG_PREAMBLE_MAGIC 0x62334d50 // PM3b
|
||||
|
||||
typedef struct {
|
||||
uint16_t crc;
|
||||
} PACKED UsbReplyNGPostamble;
|
||||
} PACKED PacketResponseNGPostamble;
|
||||
|
||||
// For internal usage
|
||||
typedef struct {
|
||||
|
@ -94,14 +103,14 @@ typedef struct {
|
|||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
||||
} data;
|
||||
bool ng; // does it store NG data or OLD data?
|
||||
} PACKED UsbReplyNG;
|
||||
} PACKED PacketResponseNG;
|
||||
|
||||
// For reception and CRC check
|
||||
typedef struct {
|
||||
UsbReplyNGPreamble pre;
|
||||
PacketResponseNGPreamble pre;
|
||||
uint8_t data[USB_CMD_DATA_SIZE];
|
||||
UsbReplyNGPostamble foopost; // Probably not at that offset!
|
||||
} PACKED UsbReplyNGRaw;
|
||||
PacketResponseNGPostamble foopost; // Probably not at that offset!
|
||||
} PACKED PacketResponseNGRaw;
|
||||
|
||||
#ifdef WITH_FPC_HOST
|
||||
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue