mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
rename globals
This commit is contained in:
+2
-2
@@ -169,7 +169,7 @@ void BigBuf_print_status(void) {
|
||||
Dbprintf(" tracing ................ %d", tracing);
|
||||
Dbprintf(" traceLen ............... %d", trace_len);
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
DbpString(_CYAN_("Sending buffers"));
|
||||
|
||||
uint16_t d8 = 0;
|
||||
@@ -250,7 +250,7 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
|
||||
|
||||
if (duration > 0xFFFF) {
|
||||
/*
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Error in LogTrace: duration too long for 16 bits encoding: 0x%08x start: 0x%08x end: 0x%08x", duration, timestamp_start, timestamp_end);
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -80,7 +80,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
|
||||
|
||||
// Setup and start DMA.
|
||||
if (!FpgaSetupSscDma((uint8_t *)dmaBuf, DMA_BUFFER_SIZE)) {
|
||||
if (DBGLEVEL > 1)
|
||||
if (g_dbglevel > 1)
|
||||
Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
return;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
|
||||
if (triggered) {
|
||||
if ((receivedCmd) &&
|
||||
((receivedCmd[0] == MIFARE_ULEV1_AUTH) || (receivedCmd[0] == MIFARE_ULC_AUTH_1))) {
|
||||
if (DBGLEVEL > 1)
|
||||
if (g_dbglevel > 1)
|
||||
Dbprintf("PWD-AUTH KEY: 0x%02x%02x%02x%02x", receivedCmd[1], receivedCmd[2],
|
||||
receivedCmd[3], receivedCmd[4]);
|
||||
|
||||
@@ -214,7 +214,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
|
||||
|
||||
// Write stuff to spiffs logfile
|
||||
if (auth_attempts > 0) {
|
||||
if (DBGLEVEL > 1)
|
||||
if (g_dbglevel > 1)
|
||||
Dbprintf("[!] Authentication attempts = %u", auth_attempts);
|
||||
|
||||
if (!exists_in_spiffs((char *)HF_BOG_LOGFILE)) {
|
||||
@@ -224,7 +224,7 @@ static void RAMFUNC SniffAndStore(uint8_t param) {
|
||||
}
|
||||
}
|
||||
|
||||
if (DBGLEVEL > 1)
|
||||
if (g_dbglevel > 1)
|
||||
Dbprintf("[!] Wrote %u Authentification attempts into logfile", auth_attempts);
|
||||
|
||||
SpinErr(LED_A, 200, 5);
|
||||
|
||||
@@ -333,7 +333,7 @@ void RunMod(void) {
|
||||
Dbprintf(">> HF Mifare ultra fast sniff/sim/clone a.k.a VIGIKPWN Started <<");
|
||||
|
||||
// turn off all debugging.
|
||||
DBGLEVEL = DBG_NONE;
|
||||
g_dbglevel = DBG_NONE;
|
||||
|
||||
// add_schema(Schemas, Noralsy, &total_schemas);
|
||||
// add_schema(Schemas, InfiHexact, &total_schemas);
|
||||
|
||||
@@ -178,7 +178,7 @@ static int saMifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_
|
||||
a particular sector. also no tracing no dbg */
|
||||
static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace,
|
||||
uint8_t keyCount, uint8_t *datain, uint64_t *key) {
|
||||
DBGLEVEL = DBG_NONE;
|
||||
g_dbglevel = DBG_NONE;
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||
set_tracing(false);
|
||||
|
||||
@@ -219,7 +219,7 @@ static int saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace,
|
||||
* - tracing is falsed
|
||||
*/
|
||||
static int saMifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
|
||||
DBGLEVEL = DBG_NONE;
|
||||
g_dbglevel = DBG_NONE;
|
||||
|
||||
uint8_t numSectors = numofsectors;
|
||||
uint8_t keyType = keytype;
|
||||
|
||||
@@ -59,7 +59,7 @@ static bool fill_eml_from_file(char *dumpfile) {
|
||||
return false;
|
||||
}
|
||||
//read and load dump file
|
||||
if (DBGLEVEL >= DBG_INFO)
|
||||
if (g_dbglevel >= DBG_INFO)
|
||||
Dbprintf(_YELLOW_("Found dump file %s. Uploading to emulator memory..."), dumpfile);
|
||||
emlClearMem();
|
||||
uint8_t *emCARD = BigBuf_get_EM_addr();
|
||||
|
||||
@@ -203,9 +203,9 @@ void RunMod(void) {
|
||||
}
|
||||
|
||||
LED_D_OFF();
|
||||
gLogin = false;
|
||||
gPassword = reflect32(tag[0]);
|
||||
gWritePasswordProcess = false;
|
||||
g_Login = false;
|
||||
g_Password = reflect32(tag[0]);
|
||||
g_WritePasswordProcess = false;
|
||||
command = EM4X50_COMMAND_STANDARD_READ;
|
||||
no_pwd = 0;
|
||||
memset(pwdlist, 0, sizeof(pwdlist));
|
||||
@@ -223,19 +223,19 @@ void RunMod(void) {
|
||||
em4x50_handle_commands(&command, tag);
|
||||
|
||||
// check if new password was found
|
||||
if (gPassword != reflect32(tag[EM4X50_DEVICE_PASSWORD])) {
|
||||
if (g_Password != reflect32(tag[EM4X50_DEVICE_PASSWORD])) {
|
||||
if (no_pwd < MAX_NO_PWDS_TO_SAVE) {
|
||||
pwdlist[no_pwd] = gPassword;
|
||||
pwdlist[no_pwd] = g_Password;
|
||||
no_pwd++;
|
||||
}
|
||||
gPassword = reflect32(tag[EM4X50_DEVICE_PASSWORD]);
|
||||
g_Password = reflect32(tag[EM4X50_DEVICE_PASSWORD]);
|
||||
}
|
||||
|
||||
// if timeout (e.g. no reader field) continue with standard read
|
||||
// mode and reset former authentication
|
||||
if (command == PM3_ETIMEOUT) {
|
||||
command = EM4X50_COMMAND_STANDARD_READ;
|
||||
gLogin = false;
|
||||
g_Login = false;
|
||||
LED_D_OFF();
|
||||
}
|
||||
|
||||
|
||||
+19
-19
@@ -67,25 +67,25 @@
|
||||
#include "spiffs.h"
|
||||
#endif
|
||||
|
||||
int DBGLEVEL = DBG_ERROR;
|
||||
int g_dbglevel = DBG_ERROR;
|
||||
uint8_t g_trigger = 0;
|
||||
bool g_hf_field_active = false;
|
||||
extern uint32_t _stack_start[], _stack_end[];
|
||||
struct common_area common_area __attribute__((section(".commonarea")));
|
||||
static int button_status = BUTTON_NO_CLICK;
|
||||
static bool allow_send_wtx = false;
|
||||
uint16_t tearoff_delay_us = 0;
|
||||
bool tearoff_enabled = false;
|
||||
uint16_t g_tearoff_delay_us = 0;
|
||||
bool g_tearoff_enabled = false;
|
||||
|
||||
int tearoff_hook(void) {
|
||||
if (tearoff_enabled) {
|
||||
if (tearoff_delay_us == 0) {
|
||||
if (g_tearoff_enabled) {
|
||||
if (g_tearoff_delay_us == 0) {
|
||||
Dbprintf(_RED_("No tear-off delay configured!"));
|
||||
return PM3_SUCCESS; // SUCCESS = the hook didn't do anything
|
||||
}
|
||||
SpinDelayUsPrecision(tearoff_delay_us);
|
||||
SpinDelayUsPrecision(g_tearoff_delay_us);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
tearoff_enabled = false;
|
||||
g_tearoff_enabled = false;
|
||||
Dbprintf(_YELLOW_("Tear-off triggered!"));
|
||||
return PM3_ETEAROFF;
|
||||
} else {
|
||||
@@ -336,7 +336,7 @@ static void TimingIntervalAcquisition(void) {
|
||||
|
||||
static void print_debug_level(void) {
|
||||
char dbglvlstr[20] = {0};
|
||||
switch (DBGLEVEL) {
|
||||
switch (g_dbglevel) {
|
||||
case DBG_NONE:
|
||||
sprintf(dbglvlstr, "none");
|
||||
break;
|
||||
@@ -353,7 +353,7 @@ static void print_debug_level(void) {
|
||||
sprintf(dbglvlstr, "extended");
|
||||
break;
|
||||
}
|
||||
Dbprintf(" Debug log level......... %d ( " _YELLOW_("%s")" )", DBGLEVEL, dbglvlstr);
|
||||
Dbprintf(" Debug log level......... %d ( " _YELLOW_("%s")" )", g_dbglevel, dbglvlstr);
|
||||
}
|
||||
|
||||
// measure the Connection Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time.
|
||||
@@ -772,7 +772,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
}
|
||||
// emulator
|
||||
case CMD_SET_DBGMODE: {
|
||||
DBGLEVEL = packet->data.asBytes[0];
|
||||
g_dbglevel = packet->data.asBytes[0];
|
||||
print_debug_level();
|
||||
reply_ng(CMD_SET_DBGMODE, PM3_SUCCESS, NULL, 0);
|
||||
break;
|
||||
@@ -787,11 +787,11 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
if (payload->on && payload->off)
|
||||
reply_ng(CMD_SET_TEAROFF, PM3_EINVARG, NULL, 0);
|
||||
if (payload->on)
|
||||
tearoff_enabled = true;
|
||||
g_tearoff_enabled = true;
|
||||
if (payload->off)
|
||||
tearoff_enabled = false;
|
||||
g_tearoff_enabled = false;
|
||||
if (payload->delay_us > 0)
|
||||
tearoff_delay_us = payload->delay_us;
|
||||
g_tearoff_delay_us = payload->delay_us;
|
||||
reply_ng(CMD_SET_TEAROFF, PM3_SUCCESS, NULL, 0);
|
||||
break;
|
||||
}
|
||||
@@ -2094,7 +2094,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
uint8_t filename[32];
|
||||
uint8_t *pfilename = packet->data.asBytes;
|
||||
memcpy(filename, pfilename, SPIFFS_OBJ_NAME_LEN);
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Filename received for spiffs dump : %s", filename);
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Filename received for spiffs dump : %s", filename);
|
||||
|
||||
uint32_t size = packet->oldarg[1];
|
||||
|
||||
@@ -2121,7 +2121,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
uint8_t filename[32];
|
||||
uint8_t *pfilename = packet->data.asBytes;
|
||||
memcpy(filename, pfilename, SPIFFS_OBJ_NAME_LEN);
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Filename received for spiffs STAT : %s", filename);
|
||||
}
|
||||
|
||||
@@ -2144,7 +2144,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
} PACKED;
|
||||
struct p *payload = (struct p *) packet->data.asBytes;
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Filename received for spiffs REMOVE : %s", payload->fn);
|
||||
}
|
||||
|
||||
@@ -2163,7 +2163,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
} PACKED;
|
||||
struct p *payload = (struct p *) packet->data.asBytes;
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("SPIFFS RENAME");
|
||||
Dbprintf("Source........ %s", payload->src);
|
||||
Dbprintf("Destination... %s", payload->dest);
|
||||
@@ -2183,7 +2183,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
} PACKED;
|
||||
struct p *payload = (struct p *) packet->data.asBytes;
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("SPIFFS COPY");
|
||||
Dbprintf("Source........ %s", payload->src);
|
||||
Dbprintf("Destination... %s", payload->dest);
|
||||
@@ -2198,7 +2198,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||
|
||||
flashmem_write_t *payload = (flashmem_write_t *)packet->data.asBytes;
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("SPIFFS WRITE, dest `%s` with APPEND set to: %c", payload->fn, payload->append ? 'Y' : 'N');
|
||||
}
|
||||
|
||||
|
||||
+40
-40
@@ -63,18 +63,18 @@
|
||||
#define EM4X50_TAG_MAX_NO_BYTES 136
|
||||
#define EM4X50_TIMEOUT_PULSE_EVAL 2500
|
||||
|
||||
int gHigh = 190;
|
||||
int gLow = 60;
|
||||
int g_High = 190;
|
||||
int g_Low = 60;
|
||||
|
||||
// indication whether a previous login has been successful, so operations
|
||||
// that require authentication can be handled
|
||||
bool gLogin = false;
|
||||
bool g_Login = false;
|
||||
// WritePassword process in simulation mode is handled in a different way
|
||||
// compared to operations like read, write, login, so it is necessary to
|
||||
// to be able to identfiy it
|
||||
bool gWritePasswordProcess = false;
|
||||
bool g_WritePasswordProcess = false;
|
||||
// if reader sends a different password than "expected" -> save it
|
||||
uint32_t gPassword = 0;
|
||||
uint32_t g_Password = 0;
|
||||
|
||||
// extract and check parities
|
||||
// return result of parity check and extracted plain data
|
||||
@@ -173,7 +173,7 @@ void em4x50_setup_sim(void) {
|
||||
}
|
||||
|
||||
// calculate signal properties (mean amplitudes) from measured data:
|
||||
// 32 amplitudes (maximum values) -> mean amplitude value -> gHigh -> gLow
|
||||
// 32 amplitudes (maximum values) -> mean amplitude value -> g_High -> g_Low
|
||||
static bool get_signalproperties(void) {
|
||||
|
||||
bool signal_found = false;
|
||||
@@ -224,8 +224,8 @@ static bool get_signalproperties(void) {
|
||||
sample_max_mean = sample_max_sum / no_periods;
|
||||
|
||||
// set global envelope variables
|
||||
gHigh = sample_ref + pct * (sample_max_mean - sample_ref) / 100;
|
||||
gLow = sample_ref - pct * (sample_max_mean - sample_ref) / 100;
|
||||
g_High = sample_ref + pct * (sample_max_mean - sample_ref) / 100;
|
||||
g_Low = sample_ref - pct * (sample_max_mean - sample_ref) / 100;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ static bool invalid_bit(void) {
|
||||
WaitUS(EM4X50_T_TAG_QUARTER_PERIOD * CYCLES2MUSEC);
|
||||
|
||||
// bit in "undefined" state?
|
||||
if (sample <= gHigh && sample >= gLow)
|
||||
if (sample <= g_High && sample >= g_Low)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -259,7 +259,7 @@ static uint32_t get_pulse_length(void) {
|
||||
|
||||
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
||||
while (sample > gLow && (timeout--))
|
||||
while (sample > g_Low && (timeout--))
|
||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
||||
if (timeout <= 0)
|
||||
@@ -268,14 +268,14 @@ static uint32_t get_pulse_length(void) {
|
||||
tval = GetTicks();
|
||||
timeout = EM4X50_TIMEOUT_PULSE_EVAL;
|
||||
|
||||
while (sample < gHigh && (timeout--))
|
||||
while (sample < g_High && (timeout--))
|
||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
||||
if (timeout <= 0)
|
||||
return 0;
|
||||
|
||||
timeout = EM4X50_TIMEOUT_PULSE_EVAL;
|
||||
while (sample > gLow && (timeout--))
|
||||
while (sample > g_Low && (timeout--))
|
||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
||||
if (timeout <= 0)
|
||||
@@ -617,7 +617,7 @@ static int login(uint32_t password) {
|
||||
return PM3_SUCCESS;
|
||||
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ void em4x50_chk(uint8_t *filename) {
|
||||
|
||||
em4x50_setup_read();
|
||||
|
||||
// set gHigh and gLow
|
||||
// set g_High and g_Low
|
||||
LED_C_ON();
|
||||
if (get_signalproperties() && find_em4x50_tag()) {
|
||||
|
||||
@@ -781,7 +781,7 @@ static int reset(void) {
|
||||
return PM3_SUCCESS;
|
||||
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
}
|
||||
|
||||
@@ -808,7 +808,7 @@ int standard_read(int *now, uint32_t *words) {
|
||||
*now -= fwr;
|
||||
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("didn't find a listen window");
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ static int selective_read(uint32_t addresses, uint32_t *words) {
|
||||
return status;
|
||||
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ void em4x50_read(em4x50_data_t *etd) {
|
||||
|
||||
em4x50_setup_read();
|
||||
|
||||
// set gHigh and gLow
|
||||
// set g_High and g_Low
|
||||
LED_C_ON();
|
||||
if (get_signalproperties() && find_em4x50_tag()) {
|
||||
|
||||
@@ -964,7 +964,7 @@ static int write(uint32_t word, uint32_t addresses) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
}
|
||||
|
||||
@@ -1013,7 +1013,7 @@ static int write_password(uint32_t password, uint32_t new_password) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("error in command request");
|
||||
}
|
||||
|
||||
@@ -1338,7 +1338,7 @@ static int check_rm_request(uint32_t *tag) {
|
||||
|
||||
// if command before was EM4X50_COMMAND_WRITE_PASSWORD
|
||||
// switch to separate process
|
||||
if (gWritePasswordProcess) {
|
||||
if (g_WritePasswordProcess) {
|
||||
return EM4X50_COMMAND_WRITE_PASSWORD;
|
||||
} else {
|
||||
// read mode request detected, get command from reader
|
||||
@@ -1454,7 +1454,7 @@ static int em4x50_sim_handle_standard_read_command(uint32_t *tag) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if ((gLogin == false) && (i >= fwrp) && (i <= lwrp)) {
|
||||
if ((g_Login == false) && (i >= fwrp) && (i <= lwrp)) {
|
||||
em4x50_sim_send_word(0x00);
|
||||
} else {
|
||||
em4x50_sim_send_word(reflect32(tag[i]));
|
||||
@@ -1509,7 +1509,7 @@ static int em4x50_sim_handle_selective_read_command(uint32_t *tag) {
|
||||
}
|
||||
|
||||
// if not authenticated do not send read protected words
|
||||
if ((gLogin == false) && (i >= fwrp) && (i <= lwrp)) {
|
||||
if ((g_Login == false) && (i >= fwrp) && (i <= lwrp)) {
|
||||
em4x50_sim_send_word(0x00);
|
||||
} else {
|
||||
em4x50_sim_send_word(reflect32(tag[i]));
|
||||
@@ -1532,15 +1532,15 @@ static int em4x50_sim_handle_login_command(uint32_t *tag) {
|
||||
|
||||
if (pwd && (password == reflect32(tag[EM4X50_DEVICE_PASSWORD]))) {
|
||||
em4x50_sim_send_ack();
|
||||
gLogin = true;
|
||||
g_Login = true;
|
||||
LED_D_ON();
|
||||
} else {
|
||||
em4x50_sim_send_nak();
|
||||
gLogin = false;
|
||||
g_Login = false;
|
||||
LED_D_OFF();
|
||||
|
||||
// save transmitted password (to be used in standalone mode)
|
||||
gPassword = password;
|
||||
g_Password = password;
|
||||
}
|
||||
// continue with standard read mode
|
||||
return EM4X50_COMMAND_STANDARD_READ;
|
||||
@@ -1554,7 +1554,7 @@ static int em4x50_sim_handle_reset_command(uint32_t *tag) {
|
||||
|
||||
// send ACK
|
||||
em4x50_sim_send_ack();
|
||||
gLogin = false;
|
||||
g_Login = false;
|
||||
LED_D_OFF();
|
||||
|
||||
// wait for initialization (tinit)
|
||||
@@ -1598,7 +1598,7 @@ static int em4x50_sim_handle_write_command(uint32_t *tag) {
|
||||
break;
|
||||
|
||||
case EM4X50_PROTECTION:
|
||||
if (gLogin) {
|
||||
if (g_Login) {
|
||||
tag[address] = reflect32(data);
|
||||
em4x50_sim_send_ack();
|
||||
} else {
|
||||
@@ -1608,7 +1608,7 @@ static int em4x50_sim_handle_write_command(uint32_t *tag) {
|
||||
break;
|
||||
|
||||
case EM4X50_CONTROL:
|
||||
if (gLogin) {
|
||||
if (g_Login) {
|
||||
tag[address] = reflect32(data);
|
||||
em4x50_sim_send_ack();
|
||||
} else {
|
||||
@@ -1629,7 +1629,7 @@ static int em4x50_sim_handle_write_command(uint32_t *tag) {
|
||||
|
||||
default:
|
||||
if ((address >= fwwp) && (address <= lwwp)) {
|
||||
if (gLogin) {
|
||||
if (g_Login) {
|
||||
tag[address] = reflect32(data);
|
||||
em4x50_sim_send_ack();
|
||||
} else {
|
||||
@@ -1675,7 +1675,7 @@ static int em4x50_sim_handle_writepwd_command(uint32_t *tag) {
|
||||
|
||||
bool pwd = false;
|
||||
|
||||
gWritePasswordProcess = true;
|
||||
g_WritePasswordProcess = true;
|
||||
|
||||
// read password
|
||||
uint32_t act_password = 0;
|
||||
@@ -1686,20 +1686,20 @@ static int em4x50_sim_handle_writepwd_command(uint32_t *tag) {
|
||||
|
||||
if (pwd && (act_password == reflect32(tag[EM4X50_DEVICE_PASSWORD]))) {
|
||||
em4x50_sim_send_ack();
|
||||
gLogin = true;
|
||||
g_Login = true;
|
||||
} else {
|
||||
em4x50_sim_send_nak();
|
||||
gLogin = false;
|
||||
gWritePasswordProcess = false;
|
||||
g_Login = false;
|
||||
g_WritePasswordProcess = false;
|
||||
|
||||
// save transmitted password (to be used in standalone mode)
|
||||
gPassword = act_password;
|
||||
g_Password = act_password;
|
||||
|
||||
return EM4X50_COMMAND_STANDARD_READ;
|
||||
}
|
||||
|
||||
int command = em4x50_sim_send_listen_window(tag);
|
||||
gWritePasswordProcess = false;
|
||||
g_WritePasswordProcess = false;
|
||||
if (command != EM4X50_COMMAND_WRITE_PASSWORD) {
|
||||
return command;
|
||||
}
|
||||
@@ -1714,7 +1714,7 @@ static int em4x50_sim_handle_writepwd_command(uint32_t *tag) {
|
||||
if (pwd) {
|
||||
em4x50_sim_send_ack();
|
||||
tag[EM4X50_DEVICE_PASSWORD] = reflect32(new_password);
|
||||
gPassword = new_password;
|
||||
g_Password = new_password;
|
||||
} else {
|
||||
em4x50_sim_send_nak();
|
||||
return EM4X50_COMMAND_STANDARD_READ;
|
||||
@@ -1793,8 +1793,8 @@ void em4x50_sim(uint32_t *password) {
|
||||
// init
|
||||
LEDsoff();
|
||||
em4x50_setup_sim();
|
||||
gLogin = false;
|
||||
gWritePasswordProcess = false;
|
||||
g_Login = false;
|
||||
g_WritePasswordProcess = false;
|
||||
|
||||
// start with inital command = standard read mode
|
||||
command = EM4X50_COMMAND_STANDARD_READ;
|
||||
@@ -1812,7 +1812,7 @@ void em4x50_sim(uint32_t *password) {
|
||||
// mode and reset former authentication
|
||||
if (command == PM3_ETIMEOUT) {
|
||||
command = EM4X50_COMMAND_STANDARD_READ;
|
||||
gLogin = false;
|
||||
g_Login = false;
|
||||
LED_D_OFF();
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -227,21 +227,21 @@ static uint8_t felica_select_card(felica_card_select_t *card) {
|
||||
|
||||
// timed-out
|
||||
if (len == 0) {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("Error: Time out card selection!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// wrong answer
|
||||
if (FelicaFrame.framebytes[3] != FELICA_POLL_ACK) {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("Error: Wrong answer selecting card!");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// VALIDATE CRC residue is 0, hence if crc is a value it failed.
|
||||
if (!check_crc(CRC_FELICA, FelicaFrame.framebytes + 2, FelicaFrame.len - 2)) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Error: CRC check failed!");
|
||||
Dbprintf("CRC check was done on Frame: ");
|
||||
Dbhexdump(FelicaFrame.len - 2, FelicaFrame.framebytes + 2, 0);
|
||||
@@ -249,7 +249,7 @@ static uint8_t felica_select_card(felica_card_select_t *card) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("Card selection successful!");
|
||||
// copy UID
|
||||
// idm 8
|
||||
@@ -261,7 +261,7 @@ static uint8_t felica_select_card(felica_card_select_t *card) {
|
||||
memcpy(card->uid, card->IDm + 2, 6);
|
||||
memcpy(card->iccode, card->PMm, 2);
|
||||
memcpy(card->mrt, card->PMm + 2, 6);
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Received Frame: ");
|
||||
Dbhexdump(FelicaFrame.len, FelicaFrame.framebytes, 0);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ static void TransmitFor18092_AsReader(uint8_t *frame, int len, uint32_t *timing,
|
||||
}
|
||||
// sending data with sync bytes
|
||||
c = 0;
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Sending frame:");
|
||||
Dbhexdump(len, frame, 0);
|
||||
}
|
||||
@@ -399,7 +399,7 @@ static void TransmitFor18092_AsReader(uint8_t *frame, int len, uint32_t *timing,
|
||||
// stop when button is pressed
|
||||
// or return TRUE when command is captured
|
||||
bool WaitForFelicaReply(uint16_t maxbytes) {
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("WaitForFelicaReply Start");
|
||||
uint32_t c = 0;
|
||||
// power, no modulation
|
||||
@@ -429,10 +429,10 @@ bool WaitForFelicaReply(uint16_t maxbytes) {
|
||||
NULL,
|
||||
false
|
||||
);
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("All bytes received! STATE_FULL");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("All bytes received! STATE_FULL");
|
||||
return true;
|
||||
} else if (c++ > timeout && (FelicaFrame.state == STATE_UNSYNCD || FelicaFrame.state == STATE_TRYING_SYNC)) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Error: Timeout! STATE_UNSYNCD");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Error: Timeout! STATE_UNSYNCD");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -442,7 +442,7 @@ bool WaitForFelicaReply(uint16_t maxbytes) {
|
||||
// Set up FeliCa communication (similar to iso14443a_setup)
|
||||
// field is setup for "Sending as Reader"
|
||||
static void iso18092_setup(uint8_t fpga_minor_mode) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Start iso18092_setup");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Start iso18092_setup");
|
||||
|
||||
LEDsoff();
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF_FELICA);
|
||||
@@ -495,7 +495,7 @@ static void felica_reset_frame_mode(void) {
|
||||
// arg1 len of commandbytes
|
||||
// d.asBytes command bytes to send
|
||||
void felica_sendraw(PacketCommandNG *c) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("FeliCa_sendraw Enter");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("FeliCa_sendraw Enter");
|
||||
|
||||
felica_command_t param = c->oldarg[0];
|
||||
size_t len = c->oldarg[1] & 0xffff;
|
||||
@@ -505,7 +505,7 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||
felica_card_select_t card;
|
||||
|
||||
if ((param & FELICA_CONNECT))
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Clear trace");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Clear trace");
|
||||
clear_trace();
|
||||
|
||||
set_tracing(true);
|
||||
@@ -518,13 +518,13 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||
arg0 = felica_select_card(&card);
|
||||
reply_mix(CMD_ACK, arg0, sizeof(card.uid), 0, &card, sizeof(felica_card_select_t));
|
||||
if (arg0 > 0) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Error: Failed selecting card! ");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Error: Failed selecting card! ");
|
||||
felica_reset_frame_mode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("No card selection");
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("No card selection");
|
||||
}
|
||||
|
||||
if ((param & FELICA_RAW)) {
|
||||
@@ -545,14 +545,14 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||
AddCrc(buf, len);
|
||||
}
|
||||
}
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Transmit Frame (no CRC shown):");
|
||||
Dbhexdump(len, buf, 0);
|
||||
Dbprintf("Buffer Length: %i", buf[2] + 4);
|
||||
};
|
||||
TransmitFor18092_AsReader(buf, buf[2] + 4, NULL, 1, 0);
|
||||
arg0 = WaitForFelicaReply(1024);
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Received Frame Code: %d", arg0);
|
||||
Dbhexdump(FelicaFrame.len, FelicaFrame.framebytes, 0);
|
||||
};
|
||||
@@ -565,7 +565,7 @@ void felica_sendraw(PacketCommandNG *c) {
|
||||
if ((param & FELICA_NO_DISCONNECT)) {
|
||||
Dbprintf("Disconnect");
|
||||
}
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("FeliCa_sendraw Exit");
|
||||
felica_reset_frame_mode();
|
||||
return;
|
||||
|
||||
+8
-8
@@ -155,7 +155,7 @@ void FlashStop(void) {
|
||||
// SPI disable
|
||||
AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SPIDIS;
|
||||
|
||||
if (DBGLEVEL > 3) Dbprintf("FlashStop");
|
||||
if (g_dbglevel > 3) Dbprintf("FlashStop");
|
||||
|
||||
StopTicks();
|
||||
}
|
||||
@@ -195,7 +195,7 @@ bool Flash_CheckBusy(uint32_t timeout) {
|
||||
StartCountUS();
|
||||
uint32_t _time = GetCountUS();
|
||||
|
||||
if (DBGLEVEL > 3) Dbprintf("Checkbusy in...");
|
||||
if (g_dbglevel > 3) Dbprintf("Checkbusy in...");
|
||||
|
||||
do {
|
||||
if (!(Flash_ReadStat1() & BUSY)) {
|
||||
@@ -224,7 +224,7 @@ uint8_t Flash_ReadID(void) {
|
||||
uint8_t man_id = FlashSendByte(0xFF);
|
||||
uint8_t dev_id = FlashSendLastByte(0xFF);
|
||||
|
||||
if (DBGLEVEL > 3) Dbprintf("Flash ReadID | Man ID %02x | Device ID %02x", man_id, dev_id);
|
||||
if (g_dbglevel > 3) Dbprintf("Flash ReadID | Man ID %02x | Device ID %02x", man_id, dev_id);
|
||||
|
||||
if ((man_id == WINBOND_MANID) && (dev_id == WINBOND_DEVID))
|
||||
return dev_id;
|
||||
@@ -331,7 +331,7 @@ uint16_t Flash_WriteData(uint32_t address, uint8_t *in, uint16_t len) {
|
||||
}
|
||||
|
||||
if (!FlashInit()) {
|
||||
if (DBGLEVEL > 3) Dbprintf("Flash_WriteData init fail");
|
||||
if (g_dbglevel > 3) Dbprintf("Flash_WriteData init fail");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ out:
|
||||
|
||||
bool Flash_WipeMemoryPage(uint8_t page) {
|
||||
if (!FlashInit()) {
|
||||
if (DBGLEVEL > 3) Dbprintf("Flash_WriteData init fail");
|
||||
if (g_dbglevel > 3) Dbprintf("Flash_WriteData init fail");
|
||||
return false;
|
||||
}
|
||||
Flash_ReadStat1();
|
||||
@@ -437,7 +437,7 @@ bool Flash_WipeMemoryPage(uint8_t page) {
|
||||
// Wipes flash memory completely, fills with 0xFF
|
||||
bool Flash_WipeMemory(void) {
|
||||
if (!FlashInit()) {
|
||||
if (DBGLEVEL > 3) Dbprintf("Flash_WriteData init fail");
|
||||
if (g_dbglevel > 3) Dbprintf("Flash_WriteData init fail");
|
||||
return false;
|
||||
}
|
||||
Flash_ReadStat1();
|
||||
@@ -464,7 +464,7 @@ bool Flash_WipeMemory(void) {
|
||||
// enable the flash write
|
||||
void Flash_WriteEnable(void) {
|
||||
FlashSendLastByte(WRITEENABLE);
|
||||
if (DBGLEVEL > 3) Dbprintf("Flash Write enabled");
|
||||
if (g_dbglevel > 3) Dbprintf("Flash Write enabled");
|
||||
}
|
||||
|
||||
// erase 4K at one time
|
||||
@@ -485,7 +485,7 @@ bool Flash_Erase4k(uint8_t block, uint8_t sector) {
|
||||
// execution time: 0,3s / 300ms
|
||||
bool Flash_Erase32k(uint32_t address) {
|
||||
if (address & (32*1024 - 1)) {
|
||||
if ( DBGLEVEL > 1 ) Dbprintf("Flash_Erase32k : Address is not align at 4096");
|
||||
if ( g_dbglevel > 1 ) Dbprintf("Flash_Erase32k : Address is not align at 4096");
|
||||
return false;
|
||||
}
|
||||
FlashSendByte(BLOCK32ERASE);
|
||||
|
||||
+2
-2
@@ -411,7 +411,7 @@ void FpgaDownloadAndGo(int bitstream_version) {
|
||||
// Send waiting time extension request as this will take a while
|
||||
send_wtx(1500);
|
||||
|
||||
bool verbose = (DBGLEVEL > 3);
|
||||
bool verbose = (g_dbglevel > 3);
|
||||
|
||||
// make sure that we have enough memory to decompress
|
||||
BigBuf_free();
|
||||
@@ -525,7 +525,7 @@ int FpgaGetCurrent(void) {
|
||||
// if HF, Disable SSC DMA
|
||||
// turn off trace and leds off.
|
||||
void switch_off(void) {
|
||||
if (DBGLEVEL > 3) {
|
||||
if (g_dbglevel > 3) {
|
||||
Dbprintf("switch_off");
|
||||
}
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
|
||||
|
||||
optimizedSniff((uint16_t *)mem, *len);
|
||||
|
||||
if (DBGLEVEL >= DBG_INFO) {
|
||||
if (g_dbglevel >= DBG_INFO) {
|
||||
Dbprintf("Trigger kicked in (%d >= 180)", r);
|
||||
Dbprintf("Collected %u samples", *len);
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
// Anon, 2019
|
||||
// Doegox, 2020
|
||||
|
||||
#define DBG if (DBGLEVEL >= DBG_EXTENDED)
|
||||
#define DBG if (g_dbglevel >= DBG_EXTENDED)
|
||||
|
||||
#include "hitag2.h"
|
||||
#include "hitag2_crypto.h"
|
||||
|
||||
+15
-15
@@ -222,7 +222,7 @@ static void hitag_send_bit(int bit) {
|
||||
}
|
||||
|
||||
static void hitag_send_frame(const uint8_t *frame, size_t frame_len) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("hitag_send_frame: (%i) %02X %02X %02X %02X", frame_len, frame[0], frame[1], frame[2], frame[3]);
|
||||
// The beginning of the frame is hidden in some high level; pause until our bits will have an effect
|
||||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG;
|
||||
@@ -368,12 +368,12 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
|
||||
switch (rxlen) {
|
||||
case 5: {
|
||||
//UID request with a selected response protocol mode
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("UID request: length: %i first byte: %02x", rxlen, rx[0]);
|
||||
tag.pstate = HT_READY;
|
||||
tag.tstate = HT_NO_OP;
|
||||
if ((rx[0] & 0xf0) == 0x30) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("HT_STANDARD");
|
||||
tag.mode = HT_STANDARD;
|
||||
sof_bits = 1;
|
||||
@@ -381,14 +381,14 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
|
||||
}
|
||||
if ((rx[0] & 0xf0) == 0xc0) {
|
||||
tag.mode = HT_ADVANCED;
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("HT_ADVANCED");
|
||||
sof_bits = 3;
|
||||
m = AC2K;
|
||||
}
|
||||
|
||||
if ((rx[0] & 0xf0) == 0xd0) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("HT_FAST_ADVANCED");
|
||||
tag.mode = HT_FAST_ADVANCED;
|
||||
sof_bits = 3;
|
||||
@@ -402,10 +402,10 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
|
||||
break;
|
||||
case 45: {
|
||||
//select command from reader received
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
DbpString("SELECT");
|
||||
if (check_select(rx, tag.uid) == 1) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
DbpString("SELECT match");
|
||||
//if the right tag was selected
|
||||
*txlen = 32;
|
||||
@@ -478,7 +478,7 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
|
||||
}
|
||||
break;
|
||||
case 40:
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("WRITE");
|
||||
//data received to be written
|
||||
if (tag.tstate == HT_WRITING_PAGE_DATA) {
|
||||
@@ -596,7 +596,7 @@ static void hitagS_handle_reader_command(uint8_t *rx, const size_t rxlen,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("unknown rxlen: (%i) %02X %02X %02X %02X ...", rxlen, rx[0], rx[1], rx[2], rx[3]);
|
||||
break;
|
||||
}
|
||||
@@ -675,7 +675,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
||||
| (uid[30] << 1)
|
||||
| uid[31];
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("UID: %02X %02X %02X %02X", uid1, uid2, uid3, uid4);
|
||||
|
||||
tag.uid = (uid4 << 24 | uid3 << 16 | uid2 << 8 | uid1);
|
||||
@@ -769,7 +769,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
||||
tag.LCK1 = response_bit[26];
|
||||
tag.LCK0 = response_bit[27];
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("conf0: %02X conf1: %02X conf2: %02X", conf_pages[0], conf_pages[1], conf_pages[2]);
|
||||
|
||||
if (tag.auth == 1) {
|
||||
@@ -792,7 +792,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
||||
tx[5] = auth_ks[1];
|
||||
tx[6] = auth_ks[2];
|
||||
tx[7] = auth_ks[3];
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("%02X %02X %02X %02X %02X %02X %02X %02X", tx[0],
|
||||
tx[1], tx[2], tx[3], tx[4], tx[5], tx[6], tx[7]);
|
||||
} else if (htf == 01 || htf == 03) { //RHTS_CHALLENGE //WHTS_CHALLENGE
|
||||
@@ -817,7 +817,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
||||
calc_crc(&crc, ((rx[1] & 0x0f) * 16 + ((rx[2] & 0xf0) / 16)), 8);
|
||||
calc_crc(&crc, ((rx[2] & 0x0f) * 16 + ((rx[3] & 0xf0) / 16)), 8);
|
||||
calc_crc(&crc, ((rx[3] & 0x0f) * 16 + ((rx[4] & 0xf0) / 16)), 8);
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("UID:::%X", tag.uid);
|
||||
Dbprintf("RND:::%X", rnd);
|
||||
}
|
||||
@@ -837,7 +837,7 @@ static int hitagS_handle_tag_auth(hitag_function htf, uint64_t key, uint64_t NrA
|
||||
pwdl1 = ((rx[3] & 0x0f) * 16 + ((rx[4] & 0xf0) / 16)) ^ _hitag2_byte(&state);
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("pwdh0 %02X pwdl0 %02X pwdl1 %02X", pwdh0, pwdl0, pwdl1);
|
||||
|
||||
//Dbprintf("%X %02X", rnd, ((rx[4] & 0x0f) * 16) + ((rx[5] & 0xf0) / 16));
|
||||
@@ -911,7 +911,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, uint8_t *data) {
|
||||
tag.max_page = 8;
|
||||
if ((tag.pages[1][0] & 0x2) == 0 && (tag.pages[1][0] & 0x1) == 0)
|
||||
tag.max_page = 0;
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
for (i = 0; i < tag.max_page; i++)
|
||||
Dbprintf("Page[%2d]: %02X %02X %02X %02X", i,
|
||||
(tag.pages[i][3]) & 0xff,
|
||||
|
||||
+8
-8
@@ -351,7 +351,7 @@ bool I2C_WriteCmd(uint8_t device_cmd, uint8_t device_address) {
|
||||
|
||||
I2C_Stop();
|
||||
if (bBreak) {
|
||||
if (DBGLEVEL > 3) DbpString(I2C_ERROR);
|
||||
if (g_dbglevel > 3) DbpString(I2C_ERROR);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -381,7 +381,7 @@ bool I2C_WriteByte(uint8_t data, uint8_t device_cmd, uint8_t device_address) {
|
||||
|
||||
I2C_Stop();
|
||||
if (bBreak) {
|
||||
if (DBGLEVEL > 3) DbpString(I2C_ERROR);
|
||||
if (g_dbglevel > 3) DbpString(I2C_ERROR);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -419,7 +419,7 @@ bool I2C_BufferWrite(uint8_t *data, uint8_t len, uint8_t device_cmd, uint8_t dev
|
||||
|
||||
I2C_Stop();
|
||||
if (bBreak) {
|
||||
if (DBGLEVEL > 3) DbpString(I2C_ERROR);
|
||||
if (g_dbglevel > 3) DbpString(I2C_ERROR);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -463,7 +463,7 @@ int16_t I2C_BufferRead(uint8_t *data, uint8_t len, uint8_t device_cmd, uint8_t d
|
||||
|
||||
if (bBreak) {
|
||||
I2C_Stop();
|
||||
if (DBGLEVEL > 3) DbpString(I2C_ERROR);
|
||||
if (g_dbglevel > 3) DbpString(I2C_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ int16_t I2C_ReadFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t
|
||||
|
||||
if (bBreak) {
|
||||
I2C_Stop();
|
||||
if (DBGLEVEL > 3) DbpString(I2C_ERROR);
|
||||
if (g_dbglevel > 3) DbpString(I2C_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ bool I2C_WriteFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t d
|
||||
|
||||
I2C_Stop();
|
||||
if (bBreak) {
|
||||
if (DBGLEVEL > 3) DbpString(I2C_ERROR);
|
||||
if (g_dbglevel > 3) DbpString(I2C_ERROR);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -694,7 +694,7 @@ bool GetATR(smart_card_atr_t *card_ptr, bool verbose) {
|
||||
chksum ^= card_ptr->atr[i];
|
||||
|
||||
if (chksum) {
|
||||
if (DBGLEVEL > 2) DbpString("Wrong ATR checksum");
|
||||
if (g_dbglevel > 2) DbpString("Wrong ATR checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -763,7 +763,7 @@ void SmartCardRaw(smart_card_raw_t *p) {
|
||||
((flags & SC_RAW_T0) ? I2C_DEVICE_CMD_SEND_T0 : I2C_DEVICE_CMD_SEND),
|
||||
I2C_DEVICE_ADDRESS_MAIN
|
||||
);
|
||||
if (res == false && DBGLEVEL > 3) {
|
||||
if (res == false && g_dbglevel > 3) {
|
||||
DbpString(I2C_ERROR);
|
||||
reply_ng(CMD_SMART_RAW, PM3_ESOFT, NULL, 0);
|
||||
goto OUT;
|
||||
|
||||
+3
-3
@@ -706,7 +706,7 @@ int do_iclass_simulation(int simulationMode, uint8_t *reader_mac_buf) {
|
||||
|
||||
if (simulationMode == ICLASS_SIM_MODE_EXIT_AFTER_MAC) {
|
||||
|
||||
if (DBGLEVEL == DBG_EXTENDED) {
|
||||
if (g_dbglevel == DBG_EXTENDED) {
|
||||
Dbprintf("CSN: %02x %02x %02x %02x %02x %02x %02x %02x", csn[0], csn[1], csn[2], csn[3], csn[4], csn[5], csn[6], csn[7]);
|
||||
Dbprintf("RDR: (len=%02d): %02x %02x %02x %02x %02x %02x %02x %02x %02x", len,
|
||||
receivedCmd[0], receivedCmd[1], receivedCmd[2],
|
||||
@@ -864,7 +864,7 @@ int do_iclass_simulation(int simulationMode, uint8_t *reader_mac_buf) {
|
||||
// standard ISO15693 INVENTORY command. Ignore.
|
||||
} else {
|
||||
// Never seen this command before
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
print_result("Unhandled command received ", receivedCmd, len);
|
||||
}
|
||||
|
||||
@@ -1217,7 +1217,7 @@ int do_iclass_simulation_nonsec(void) {
|
||||
// standard ISO15693 INVENTORY command. Ignore.
|
||||
} else {
|
||||
// Never seen this command before
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
print_result("Unhandled command received ", receivedCmd, len);
|
||||
}
|
||||
|
||||
|
||||
+23
-23
@@ -671,7 +671,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
||||
|
||||
// Setup and start DMA.
|
||||
if (!FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE)) {
|
||||
if (DBGLEVEL > 1) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
if (g_dbglevel > 1) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
||||
|
||||
FpgaDisableTracing();
|
||||
|
||||
if (DBGLEVEL >= DBG_ERROR) {
|
||||
if (g_dbglevel >= DBG_ERROR) {
|
||||
Dbprintf("trace len = " _YELLOW_("%d"), BigBuf_get_traceLen());
|
||||
}
|
||||
switch_off();
|
||||
@@ -1112,7 +1112,7 @@ bool SimulateIso14443aInit(int tagType, int flags, uint8_t *data, tag_response_i
|
||||
break;
|
||||
|
||||
default: {
|
||||
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Error: unknown tagtype (%d)", tagType);
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("Error: unknown tagtype (%d)", tagType);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -1199,7 +1199,7 @@ bool SimulateIso14443aInit(int tagType, int flags, uint8_t *data, tag_response_i
|
||||
|
||||
*cuid = bytes_to_num(data + 3 + 3, 4);
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_ERROR) Dbprintf("[-] ERROR: UID size not defined");
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("[-] ERROR: UID size not defined");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1241,7 +1241,7 @@ bool SimulateIso14443aInit(int tagType, int flags, uint8_t *data, tag_response_i
|
||||
for (size_t i = 0; i < ARRAYLEN(responses_init); i++) {
|
||||
if (prepare_allocated_tag_modulation(&responses_init[i], &free_buffer_pointer, &free_buffer_size) == false) {
|
||||
BigBuf_free_keep_EM();
|
||||
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Not enough modulation buffer size, exit after %d elements", i);
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("Not enough modulation buffer size, exit after %d elements", i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1636,7 +1636,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data, uint8_t
|
||||
EmSendCmd(pack, sizeof(pack));
|
||||
} else {
|
||||
EmSend4bit(CARD_NACK_NA);
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("Auth attempt: %08x", bytes_to_num(receivedCmd + 1, 4));
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Auth attempt: %08x", bytes_to_num(receivedCmd + 1, 4));
|
||||
}
|
||||
p_response = NULL;
|
||||
} else if (receivedCmd[0] == MIFARE_ULEV1_VCSL && len == 23 && tagType == 7) {
|
||||
@@ -1732,7 +1732,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data, uint8_t
|
||||
default: {
|
||||
// Never seen this command before
|
||||
LogTrace(receivedCmd, Uart.len, Uart.startTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.endTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.parity, true);
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Received unknown command (len=%d):", len);
|
||||
Dbhexdump(len, receivedCmd, false);
|
||||
}
|
||||
@@ -1755,7 +1755,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data, uint8_t
|
||||
dynamic_response_info.response_n += 2;
|
||||
|
||||
if (prepare_tag_modulation(&dynamic_response_info, DYNAMIC_MODULATION_BUFFER_SIZE) == false) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) DbpString("Error preparing tag response");
|
||||
if (g_dbglevel >= DBG_DEBUG) DbpString("Error preparing tag response");
|
||||
LogTrace(receivedCmd, Uart.len, Uart.startTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.endTime * 16 - DELAY_AIR2ARM_AS_TAG, Uart.parity, true);
|
||||
break;
|
||||
}
|
||||
@@ -1780,7 +1780,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data, uint8_t
|
||||
set_tracing(false);
|
||||
BigBuf_free_keep_EM();
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("-[ Wake ups after halt [%d]", happened);
|
||||
Dbprintf("-[ Messages after halt [%d]", happened2);
|
||||
Dbprintf("-[ Num of received cmd [%d]", cmdsRecvd);
|
||||
@@ -1837,7 +1837,7 @@ static void TransmitFor14443a(const uint8_t *cmd, uint16_t len, uint32_t *timing
|
||||
else
|
||||
PrepareDelayedTransfer(*timing & 0x00000007); // Delay transfer (fine tuning - up to 7 MF clock ticks)
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED && GetCountSspClk() >= (*timing & 0xfffffff8))
|
||||
if (g_dbglevel >= DBG_EXTENDED && GetCountSspClk() >= (*timing & 0xfffffff8))
|
||||
Dbprintf("TransmitFor14443a: Missed timing");
|
||||
while (GetCountSspClk() < (*timing & 0xfffffff8)) {}; // Delay transfer (multiple of 8 MF clock ticks)
|
||||
LastTimeProxToAirStart = *timing;
|
||||
@@ -2419,12 +2419,12 @@ void iso14443a_antifuzz(uint32_t flags) {
|
||||
|
||||
// trigger a faulty/collision response
|
||||
EmSendCmdEx(resp, 5, true);
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("ANTICOLL or SELECT %x", received[1]);
|
||||
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("ANTICOLL or SELECT %x", received[1]);
|
||||
LED_D_INV();
|
||||
|
||||
continue;
|
||||
} else if (received[1] == 0x20 && received[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_2) { // Received request for UID (cascade 2)
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("ANTICOLL or SELECT_2");
|
||||
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("ANTICOLL or SELECT_2");
|
||||
} else if (received[1] == 0x70 && received[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT) { // Received a SELECT (cascade 1)
|
||||
} else if (received[1] == 0x70 && received[0] == ISO14443A_CMD_ANTICOLL_OR_SELECT_2) { // Received a SELECT (cascade 2)
|
||||
} else {
|
||||
@@ -3113,7 +3113,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||
if (!have_uid) { // need a full select cycle to get the uid first
|
||||
iso14a_card_select_t card_info;
|
||||
if (!iso14443a_select_card(uid, &card_info, &cuid, true, 0, true)) {
|
||||
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (ALL)");
|
||||
if (g_dbglevel >= DBG_INFO) Dbprintf("Mifare: Can't select card (ALL)");
|
||||
continue;
|
||||
}
|
||||
switch (card_info.uidlen) {
|
||||
@@ -3132,7 +3132,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||
have_uid = true;
|
||||
} else { // no need for anticollision. We can directly select the card
|
||||
if (!iso14443a_fast_select_card(uid, cascade_levels)) {
|
||||
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (UID)");
|
||||
if (g_dbglevel >= DBG_INFO) Dbprintf("Mifare: Can't select card (UID)");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -3212,7 +3212,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||
sync_time = GetCountSspClk() & 0xfffffff8;
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("calibrating in cycle %d. nt_distance=%d, elapsed_prng_sequences=%d, new sync_cycles: %d\n", i, nt_distance, elapsed_prng_sequences, sync_cycles);
|
||||
|
||||
LED_B_OFF();
|
||||
@@ -3239,13 +3239,13 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||
}
|
||||
|
||||
if (consecutive_resyncs < 3) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("Lost sync in cycle %d. nt_distance=%d. Consecutive Resyncs = %d. Trying one time catch up...\n", i, catch_up_cycles, consecutive_resyncs);
|
||||
}
|
||||
} else {
|
||||
sync_cycles += catch_up_cycles;
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("Lost sync in cycle %d for the fourth time consecutively (nt_distance = %d). Adjusting sync_cycles to %d.\n", i, catch_up_cycles, sync_cycles);
|
||||
|
||||
last_catch_up = 0;
|
||||
@@ -3295,7 +3295,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||
|
||||
mf_nr_ar[3] &= 0x1F;
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("Number of sent auth requests: %u", i);
|
||||
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("Number of sent auth requests: %u", i);
|
||||
|
||||
FpgaDisableTracing();
|
||||
|
||||
@@ -3388,7 +3388,7 @@ void DetectNACKbug(void) {
|
||||
if (!have_uid) { // need a full select cycle to get the uid first
|
||||
iso14a_card_select_t card_info;
|
||||
if (!iso14443a_select_card(uid, &card_info, &cuid, true, 0, true)) {
|
||||
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (ALL)");
|
||||
if (g_dbglevel >= DBG_INFO) Dbprintf("Mifare: Can't select card (ALL)");
|
||||
i = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -3410,7 +3410,7 @@ void DetectNACKbug(void) {
|
||||
have_uid = true;
|
||||
} else { // no need for anticollision. We can directly select the card
|
||||
if (!iso14443a_fast_select_card(uid, cascade_levels)) {
|
||||
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (UID)");
|
||||
if (g_dbglevel >= DBG_INFO) Dbprintf("Mifare: Can't select card (UID)");
|
||||
i = 0;
|
||||
have_uid = false;
|
||||
continue;
|
||||
@@ -3491,7 +3491,7 @@ void DetectNACKbug(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (g_dbglevel >= DBG_EXTENDED)
|
||||
Dbprintf("calibrating in cycle %d. nt_distance=%d, elapsed_prng_sequences=%d, new sync_cycles: %d\n", i, nt_distance, elapsed_prng_sequences, sync_cycles);
|
||||
|
||||
continue;
|
||||
@@ -3518,13 +3518,13 @@ void DetectNACKbug(void) {
|
||||
}
|
||||
|
||||
if (consecutive_resyncs < 3) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("Lost sync in cycle %d. nt_distance=%d. Consecutive Resyncs = %d. Trying one time catch up...\n", i, catch_up_cycles, consecutive_resyncs);
|
||||
}
|
||||
} else {
|
||||
sync_cycles += catch_up_cycles;
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("Lost sync in cycle %d for the fourth time consecutively (nt_distance = %d). Adjusting sync_cycles to %d.\n", i, catch_up_cycles, sync_cycles);
|
||||
Dbprintf("nt [%08x] attacted [%08x]", nt, nt_attacked);
|
||||
}
|
||||
|
||||
+15
-15
@@ -12,7 +12,7 @@
|
||||
#include "iso14443b.h"
|
||||
|
||||
#include "proxmark3_arm.h"
|
||||
#include "common.h" // access to global variable: DBGLEVEL
|
||||
#include "common.h" // access to global variable: g_dbglevel
|
||||
#include "util.h"
|
||||
#include "string.h"
|
||||
#include "crc16.h"
|
||||
@@ -437,7 +437,7 @@ static void iso14b_set_timeout(uint32_t timeout_etu) {
|
||||
ssp = MAX_14B_TIMEOUT;
|
||||
|
||||
iso14b_timeout = ssp;
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("ISO14443B Timeout set to %ld fwt", iso14b_timeout);
|
||||
}
|
||||
}
|
||||
@@ -453,7 +453,7 @@ static void iso14b_set_maxframesize(uint16_t size) {
|
||||
size = MAX_FRAME_SIZE;
|
||||
|
||||
Uart.byteCntMax = size;
|
||||
if (DBGLEVEL >= DBG_DEBUG) Dbprintf("ISO14443B Max frame size set to %d bytes", Uart.byteCntMax);
|
||||
if (g_dbglevel >= DBG_DEBUG) Dbprintf("ISO14443B Max frame size set to %d bytes", Uart.byteCntMax);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -846,19 +846,19 @@ void SimulateIso14443bTag(uint8_t *pupi) {
|
||||
// - SLOT MARKER
|
||||
// - ISO7816
|
||||
// - emulate with a memory dump
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("new cmd from reader: len=%d, cmdsRecvd=%d", len, cmdsReceived);
|
||||
|
||||
// CRC Check
|
||||
if (len >= 3) { // if crc exists
|
||||
|
||||
if (!check_crc(CRC_14443_B, receivedCmd, len)) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
DbpString("CRC fail");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
DbpString("CRC passed");
|
||||
}
|
||||
}
|
||||
@@ -873,7 +873,7 @@ void SimulateIso14443bTag(uint8_t *pupi) {
|
||||
++cmdsReceived;
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("Emulator stopped. Trace length: %d ", BigBuf_get_traceLen());
|
||||
|
||||
switch_off(); //simulate
|
||||
@@ -1050,19 +1050,19 @@ void Simulate_iso14443b_srx_tag(uint8_t *uid) {
|
||||
// - SLOT MARKER
|
||||
// - ISO7816
|
||||
// - emulate with a memory dump
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("new cmd from reader: len=%d, cmdsRecvd=%d", len, cmdsReceived);
|
||||
|
||||
// CRC Check
|
||||
if (len >= 3) { // if crc exists
|
||||
|
||||
if (!check_crc(CRC_14443_B, receivedCmd, len)) {
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
DbpString("CRC fail");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
DbpString("CRC passed");
|
||||
}
|
||||
}
|
||||
@@ -1077,7 +1077,7 @@ void Simulate_iso14443b_srx_tag(uint8_t *uid) {
|
||||
++cmdsReceived;
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG)
|
||||
if (g_dbglevel >= DBG_DEBUG)
|
||||
Dbprintf("Emulator stopped. Trace length: %d ", BigBuf_get_traceLen());
|
||||
|
||||
switch_off(); //simulate
|
||||
@@ -1301,7 +1301,7 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, uint32_t
|
||||
// The DMA buffer, used to stream samples from the FPGA
|
||||
dmabuf16_t *dma = get_dma16();
|
||||
if (FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE) == false) {
|
||||
if (DBGLEVEL > DBG_ERROR) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
if (g_dbglevel > DBG_ERROR) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1936,7 +1936,7 @@ static int read_srx_block(uint8_t blocknr, uint8_t *block) {
|
||||
memcpy(block, r_block, 4);
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_DEBUG) {
|
||||
if (g_dbglevel >= DBG_DEBUG) {
|
||||
Dbprintf("Address=%02x, Contents=%08x, CRC=%04x",
|
||||
blocknr,
|
||||
(r_block[3] << 24) + (r_block[2] << 16) + (r_block[1] << 8) + r_block[0],
|
||||
@@ -2027,7 +2027,7 @@ void SniffIso14443b(void) {
|
||||
|
||||
// Setup and start DMA.
|
||||
if (!FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE)) {
|
||||
if (DBGLEVEL > DBG_ERROR) DbpString("FpgaSetupSscDma failed. Exiting");
|
||||
if (g_dbglevel > DBG_ERROR) DbpString("FpgaSetupSscDma failed. Exiting");
|
||||
switch_off();
|
||||
return;
|
||||
}
|
||||
@@ -2175,7 +2175,7 @@ void SendRawCommand14443B_Ex(iso14b_raw_cmd_t *p) {
|
||||
// receive buffer
|
||||
uint8_t buf[PM3_CMD_DATA_SIZE];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (DBGLEVEL > DBG_DEBUG) {
|
||||
if (g_dbglevel > DBG_DEBUG) {
|
||||
Dbprintf("14b raw: param, %04x", p->flags);
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -667,7 +667,7 @@ int GetIso15693AnswerFromTag(uint8_t *response, uint16_t max_len, uint16_t timeo
|
||||
|
||||
// Setup and start DMA.
|
||||
if (FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE) == false) {
|
||||
if (DBGLEVEL > DBG_ERROR) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
if (g_dbglevel > DBG_ERROR) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
return -4;
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ int GetIso15693AnswerFromTag(uint8_t *response, uint16_t max_len, uint16_t timeo
|
||||
- (32 * 16) // time for SOF transfer
|
||||
- (dt->lastBit != SOF_PART2 ? (32 * 16) : 0); // time for EOF transfer
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("samples = %d, ret = %d, Decoder: state = %d, lastBit = %d, len = %d, bitCount = %d, posCount = %d, maxlen = %u",
|
||||
samples,
|
||||
ret,
|
||||
@@ -1120,7 +1120,7 @@ int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eo
|
||||
// Setup and start DMA.
|
||||
dmabuf8_t *dma = get_dma8();
|
||||
if (FpgaSetupSscDma(dma->buf, DMA_BUFFER_SIZE) == false) {
|
||||
if (DBGLEVEL > DBG_ERROR) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
if (g_dbglevel > DBG_ERROR) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
||||
return -4;
|
||||
}
|
||||
uint8_t *upTo = dma->buf;
|
||||
@@ -1172,7 +1172,7 @@ int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eo
|
||||
|
||||
FpgaDisableSscDma();
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("samples = %d, gotFrame = %d, Decoder: state = %d, len = %d, bitCount = %d, posCount = %d",
|
||||
samples, gotFrame, dr->state, dr->byteCount,
|
||||
dr->bitCount, dr->posCount);
|
||||
@@ -1287,7 +1287,7 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
|
||||
|
||||
// Setup and start DMA.
|
||||
if (FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE) == false) {
|
||||
if (DBGLEVEL > DBG_ERROR) DbpString("FpgaSetupSscDma failed. Exiting");
|
||||
if (g_dbglevel > DBG_ERROR) DbpString("FpgaSetupSscDma failed. Exiting");
|
||||
switch_off();
|
||||
return;
|
||||
}
|
||||
@@ -1587,7 +1587,7 @@ static void DbdecodeIso15693Answer(int len, uint8_t *d) {
|
||||
else
|
||||
strncat(status, "[!] crc (" _RED_("fail") ")", DBD15STATLEN - strlen(status));
|
||||
|
||||
if (DBGLEVEL >= DBG_ERROR) Dbprintf("%s", status);
|
||||
if (g_dbglevel >= DBG_ERROR) Dbprintf("%s", status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1642,7 +1642,7 @@ void ReaderIso15693(uint32_t parameter, iso15_card_select_t *p_card) {
|
||||
p_card->uidlen = 8;
|
||||
}
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("[+] UID = %02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
uid[0], uid[1], uid[2], uid[3],
|
||||
uid[4], uid[5], uid[5], uid[6]
|
||||
@@ -1655,7 +1655,7 @@ void ReaderIso15693(uint32_t parameter, iso15_card_select_t *p_card) {
|
||||
// asbytes = uid.
|
||||
reply_mix(CMD_ACK, 1, sizeof(uid), 0, uid, sizeof(uid));
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
if (g_dbglevel >= DBG_EXTENDED) {
|
||||
Dbprintf("[+] %d octets read from IDENTIFY request:", recvlen);
|
||||
DbdecodeIso15693Answer(recvlen, answer);
|
||||
Dbhexdump(recvlen, answer, true);
|
||||
|
||||
+1
-1
@@ -503,7 +503,7 @@ void LegicRfSimulate(uint8_t tagtype, bool send_reply) {
|
||||
|
||||
OUT:
|
||||
|
||||
if (DBGLEVEL >= DBG_ERROR) {
|
||||
if (g_dbglevel >= DBG_ERROR) {
|
||||
Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", get_tracing(), BigBuf_get_traceLen());
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user