mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-24 05:58:04 +08:00
Rename few USB -> PM3 to avoid misleading interpretations
This commit is contained in:
parent
cddc25994c
commit
27f7057961
42 changed files with 165 additions and 165 deletions
armsrc
bootrom
client
Makefilecmdanalyse.ccmdhf14a.ccmdhf14b.ccmdhf15.ccmdhfepa.ccmdhffelica.ccmdhficlass.ccmdhficlass.hcmdhflegic.ccmdhfmf.ccmdhw.ccmdlf.ccmdlfhitag.ccmdmain.hcmdsmartcard.ccmdtrace.ccomms.ccomms.hflash.hflasher.c
mifare
pm3_cmd_h2lua.awkproxmark3.hscripting.cscripting.hcommon
include
uart
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "standalone.h" // standalone definitions
|
#include "standalone.h" // standalone definitions
|
||||||
#include "apps.h" // debugstatements, lfops?
|
#include "apps.h" // debugstatements, lfops?
|
||||||
#include "usb_cmd.h" // mifare1ksim flags
|
#include "pm3_cmd.h" // mifare1ksim flags
|
||||||
#include "mifaresim.h" // mifare1ksim
|
#include "mifaresim.h" // mifare1ksim
|
||||||
#include "mifareutil.h"
|
#include "mifareutil.h"
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ void DbpStringEx(uint32_t flags, char *str) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
struct {
|
struct {
|
||||||
uint16_t flag;
|
uint16_t flag;
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE - sizeof(uint16_t)];
|
uint8_t buf[PM3_CMD_DATA_SIZE - sizeof(uint16_t)];
|
||||||
} PACKED data;
|
} PACKED data;
|
||||||
data.flag = flags;
|
data.flag = flags;
|
||||||
uint16_t len = MIN(strlen(str), sizeof(data.buf));
|
uint16_t len = MIN(strlen(str), sizeof(data.buf));
|
||||||
|
@ -333,8 +333,8 @@ extern struct version_information version_information;
|
||||||
/* bootrom version information is pointed to from _bootphase1_version_pointer */
|
/* bootrom version information is pointed to from _bootphase1_version_pointer */
|
||||||
extern char *_bootphase1_version_pointer, _flash_start, _flash_end, _bootrom_start, _bootrom_end, __data_src_start__;
|
extern char *_bootphase1_version_pointer, _flash_start, _flash_end, _bootrom_start, _bootrom_end, __data_src_start__;
|
||||||
void SendVersion(void) {
|
void SendVersion(void) {
|
||||||
char temp[USB_CMD_DATA_SIZE]; /* Limited data payload in USB packets */
|
char temp[PM3_CMD_DATA_SIZE]; /* Limited data payload in USB packets */
|
||||||
char VersionString[USB_CMD_DATA_SIZE] = { '\0' };
|
char VersionString[PM3_CMD_DATA_SIZE] = { '\0' };
|
||||||
|
|
||||||
/* Try to find the bootrom version information. Expect to find a pointer at
|
/* Try to find the bootrom version information. Expect to find a pointer at
|
||||||
* symbol _bootphase1_version_pointer, perform slight sanity checks on the
|
* symbol _bootphase1_version_pointer, perform slight sanity checks on the
|
||||||
|
@ -384,9 +384,9 @@ void printUSBSpeed(void) {
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
|
|
||||||
while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) {
|
while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) {
|
||||||
reply_ng(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, PM3_SUCCESS, test_data, USB_CMD_DATA_SIZE);
|
reply_ng(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, PM3_SUCCESS, test_data, PM3_CMD_DATA_SIZE);
|
||||||
end_time = GetTickCount();
|
end_time = GetTickCount();
|
||||||
bytes_transferred += USB_CMD_DATA_SIZE;
|
bytes_transferred += PM3_CMD_DATA_SIZE;
|
||||||
}
|
}
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
||||||
|
@ -1089,7 +1089,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
case CMD_SMART_UPLOAD: {
|
case CMD_SMART_UPLOAD: {
|
||||||
// upload file from client
|
// upload file from client
|
||||||
uint8_t *mem = BigBuf_get_addr();
|
uint8_t *mem = BigBuf_get_addr();
|
||||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, USB_CMD_DATA_SIZE);
|
memcpy(mem + packet->oldarg[0], packet->data.asBytes, PM3_CMD_DATA_SIZE);
|
||||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1205,8 +1205,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
// arg2 = BigBuf tracelen
|
// arg2 = BigBuf tracelen
|
||||||
//Dbprintf("transfer to client parameters: %" PRIu32 " | %" PRIu32 " | %" PRIu32, startidx, numofbytes, packet->oldarg[2]);
|
//Dbprintf("transfer to client parameters: %" PRIu32 " | %" PRIu32 " | %" PRIu32, startidx, numofbytes, packet->oldarg[2]);
|
||||||
|
|
||||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
for (size_t i = 0; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||||
int result = reply_old(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), mem + startidx + i, len);
|
int result = reply_old(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), mem + startidx + i, len);
|
||||||
if (result != PM3_SUCCESS)
|
if (result != PM3_SUCCESS)
|
||||||
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d) | result: %d", i, i + len, len, result);
|
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d) | result: %d", i, i + len, len, result);
|
||||||
|
@ -1234,7 +1234,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
|
|
||||||
uint8_t *mem = BigBuf_get_addr();
|
uint8_t *mem = BigBuf_get_addr();
|
||||||
memcpy(mem + packet->oldarg[0], packet->data.asBytes, USB_CMD_DATA_SIZE);
|
memcpy(mem + packet->oldarg[0], packet->data.asBytes, PM3_CMD_DATA_SIZE);
|
||||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1249,8 +1249,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
// arg1 = length bytes to transfer
|
// arg1 = length bytes to transfer
|
||||||
// arg2 = RFU
|
// arg2 = RFU
|
||||||
|
|
||||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
for (size_t i = 0; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||||
len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||||
int result = reply_old(CMD_DOWNLOADED_EML_BIGBUF, i, len, 0, mem + startidx + i, len);
|
int result = reply_old(CMD_DOWNLOADED_EML_BIGBUF, i, len, 0, mem + startidx + i, len);
|
||||||
if (result != PM3_SUCCESS)
|
if (result != PM3_SUCCESS)
|
||||||
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d) | result: %d", i, i + len, len, result);
|
Dbprintf("transfer to client failed :: | bytes between %d - %d (%d) | result: %d", i, i + len, len, result);
|
||||||
|
@ -1274,7 +1274,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
|
|
||||||
Dbprintf("FlashMem read | %d - %d | ", startidx, len);
|
Dbprintf("FlashMem read | %d - %d | ", startidx, len);
|
||||||
|
|
||||||
size_t size = MIN(USB_CMD_DATA_SIZE, len);
|
size_t size = MIN(PM3_CMD_DATA_SIZE, len);
|
||||||
|
|
||||||
if (!FlashInit()) {
|
if (!FlashInit()) {
|
||||||
break;
|
break;
|
||||||
|
@ -1383,7 +1383,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
case CMD_FLASHMEM_DOWNLOAD: {
|
case CMD_FLASHMEM_DOWNLOAD: {
|
||||||
|
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
uint8_t *mem = BigBuf_malloc(USB_CMD_DATA_SIZE);
|
uint8_t *mem = BigBuf_malloc(PM3_CMD_DATA_SIZE);
|
||||||
uint32_t startidx = packet->oldarg[0];
|
uint32_t startidx = packet->oldarg[0];
|
||||||
uint32_t numofbytes = packet->oldarg[1];
|
uint32_t numofbytes = packet->oldarg[1];
|
||||||
// arg0 = startindex
|
// arg0 = startindex
|
||||||
|
@ -1394,8 +1394,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
for (size_t i = 0; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||||
|
|
||||||
bool isok = Flash_ReadDataCont(startidx + i, mem, len);
|
bool isok = Flash_ReadDataCont(startidx + i, mem, len);
|
||||||
if (!isok)
|
if (!isok)
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
||||||
|
|
||||||
//Use the emulator memory for SIM
|
//Use the emulator memory for SIM
|
||||||
uint8_t *emulator = BigBuf_get_EM_addr();
|
uint8_t *emulator = BigBuf_get_EM_addr();
|
||||||
uint8_t mac_responses[USB_CMD_DATA_SIZE] = { 0 };
|
uint8_t mac_responses[PM3_CMD_DATA_SIZE] = { 0 };
|
||||||
|
|
||||||
if (simType == 0) {
|
if (simType == 0) {
|
||||||
// Use the CSN from commandline
|
// Use the CSN from commandline
|
||||||
|
@ -1188,7 +1188,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
||||||
// in order to obtain the keys, as in the "dismantling iclass"-paper.
|
// in order to obtain the keys, as in the "dismantling iclass"-paper.
|
||||||
#define EPURSE_MAC_SIZE 16
|
#define EPURSE_MAC_SIZE 16
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < USB_CMD_DATA_SIZE; i++) {
|
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < PM3_CMD_DATA_SIZE; i++) {
|
||||||
// The usb data is 512 bytes, fitting 65 8-byte CSNs in there.
|
// The usb data is 512 bytes, fitting 65 8-byte CSNs in there.
|
||||||
|
|
||||||
memcpy(emulator, datain + (i * 8), 8);
|
memcpy(emulator, datain + (i * 8), 8);
|
||||||
|
@ -1220,7 +1220,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
||||||
// attack below is same as SIM 2, but we run the CSN twice to collected the mac for both keys.
|
// attack below is same as SIM 2, but we run the CSN twice to collected the mac for both keys.
|
||||||
int i = 0;
|
int i = 0;
|
||||||
// The usb data is 512 bytes, fitting 65 8-byte CSNs in there. iceman fork uses 9 CSNS
|
// The usb data is 512 bytes, fitting 65 8-byte CSNs in there. iceman fork uses 9 CSNS
|
||||||
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < USB_CMD_DATA_SIZE; i++) {
|
for (; i < numberOfCSNS && i * EPURSE_MAC_SIZE + 8 < PM3_CMD_DATA_SIZE; i++) {
|
||||||
|
|
||||||
memcpy(emulator, datain + (i * 8), 8);
|
memcpy(emulator, datain + (i * 8), 8);
|
||||||
|
|
||||||
|
@ -2110,7 +2110,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
||||||
uint8_t mem = 0;
|
uint8_t mem = 0;
|
||||||
uint8_t check[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
uint8_t check[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
uint8_t read[] = { 0x0c, 0x00, 0x00, 0x00 };
|
uint8_t read[] = { 0x0c, 0x00, 0x00, 0x00 };
|
||||||
uint8_t card_data[USB_CMD_DATA_SIZE] = {0};
|
uint8_t card_data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
uint8_t resp[ICLASS_BUFFER_SIZE] = {0};
|
uint8_t resp[ICLASS_BUFFER_SIZE] = {0};
|
||||||
|
|
||||||
static struct memory_t {
|
static struct memory_t {
|
||||||
|
@ -2158,7 +2158,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
||||||
|
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
//Set card_data to all zeroes, we'll fill it with data
|
//Set card_data to all zeroes, we'll fill it with data
|
||||||
memset(card_data, 0x0, USB_CMD_DATA_SIZE);
|
memset(card_data, 0x0, PM3_CMD_DATA_SIZE);
|
||||||
uint8_t failedRead = 0;
|
uint8_t failedRead = 0;
|
||||||
uint32_t stored_data_length = 0;
|
uint32_t stored_data_length = 0;
|
||||||
|
|
||||||
|
@ -2178,7 +2178,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *mac) {
|
||||||
//Fill up the buffer
|
//Fill up the buffer
|
||||||
memcpy(card_data + stored_data_length, resp, 8);
|
memcpy(card_data + stored_data_length, resp, 8);
|
||||||
stored_data_length += 8;
|
stored_data_length += 8;
|
||||||
if (stored_data_length + 8 > USB_CMD_DATA_SIZE) {
|
if (stored_data_length + 8 > PM3_CMD_DATA_SIZE) {
|
||||||
//Time to send this off and start afresh
|
//Time to send this off and start afresh
|
||||||
reply_old(CMD_ACK,
|
reply_old(CMD_ACK,
|
||||||
stored_data_length,//data length
|
stored_data_length,//data length
|
||||||
|
|
|
@ -2406,7 +2406,7 @@ void ReaderIso14443a(PacketCommandNG *c) {
|
||||||
uint32_t timeout = c->oldarg[2];
|
uint32_t timeout = c->oldarg[2];
|
||||||
uint8_t *cmd = c->data.asBytes;
|
uint8_t *cmd = c->data.asBytes;
|
||||||
uint32_t arg0;
|
uint32_t arg0;
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
uint8_t par[MAX_PARITY_SIZE] = {0x00};
|
uint8_t par[MAX_PARITY_SIZE] = {0x00};
|
||||||
|
|
||||||
if ((param & ISO14A_CONNECT))
|
if ((param & ISO14A_CONNECT))
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "apps.h"
|
#include "apps.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
|
@ -1573,7 +1573,7 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||||
uint8_t *cmd = c->data.asBytes;
|
uint8_t *cmd = c->data.asBytes;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
uint32_t sendlen = sizeof(iso14b_card_select_t);
|
uint32_t sendlen = sizeof(iso14b_card_select_t);
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
if (MF_DBGLEVEL > 3) Dbprintf("14b raw: param, %04x", param);
|
if (MF_DBGLEVEL > 3) Dbprintf("14b raw: param, %04x", param);
|
||||||
|
|
||||||
|
@ -1621,7 +1621,7 @@ void SendRawCommand14443B_Ex(PacketCommandNG *c) {
|
||||||
CodeAndTransmit14443bAsReader(cmd, len); // raw
|
CodeAndTransmit14443bAsReader(cmd, len); // raw
|
||||||
GetTagSamplesFor14443bDemod(); // raw
|
GetTagSamplesFor14443bDemod(); // raw
|
||||||
|
|
||||||
sendlen = MIN(Demod.len, USB_CMD_DATA_SIZE);
|
sendlen = MIN(Demod.len, PM3_CMD_DATA_SIZE);
|
||||||
status = (Demod.len > 0) ? 0 : 1;
|
status = (Demod.len > 0) ? 0 : 1;
|
||||||
reply_old(CMD_ACK, status, sendlen, 0, Demod.output, sendlen);
|
reply_old(CMD_ACK, status, sendlen, 0, Demod.output, sendlen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -621,7 +621,7 @@ void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *
|
||||||
uint8_t uid[10] = {0x00};
|
uint8_t uid[10] = {0x00};
|
||||||
uint8_t answer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
uint8_t answer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||||
uint8_t par[1] = {0x00};
|
uint8_t par[1] = {0x00};
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
uint32_t cuid = 0;
|
uint32_t cuid = 0;
|
||||||
int16_t isOK = 0;
|
int16_t isOK = 0;
|
||||||
uint16_t num_nonces = 0;
|
uint16_t num_nonces = 0;
|
||||||
|
@ -645,7 +645,7 @@ void MifareAcquireNonces(uint32_t arg0, uint32_t arg1, uint32_t flags, uint8_t *
|
||||||
|
|
||||||
LED_C_ON();
|
LED_C_ON();
|
||||||
|
|
||||||
for (uint16_t i = 0; i <= USB_CMD_DATA_SIZE - 4; i += 4) {
|
for (uint16_t i = 0; i <= PM3_CMD_DATA_SIZE - 4; i += 4) {
|
||||||
|
|
||||||
// Test if the action was cancelled
|
// Test if the action was cancelled
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
|
@ -733,7 +733,7 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
||||||
uint8_t uid[10] = {0x00};
|
uint8_t uid[10] = {0x00};
|
||||||
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE] = {0x00};
|
||||||
uint8_t par_enc[1] = {0x00};
|
uint8_t par_enc[1] = {0x00};
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
uint64_t ui64Key = bytes_to_num(datain, 6);
|
uint64_t ui64Key = bytes_to_num(datain, 6);
|
||||||
uint32_t cuid = 0;
|
uint32_t cuid = 0;
|
||||||
|
@ -763,7 +763,7 @@ void MifareAcquireEncryptedNonces(uint32_t arg0, uint32_t arg1, uint32_t flags,
|
||||||
|
|
||||||
LED_C_ON();
|
LED_C_ON();
|
||||||
|
|
||||||
for (uint16_t i = 0; i <= USB_CMD_DATA_SIZE - 9;) {
|
for (uint16_t i = 0; i <= PM3_CMD_DATA_SIZE - 9;) {
|
||||||
|
|
||||||
// Test if the action was cancelled
|
// Test if the action was cancelled
|
||||||
if (BUTTON_PRESS()) {
|
if (BUTTON_PRESS()) {
|
||||||
|
@ -1645,11 +1645,11 @@ void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
||||||
|
|
||||||
void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain) {
|
void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain) {
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
emlGetMem(buf, arg0, arg1); // data, block num, blocks count (max 4)
|
emlGetMem(buf, arg0, arg1); // data, block num, blocks count (max 4)
|
||||||
|
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
reply_old(CMD_ACK, arg0, arg1, 0, buf, USB_CMD_DATA_SIZE);
|
reply_old(CMD_ACK, arg0, arg1, 0, buf, PM3_CMD_DATA_SIZE);
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1949,7 +1949,7 @@ void MifareCIdent() {
|
||||||
uint8_t recpar[1] = {0x00};
|
uint8_t recpar[1] = {0x00};
|
||||||
uint8_t rats[4] = { ISO14443A_CMD_RATS, 0x80, 0x31, 0x73 };
|
uint8_t rats[4] = { ISO14443A_CMD_RATS, 0x80, 0x31, 0x73 };
|
||||||
uint8_t *par = BigBuf_malloc(MAX_PARITY_SIZE);
|
uint8_t *par = BigBuf_malloc(MAX_PARITY_SIZE);
|
||||||
uint8_t *buf = BigBuf_malloc(USB_CMD_DATA_SIZE);
|
uint8_t *buf = BigBuf_malloc(PM3_CMD_DATA_SIZE);
|
||||||
uint8_t *uid = BigBuf_malloc(10);
|
uint8_t *uid = BigBuf_malloc(10);
|
||||||
uint32_t cuid = 0;
|
uint32_t cuid = 0;
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,8 @@ void MifareDesfireGetInformation() {
|
||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
iso14a_card_select_t card;
|
iso14a_card_select_t card;
|
||||||
uint8_t resp[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t resp[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
uint8_t dataout[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t dataout[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1 = PCB 1
|
1 = PCB 1
|
||||||
|
@ -505,7 +505,7 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout) {
|
||||||
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
size_t wrappedLen = 0;
|
size_t wrappedLen = 0;
|
||||||
uint8_t wCmd[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t wCmd[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
uint8_t resp[MAX_FRAME_SIZE];
|
uint8_t resp[MAX_FRAME_SIZE];
|
||||||
uint8_t par[MAX_PARITY_SIZE];
|
uint8_t par[MAX_PARITY_SIZE];
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout) {
|
||||||
// CreateAPDU
|
// CreateAPDU
|
||||||
size_t CreateAPDU(uint8_t *datain, size_t len, uint8_t *dataout) {
|
size_t CreateAPDU(uint8_t *datain, size_t len, uint8_t *dataout) {
|
||||||
|
|
||||||
size_t cmdlen = MIN(len + 4, USB_CMD_DATA_SIZE - 1);
|
size_t cmdlen = MIN(len + 4, PM3_CMD_DATA_SIZE - 1);
|
||||||
|
|
||||||
uint8_t cmd[cmdlen];
|
uint8_t cmd[cmdlen];
|
||||||
memset(cmd, 0, cmdlen);
|
memset(cmd, 0, cmdlen);
|
||||||
|
|
|
@ -315,7 +315,7 @@ void RAMFUNC MfSniffSend() {
|
||||||
|
|
||||||
while (packlen > 0) {
|
while (packlen > 0) {
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
chunksize = MIN(USB_CMD_DATA_SIZE, packlen); // chunk size 512
|
chunksize = MIN(PM3_CMD_DATA_SIZE, packlen); // chunk size 512
|
||||||
reply_old(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
reply_old(CMD_ACK, 1, tracelen, chunksize, data + tracelen - packlen, chunksize);
|
||||||
packlen -= chunksize;
|
packlen -= chunksize;
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
|
@ -26,9 +26,9 @@ static int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2,
|
||||||
txcmd.arg[1] = arg1;
|
txcmd.arg[1] = arg1;
|
||||||
txcmd.arg[2] = arg2;
|
txcmd.arg[2] = arg2;
|
||||||
|
|
||||||
// Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE
|
// Add the (optional) content to the frame, with a maximum size of PM3_CMD_DATA_SIZE
|
||||||
if (data && len) {
|
if (data && len) {
|
||||||
len = MIN(len, USB_CMD_DATA_SIZE);
|
len = MIN(len, PM3_CMD_DATA_SIZE);
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
txcmd.d.asBytes[i] = ((uint8_t *)data)[i];
|
txcmd.d.asBytes[i] = ((uint8_t *)data)[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ ifeq "$(SUPPORTS_AVX512)" "True"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
BINS = proxmark3 flasher fpga_compress
|
BINS = proxmark3 flasher fpga_compress
|
||||||
CLEAN = $(BINS) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/usb_cmd.lua lualibs/mf_default_keys.lua
|
CLEAN = $(BINS) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/pm3_cmd.lua lualibs/mf_default_keys.lua
|
||||||
|
|
||||||
# need to assign dependancies to build these first...
|
# need to assign dependancies to build these first...
|
||||||
all: lua_build jansson_build mbedtls_build cbor_build $(BINS)
|
all: lua_build jansson_build mbedtls_build cbor_build $(BINS)
|
||||||
|
@ -292,7 +292,7 @@ all-static: LDLIBS:=-static $(LDLIBS)
|
||||||
all-static: proxmark3 flasher fpga_compress
|
all-static: proxmark3 flasher fpga_compress
|
||||||
|
|
||||||
proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS)
|
proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS)
|
||||||
proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua lualibs/mf_default_keys.lua
|
proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/pm3_cmd.lua lualibs/mf_default_keys.lua
|
||||||
$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
|
$(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
|
||||||
|
|
||||||
flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS) $(OBJCOBJS)
|
flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS) $(OBJCOBJS)
|
||||||
|
@ -309,8 +309,8 @@ proxguiqt.moc.cpp: proxguiqt.h
|
||||||
ui/ui_overlays.h: ui/overlays.ui
|
ui/ui_overlays.h: ui/overlays.ui
|
||||||
$(UIC) $^ > $@
|
$(UIC) $^ > $@
|
||||||
|
|
||||||
lualibs/usb_cmd.lua: ../include/usb_cmd.h
|
lualibs/pm3_cmd.lua: ../include/pm3_cmd.h
|
||||||
awk -f usb_cmd_h2lua.awk $^ > $@
|
awk -f pm3_cmd_h2lua.awk $^ > $@
|
||||||
|
|
||||||
lualibs/mf_default_keys.lua : default_keys.dic
|
lualibs/mf_default_keys.lua : default_keys.dic
|
||||||
awk -f default_keys_dic2lua.awk $^ > $@
|
awk -f default_keys_dic2lua.awk $^ > $@
|
||||||
|
|
|
@ -488,7 +488,7 @@ static int CmdAnalyseA(const char *Cmd) {
|
||||||
int hexlen = 0;
|
int hexlen = 0;
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
|
@ -513,7 +513,7 @@ static int CmdAnalyseA(const char *Cmd) {
|
||||||
|
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_FPC_SEND, 0, 0, 0, data, USB_CMD_DATA_SIZE);
|
SendCommandOLD(CMD_FPC_SEND, 0, 0, 0, data, PM3_CMD_DATA_SIZE);
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||||
|
|
|
@ -558,7 +558,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
|
||||||
if (leaveSignalON)
|
if (leaveSignalON)
|
||||||
cmdc |= ISO14A_NO_DISCONNECT;
|
cmdc |= ISO14A_NO_DISCONNECT;
|
||||||
|
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = { 0x0a | responseNum, 0x00};
|
uint8_t data[PM3_CMD_DATA_SIZE] = { 0x0a | responseNum, 0x00};
|
||||||
responseNum ^= 1;
|
responseNum ^= 1;
|
||||||
memcpy(&data[2], datain, datainlen & 0xFFFF);
|
memcpy(&data[2], datain, datainlen & 0xFFFF);
|
||||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0, data, (datainlen & 0xFFFF) + 2);
|
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_RAW | ISO14A_APPEND_CRC | cmdc, (datainlen & 0xFFFF) + 2, 0, data, (datainlen & 0xFFFF) + 2);
|
||||||
|
@ -688,7 +688,7 @@ static int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool
|
||||||
|
|
||||||
// "Command APDU" length should be 5+255+1, but javacard's APDU buffer might be smaller - 133 bytes
|
// "Command APDU" length should be 5+255+1, but javacard's APDU buffer might be smaller - 133 bytes
|
||||||
// https://stackoverflow.com/questions/32994936/safe-max-java-card-apdu-data-command-and-respond-size
|
// https://stackoverflow.com/questions/32994936/safe-max-java-card-apdu-data-command-and-respond-size
|
||||||
// here length USB_CMD_DATA_SIZE=512
|
// here length PM3_CMD_DATA_SIZE=512
|
||||||
// timeout must be authomatically set by "get ATS"
|
// timeout must be authomatically set by "get ATS"
|
||||||
if (datain)
|
if (datain)
|
||||||
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0, datain, datainlen & 0xFFFF);
|
SendCommandOLD(CMD_READER_ISO_14443a, ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0, datain, datainlen & 0xFFFF);
|
||||||
|
@ -764,7 +764,7 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
|
||||||
|
|
||||||
// 3 byte here - 1b framing header, 2b crc16
|
// 3 byte here - 1b framing header, 2b crc16
|
||||||
if (APDUInFramingEnable &&
|
if (APDUInFramingEnable &&
|
||||||
((frameLength && (datainlen > frameLength - 3)) || (datainlen > USB_CMD_DATA_SIZE - 3))) {
|
((frameLength && (datainlen > frameLength - 3)) || (datainlen > PM3_CMD_DATA_SIZE - 3))) {
|
||||||
int clen = 0;
|
int clen = 0;
|
||||||
|
|
||||||
bool vActivateField = activateField;
|
bool vActivateField = activateField;
|
||||||
|
@ -828,7 +828,7 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
|
||||||
|
|
||||||
// ISO14443-4. 7. Half-duplex block transmission protocol
|
// ISO14443-4. 7. Half-duplex block transmission protocol
|
||||||
static int CmdHF14AAPDU(const char *Cmd) {
|
static int CmdHF14AAPDU(const char *Cmd) {
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
bool activateField = false;
|
bool activateField = false;
|
||||||
bool leaveSignalON = false;
|
bool leaveSignalON = false;
|
||||||
|
@ -857,7 +857,7 @@ static int CmdHF14AAPDU(const char *Cmd) {
|
||||||
CLIParserFree();
|
CLIParserFree();
|
||||||
PrintAndLogEx(NORMAL, ">>>>[%s%s%s] %s", activateField ? "sel " : "", leaveSignalON ? "keep " : "", decodeTLV ? "TLV" : "", sprint_hex(data, datalen));
|
PrintAndLogEx(NORMAL, ">>>>[%s%s%s] %s", activateField ? "sel " : "", leaveSignalON ? "keep " : "", decodeTLV ? "TLV" : "", sprint_hex(data, datalen));
|
||||||
|
|
||||||
int res = ExchangeAPDU14a(data, datalen, activateField, leaveSignalON, data, USB_CMD_DATA_SIZE, &datalen);
|
int res = ExchangeAPDU14a(data, datalen, activateField, leaveSignalON, data, PM3_CMD_DATA_SIZE, &datalen);
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
@ -887,7 +887,7 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
|
||||||
bool topazmode = false;
|
bool topazmode = false;
|
||||||
char buf[5] = "";
|
char buf[5] = "";
|
||||||
int i = 0;
|
int i = 0;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
uint16_t datalen = 0;
|
uint16_t datalen = 0;
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
|
|
||||||
|
@ -1012,8 +1012,8 @@ static int CmdHF14ACmdRaw(const char *Cmd) {
|
||||||
flags |= ISO14A_NO_RATS;
|
flags |= ISO14A_NO_RATS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max buffer is USB_CMD_DATA_SIZE
|
// Max buffer is PM3_CMD_DATA_SIZE
|
||||||
datalen = (datalen > USB_CMD_DATA_SIZE) ? USB_CMD_DATA_SIZE : datalen;
|
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_READER_ISO_14443a, flags, (datalen & 0xFFFF) | ((uint32_t)(numbits << 16)), argtimeout, data, datalen & 0xFFFF);
|
SendCommandOLD(CMD_READER_ISO_14443a, flags, (datalen & 0xFFFF) | ((uint32_t)(numbits << 16)), argtimeout, data, datalen & 0xFFFF);
|
||||||
|
|
|
@ -121,7 +121,7 @@ static int switch_off_field_14b(void) {
|
||||||
|
|
||||||
static bool waitCmd14b(bool verbose) {
|
static bool waitCmd14b(bool verbose) {
|
||||||
|
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
if (WaitForResponseTimeout(CMD_ACK, &resp, TIMEOUT)) {
|
||||||
|
@ -188,7 +188,7 @@ static int CmdHF14BCmdRaw(const char *Cmd) {
|
||||||
bool reply = true, power = false, select = false, hasTimeout = false;
|
bool reply = true, power = false, select = false, hasTimeout = false;
|
||||||
char buf[5] = "";
|
char buf[5] = "";
|
||||||
int i = 0;
|
int i = 0;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
uint16_t datalen = 0;
|
uint16_t datalen = 0;
|
||||||
uint32_t flags = ISO14B_CONNECT;
|
uint32_t flags = ISO14B_CONNECT;
|
||||||
uint32_t temp = 0, user_timeout = 0, time_wait = 0;
|
uint32_t temp = 0, user_timeout = 0, time_wait = 0;
|
||||||
|
@ -270,8 +270,8 @@ static int CmdHF14BCmdRaw(const char *Cmd) {
|
||||||
if (datalen > 0)
|
if (datalen > 0)
|
||||||
flags |= ISO14B_RAW;
|
flags |= ISO14B_RAW;
|
||||||
|
|
||||||
// Max buffer is USB_CMD_DATA_SIZE
|
// Max buffer is PM3_CMD_DATA_SIZE
|
||||||
datalen = (datalen > USB_CMD_DATA_SIZE) ? USB_CMD_DATA_SIZE : datalen;
|
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_ISO_14443B_COMMAND, flags, datalen, time_wait, data, datalen);
|
SendCommandOLD(CMD_ISO_14443B_COMMAND, flags, datalen, time_wait, data, datalen);
|
||||||
|
|
|
@ -592,7 +592,7 @@ static int CmdHF15Info(const char *Cmd) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
uint8_t *recv;
|
uint8_t *recv;
|
||||||
uint8_t req[USB_CMD_DATA_SIZE] = {0};
|
uint8_t req[PM3_CMD_DATA_SIZE] = {0};
|
||||||
uint16_t reqlen;
|
uint16_t reqlen;
|
||||||
uint8_t arg1 = 1;
|
uint8_t arg1 = 1;
|
||||||
char cmdbuf[100] = {0};
|
char cmdbuf[100] = {0};
|
||||||
|
@ -932,7 +932,7 @@ static int CmdHF15Readmulti(const char *Cmd) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
uint8_t *recv;
|
uint8_t *recv;
|
||||||
uint8_t req[USB_CMD_DATA_SIZE] = {0};
|
uint8_t req[PM3_CMD_DATA_SIZE] = {0};
|
||||||
uint16_t reqlen = 0;
|
uint16_t reqlen = 0;
|
||||||
uint8_t arg1 = 1;
|
uint8_t arg1 = 1;
|
||||||
uint8_t pagenum, pagecount;
|
uint8_t pagenum, pagecount;
|
||||||
|
@ -1018,7 +1018,7 @@ static int CmdHF15Read(const char *Cmd) {
|
||||||
// arg0 (datalen, cmd len? .arg0 == crc?)
|
// arg0 (datalen, cmd len? .arg0 == crc?)
|
||||||
// arg1 (speed == 0 == 1 of 256, == 1 == 1 of 4 )
|
// arg1 (speed == 0 == 1 of 256, == 1 == 1 of 4 )
|
||||||
// arg2 (recv == 1 == expect a response)
|
// arg2 (recv == 1 == expect a response)
|
||||||
uint8_t req[USB_CMD_DATA_SIZE] = {0};
|
uint8_t req[PM3_CMD_DATA_SIZE] = {0};
|
||||||
uint16_t reqlen = 0;
|
uint16_t reqlen = 0;
|
||||||
uint8_t arg1 = 1;
|
uint8_t arg1 = 1;
|
||||||
int blocknum;
|
int blocknum;
|
||||||
|
@ -1085,7 +1085,7 @@ static int CmdHF15Write(const char *Cmd) {
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
uint8_t *recv;
|
uint8_t *recv;
|
||||||
uint8_t req[USB_CMD_DATA_SIZE] = {0};
|
uint8_t req[PM3_CMD_DATA_SIZE] = {0};
|
||||||
uint16_t reqlen = 0;
|
uint16_t reqlen = 0;
|
||||||
uint8_t arg1 = 1;
|
uint8_t arg1 = 1;
|
||||||
int pagenum, temp;
|
int pagenum, temp;
|
||||||
|
|
|
@ -108,7 +108,7 @@ static int CmdHFEPAPACEReplay(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// transfer the APDUs to the Proxmark
|
// transfer the APDUs to the Proxmark
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
for (int i = 0; i < sizeof(apdu_lengths); i++) {
|
for (int i = 0; i < sizeof(apdu_lengths); i++) {
|
||||||
// transfer the APDU in several parts if necessary
|
// transfer the APDU in several parts if necessary
|
||||||
for (int j = 0; j * sizeof(data) < apdu_lengths[i]; j++) {
|
for (int j = 0; j * sizeof(data) < apdu_lengths[i]; j++) {
|
||||||
|
|
|
@ -429,7 +429,7 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||||
uint16_t numbits = 0;
|
uint16_t numbits = 0;
|
||||||
char buf[5] = "";
|
char buf[5] = "";
|
||||||
int i = 0;
|
int i = 0;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
uint16_t datalen = 0;
|
uint16_t datalen = 0;
|
||||||
uint32_t temp;
|
uint32_t temp;
|
||||||
|
|
||||||
|
@ -518,8 +518,8 @@ static int CmdHFFelicaCmdRaw(const char *Cmd) {
|
||||||
flags |= FELICA_RAW;
|
flags |= FELICA_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max buffer is USB_CMD_DATA_SIZE
|
// Max buffer is PM3_CMD_DATA_SIZE
|
||||||
datalen = (datalen > USB_CMD_DATA_SIZE) ? USB_CMD_DATA_SIZE : datalen;
|
datalen = (datalen > PM3_CMD_DATA_SIZE) ? PM3_CMD_DATA_SIZE : datalen;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_FELICA_COMMAND, flags, (datalen & 0xFFFF) | (uint32_t)(numbits << 16), 0, data, datalen);
|
SendCommandOLD(CMD_FELICA_COMMAND, flags, (datalen & 0xFFFF) | (uint32_t)(numbits << 16), 0, data, datalen);
|
||||||
|
|
|
@ -595,7 +595,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
||||||
uint32_t bytes_remaining = bytes_read;
|
uint32_t bytes_remaining = bytes_read;
|
||||||
|
|
||||||
while (bytes_remaining > 0) {
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
|
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_ICLASS_EML_MEMSET, bytes_sent, bytes_in_packet, 0, dump + bytes_sent, bytes_in_packet);
|
SendCommandOLD(CMD_ICLASS_EML_MEMSET, bytes_sent, bytes_in_packet, 0, dump + bytes_sent, bytes_in_packet);
|
||||||
bytes_remaining -= bytes_in_packet;
|
bytes_remaining -= bytes_in_packet;
|
||||||
|
@ -1272,10 +1272,10 @@ static int CmdHFiClassCloneTag(const char *Cmd) {
|
||||||
|
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
iclass_block_t tag_data[USB_CMD_DATA_SIZE / 12];
|
iclass_block_t tag_data[PM3_CMD_DATA_SIZE / 12];
|
||||||
|
|
||||||
if ((endblock - startblock + 1) * 12 > USB_CMD_DATA_SIZE) {
|
if ((endblock - startblock + 1) * 12 > PM3_CMD_DATA_SIZE) {
|
||||||
PrintAndLogEx(NORMAL, "Trying to write too many blocks at once. Max: %d", USB_CMD_DATA_SIZE / 8);
|
PrintAndLogEx(NORMAL, "Trying to write too many blocks at once. Max: %d", PM3_CMD_DATA_SIZE / 8);
|
||||||
}
|
}
|
||||||
// file handling and reading
|
// file handling and reading
|
||||||
f = fopen(filename, "rb");
|
f = fopen(filename, "rb");
|
||||||
|
@ -1944,7 +1944,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
||||||
//PrintPreCalcMac(keyBlock, keycnt, pre);
|
//PrintPreCalcMac(keyBlock, keycnt, pre);
|
||||||
|
|
||||||
// max 42 keys inside USB_COMMAND. 512/4 = 103 mac
|
// max 42 keys inside USB_COMMAND. 512/4 = 103 mac
|
||||||
uint32_t chunksize = keycnt > (USB_CMD_DATA_SIZE / 4) ? (USB_CMD_DATA_SIZE / 4) : keycnt;
|
uint32_t chunksize = keycnt > (PM3_CMD_DATA_SIZE / 4) ? (PM3_CMD_DATA_SIZE / 4) : keycnt;
|
||||||
bool lastChunk = false;
|
bool lastChunk = false;
|
||||||
|
|
||||||
// fast push mode
|
// fast push mode
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "loclass/elite_crack.h"
|
#include "loclass/elite_crack.h"
|
||||||
#include "loclass/fileutils.h"
|
#include "loclass/fileutils.h"
|
||||||
#include "protocols.h"
|
#include "protocols.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "cmdhfmfu.h"
|
#include "cmdhfmfu.h"
|
||||||
#include "cmdhf.h"
|
#include "cmdhf.h"
|
||||||
#include "protocols.h" // picopass structs,
|
#include "protocols.h" // picopass structs,
|
||||||
|
|
|
@ -833,9 +833,9 @@ void legic_chk_iv(uint32_t *iv) {
|
||||||
}
|
}
|
||||||
void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
void legic_seteml(uint8_t *src, uint32_t offset, uint32_t numofbytes) {
|
||||||
|
|
||||||
for (size_t i = offset; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
for (size_t i = offset; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||||
|
|
||||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_LEGIC_ESET, i, len, 0, src + i, len);
|
SendCommandOLD(CMD_LEGIC_ESET, i, len, 0, src + i, len);
|
||||||
}
|
}
|
||||||
|
@ -1041,9 +1041,9 @@ static int CmdLegicRestore(const char *Cmd) {
|
||||||
|
|
||||||
// transfer to device
|
// transfer to device
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
for (size_t i = 7; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
for (size_t i = 7; i < numofbytes; i += PM3_CMD_DATA_SIZE) {
|
||||||
|
|
||||||
size_t len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
size_t len = MIN((numofbytes - i), PM3_CMD_DATA_SIZE);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_WRITER_LEGIC_RF, i, len, 0x55, data + i, len);
|
SendCommandOLD(CMD_WRITER_LEGIC_RF, i, len, 0x55, data + i, len);
|
||||||
|
|
||||||
|
@ -1230,11 +1230,11 @@ static int CmdLegicWipe(const char *Cmd) {
|
||||||
|
|
||||||
// transfer to device
|
// transfer to device
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
for (size_t i = 7; i < card.cardsize; i += USB_CMD_DATA_SIZE) {
|
for (size_t i = 7; i < card.cardsize; i += PM3_CMD_DATA_SIZE) {
|
||||||
|
|
||||||
printf(".");
|
printf(".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
size_t len = MIN((card.cardsize - i), USB_CMD_DATA_SIZE);
|
size_t len = MIN((card.cardsize - i), PM3_CMD_DATA_SIZE);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_WRITER_LEGIC_RF, i, len, 0x55, data + i, len);
|
SendCommandOLD(CMD_WRITER_LEGIC_RF, i, len, 0x55, data + i, len);
|
||||||
|
|
||||||
|
|
|
@ -1661,7 +1661,7 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t chunksize = keycnt > (USB_CMD_DATA_SIZE / 6) ? (USB_CMD_DATA_SIZE / 6) : keycnt;
|
uint32_t chunksize = keycnt > (PM3_CMD_DATA_SIZE / 6) ? (PM3_CMD_DATA_SIZE / 6) : keycnt;
|
||||||
bool firstChunk = true, lastChunk = false;
|
bool firstChunk = true, lastChunk = false;
|
||||||
|
|
||||||
// time
|
// time
|
||||||
|
@ -1933,7 +1933,7 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
||||||
|
|
||||||
|
|
||||||
uint8_t trgKeyType = 0;
|
uint8_t trgKeyType = 0;
|
||||||
uint32_t max_keys = keycnt > ((USB_CMD_DATA_SIZE - 4) / 6) ? ((USB_CMD_DATA_SIZE - 4) / 6) : keycnt;
|
uint32_t max_keys = keycnt > ((PM3_CMD_DATA_SIZE - 4) / 6) ? ((PM3_CMD_DATA_SIZE - 4) / 6) : keycnt;
|
||||||
|
|
||||||
// time
|
// time
|
||||||
uint64_t t1 = msclock();
|
uint64_t t1 = msclock();
|
||||||
|
|
|
@ -442,12 +442,12 @@ static int CmdPing(const char *Cmd) {
|
||||||
|
|
||||||
static int CmdPingNG(const char *Cmd) {
|
static int CmdPingNG(const char *Cmd) {
|
||||||
uint32_t len = strtol(Cmd, NULL, 0);
|
uint32_t len = strtol(Cmd, NULL, 0);
|
||||||
if (len > USB_CMD_DATA_SIZE)
|
if (len > PM3_CMD_DATA_SIZE)
|
||||||
len = USB_CMD_DATA_SIZE;
|
len = PM3_CMD_DATA_SIZE;
|
||||||
PrintAndLogEx(NORMAL, "PingNG sent with payload len=%d", len);
|
PrintAndLogEx(NORMAL, "PingNG sent with payload len=%d", len);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
for (uint16_t i = 0; i < len; i++)
|
for (uint16_t i = 0; i < len; i++)
|
||||||
data[i] = i & 0xFF;
|
data[i] = i & 0xFF;
|
||||||
SendCommandNG(CMD_PING, data, len);
|
SendCommandNG(CMD_PING, data, len);
|
||||||
|
|
|
@ -149,7 +149,7 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
uint32_t arg0 = 0;
|
uint32_t arg0 = 0;
|
||||||
uint32_t arg1 = 0;
|
uint32_t arg1 = 0;
|
||||||
uint32_t arg2 = 0;
|
uint32_t arg2 = 0;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
uint16_t datalen = 0;
|
uint16_t datalen = 0;
|
||||||
|
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
|
@ -423,9 +423,9 @@ int CmdLFSim(const char *Cmd) {
|
||||||
conn.block_after_ACK = true;
|
conn.block_after_ACK = true;
|
||||||
|
|
||||||
//can send only 512 bits at a time (1 byte sent per bit...)
|
//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) {
|
for (uint16_t i = 0; i < GraphTraceLen; i += PM3_CMD_DATA_SIZE) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_UPLOAD_SIM_SAMPLES_125K, i, FPGA_LF, 0, &GraphBuffer[i], USB_CMD_DATA_SIZE);
|
SendCommandOLD(CMD_UPLOAD_SIM_SAMPLES_125K, i, FPGA_LF, 0, &GraphBuffer[i], PM3_CMD_DATA_SIZE);
|
||||||
WaitForResponse(CMD_ACK, NULL);
|
WaitForResponse(CMD_ACK, NULL);
|
||||||
printf(".");
|
printf(".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -518,9 +518,9 @@ int CmdLFfskSim(const char *Cmd) {
|
||||||
if (fcLow == 0) fcLow = 8;
|
if (fcLow == 0) fcLow = 8;
|
||||||
|
|
||||||
size_t size = DemodBufferLen;
|
size_t size = DemodBufferLen;
|
||||||
if (size > USB_CMD_DATA_SIZE) {
|
if (size > PM3_CMD_DATA_SIZE) {
|
||||||
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
|
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, PM3_CMD_DATA_SIZE);
|
||||||
size = USB_CMD_DATA_SIZE;
|
size = PM3_CMD_DATA_SIZE;
|
||||||
}
|
}
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_FSK_SIM_TAG, fcHigh << 8 | fcLow, (separator << 8) | clk, size, DemodBuffer, size);
|
SendCommandOLD(CMD_FSK_SIM_TAG, fcHigh << 8 | fcLow, (separator << 8) | clk, size, DemodBuffer, size);
|
||||||
|
@ -603,9 +603,9 @@ int CmdLFaskSim(const char *Cmd) {
|
||||||
if (encoding == 0) clk /= 2; //askraw needs to double the clock speed
|
if (encoding == 0) clk /= 2; //askraw needs to double the clock speed
|
||||||
|
|
||||||
size_t size = DemodBufferLen;
|
size_t size = DemodBufferLen;
|
||||||
if (size > USB_CMD_DATA_SIZE) {
|
if (size > PM3_CMD_DATA_SIZE) {
|
||||||
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
|
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, PM3_CMD_DATA_SIZE);
|
||||||
size = USB_CMD_DATA_SIZE;
|
size = PM3_CMD_DATA_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "preparing to sim ask data: %d bits", size);
|
PrintAndLogEx(NORMAL, "preparing to sim ask data: %d bits", size);
|
||||||
|
@ -707,9 +707,9 @@ int CmdLFpskSim(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t size = DemodBufferLen;
|
size_t size = DemodBufferLen;
|
||||||
if (size > USB_CMD_DATA_SIZE) {
|
if (size > PM3_CMD_DATA_SIZE) {
|
||||||
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE);
|
PrintAndLogEx(NORMAL, "DemodBuffer too long for current implementation - length: %d - max: %d", size, PM3_CMD_DATA_SIZE);
|
||||||
size = USB_CMD_DATA_SIZE;
|
size = PM3_CMD_DATA_SIZE;
|
||||||
}
|
}
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Sending DemodBuffer Length: %d", size);
|
PrintAndLogEx(DEBUG, "DEBUG: Sending DemodBuffer Length: %d", size);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
|
@ -128,7 +128,7 @@ static int CmdLFHitagList(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uint8_t *got = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *got = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (!got) {
|
if (!got) {
|
||||||
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -136,14 +136,14 @@ static int CmdLFHitagList(const char *Cmd) {
|
||||||
|
|
||||||
// Query for the actual size of the trace
|
// Query for the actual size of the trace
|
||||||
PacketResponseNG response;
|
PacketResponseNG response;
|
||||||
if (!GetFromDevice(BIG_BUF, got, USB_CMD_DATA_SIZE, 0, &response, 2500, false)) {
|
if (!GetFromDevice(BIG_BUF, got, PM3_CMD_DATA_SIZE, 0, &response, 2500, false)) {
|
||||||
PrintAndLogEx(WARNING, "command execution time out");
|
PrintAndLogEx(WARNING, "command execution time out");
|
||||||
free(got);
|
free(got);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t traceLen = response.arg[2];
|
uint16_t traceLen = response.arg[2];
|
||||||
if (traceLen > USB_CMD_DATA_SIZE) {
|
if (traceLen > PM3_CMD_DATA_SIZE) {
|
||||||
uint8_t *p = realloc(got, traceLen);
|
uint8_t *p = realloc(got, traceLen);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
PrintAndLogEx(WARNING, "Cannot allocate memory for trace");
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "util_posix.h"
|
#include "util_posix.h"
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "cmdparser.h"
|
#include "cmdparser.h"
|
||||||
|
|
|
@ -395,7 +395,7 @@ static int CmdSmartRaw(const char *Cmd) {
|
||||||
bool useT0 = false;
|
bool useT0 = false;
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false, reply = true, decodeTLV = false, breakloop = false;
|
bool errors = false, reply = true, decodeTLV = false, breakloop = false;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
|
@ -470,7 +470,7 @@ static int CmdSmartRaw(const char *Cmd) {
|
||||||
// reading response from smart card
|
// reading response from smart card
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
|
||||||
uint8_t *buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
|
||||||
uint32_t bytes_remaining = firmware_size;
|
uint32_t bytes_remaining = firmware_size;
|
||||||
|
|
||||||
while (bytes_remaining > 0) {
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
|
uint32_t bytes_in_packet = MIN(PM3_CMD_DATA_SIZE, bytes_remaining);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_SMART_UPLOAD, index + bytes_sent, bytes_in_packet, 0, dump + bytes_sent, bytes_in_packet);
|
SendCommandOLD(CMD_SMART_UPLOAD, index + bytes_sent, bytes_in_packet, 0, dump + bytes_sent, bytes_in_packet);
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2000)) {
|
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2000)) {
|
||||||
|
@ -858,7 +858,7 @@ static int CmdSmartList(const char *Cmd) {
|
||||||
|
|
||||||
static void smart_brute_prim() {
|
static void smart_brute_prim() {
|
||||||
|
|
||||||
uint8_t *buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ static void smart_brute_prim() {
|
||||||
|
|
||||||
static int smart_brute_sfi(bool decodeTLV) {
|
static int smart_brute_sfi(bool decodeTLV) {
|
||||||
|
|
||||||
uint8_t *buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ static int smart_brute_sfi(bool decodeTLV) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memset(buf, 0x00, USB_CMD_DATA_SIZE);
|
memset(buf, 0x00, PM3_CMD_DATA_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -954,7 +954,7 @@ static int smart_brute_sfi(bool decodeTLV) {
|
||||||
|
|
||||||
static void smart_brute_options(bool decodeTLV) {
|
static void smart_brute_options(bool decodeTLV) {
|
||||||
|
|
||||||
uint8_t *buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||||
json_t *root = NULL;
|
json_t *root = NULL;
|
||||||
smart_loadjson("aidlist", "json", &root);
|
smart_loadjson("aidlist", "json", &root);
|
||||||
|
|
||||||
uint8_t *buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
uint8_t *buf = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -1064,7 +1064,7 @@ static int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||||
snprintf(caid, 8 + 2 + aidlen + 1, SELECT, aidlen >> 1, aid);
|
snprintf(caid, 8 + 2 + aidlen + 1, SELECT, aidlen >> 1, aid);
|
||||||
|
|
||||||
int hexlen = 0;
|
int hexlen = 0;
|
||||||
uint8_t cmddata[USB_CMD_DATA_SIZE];
|
uint8_t cmddata[PM3_CMD_DATA_SIZE];
|
||||||
int res = param_gethex_to_eol(caid, 0, cmddata, sizeof(cmddata), &hexlen);
|
int res = param_gethex_to_eol(caid, 0, cmddata, sizeof(cmddata), &hexlen);
|
||||||
if (res)
|
if (res)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -664,18 +664,18 @@ int CmdTraceList(const char *Cmd) {
|
||||||
|
|
||||||
// reserv some space.
|
// reserv some space.
|
||||||
if (!trace)
|
if (!trace)
|
||||||
trace = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
|
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
// Query for the size of the trace, downloading USB_CMD_DATA_SIZE
|
// Query for the size of the trace, downloading PM3_CMD_DATA_SIZE
|
||||||
PacketResponseNG response;
|
PacketResponseNG response;
|
||||||
if (!GetFromDevice(BIG_BUF, trace, USB_CMD_DATA_SIZE, 0, &response, 4000, true)) {
|
if (!GetFromDevice(BIG_BUF, trace, PM3_CMD_DATA_SIZE, 0, &response, 4000, true)) {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
traceLen = response.oldarg[2];
|
traceLen = response.oldarg[2];
|
||||||
if (traceLen > USB_CMD_DATA_SIZE) {
|
if (traceLen > PM3_CMD_DATA_SIZE) {
|
||||||
uint8_t *p = realloc(trace, traceLen);
|
uint8_t *p = realloc(trace, traceLen);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
||||||
PrintAndLogEx(NORMAL, "Sending bytes to proxmark failed - offline");
|
PrintAndLogEx(NORMAL, "Sending bytes to proxmark failed - offline");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (len > USB_CMD_DATA_SIZE) {
|
if (len > PM3_CMD_DATA_SIZE) {
|
||||||
PrintAndLogEx(WARNING, "Sending %d bytes of payload is too much, abort", len);
|
PrintAndLogEx(WARNING, "Sending %d bytes of payload is too much, abort", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,11 +182,11 @@ void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) {
|
||||||
|
|
||||||
void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||||
uint64_t arg[3] = {arg0, arg1, arg2};
|
uint64_t arg[3] = {arg0, arg1, arg2};
|
||||||
if (len > USB_CMD_DATA_SIZE_MIX) {
|
if (len > PM3_CMD_DATA_SIZE_MIX) {
|
||||||
PrintAndLogEx(WARNING, "Sending %d bytes of payload is too much for MIX frames, abort", len);
|
PrintAndLogEx(WARNING, "Sending %d bytes of payload is too much for MIX frames, abort", len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t cmddata[USB_CMD_DATA_SIZE];
|
uint8_t cmddata[PM3_CMD_DATA_SIZE];
|
||||||
memcpy(cmddata, arg, sizeof(arg));
|
memcpy(cmddata, arg, sizeof(arg));
|
||||||
if (len && data)
|
if (len && data)
|
||||||
memcpy(cmddata + sizeof(arg), data, len);
|
memcpy(cmddata + sizeof(arg), data, len);
|
||||||
|
@ -307,7 +307,7 @@ static void PacketResponseReceived(PacketResponseNG *packet) {
|
||||||
// First check if we are handling a debug message
|
// First check if we are handling a debug message
|
||||||
case CMD_DEBUG_PRINT_STRING: {
|
case CMD_DEBUG_PRINT_STRING: {
|
||||||
|
|
||||||
char s[USB_CMD_DATA_SIZE + 1];
|
char s[PM3_CMD_DATA_SIZE + 1];
|
||||||
memset(s, 0x00, sizeof(s));
|
memset(s, 0x00, sizeof(s));
|
||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -315,14 +315,14 @@ static void PacketResponseReceived(PacketResponseNG *packet) {
|
||||||
if (packet->ng) {
|
if (packet->ng) {
|
||||||
struct d {
|
struct d {
|
||||||
uint16_t flag;
|
uint16_t flag;
|
||||||
uint8_t buf[USB_CMD_DATA_SIZE - sizeof(uint16_t)];
|
uint8_t buf[PM3_CMD_DATA_SIZE - sizeof(uint16_t)];
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct d *data = (struct d *)&packet->data.asBytes;
|
struct d *data = (struct d *)&packet->data.asBytes;
|
||||||
len = packet->length - sizeof(data->flag);
|
len = packet->length - sizeof(data->flag);
|
||||||
flag = data->flag;
|
flag = data->flag;
|
||||||
memcpy_filtered(s, data->buf, len, flag & FLAG_ANSI);
|
memcpy_filtered(s, data->buf, len, flag & FLAG_ANSI);
|
||||||
} else {
|
} else {
|
||||||
len = MIN(packet->oldarg[0], USB_CMD_DATA_SIZE);
|
len = MIN(packet->oldarg[0], PM3_CMD_DATA_SIZE);
|
||||||
flag = packet->oldarg[1];
|
flag = packet->oldarg[1];
|
||||||
memcpy_filtered(s, packet->data.asBytes, len, flag & FLAG_ANSI);
|
memcpy_filtered(s, packet->data.asBytes, len, flag & FLAG_ANSI);
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
rx.status = rx_raw.pre.status;
|
rx.status = rx_raw.pre.status;
|
||||||
rx.cmd = rx_raw.pre.cmd;
|
rx.cmd = rx_raw.pre.cmd;
|
||||||
if (rx.magic == RESPONSENG_PREAMBLE_MAGIC) { // New style NG reply
|
if (rx.magic == RESPONSENG_PREAMBLE_MAGIC) { // New style NG reply
|
||||||
if (length > USB_CMD_DATA_SIZE) {
|
if (length > PM3_CMD_DATA_SIZE) {
|
||||||
PrintAndLogEx(WARNING, "Received packet frame with incompatible length: 0x%04x", length);
|
PrintAndLogEx(WARNING, "Received packet frame with incompatible length: 0x%04x", length);
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
rx.oldarg[0] = rx_old.arg[0];
|
rx.oldarg[0] = rx_old.arg[0];
|
||||||
rx.oldarg[1] = rx_old.arg[1];
|
rx.oldarg[1] = rx_old.arg[1];
|
||||||
rx.oldarg[2] = rx_old.arg[2];
|
rx.oldarg[2] = rx_old.arg[2];
|
||||||
rx.length = USB_CMD_DATA_SIZE;
|
rx.length = PM3_CMD_DATA_SIZE;
|
||||||
memcpy(&rx.data, &rx_old.d, rx.length);
|
memcpy(&rx.data, &rx_old.d, rx.length);
|
||||||
PacketResponseReceived(&rx);
|
PacketResponseReceived(&rx);
|
||||||
if (rx.cmd == CMD_ACK) {
|
if (rx.cmd == CMD_ACK) {
|
||||||
|
@ -829,9 +829,9 @@ static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketRes
|
||||||
uint32_t copy_bytes = MIN(bytes - bytes_completed, response->oldarg[1]);
|
uint32_t copy_bytes = MIN(bytes - bytes_completed, response->oldarg[1]);
|
||||||
//uint32_t tracelen = response->oldarg[2];
|
//uint32_t tracelen = response->oldarg[2];
|
||||||
|
|
||||||
// extended bounds check1. upper limit is USB_CMD_DATA_SIZE
|
// extended bounds check1. upper limit is PM3_CMD_DATA_SIZE
|
||||||
// shouldn't happen
|
// shouldn't happen
|
||||||
copy_bytes = MIN(copy_bytes, USB_CMD_DATA_SIZE);
|
copy_bytes = MIN(copy_bytes, PM3_CMD_DATA_SIZE);
|
||||||
|
|
||||||
// extended bounds check2.
|
// extended bounds check2.
|
||||||
if (offset + copy_bytes > bytes) {
|
if (offset + copy_bytes > bytes) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "proxendian.h"
|
#include "proxendian.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "at91sam7s512.h"
|
#include "at91sam7s512.h"
|
||||||
#include "util_posix.h"
|
#include "util_posix.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
|
|
||||||
#define MAX_FILES 4
|
#define MAX_FILES 4
|
||||||
|
|
||||||
|
|
|
@ -89,8 +89,8 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) {
|
||||||
PrintAndLogEx(SUCCESS, "found %u candidate key%s\n", keycount, (keycount > 1) ? "s." : ".");
|
PrintAndLogEx(SUCCESS, "found %u candidate key%s\n", keycount, (keycount > 1) ? "s." : ".");
|
||||||
|
|
||||||
*key = UINT64_C(-1);
|
*key = UINT64_C(-1);
|
||||||
uint8_t keyBlock[USB_CMD_DATA_SIZE];
|
uint8_t keyBlock[PM3_CMD_DATA_SIZE];
|
||||||
uint32_t max_keys = (USB_CMD_DATA_SIZE - 4) / 6;
|
uint32_t max_keys = (PM3_CMD_DATA_SIZE - 4) / 6;
|
||||||
for (uint32_t i = 0; i < keycount; i += max_keys) {
|
for (uint32_t i = 0; i < keycount; i += max_keys) {
|
||||||
|
|
||||||
uint32_t size = keycount - i > max_keys ? max_keys : keycount - i;
|
uint32_t size = keycount - i > max_keys ? max_keys : keycount - i;
|
||||||
|
@ -123,7 +123,7 @@ 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) {
|
int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t *keyBlock, uint64_t *key) {
|
||||||
*key = -1;
|
*key = -1;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
data[0] = keyType;
|
data[0] = keyType;
|
||||||
data[1] = blockNo;
|
data[1] = blockNo;
|
||||||
data[2] = clear_trace;
|
data[2] = clear_trace;
|
||||||
|
@ -220,7 +220,7 @@ int mfCheckKeys_fast(uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
|
||||||
// ref: https://github.com/J-Run/mf_key_brute
|
// ref: https://github.com/J-Run/mf_key_brute
|
||||||
int mfKeyBrute(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint64_t *resultkey) {
|
int mfKeyBrute(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint64_t *resultkey) {
|
||||||
|
|
||||||
#define KEYS_IN_BLOCK ((USB_CMD_DATA_SIZE - 4) / 6)
|
#define KEYS_IN_BLOCK ((PM3_CMD_DATA_SIZE - 4) / 6)
|
||||||
#define KEYBLOCK_SIZE (KEYS_IN_BLOCK * 6)
|
#define KEYBLOCK_SIZE (KEYS_IN_BLOCK * 6)
|
||||||
#define CANDIDATE_SIZE (0xFFFF * 6)
|
#define CANDIDATE_SIZE (0xFFFF * 6)
|
||||||
|
|
||||||
|
@ -379,8 +379,8 @@ int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBlockNo,
|
||||||
uint64_t key64 = -1;
|
uint64_t key64 = -1;
|
||||||
|
|
||||||
// The list may still contain several key candidates. Test each of them with mfCheckKeys
|
// The list may still contain several key candidates. Test each of them with mfCheckKeys
|
||||||
uint32_t max_keys = keycnt > ((USB_CMD_DATA_SIZE - 4) / 6) ? ((USB_CMD_DATA_SIZE - 4) / 6) : keycnt;
|
uint32_t max_keys = keycnt > ((PM3_CMD_DATA_SIZE - 4) / 6) ? ((PM3_CMD_DATA_SIZE - 4) / 6) : keycnt;
|
||||||
uint8_t keyBlock[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t keyBlock[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
|
|
||||||
for (i = 0; i < keycnt; i += max_keys) {
|
for (i = 0; i < keycnt; i += max_keys) {
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
BEGIN {
|
BEGIN {
|
||||||
print "--[["
|
print "--[["
|
||||||
print "These are Proxmark command definitions."
|
print "These are Proxmark command definitions."
|
||||||
print "This file is automatically generated from usb_cmd.h - DON'T EDIT MANUALLY."
|
print "This file is automatically generated from pm3_cmd.h - DON'T EDIT MANUALLY."
|
||||||
print "--]]"
|
print "--]]"
|
||||||
print "local __commands = {"
|
print "local __commands = {"
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@
|
||||||
#ifndef PROXMARK3_H__
|
#ifndef PROXMARK3_H__
|
||||||
#define PROXMARK3_H__
|
#define PROXMARK3_H__
|
||||||
|
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "cmdscript.h" // CmdScriptRun
|
#include "cmdscript.h" // CmdScriptRun
|
||||||
|
|
||||||
#define PROXPROMPT "pm3 --> "
|
#define PROXPROMPT "pm3 --> "
|
||||||
|
|
|
@ -90,7 +90,7 @@ static int l_SendCommandOLD(lua_State *L) {
|
||||||
// (uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len)
|
// (uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len)
|
||||||
|
|
||||||
uint64_t cmd, arg0, arg1, arg2;
|
uint64_t cmd, arg0, arg1, arg2;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
size_t len = 0, size;
|
size_t len = 0, size;
|
||||||
|
|
||||||
//Check number of arguments
|
//Check number of arguments
|
||||||
|
@ -138,7 +138,7 @@ static int l_SendCommandOLD(lua_State *L) {
|
||||||
static int l_SendCommandMIX(lua_State *L) {
|
static int l_SendCommandMIX(lua_State *L) {
|
||||||
|
|
||||||
uint64_t cmd, arg0, arg1, arg2;
|
uint64_t cmd, arg0, arg1, arg2;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
size_t len = 0, size;
|
size_t len = 0, size;
|
||||||
|
|
||||||
// check number of arguments
|
// check number of arguments
|
||||||
|
@ -180,7 +180,7 @@ static int l_SendCommandMIX(lua_State *L) {
|
||||||
*/
|
*/
|
||||||
static int l_SendCommandNG(lua_State *L) {
|
static int l_SendCommandNG(lua_State *L) {
|
||||||
|
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0};
|
uint8_t data[PM3_CMD_DATA_SIZE] = {0};
|
||||||
size_t len = 0, size;
|
size_t len = 0, size;
|
||||||
|
|
||||||
// check number of arguments
|
// check number of arguments
|
||||||
|
@ -414,7 +414,7 @@ static int l_CmdConsole(lua_State *L) {
|
||||||
|
|
||||||
static int l_iso15693_crc(lua_State *L) {
|
static int l_iso15693_crc(lua_State *L) {
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
unsigned char buf[USB_CMD_DATA_SIZE] = {0x00};
|
unsigned char buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
const char *data = luaL_checklstring(L, 1, &size);
|
const char *data = luaL_checklstring(L, 1, &size);
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ static int l_iso15693_crc(lua_State *L) {
|
||||||
|
|
||||||
static int l_iso14443b_crc(lua_State *L) {
|
static int l_iso14443b_crc(lua_State *L) {
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
unsigned char buf[USB_CMD_DATA_SIZE] = {0x00};
|
unsigned char buf[PM3_CMD_DATA_SIZE] = {0x00};
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
const char *data = luaL_checklstring(L, 1, &size);
|
const char *data = luaL_checklstring(L, 1, &size);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "cmdmain.h"
|
#include "cmdmain.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
|
@ -62,7 +62,7 @@ endif
|
||||||
# Also search prerequisites in the common directory (for usb.c), the fpga directory (for fpga.bit), and the zlib directory
|
# Also search prerequisites in the common directory (for usb.c), the fpga directory (for fpga.bit), and the zlib directory
|
||||||
VPATH = . ../common ../common/crapto1 ../common/polarssl ../fpga ../zlib ../armsrc/Standalone ../uart
|
VPATH = . ../common ../common/crapto1 ../common/polarssl ../fpga ../zlib ../armsrc/Standalone ../uart
|
||||||
|
|
||||||
INCLUDES = ../include/proxmark3.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/usb_cmd.h $(APP_INCLUDES)
|
INCLUDES = ../include/proxmark3.h ../include/at91sam7s512.h ../include/config_gpio.h ../include/pm3_cmd.h $(APP_INCLUDES)
|
||||||
|
|
||||||
CFLAGS = -c $(INCLUDE) -Wall -Werror -pedantic -Wunused -std=c99 $(APP_CFLAGS) -Os
|
CFLAGS = -c $(INCLUDE) -Wall -Werror -pedantic -Wunused -std=c99 $(APP_CFLAGS) -Os
|
||||||
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-gc-sections -n
|
LDFLAGS = -nostartfiles -nodefaultlibs -Wl,-gc-sections -n
|
||||||
|
|
20
common/cmd.c
20
common/cmd.c
|
@ -59,9 +59,9 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *d
|
||||||
txcmd.arg[1] = arg1;
|
txcmd.arg[1] = arg1;
|
||||||
txcmd.arg[2] = arg2;
|
txcmd.arg[2] = arg2;
|
||||||
|
|
||||||
// Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE
|
// Add the (optional) content to the frame, with a maximum size of PM3_CMD_DATA_SIZE
|
||||||
if (data && len) {
|
if (data && len) {
|
||||||
len = MIN(len, USB_CMD_DATA_SIZE);
|
len = MIN(len, PM3_CMD_DATA_SIZE);
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
txcmd.d.asBytes[i] = ((uint8_t *)data)[i];
|
txcmd.d.asBytes[i] = ((uint8_t *)data)[i];
|
||||||
}
|
}
|
||||||
|
@ -95,14 +95,14 @@ static int reply_ng_internal(uint16_t cmd, int16_t status, uint8_t *data, size_t
|
||||||
txBufferNG.pre.cmd = cmd;
|
txBufferNG.pre.cmd = cmd;
|
||||||
txBufferNG.pre.status = status;
|
txBufferNG.pre.status = status;
|
||||||
txBufferNG.pre.ng = ng;
|
txBufferNG.pre.ng = ng;
|
||||||
if (len > USB_CMD_DATA_SIZE) {
|
if (len > PM3_CMD_DATA_SIZE) {
|
||||||
len = USB_CMD_DATA_SIZE;
|
len = PM3_CMD_DATA_SIZE;
|
||||||
// overwrite status
|
// overwrite status
|
||||||
txBufferNG.pre.status = PM3_EOVFLOW;
|
txBufferNG.pre.status = PM3_EOVFLOW;
|
||||||
}
|
}
|
||||||
txBufferNG.pre.length = len;
|
txBufferNG.pre.length = len;
|
||||||
|
|
||||||
// Add the (optional) content to the frame, with a maximum size of USB_CMD_DATA_SIZE
|
// Add the (optional) content to the frame, with a maximum size of PM3_CMD_DATA_SIZE
|
||||||
if (data && len) {
|
if (data && len) {
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
txBufferNG.data[i] = data[i];
|
txBufferNG.data[i] = data[i];
|
||||||
|
@ -143,11 +143,11 @@ int reply_ng(uint16_t cmd, int16_t status, uint8_t *data, size_t len) {
|
||||||
int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||||
uint16_t status = PM3_SUCCESS;
|
uint16_t status = PM3_SUCCESS;
|
||||||
uint64_t arg[3] = {arg0, arg1, arg2};
|
uint64_t arg[3] = {arg0, arg1, arg2};
|
||||||
if (len > USB_CMD_DATA_SIZE - sizeof(arg)) {
|
if (len > PM3_CMD_DATA_SIZE - sizeof(arg)) {
|
||||||
len = USB_CMD_DATA_SIZE - sizeof(arg);
|
len = PM3_CMD_DATA_SIZE - sizeof(arg);
|
||||||
status = PM3_EOVFLOW;
|
status = PM3_EOVFLOW;
|
||||||
}
|
}
|
||||||
uint8_t cmddata[USB_CMD_DATA_SIZE];
|
uint8_t cmddata[PM3_CMD_DATA_SIZE];
|
||||||
memcpy(cmddata, arg, sizeof(arg));
|
memcpy(cmddata, arg, sizeof(arg));
|
||||||
if (len && data)
|
if (len && data)
|
||||||
memcpy(cmddata + sizeof(arg), data, len);
|
memcpy(cmddata + sizeof(arg), data, len);
|
||||||
|
@ -166,7 +166,7 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
|
||||||
uint16_t length = rx_raw.pre.length;
|
uint16_t length = rx_raw.pre.length;
|
||||||
rx->cmd = rx_raw.pre.cmd;
|
rx->cmd = rx_raw.pre.cmd;
|
||||||
if (rx->magic == COMMANDNG_PREAMBLE_MAGIC) { // New style NG command
|
if (rx->magic == COMMANDNG_PREAMBLE_MAGIC) { // New style NG command
|
||||||
if (length > USB_CMD_DATA_SIZE)
|
if (length > PM3_CMD_DATA_SIZE)
|
||||||
return PM3_EOVFLOW;
|
return PM3_EOVFLOW;
|
||||||
// Get the core and variable length payload
|
// Get the core and variable length payload
|
||||||
bytes = read_ng((uint8_t *)&rx_raw.data, length);
|
bytes = read_ng((uint8_t *)&rx_raw.data, length);
|
||||||
|
@ -213,7 +213,7 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
|
||||||
rx->oldarg[0] = rx_old.arg[0];
|
rx->oldarg[0] = rx_old.arg[0];
|
||||||
rx->oldarg[1] = rx_old.arg[1];
|
rx->oldarg[1] = rx_old.arg[1];
|
||||||
rx->oldarg[2] = rx_old.arg[2];
|
rx->oldarg[2] = rx_old.arg[2];
|
||||||
rx->length = USB_CMD_DATA_SIZE;
|
rx->length = PM3_CMD_DATA_SIZE;
|
||||||
memcpy(&rx->data, &rx_old.d.asBytes, rx->length);
|
memcpy(&rx->data, &rx_old.d.asBytes, rx->length);
|
||||||
}
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#define _PROXMARK_CMD_H_
|
#define _PROXMARK_CMD_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
#include "usb_cdc.h"
|
#include "usb_cdc.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
|
|
|
@ -27,15 +27,15 @@ typedef BYTE uint8_t;
|
||||||
#define PACKED __attribute__((packed))
|
#define PACKED __attribute__((packed))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USB_CMD_DATA_SIZE 512
|
#define PM3_CMD_DATA_SIZE 512
|
||||||
#define USB_CMD_DATA_SIZE_MIX ( USB_CMD_DATA_SIZE - 3 * sizeof(uint64_t) )
|
#define PM3_CMD_DATA_SIZE_MIX ( PM3_CMD_DATA_SIZE - 3 * sizeof(uint64_t) )
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t cmd;
|
uint64_t cmd;
|
||||||
uint64_t arg[3];
|
uint64_t arg[3];
|
||||||
union {
|
union {
|
||||||
uint8_t asBytes[USB_CMD_DATA_SIZE];
|
uint8_t asBytes[PM3_CMD_DATA_SIZE];
|
||||||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
|
||||||
} d;
|
} d;
|
||||||
} PACKED PacketCommandOLD;
|
} PACKED PacketCommandOLD;
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ typedef struct {
|
||||||
uint16_t crc; // NG
|
uint16_t crc; // NG
|
||||||
uint64_t oldarg[3]; // OLD
|
uint64_t oldarg[3]; // OLD
|
||||||
union {
|
union {
|
||||||
uint8_t asBytes[USB_CMD_DATA_SIZE];
|
uint8_t asBytes[PM3_CMD_DATA_SIZE];
|
||||||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
|
||||||
} data;
|
} data;
|
||||||
bool ng; // does it store NG data or OLD data?
|
bool ng; // does it store NG data or OLD data?
|
||||||
} PACKED PacketCommandNG;
|
} PACKED PacketCommandNG;
|
||||||
|
@ -70,7 +70,7 @@ typedef struct {
|
||||||
// For reception and CRC check
|
// For reception and CRC check
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PacketCommandNGPreamble pre;
|
PacketCommandNGPreamble pre;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
PacketCommandNGPostamble foopost; // Probably not at that offset!
|
PacketCommandNGPostamble foopost; // Probably not at that offset!
|
||||||
} PACKED PacketCommandNGRaw;
|
} PACKED PacketCommandNGRaw;
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ typedef struct {
|
||||||
uint64_t cmd;
|
uint64_t cmd;
|
||||||
uint64_t arg[3];
|
uint64_t arg[3];
|
||||||
union {
|
union {
|
||||||
uint8_t asBytes[USB_CMD_DATA_SIZE];
|
uint8_t asBytes[PM3_CMD_DATA_SIZE];
|
||||||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
|
||||||
} d;
|
} d;
|
||||||
} PACKED PacketResponseOLD;
|
} PACKED PacketResponseOLD;
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ typedef struct {
|
||||||
uint16_t crc; // NG
|
uint16_t crc; // NG
|
||||||
uint64_t oldarg[3]; // OLD
|
uint64_t oldarg[3]; // OLD
|
||||||
union {
|
union {
|
||||||
uint8_t asBytes[USB_CMD_DATA_SIZE];
|
uint8_t asBytes[PM3_CMD_DATA_SIZE];
|
||||||
uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
|
uint32_t asDwords[PM3_CMD_DATA_SIZE / 4];
|
||||||
} data;
|
} data;
|
||||||
bool ng; // does it store NG data or OLD data?
|
bool ng; // does it store NG data or OLD data?
|
||||||
} PACKED PacketResponseNG;
|
} PACKED PacketResponseNG;
|
||||||
|
@ -116,7 +116,7 @@ typedef struct {
|
||||||
// For reception and CRC check
|
// For reception and CRC check
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PacketResponseNGPreamble pre;
|
PacketResponseNGPreamble pre;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[PM3_CMD_DATA_SIZE];
|
||||||
PacketResponseNGPostamble foopost; // Probably not at that offset!
|
PacketResponseNGPostamble foopost; // Probably not at that offset!
|
||||||
} PACKED PacketResponseNGRaw;
|
} PACKED PacketResponseNGRaw;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
// Might as well have the hardware-specific defines everywhere.
|
// Might as well have the hardware-specific defines everywhere.
|
||||||
#include "at91sam7s512.h"
|
#include "at91sam7s512.h"
|
||||||
#include "config_gpio.h"
|
#include "config_gpio.h"
|
||||||
#include "usb_cmd.h"
|
#include "pm3_cmd.h"
|
||||||
|
|
||||||
#define WDT_HIT() AT91C_BASE_WDTC->WDTC_WDCR = 0xa5000001
|
#define WDT_HIT() AT91C_BASE_WDTC->WDTC_WDCR = 0xa5000001
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef struct {
|
||||||
term_info tiNew; // Terminal info during the transaction
|
term_info tiNew; // Terminal info during the transaction
|
||||||
} serial_port_unix;
|
} serial_port_unix;
|
||||||
|
|
||||||
// see usb_cmd.h
|
// see pm3_cmd.h
|
||||||
struct timeval timeout = {
|
struct timeval timeout = {
|
||||||
.tv_sec = 0, // 0 second
|
.tv_sec = 0, // 0 second
|
||||||
.tv_usec = UART_FPC_CLIENT_RX_TIMEOUT_MS * 1000
|
.tv_usec = UART_FPC_CLIENT_RX_TIMEOUT_MS * 1000
|
||||||
|
|
Loading…
Add table
Reference in a new issue