mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
style
This commit is contained in:
parent
f49d7e6d39
commit
68e5b3c355
21 changed files with 106 additions and 106 deletions
|
@ -1189,7 +1189,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
uint8_t *dest = BigBuf_malloc(USART_FIFOLEN);
|
uint8_t *dest = BigBuf_malloc(USART_FIFOLEN);
|
||||||
uint16_t available = usart_rxdata_available();
|
uint16_t available = usart_rxdata_available();
|
||||||
|
|
||||||
if (available > 0) {
|
if (available > 0) {
|
||||||
uint16_t len = usart_read_ng(dest, available);
|
uint16_t len = usart_read_ng(dest, available);
|
||||||
reply_ng(CMD_USART_RX, PM3_SUCCESS, dest, len);
|
reply_ng(CMD_USART_RX, PM3_SUCCESS, dest, len);
|
||||||
|
@ -1212,7 +1212,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
WaitMS(payload->waittime);
|
WaitMS(payload->waittime);
|
||||||
|
|
||||||
uint8_t *dest = BigBuf_malloc(USART_FIFOLEN);
|
uint8_t *dest = BigBuf_malloc(USART_FIFOLEN);
|
||||||
|
|
||||||
available = usart_rxdata_available();
|
available = usart_rxdata_available();
|
||||||
// Dbprintf("avail (%u)", available);
|
// Dbprintf("avail (%u)", available);
|
||||||
if (available > 0) {
|
if (available > 0) {
|
||||||
|
@ -1635,8 +1635,8 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
if (ret == PM3_SUCCESS) {
|
if (ret == PM3_SUCCESS) {
|
||||||
PacketReceived(&rx);
|
PacketReceived(&rx);
|
||||||
} else if (ret != PM3_ENODATA) {
|
} else if (ret != PM3_ENODATA) {
|
||||||
|
|
||||||
Dbprintf("Error in frame reception: %d %s", ret, (ret == PM3_EIO)?"PM3_EIO":"");
|
Dbprintf("Error in frame reception: %d %s", ret, (ret == PM3_EIO) ? "PM3_EIO" : "");
|
||||||
// TODO if error, shall we resync ?
|
// TODO if error, shall we resync ?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ static int CmdFlashmemSpiBaudrate(const char *Cmd) {
|
||||||
if (strlen(Cmd) < 1 || ctmp == 'h') {
|
if (strlen(Cmd) < 1 || ctmp == 'h') {
|
||||||
return usage_flashmem_spibaud();
|
return usage_flashmem_spibaud();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t baudrate = param_get32ex(Cmd, 0, 0, 10);
|
uint32_t baudrate = param_get32ex(Cmd, 0, 0, 10);
|
||||||
baudrate = baudrate * 1000000;
|
baudrate = baudrate * 1000000;
|
||||||
if (baudrate != FLASH_BAUD && baudrate != FLASH_MINBAUD) {
|
if (baudrate != FLASH_BAUD && baudrate != FLASH_MINBAUD) {
|
||||||
|
@ -279,7 +279,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
||||||
|
|
||||||
// fast push mode
|
// fast push mode
|
||||||
conn.block_after_ACK = true;
|
conn.block_after_ACK = true;
|
||||||
|
|
||||||
while (bytes_remaining > 0) {
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_in_packet = MIN(FLASH_MEM_BLOCK_SIZE, bytes_remaining);
|
uint32_t bytes_in_packet = MIN(FLASH_MEM_BLOCK_SIZE, bytes_remaining);
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
||||||
|
|
||||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
uint8_t isok = resp.oldarg[0] & 0xFF;
|
||||||
if (!isok) {
|
if (!isok) {
|
||||||
conn.block_after_ACK = false;
|
conn.block_after_ACK = false;
|
||||||
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
|
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
|
||||||
return PM3_EFLASH;
|
return PM3_EFLASH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,7 +429,7 @@ static int CmdSetMux(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
str_lower((char *)Cmd);
|
str_lower((char *)Cmd);
|
||||||
|
|
||||||
uint8_t arg = 0;
|
uint8_t arg = 0;
|
||||||
if (strcmp(Cmd, "lopkd") == 0) arg = 0;
|
if (strcmp(Cmd, "lopkd") == 0) arg = 0;
|
||||||
else if (strcmp(Cmd, "loraw") == 0) arg = 1;
|
else if (strcmp(Cmd, "loraw") == 0) arg = 1;
|
||||||
|
@ -438,7 +438,7 @@ static int CmdSetMux(const char *Cmd) {
|
||||||
else {
|
else {
|
||||||
usage_hw_setmux();
|
usage_hw_setmux();
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_SET_ADC_MUX, arg, 0, 0, NULL, 0);
|
SendCommandMIX(CMD_SET_ADC_MUX, arg, 0, 0, NULL, 0);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -483,9 +483,9 @@ static int CmdPing(const char *Cmd) {
|
||||||
bool error = false;
|
bool error = false;
|
||||||
if (len) {
|
if (len) {
|
||||||
error = memcmp(data, resp.data.asBytes, len) != 0;
|
error = memcmp(data, resp.data.asBytes, len) != 0;
|
||||||
PrintAndLogEx((error)? ERR:SUCCESS, "Ping response " _GREEN_("received") "and content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
|
PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received") "and content is %s", error ? _RED_("NOT ok") : _GREEN_("ok"));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx((error)? ERR:SUCCESS, "Ping response " _GREEN_("received"));
|
PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received"));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
PrintAndLogEx(WARNING, "Ping response " _RED_("timeout"));
|
PrintAndLogEx(WARNING, "Ping response " _RED_("timeout"));
|
||||||
|
@ -498,11 +498,11 @@ static int CmdConnect(const char *Cmd) {
|
||||||
return usage_hw_connect();
|
return usage_hw_connect();
|
||||||
|
|
||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
|
|
||||||
// default back to previous used serial port
|
// default back to previous used serial port
|
||||||
if (strlen(Cmd) == 0 ) {
|
if (strlen(Cmd) == 0) {
|
||||||
int len = strlen((char *)conn.serial_port_name);
|
int len = strlen((char *)conn.serial_port_name);
|
||||||
if ( len == 0 ) {
|
if (len == 0) {
|
||||||
return usage_hw_connect();
|
return usage_hw_connect();
|
||||||
}
|
}
|
||||||
port = (char *)conn.serial_port_name;
|
port = (char *)conn.serial_port_name;
|
||||||
|
@ -510,10 +510,10 @@ static int CmdConnect(const char *Cmd) {
|
||||||
port = (char *)Cmd;
|
port = (char *)Cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( port == NULL )
|
if (port == NULL)
|
||||||
return usage_hw_connect();
|
return usage_hw_connect();
|
||||||
|
|
||||||
if ( session.pm3_present ) {
|
if (session.pm3_present) {
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,12 +558,12 @@ int CmdHW(const char *Cmd) {
|
||||||
void pm3_version(bool verbose) {
|
void pm3_version(bool verbose) {
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
||||||
SendCommandNG(CMD_VERSION, NULL, 0);
|
SendCommandNG(CMD_VERSION, NULL, 0);
|
||||||
|
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
|
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
|
||||||
PrintAndLogEx(NORMAL, "\n" _BLUE_(" [ Proxmark3 RFID instrument ]") "\n");
|
PrintAndLogEx(NORMAL, "\n" _BLUE_(" [ Proxmark3 RFID instrument ]") "\n");
|
||||||
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
|
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
|
||||||
|
@ -573,10 +573,10 @@ void pm3_version(bool verbose) {
|
||||||
PrintAndLogEx(NORMAL, " smartcard reader: %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent"));
|
PrintAndLogEx(NORMAL, " smartcard reader: %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK RDV4 Extras ]");
|
PrintAndLogEx(NORMAL, "\n [ PROXMARK RDV4 Extras ]");
|
||||||
PrintAndLogEx(NORMAL, " FPC USART for BT add-on support: %s", IfPm3FpcUsartHost() ? _GREEN_("present") : _YELLOW_("absent"));
|
PrintAndLogEx(NORMAL, " FPC USART for BT add-on support: %s", IfPm3FpcUsartHost() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||||
|
|
||||||
if (IfPm3FpcUsartDevFromUsb())
|
if (IfPm3FpcUsartDevFromUsb())
|
||||||
PrintAndLogEx(NORMAL, " FPC USART for developer support: %s", _GREEN_("present"));
|
PrintAndLogEx(NORMAL, " FPC USART for developer support: %s", _GREEN_("present"));
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, (char *)resp.data.asBytes);
|
PrintAndLogEx(NORMAL, (char *)resp.data.asBytes);
|
||||||
lookupChipID(resp.oldarg[0], resp.oldarg[1]);
|
lookupChipID(resp.oldarg[0], resp.oldarg[1]);
|
||||||
|
|
|
@ -161,7 +161,7 @@ static int CmdUsartBtPin(const char *Cmd) {
|
||||||
case 'h':
|
case 'h':
|
||||||
return usage_usart_bt_pin();
|
return usage_usart_bt_pin();
|
||||||
case 'd':
|
case 'd':
|
||||||
if (param_getstr(Cmd, cmdp + 1, pin, sizeof(pin)) != sizeof(pin)-1) {
|
if (param_getstr(Cmd, cmdp + 1, pin, sizeof(pin)) != sizeof(pin) - 1) {
|
||||||
PrintAndLogEx(FAILED, "PIN has wrong length, must be 4 digits");
|
PrintAndLogEx(FAILED, "PIN has wrong length, must be 4 digits");
|
||||||
errors = true;
|
errors = true;
|
||||||
break;
|
break;
|
||||||
|
@ -201,7 +201,7 @@ static int CmdUsartBtPin(const char *Cmd) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// PrintAndLogEx(NORMAL, "RX (%3u):%.*s", len, len, data);
|
// PrintAndLogEx(NORMAL, "RX (%3u):%.*s", len, len, data);
|
||||||
if (strcmp((char*)data, "OKsetPIN") == 0) {
|
if (strcmp((char *)data, "OKsetPIN") == 0) {
|
||||||
PrintAndLogEx(NORMAL, "PIN changed " _GREEN_("successfully"));
|
PrintAndLogEx(NORMAL, "PIN changed " _GREEN_("successfully"));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "Unexpected answer: %.*s", len, data);
|
PrintAndLogEx(WARNING, "Unexpected answer: %.*s", len, data);
|
||||||
|
|
|
@ -302,7 +302,7 @@ static void PacketResponseReceived(PacketResponseNG *packet) {
|
||||||
|
|
||||||
// The communications thread.
|
// The communications thread.
|
||||||
// signals to main thread when a response is ready to process.
|
// signals to main thread when a response is ready to process.
|
||||||
//
|
//
|
||||||
static void
|
static void
|
||||||
#ifdef __has_attribute
|
#ifdef __has_attribute
|
||||||
#if __has_attribute(force_align_arg_pointer)
|
#if __has_attribute(force_align_arg_pointer)
|
||||||
|
@ -329,14 +329,14 @@ __attribute__((force_align_arg_pointer))
|
||||||
|
|
||||||
// Signal to main thread that communications seems off.
|
// Signal to main thread that communications seems off.
|
||||||
// main thread will kill and restart this thread.
|
// main thread will kill and restart this thread.
|
||||||
if ( commfailed ) {
|
if (commfailed) {
|
||||||
PrintAndLogEx(WARNING, "Communicating with Proxmark3 device " _RED_("failed"));
|
PrintAndLogEx(WARNING, "Communicating with Proxmark3 device " _RED_("failed"));
|
||||||
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&spMutex);
|
pthread_mutex_lock(&spMutex);
|
||||||
|
|
||||||
res = uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(PacketResponseNGPreamble), &rxlen);
|
res = uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(PacketResponseNGPreamble), &rxlen);
|
||||||
if ((res == PM3_SUCCESS) && (rxlen == sizeof(PacketResponseNGPreamble))) {
|
if ((res == PM3_SUCCESS) && (rxlen == sizeof(PacketResponseNGPreamble))) {
|
||||||
rx.magic = rx_raw.pre.magic;
|
rx.magic = rx_raw.pre.magic;
|
||||||
|
@ -350,9 +350,9 @@ __attribute__((force_align_arg_pointer))
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
if ((!error) && (length > 0)) { // Get the variable length payload
|
if ((!error) && (length > 0)) { // Get the variable length payload
|
||||||
|
|
||||||
res = uart_receive(sp, (uint8_t *)&rx_raw.data, length, &rxlen);
|
res = uart_receive(sp, (uint8_t *)&rx_raw.data, length, &rxlen);
|
||||||
if ( (res != PM3_SUCCESS) || (rxlen != length)) {
|
if ((res != PM3_SUCCESS) || (rxlen != length)) {
|
||||||
PrintAndLogEx(WARNING, "Received packet frame error variable part too short? %d/%d", rxlen, length);
|
PrintAndLogEx(WARNING, "Received packet frame error variable part too short? %d/%d", rxlen, length);
|
||||||
error = true;
|
error = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -415,7 +415,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
} else { // Old style reply
|
} else { // Old style reply
|
||||||
PacketResponseOLD rx_old;
|
PacketResponseOLD rx_old;
|
||||||
memcpy(&rx_old, &rx_raw.pre, sizeof(PacketResponseNGPreamble));
|
memcpy(&rx_old, &rx_raw.pre, sizeof(PacketResponseNGPreamble));
|
||||||
|
|
||||||
res = uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(PacketResponseNGPreamble), sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble), &rxlen);
|
res = uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(PacketResponseNGPreamble), sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble), &rxlen);
|
||||||
if ((res != PM3_SUCCESS) || (rxlen != sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble))) {
|
if ((res != PM3_SUCCESS) || (rxlen != sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble))) {
|
||||||
PrintAndLogEx(WARNING, "Received packet OLD frame payload error too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble));
|
PrintAndLogEx(WARNING, "Received packet OLD frame payload error too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble));
|
||||||
|
@ -495,9 +495,9 @@ __attribute__((force_align_arg_pointer))
|
||||||
pthread_mutex_unlock(&spMutex);
|
pthread_mutex_unlock(&spMutex);
|
||||||
|
|
||||||
txBuffer_pending = false;
|
txBuffer_pending = false;
|
||||||
|
|
||||||
// main thread doesn't know send failed...
|
// main thread doesn't know send failed...
|
||||||
|
|
||||||
// tell main thread that txBuffer is empty
|
// tell main thread that txBuffer is empty
|
||||||
pthread_cond_signal(&txBufferSig);
|
pthread_cond_signal(&txBufferSig);
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
#if defined(__MACH__) && defined(__APPLE__)
|
#if defined(__MACH__) && defined(__APPLE__)
|
||||||
enableAppNap();
|
enableAppNap();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -551,8 +551,8 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// start the communication thread
|
// start the communication thread
|
||||||
if ( portname != (char*)conn.serial_port_name) {
|
if (portname != (char *)conn.serial_port_name) {
|
||||||
uint16_t len = MIN( strlen(portname), FILE_PATH_SIZE - 1);
|
uint16_t len = MIN(strlen(portname), FILE_PATH_SIZE - 1);
|
||||||
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
|
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
|
||||||
memcpy(conn.serial_port_name, portname, len);
|
memcpy(conn.serial_port_name, portname, len);
|
||||||
}
|
}
|
||||||
|
@ -582,20 +582,20 @@ int TestProxmark(void) {
|
||||||
uint8_t data[len];
|
uint8_t data[len];
|
||||||
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);
|
||||||
|
|
||||||
uint32_t timeout = 1000;
|
uint32_t timeout = 1000;
|
||||||
|
|
||||||
#ifdef USART_SLOW_LINK
|
#ifdef USART_SLOW_LINK
|
||||||
timeout = 10000;
|
timeout = 10000;
|
||||||
// 10s timeout for slow FPC, e.g. over BT
|
// 10s timeout for slow FPC, e.g. over BT
|
||||||
// as this is the very first command sent to the pm3
|
// as this is the very first command sent to the pm3
|
||||||
// that initiates the BT connection
|
// that initiates the BT connection
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (WaitForResponseTimeoutW(CMD_PING, &resp, timeout, false)) {
|
if (WaitForResponseTimeoutW(CMD_PING, &resp, timeout, false)) {
|
||||||
|
|
||||||
bool error = false;
|
bool error = false;
|
||||||
if (len)
|
if (len)
|
||||||
error = memcmp(data, resp.data.asBytes, len) != 0;
|
error = memcmp(data, resp.data.asBytes, len) != 0;
|
||||||
|
@ -652,7 +652,7 @@ void CloseProxmark(void) {
|
||||||
// Clean up our state
|
// Clean up our state
|
||||||
sp = NULL;
|
sp = NULL;
|
||||||
memset(&communication_thread, 0, sizeof(pthread_t));
|
memset(&communication_thread, 0, sizeof(pthread_t));
|
||||||
|
|
||||||
session.pm3_present = false;
|
session.pm3_present = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ local function parse1443b(data)
|
||||||
|
|
||||||
local count, uid, uidlen, atqb, chipid, cid = bin.unpack('H10CH7CC',data)
|
local count, uid, uidlen, atqb, chipid, cid = bin.unpack('H10CH7CC',data)
|
||||||
uid = uid:sub(1, 2 * uidlen)
|
uid = uid:sub(1, 2 * uidlen)
|
||||||
return {
|
return {
|
||||||
uid = uid,
|
uid = uid,
|
||||||
uidlen = uidlen,
|
uidlen = uidlen,
|
||||||
atqb = atqb,
|
atqb = atqb,
|
||||||
|
@ -73,7 +73,7 @@ local function read14443b(disconnect)
|
||||||
cmd = cmds.CMD_ISO_14443B_COMMAND,
|
cmd = cmds.CMD_ISO_14443B_COMMAND,
|
||||||
arg1 = flags
|
arg1 = flags
|
||||||
}
|
}
|
||||||
|
|
||||||
local result, err = command:sendMIX()
|
local result, err = command:sendMIX()
|
||||||
if result then
|
if result then
|
||||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
||||||
|
|
|
@ -120,7 +120,7 @@ local function read15693(slow, dont_readresponse)
|
||||||
else
|
else
|
||||||
err = 'No response from card'
|
err = 'No response from card'
|
||||||
end
|
end
|
||||||
|
|
||||||
if err then
|
if err then
|
||||||
print(err)
|
print(err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -54,10 +54,10 @@ static void showBanner(void) {
|
||||||
|
|
||||||
int check_comm(void) {
|
int check_comm(void) {
|
||||||
// If communications thread goes down. Device disconnected then this should hook up PM3 again.
|
// If communications thread goes down. Device disconnected then this should hook up PM3 again.
|
||||||
if ( IsCommunicationThreadDead() && session.pm3_present) {
|
if (IsCommunicationThreadDead() && session.pm3_present) {
|
||||||
rl_set_prompt("[offline] "PROXPROMPT);
|
rl_set_prompt("[offline] "PROXPROMPT);
|
||||||
rl_forced_update_display ();
|
rl_forced_update_display();
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Use \"hw connect\" to reconnect\n");
|
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Use \"hw connect\" to reconnect\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -159,11 +159,11 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rl_event_hook = check_comm;
|
rl_event_hook = check_comm;
|
||||||
if (session.pm3_present )
|
if (session.pm3_present)
|
||||||
cmd = readline(PROXPROMPT);
|
cmd = readline(PROXPROMPT);
|
||||||
else
|
else
|
||||||
cmd = readline("[offline] "PROXPROMPT);
|
cmd = readline("[offline] "PROXPROMPT);
|
||||||
|
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,9 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
||||||
if (cmd[0] != '\0') {
|
if (cmd[0] != '\0') {
|
||||||
if (printprompt)
|
if (printprompt)
|
||||||
PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd);
|
PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd);
|
||||||
|
|
||||||
int ret = CommandReceived(cmd);
|
int ret = CommandReceived(cmd);
|
||||||
|
|
||||||
HIST_ENTRY *entry = history_get(history_length);
|
HIST_ENTRY *entry = history_get(history_length);
|
||||||
if ((!entry) || (strcmp(entry->line, cmd) != 0))
|
if ((!entry) || (strcmp(entry->line, cmd) != 0))
|
||||||
add_history(cmd);
|
add_history(cmd);
|
||||||
|
|
|
@ -11,17 +11,17 @@ This is a script to allow raw 1444a commands to be sent and received.
|
||||||
example = [[
|
example = [[
|
||||||
# 1. Connect and don't disconnect
|
# 1. Connect and don't disconnect
|
||||||
script run 14araw -p
|
script run 14araw -p
|
||||||
|
|
||||||
# 2. Send mf auth, read response (nonce)
|
# 2. Send mf auth, read response (nonce)
|
||||||
script run 14araw -o -x 6000F57b -p
|
script run 14araw -o -x 6000F57b -p
|
||||||
|
|
||||||
# 3. disconnect
|
# 3. disconnect
|
||||||
script run 14araw -o
|
script run 14araw -o
|
||||||
|
|
||||||
# All three steps in one go:
|
# All three steps in one go:
|
||||||
script run 14araw -x 6000F57b
|
script run 14araw -x 6000F57b
|
||||||
]]
|
]]
|
||||||
usage = [[
|
usage = [[
|
||||||
script run 14araw -x 6000F57b
|
script run 14araw -x 6000F57b
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
@ -124,7 +124,7 @@ function main(args)
|
||||||
-- The actual raw payload, if any
|
-- The actual raw payload, if any
|
||||||
if payload then
|
if payload then
|
||||||
res, err = sendRaw(payload,{ignore_response = ignore_response, topaz_mode = topaz_mode, append_crc = append_crc})
|
res, err = sendRaw(payload,{ignore_response = ignore_response, topaz_mode = topaz_mode, append_crc = append_crc})
|
||||||
if err then
|
if err then
|
||||||
lib14a.disconnect()
|
lib14a.disconnect()
|
||||||
return oops(err)
|
return oops(err)
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,10 +118,10 @@ local bxor = bit32.bxor
|
||||||
|
|
||||||
-- we need always 2 digits
|
-- we need always 2 digits
|
||||||
local function prepend_zero(s)
|
local function prepend_zero(s)
|
||||||
if (string.len(s) == 1) then
|
if (string.len(s) == 1) then
|
||||||
return '0' .. s
|
return '0' .. s
|
||||||
else
|
else
|
||||||
if (string.len(s) == 0) then
|
if (string.len(s) == 0) then
|
||||||
return '00'
|
return '00'
|
||||||
else
|
else
|
||||||
return s
|
return s
|
||||||
|
@ -360,7 +360,7 @@ function displaySegments(bytes)
|
||||||
pld = pld..bytes[(start+4+1+Seg[5]+Seg[6]+i)-1]..' '
|
pld = pld..bytes[(start+4+1+Seg[5]+Seg[6]+i)-1]..' '
|
||||||
end
|
end
|
||||||
print(pld)
|
print(pld)
|
||||||
if (KGH) then
|
if (KGH) then
|
||||||
print("'Kaba Group Header' detected")
|
print("'Kaba Group Header' detected")
|
||||||
end
|
end
|
||||||
start = start+Seg[4]
|
start = start+Seg[4]
|
||||||
|
|
|
@ -57,7 +57,7 @@ local function help()
|
||||||
print(desc)
|
print(desc)
|
||||||
print("Example usage")
|
print("Example usage")
|
||||||
print(example)
|
print(example)
|
||||||
print(usage)
|
print(usage)
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
-- Exit message
|
-- Exit message
|
||||||
|
|
|
@ -64,7 +64,7 @@ local function help()
|
||||||
print(desc)
|
print(desc)
|
||||||
print("Example usage")
|
print("Example usage")
|
||||||
print(example)
|
print(example)
|
||||||
print(usage)
|
print(usage)
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
-- Exit message
|
-- Exit message
|
||||||
|
|
|
@ -118,7 +118,7 @@ local function calypso_send_cmd_raw(data, ignoreresponse )
|
||||||
arg1 = flags,
|
arg1 = flags,
|
||||||
arg2 = #data/2, -- LEN of data, half the length of the ASCII-string hex string
|
arg2 = #data/2, -- LEN of data, half the length of the ASCII-string hex string
|
||||||
data = data} -- data bytes (commands etc)
|
data = data} -- data bytes (commands etc)
|
||||||
|
|
||||||
result, err = command:sendMIX(ignoreresponse)
|
result, err = command:sendMIX(ignoreresponse)
|
||||||
if result then
|
if result then
|
||||||
local r = calypso_parse(result)
|
local r = calypso_parse(result)
|
||||||
|
@ -212,7 +212,7 @@ function main(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
lib14b.connect()
|
lib14b.connect()
|
||||||
|
|
||||||
-- Select 14b tag.
|
-- Select 14b tag.
|
||||||
card, err = lib14b.waitFor14443b()
|
card, err = lib14b.waitFor14443b()
|
||||||
if not card then return oops(err) end
|
if not card then return oops(err) end
|
||||||
|
|
|
@ -16,13 +16,13 @@ The dump is decrypted. If a raw dump is wanted, use the -r parameter
|
||||||
]]
|
]]
|
||||||
example = [[
|
example = [[
|
||||||
script run didump
|
script run didump
|
||||||
|
|
||||||
-- selftest
|
-- selftest
|
||||||
script run didump -t
|
script run didump -t
|
||||||
|
|
||||||
-- Generate raw dump, into json.
|
-- Generate raw dump, into json.
|
||||||
script run didump -r
|
script run didump -r
|
||||||
|
|
||||||
-- load file
|
-- load file
|
||||||
script run didump -i dumpdata.json
|
script run didump -i dumpdata.json
|
||||||
]]
|
]]
|
||||||
|
@ -37,7 +37,7 @@ Arguments:
|
||||||
e encrypt data
|
e encrypt data
|
||||||
v validate data
|
v validate data
|
||||||
i dumpdata.json load json dump file
|
i dumpdata.json load json dump file
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- Some shortcuts
|
-- Some shortcuts
|
||||||
|
@ -589,7 +589,7 @@ function main(args)
|
||||||
|
|
||||||
-- GET TAG UID
|
-- GET TAG UID
|
||||||
tag, err = lib14a.read(false, true)
|
tag, err = lib14a.read(false, true)
|
||||||
if err then
|
if err then
|
||||||
lib14a.disconnect()
|
lib14a.disconnect()
|
||||||
return oops(err)
|
return oops(err)
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,7 +58,7 @@ local function help()
|
||||||
print(desc)
|
print(desc)
|
||||||
print('Example usage')
|
print('Example usage')
|
||||||
print(example)
|
print(example)
|
||||||
print(usage)
|
print(usage)
|
||||||
end
|
end
|
||||||
---
|
---
|
||||||
-- Exit message
|
-- Exit message
|
||||||
|
|
|
@ -311,14 +311,14 @@ function main(args)
|
||||||
-- Initialize the card using the already-present read14a library
|
-- Initialize the card using the already-present read14a library
|
||||||
-- Perform RATS and PPS (Protocol and Parameter Selection) check to finish the ISO 14443-4 protocol.
|
-- Perform RATS and PPS (Protocol and Parameter Selection) check to finish the ISO 14443-4 protocol.
|
||||||
info,err = lib14a.read(true, false)
|
info,err = lib14a.read(true, false)
|
||||||
if not info then
|
if not info then
|
||||||
lib14a.disconnect()
|
lib14a.disconnect()
|
||||||
return oops(err)
|
return oops(err)
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
response = sendRaw("D01100", true, true)
|
response = sendRaw("D01100", true, true)
|
||||||
if not response then
|
if not response then
|
||||||
lib14a.disconnect()
|
lib14a.disconnect()
|
||||||
return oops("No response from PPS check")
|
return oops("No response from PPS check")
|
||||||
end
|
end
|
||||||
|
|
|
@ -121,7 +121,7 @@ function main(args)
|
||||||
|
|
||||||
-- First of all, connect
|
-- First of all, connect
|
||||||
info, err = lib14a.read(true, true)
|
info, err = lib14a.read(true, true)
|
||||||
if err then
|
if err then
|
||||||
lib14a.disconnect()
|
lib14a.disconnect()
|
||||||
return oops(err)
|
return oops(err)
|
||||||
end
|
end
|
||||||
|
@ -137,7 +137,7 @@ function main(args)
|
||||||
for block = 00, endblock do
|
for block = 00, endblock do
|
||||||
local cmd = string.format('10%02x00', block)
|
local cmd = string.format('10%02x00', block)
|
||||||
res, err = sendRaw(cmd , {ignore_response = ignore_response})
|
res, err = sendRaw(cmd , {ignore_response = ignore_response})
|
||||||
if err then
|
if err then
|
||||||
lib14a.disconnect()
|
lib14a.disconnect()
|
||||||
return oops(err)
|
return oops(err)
|
||||||
end
|
end
|
||||||
|
|
20
common/cmd.c
20
common/cmd.c
|
@ -146,34 +146,34 @@ int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *d
|
||||||
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);
|
||||||
|
|
||||||
return reply_ng_internal(cmd, status, cmddata, len + sizeof(arg), false);
|
return reply_ng_internal(cmd, status, cmddata, len + sizeof(arg), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *data, size_t len), bool fpc) {
|
static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *data, size_t len), bool fpc) {
|
||||||
PacketCommandNGRaw rx_raw;
|
PacketCommandNGRaw rx_raw;
|
||||||
size_t bytes = read_ng((uint8_t *)&rx_raw.pre, sizeof(PacketCommandNGPreamble));
|
size_t bytes = read_ng((uint8_t *)&rx_raw.pre, sizeof(PacketCommandNGPreamble));
|
||||||
|
|
||||||
if (bytes == 0)
|
if (bytes == 0)
|
||||||
return PM3_ENODATA;
|
return PM3_ENODATA;
|
||||||
|
|
||||||
if (bytes != sizeof(PacketCommandNGPreamble))
|
if (bytes != sizeof(PacketCommandNGPreamble))
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
|
||||||
rx->magic = rx_raw.pre.magic;
|
rx->magic = rx_raw.pre.magic;
|
||||||
rx->ng = rx_raw.pre.ng;
|
rx->ng = rx_raw.pre.ng;
|
||||||
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 > PM3_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);
|
||||||
if (bytes != length)
|
if (bytes != length)
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
|
||||||
if (rx->ng) {
|
if (rx->ng) {
|
||||||
memcpy(rx->data.asBytes, rx_raw.data, length);
|
memcpy(rx->data.asBytes, rx_raw.data, length);
|
||||||
rx->length = length;
|
rx->length = length;
|
||||||
|
@ -181,7 +181,7 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
|
||||||
uint64_t arg[3];
|
uint64_t arg[3];
|
||||||
if (length < sizeof(arg))
|
if (length < sizeof(arg))
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
|
||||||
memcpy(arg, rx_raw.data, sizeof(arg));
|
memcpy(arg, rx_raw.data, sizeof(arg));
|
||||||
rx->oldarg[0] = arg[0];
|
rx->oldarg[0] = arg[0];
|
||||||
rx->oldarg[1] = arg[1];
|
rx->oldarg[1] = arg[1];
|
||||||
|
@ -193,7 +193,7 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
|
||||||
bytes = read_ng((uint8_t *)&rx_raw.foopost, sizeof(PacketCommandNGPostamble));
|
bytes = read_ng((uint8_t *)&rx_raw.foopost, sizeof(PacketCommandNGPostamble));
|
||||||
if (bytes != sizeof(PacketCommandNGPostamble))
|
if (bytes != sizeof(PacketCommandNGPostamble))
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
|
||||||
// Check CRC, accept MAGIC as placeholder
|
// Check CRC, accept MAGIC as placeholder
|
||||||
rx->crc = rx_raw.foopost.crc;
|
rx->crc = rx_raw.foopost.crc;
|
||||||
if (rx->crc != COMMANDNG_POSTAMBLE_MAGIC) {
|
if (rx->crc != COMMANDNG_POSTAMBLE_MAGIC) {
|
||||||
|
@ -209,7 +209,7 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
|
||||||
bytes = read_ng(((uint8_t *)&rx_old) + sizeof(PacketCommandNGPreamble), sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble));
|
bytes = read_ng(((uint8_t *)&rx_old) + sizeof(PacketCommandNGPreamble), sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble));
|
||||||
if (bytes != sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble))
|
if (bytes != sizeof(PacketCommandOLD) - sizeof(PacketCommandNGPreamble))
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
|
||||||
reply_via_fpc = fpc;
|
reply_via_fpc = fpc;
|
||||||
rx->ng = false;
|
rx->ng = false;
|
||||||
rx->magic = 0;
|
rx->magic = 0;
|
||||||
|
|
|
@ -139,30 +139,30 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t baudrate;
|
uint32_t baudrate;
|
||||||
bool via_fpc :1;
|
bool via_fpc : 1;
|
||||||
// rdv4
|
// rdv4
|
||||||
bool compiled_with_flash :1;
|
bool compiled_with_flash : 1;
|
||||||
bool compiled_with_smartcard :1;
|
bool compiled_with_smartcard : 1;
|
||||||
bool compiled_with_fpc_usart :1;
|
bool compiled_with_fpc_usart : 1;
|
||||||
bool compiled_with_fpc_usart_dev :1;
|
bool compiled_with_fpc_usart_dev : 1;
|
||||||
bool compiled_with_fpc_usart_host :1;
|
bool compiled_with_fpc_usart_host : 1;
|
||||||
// lf
|
// lf
|
||||||
bool compiled_with_lf :1;
|
bool compiled_with_lf : 1;
|
||||||
bool compiled_with_hitag :1;
|
bool compiled_with_hitag : 1;
|
||||||
// hf
|
// hf
|
||||||
bool compiled_with_hfsniff :1;
|
bool compiled_with_hfsniff : 1;
|
||||||
bool compiled_with_iso14443a :1;
|
bool compiled_with_iso14443a : 1;
|
||||||
bool compiled_with_iso14443b :1;
|
bool compiled_with_iso14443b : 1;
|
||||||
bool compiled_with_iso15693 :1;
|
bool compiled_with_iso15693 : 1;
|
||||||
bool compiled_with_felica :1;
|
bool compiled_with_felica : 1;
|
||||||
bool compiled_with_legicrf :1;
|
bool compiled_with_legicrf : 1;
|
||||||
bool compiled_with_iclass :1;
|
bool compiled_with_iclass : 1;
|
||||||
// misc
|
// misc
|
||||||
bool compiled_with_lcd :1;
|
bool compiled_with_lcd : 1;
|
||||||
|
|
||||||
// rdv4
|
// rdv4
|
||||||
bool hw_available_flash :1;
|
bool hw_available_flash : 1;
|
||||||
bool hw_available_smartcard :1;
|
bool hw_available_smartcard : 1;
|
||||||
} PACKED capabilities_t;
|
} PACKED capabilities_t;
|
||||||
|
|
||||||
extern capabilities_t pm3_capabilities;
|
extern capabilities_t pm3_capabilities;
|
||||||
|
|
|
@ -323,7 +323,7 @@ int uart_send(const serial_port sp, const uint8_t *pbtTx, const uint32_t len) {
|
||||||
res = write(((serial_port_unix *)sp)->fd, pbtTx + pos, len - pos);
|
res = write(((serial_port_unix *)sp)->fd, pbtTx + pos, len - pos);
|
||||||
|
|
||||||
// Stop if the OS has some troubles sending the data
|
// Stop if the OS has some troubles sending the data
|
||||||
if (res <= 0)
|
if (res <= 0)
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
|
||||||
pos += res;
|
pos += res;
|
||||||
|
|
|
@ -160,8 +160,8 @@ uint32_t uart_get_speed(const serial_port sp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uint32_t *pszRxLen) {
|
int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uint32_t *pszRxLen) {
|
||||||
int res = ReadFile(((serial_port_windows *)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
|
int res = ReadFile(((serial_port_windows *)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
|
||||||
if ( res )
|
if (res)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
||||||
int errorcode = GetLastError();
|
int errorcode = GetLastError();
|
||||||
|
@ -171,22 +171,22 @@ int uart_receive(const serial_port sp, uint8_t *pbtRx, uint32_t pszMaxRxLen, uin
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[!]res %d | rx errorcode == %d \n",res, errorcode);
|
printf("[!]res %d | rx errorcode == %d \n", res, errorcode);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int uart_send(const serial_port sp, const uint8_t *p_tx, const uint32_t len) {
|
int uart_send(const serial_port sp, const uint8_t *p_tx, const uint32_t len) {
|
||||||
DWORD txlen = 0;
|
DWORD txlen = 0;
|
||||||
int res = WriteFile(((serial_port_windows *)sp)->hPort, p_tx, len, &txlen, NULL);
|
int res = WriteFile(((serial_port_windows *)sp)->hPort, p_tx, len, &txlen, NULL);
|
||||||
if ( res )
|
if (res)
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
||||||
int errorcode = GetLastError();
|
int errorcode = GetLastError();
|
||||||
if (res == 0 && errorcode == 2) {
|
if (res == 0 && errorcode == 2) {
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("[!!]res %d | send errorcode == %d \n",res, errorcode);
|
printf("[!!]res %d | send errorcode == %d \n", res, errorcode);
|
||||||
return PM3_ENOTTY;
|
return PM3_ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue