This commit is contained in:
Philippe Teuwen
2019-05-08 01:35:51 +02:00
parent f49d7e6d39
commit 68e5b3c355
21 changed files with 106 additions and 106 deletions

View File

@@ -151,7 +151,7 @@ static int CmdFlashmemSpiBaudrate(const char *Cmd) {
if (strlen(Cmd) < 1 || ctmp == 'h') {
return usage_flashmem_spibaud();
}
uint32_t baudrate = param_get32ex(Cmd, 0, 0, 10);
baudrate = baudrate * 1000000;
if (baudrate != FLASH_BAUD && baudrate != FLASH_MINBAUD) {
@@ -279,7 +279,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
// fast push mode
conn.block_after_ACK = true;
while (bytes_remaining > 0) {
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;
if (!isok) {
conn.block_after_ACK = false;
conn.block_after_ACK = false;
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
return PM3_EFLASH;
}

View File

@@ -429,7 +429,7 @@ static int CmdSetMux(const char *Cmd) {
}
str_lower((char *)Cmd);
uint8_t arg = 0;
if (strcmp(Cmd, "lopkd") == 0) arg = 0;
else if (strcmp(Cmd, "loraw") == 0) arg = 1;
@@ -438,7 +438,7 @@ static int CmdSetMux(const char *Cmd) {
else {
usage_hw_setmux();
return PM3_EINVARG;
}
}
clearCommandBuffer();
SendCommandMIX(CMD_SET_ADC_MUX, arg, 0, 0, NULL, 0);
return PM3_SUCCESS;
@@ -483,9 +483,9 @@ static int CmdPing(const char *Cmd) {
bool error = false;
if (len) {
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 {
PrintAndLogEx((error)? ERR:SUCCESS, "Ping response " _GREEN_("received"));
PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received"));
}
} else
PrintAndLogEx(WARNING, "Ping response " _RED_("timeout"));
@@ -498,11 +498,11 @@ static int CmdConnect(const char *Cmd) {
return usage_hw_connect();
char *port = NULL;
// default back to previous used serial port
if (strlen(Cmd) == 0 ) {
if (strlen(Cmd) == 0) {
int len = strlen((char *)conn.serial_port_name);
if ( len == 0 ) {
if (len == 0) {
return usage_hw_connect();
}
port = (char *)conn.serial_port_name;
@@ -510,10 +510,10 @@ static int CmdConnect(const char *Cmd) {
port = (char *)Cmd;
}
if ( port == NULL )
if (port == NULL)
return usage_hw_connect();
if ( session.pm3_present ) {
if (session.pm3_present) {
CloseProxmark();
}
@@ -558,12 +558,12 @@ int CmdHW(const char *Cmd) {
void pm3_version(bool verbose) {
if (!verbose)
return;
PacketResponseNG resp;
clearCommandBuffer();
SendCommandNG(CMD_VERSION, NULL, 0);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
PrintAndLogEx(NORMAL, "\n" _BLUE_(" [ Proxmark3 RFID instrument ]") "\n");
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, "\n [ PROXMARK RDV4 Extras ]");
PrintAndLogEx(NORMAL, " FPC USART for BT add-on support: %s", IfPm3FpcUsartHost() ? _GREEN_("present") : _YELLOW_("absent"));
if (IfPm3FpcUsartDevFromUsb())
PrintAndLogEx(NORMAL, " FPC USART for developer support: %s", _GREEN_("present"));
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, (char *)resp.data.asBytes);
lookupChipID(resp.oldarg[0], resp.oldarg[1]);

View File

@@ -161,7 +161,7 @@ static int CmdUsartBtPin(const char *Cmd) {
case 'h':
return usage_usart_bt_pin();
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");
errors = true;
break;
@@ -201,7 +201,7 @@ static int CmdUsartBtPin(const char *Cmd) {
return ret;
}
// 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"));
} else {
PrintAndLogEx(WARNING, "Unexpected answer: %.*s", len, data);

View File

@@ -302,7 +302,7 @@ static void PacketResponseReceived(PacketResponseNG *packet) {
// The communications thread.
// signals to main thread when a response is ready to process.
//
//
static void
#ifdef __has_attribute
#if __has_attribute(force_align_arg_pointer)
@@ -329,14 +329,14 @@ __attribute__((force_align_arg_pointer))
// Signal to main thread that communications seems off.
// main thread will kill and restart this thread.
if ( commfailed ) {
if (commfailed) {
PrintAndLogEx(WARNING, "Communicating with Proxmark3 device " _RED_("failed"));
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
break;
}
pthread_mutex_lock(&spMutex);
res = uart_receive(sp, (uint8_t *)&rx_raw.pre, sizeof(PacketResponseNGPreamble), &rxlen);
if ((res == PM3_SUCCESS) && (rxlen == sizeof(PacketResponseNGPreamble))) {
rx.magic = rx_raw.pre.magic;
@@ -350,9 +350,9 @@ __attribute__((force_align_arg_pointer))
error = true;
}
if ((!error) && (length > 0)) { // Get the variable length payload
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);
error = true;
} else {
@@ -415,7 +415,7 @@ __attribute__((force_align_arg_pointer))
} else { // Old style reply
PacketResponseOLD rx_old;
memcpy(&rx_old, &rx_raw.pre, sizeof(PacketResponseNGPreamble));
res = uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(PacketResponseNGPreamble), sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble), &rxlen);
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));
@@ -495,9 +495,9 @@ __attribute__((force_align_arg_pointer))
pthread_mutex_unlock(&spMutex);
txBuffer_pending = false;
// main thread doesn't know send failed...
// tell main thread that txBuffer is empty
pthread_cond_signal(&txBufferSig);
}
@@ -512,7 +512,7 @@ __attribute__((force_align_arg_pointer))
#if defined(__MACH__) && defined(__APPLE__)
enableAppNap();
#endif
pthread_exit(NULL);
return NULL;
}
@@ -551,8 +551,8 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
return false;
} else {
// start the communication thread
if ( portname != (char*)conn.serial_port_name) {
uint16_t len = MIN( strlen(portname), FILE_PATH_SIZE - 1);
if (portname != (char *)conn.serial_port_name) {
uint16_t len = MIN(strlen(portname), FILE_PATH_SIZE - 1);
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
memcpy(conn.serial_port_name, portname, len);
}
@@ -582,20 +582,20 @@ int TestProxmark(void) {
uint8_t data[len];
for (uint16_t i = 0; i < len; i++)
data[i] = i & 0xFF;
SendCommandNG(CMD_PING, data, len);
uint32_t timeout = 1000;
#ifdef USART_SLOW_LINK
timeout = 10000;
// 10s timeout for slow FPC, e.g. over BT
// as this is the very first command sent to the pm3
// that initiates the BT connection
// that initiates the BT connection
#endif
if (WaitForResponseTimeoutW(CMD_PING, &resp, timeout, false)) {
bool error = false;
if (len)
error = memcmp(data, resp.data.asBytes, len) != 0;
@@ -652,7 +652,7 @@ void CloseProxmark(void) {
// Clean up our state
sp = NULL;
memset(&communication_thread, 0, sizeof(pthread_t));
session.pm3_present = false;
}

View File

@@ -45,7 +45,7 @@ local function parse1443b(data)
local count, uid, uidlen, atqb, chipid, cid = bin.unpack('H10CH7CC',data)
uid = uid:sub(1, 2 * uidlen)
return {
return {
uid = uid,
uidlen = uidlen,
atqb = atqb,
@@ -73,7 +73,7 @@ local function read14443b(disconnect)
cmd = cmds.CMD_ISO_14443B_COMMAND,
arg1 = flags
}
local result, err = command:sendMIX()
if result then
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)

View File

@@ -120,7 +120,7 @@ local function read15693(slow, dont_readresponse)
else
err = 'No response from card'
end
if err then
print(err)
return nil, err

View File

@@ -54,10 +54,10 @@ static void showBanner(void) {
int check_comm(void) {
// 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_forced_update_display ();
CloseProxmark();
rl_forced_update_display();
CloseProxmark();
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Use \"hw connect\" to reconnect\n");
}
return 0;
@@ -159,11 +159,11 @@ main_loop(char *script_cmds_file, char *script_cmd) {
} else {
rl_event_hook = check_comm;
if (session.pm3_present )
if (session.pm3_present)
cmd = readline(PROXPROMPT);
else
cmd = readline("[offline] "PROXPROMPT);
fflush(NULL);
}
}
@@ -188,9 +188,9 @@ main_loop(char *script_cmds_file, char *script_cmd) {
if (cmd[0] != '\0') {
if (printprompt)
PrintAndLogEx(NORMAL, PROXPROMPT"%s", cmd);
int ret = CommandReceived(cmd);
HIST_ENTRY *entry = history_get(history_length);
if ((!entry) || (strcmp(entry->line, cmd) != 0))
add_history(cmd);

View File

@@ -11,17 +11,17 @@ This is a script to allow raw 1444a commands to be sent and received.
example = [[
# 1. Connect and don't disconnect
script run 14araw -p
# 2. Send mf auth, read response (nonce)
script run 14araw -o -x 6000F57b -p
# 3. disconnect
script run 14araw -o
# All three steps in one go:
script run 14araw -x 6000F57b
]]
usage = [[
usage = [[
script run 14araw -x 6000F57b
Arguments:
@@ -124,7 +124,7 @@ function main(args)
-- The actual raw payload, if any
if payload then
res, err = sendRaw(payload,{ignore_response = ignore_response, topaz_mode = topaz_mode, append_crc = append_crc})
if err then
if err then
lib14a.disconnect()
return oops(err)
end

View File

@@ -118,10 +118,10 @@ local bxor = bit32.bxor
-- we need always 2 digits
local function prepend_zero(s)
if (string.len(s) == 1) then
if (string.len(s) == 1) then
return '0' .. s
else
if (string.len(s) == 0) then
if (string.len(s) == 0) then
return '00'
else
return s
@@ -360,7 +360,7 @@ function displaySegments(bytes)
pld = pld..bytes[(start+4+1+Seg[5]+Seg[6]+i)-1]..' '
end
print(pld)
if (KGH) then
if (KGH) then
print("'Kaba Group Header' detected")
end
start = start+Seg[4]

View File

@@ -57,7 +57,7 @@ local function help()
print(desc)
print("Example usage")
print(example)
print(usage)
print(usage)
end
--
-- Exit message

View File

@@ -64,7 +64,7 @@ local function help()
print(desc)
print("Example usage")
print(example)
print(usage)
print(usage)
end
--
-- Exit message

View File

@@ -118,7 +118,7 @@ local function calypso_send_cmd_raw(data, ignoreresponse )
arg1 = flags,
arg2 = #data/2, -- LEN of data, half the length of the ASCII-string hex string
data = data} -- data bytes (commands etc)
result, err = command:sendMIX(ignoreresponse)
if result then
local r = calypso_parse(result)
@@ -212,7 +212,7 @@ function main(args)
end
lib14b.connect()
-- Select 14b tag.
card, err = lib14b.waitFor14443b()
if not card then return oops(err) end

View File

@@ -16,13 +16,13 @@ The dump is decrypted. If a raw dump is wanted, use the -r parameter
]]
example = [[
script run didump
-- selftest
script run didump -t
-- Generate raw dump, into json.
script run didump -r
-- load file
script run didump -i dumpdata.json
]]
@@ -37,7 +37,7 @@ Arguments:
e encrypt data
v validate data
i dumpdata.json load json dump file
end
end
]]
-- Some shortcuts
@@ -589,7 +589,7 @@ function main(args)
-- GET TAG UID
tag, err = lib14a.read(false, true)
if err then
if err then
lib14a.disconnect()
return oops(err)
end

View File

@@ -58,7 +58,7 @@ local function help()
print(desc)
print('Example usage')
print(example)
print(usage)
print(usage)
end
---
-- Exit message

View File

@@ -311,14 +311,14 @@ function main(args)
-- 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.
info,err = lib14a.read(true, false)
if not info then
if not info then
lib14a.disconnect()
return oops(err)
end
--
response = sendRaw("D01100", true, true)
if not response then
if not response then
lib14a.disconnect()
return oops("No response from PPS check")
end

View File

@@ -121,7 +121,7 @@ function main(args)
-- First of all, connect
info, err = lib14a.read(true, true)
if err then
if err then
lib14a.disconnect()
return oops(err)
end
@@ -137,7 +137,7 @@ function main(args)
for block = 00, endblock do
local cmd = string.format('10%02x00', block)
res, err = sendRaw(cmd , {ignore_response = ignore_response})
if err then
if err then
lib14a.disconnect()
return oops(err)
end