mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
make style
This commit is contained in:
+2
-2
@@ -214,7 +214,7 @@ void MeasureAntennaTuning(void) {
|
||||
}
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING, PM3_SUCCESS, (uint8_t*)&payload, sizeof(payload));
|
||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING, PM3_SUCCESS, (uint8_t *)&payload, sizeof(payload));
|
||||
LEDsoff();
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ uint16_t MeasureAntennaTuningHfData(void) {
|
||||
|
||||
// Measure LF in milliVolt
|
||||
uint32_t MeasureAntennaTuningLfData(void) {
|
||||
return (MAX_ADC_LF_VOLTAGE * AvgAdc(ADC_CHAN_LF)) >> 10;
|
||||
return (MAX_ADC_LF_VOLTAGE * AvgAdc(ADC_CHAN_LF)) >> 10;
|
||||
}
|
||||
|
||||
void ReadMem(int addr) {
|
||||
|
||||
+1
-1
@@ -3034,7 +3034,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
|
||||
memcpy(payload.nr, mf_nr_ar, sizeof(payload.nr));
|
||||
memcpy(payload.ar, mf_nr_ar + 4, sizeof(payload.ar));
|
||||
|
||||
reply_ng(CMD_HF_MIFARE_READER, return_status, (uint8_t*)&payload, sizeof(payload));
|
||||
reply_ng(CMD_HF_MIFARE_READER, return_status, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
hf_field_off();
|
||||
set_tracing(false);
|
||||
|
||||
+3
-3
@@ -404,7 +404,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint
|
||||
DbpString("[!] Warning periods cannot be less than 7us in bit bang mode");
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LED_D_OFF();
|
||||
reply_ng(CMD_LF_MOD_THEN_ACQ_RAW_ADC, PM3_EINVARG, NULL, 0);
|
||||
reply_ng(CMD_LF_MOD_THEN_ACQ_RAW_ADC, PM3_EINVARG, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1708,12 +1708,12 @@ void T55xxDangerousRawTest(uint8_t *data) {
|
||||
t55xx_test_block_t *c = (t55xx_test_block_t *)data;
|
||||
|
||||
uint8_t start_wait = 4;
|
||||
uint8_t bs[128/8];
|
||||
uint8_t bs[128 / 8];
|
||||
memset(bs, 0x00, sizeof(bs));
|
||||
uint8_t len = 0;
|
||||
if (c->bitlen == 0 || c->bitlen > 128 || c->time == 0)
|
||||
reply_ng(CMD_LF_T55XX_DANGERRAW, PM3_EINVARG, NULL, 0);
|
||||
for (uint8_t i=0; i<c->bitlen; i++)
|
||||
for (uint8_t i = 0; i < c->bitlen; i++)
|
||||
len = T55xx_SetBits(bs, len, c->data[i], 1, sizeof(bs));
|
||||
|
||||
if (DBGLEVEL > 1) {
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0, 1} ;
|
||||
void printConfig() {
|
||||
uint32_t d = config.divisor;
|
||||
DbpString(_BLUE_("LF Sampling config"));
|
||||
Dbprintf(" [q] divisor.............%d ( "_GREEN_("%d.%02d kHz")")", d, 12000 / (d+1), ((1200000 + (d+1)/2) / (d+1)) - ((12000 / (d+1)) * 100));
|
||||
Dbprintf(" [q] divisor.............%d ( "_GREEN_("%d.%02d kHz")")", d, 12000 / (d + 1), ((1200000 + (d + 1) / 2) / (d + 1)) - ((12000 / (d + 1)) * 100));
|
||||
Dbprintf(" [b] bps.................%d", config.bits_per_sample);
|
||||
Dbprintf(" [d] decimation..........%d", config.decimation);
|
||||
Dbprintf(" [a] averaging...........%s", (config.averaging) ? "Yes" : "No");
|
||||
@@ -54,7 +54,7 @@ void setSamplingConfig(sample_config *sc) {
|
||||
if (sc->divisor != 0) config.divisor = sc->divisor;
|
||||
if (sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample;
|
||||
if (sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
|
||||
// if (sc->samples_to_skip == 0xffffffff) // if needed to not update if not supplied
|
||||
// if (sc->samples_to_skip == 0xffffffff) // if needed to not update if not supplied
|
||||
|
||||
config.samples_to_skip = sc->samples_to_skip;
|
||||
config.decimation = (sc->decimation != 0) ? sc->decimation : 1;
|
||||
|
||||
+11
-11
@@ -952,8 +952,8 @@ void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8
|
||||
|
||||
// cards with fixed nonce
|
||||
if (nt1 == nt2) {
|
||||
Dbprintf("Nested: %08x vs %08x", nt1, nt2);
|
||||
break;
|
||||
Dbprintf("Nested: %08x vs %08x", nt1, nt2);
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t nttmp = prng_successor(nt1, 100); //NXP Mifare is typical around 840,but for some unlicensed/compatible mifare card this can be 160
|
||||
@@ -1064,14 +1064,14 @@ void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8
|
||||
crypto1_destroy(pcs);
|
||||
|
||||
struct p {
|
||||
int16_t isOK;
|
||||
uint8_t block;
|
||||
uint8_t keytype;
|
||||
uint8_t cuid[4];
|
||||
uint8_t nt_a[4];
|
||||
uint8_t ks_a[4];
|
||||
uint8_t nt_b[4];
|
||||
uint8_t ks_b[4];
|
||||
int16_t isOK;
|
||||
uint8_t block;
|
||||
uint8_t keytype;
|
||||
uint8_t cuid[4];
|
||||
uint8_t nt_a[4];
|
||||
uint8_t ks_a[4];
|
||||
uint8_t nt_b[4];
|
||||
uint8_t ks_b[4];
|
||||
} PACKED payload;
|
||||
payload.isOK = isOK;
|
||||
payload.block = targetBlockNo;
|
||||
@@ -1084,7 +1084,7 @@ void MifareNested(uint8_t blockNo, uint8_t keyType, uint8_t targetBlockNo, uint8
|
||||
memcpy(payload.ks_b, &target_ks[1], 4);
|
||||
|
||||
LED_B_ON();
|
||||
reply_ng(CMD_HF_MIFARE_NESTED, PM3_SUCCESS, (uint8_t*)&payload, sizeof(payload));
|
||||
reply_ng(CMD_HF_MIFARE_NESTED, PM3_SUCCESS, (uint8_t *)&payload, sizeof(payload));
|
||||
LED_B_OFF();
|
||||
|
||||
if (DBGLEVEL >= 3) DbpString("NESTED FINISHED");
|
||||
|
||||
+1
-1
@@ -723,7 +723,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
||||
|
||||
// iceman, u8 can never be larger than 256
|
||||
// if authenticating to a block that shouldn't exist - as long as we are not doing the reader attack
|
||||
if ( ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) ) {
|
||||
if (((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK)) {
|
||||
EmSend4bit(mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA));
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("Reader tried to operate (0x%02x) on out of range block: %d (0x%02x), nacking", receivedCmd_dec[0], receivedCmd_dec[1], receivedCmd_dec[1]);
|
||||
break;
|
||||
|
||||
@@ -145,7 +145,7 @@ bool nfc3d_amiibo_load_keys(nfc3d_amiibo_keys *amiiboKeys, const char *path) {
|
||||
}
|
||||
|
||||
if ((amiiboKeys->data.magicBytesSize > 16) ||
|
||||
(amiiboKeys->tag.magicBytesSize > 16)) {
|
||||
(amiiboKeys->tag.magicBytesSize > 16)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -899,20 +899,20 @@ static int CmdAnalyseDemodBuffer(const char *Cmd) {
|
||||
|
||||
int bg = 0, en = 0;
|
||||
if (param_getptr(Cmd, &bg, &en, 0))
|
||||
return usage_analyse_demodbuffer();
|
||||
return usage_analyse_demodbuffer();
|
||||
|
||||
int len = MIN( (en- bg + 1), MAX_DEMOD_BUF_LEN);
|
||||
int len = MIN((en - bg + 1), MAX_DEMOD_BUF_LEN);
|
||||
|
||||
// add 1 for null terminator.
|
||||
uint8_t *data = calloc(len + 1, sizeof(uint8_t));
|
||||
if (!data) return PM3_EMALLOC;
|
||||
|
||||
for(int i = 0; bg <= en; bg++ , i++) {
|
||||
for (int i = 0; bg <= en; bg++, i++) {
|
||||
char c = Cmd[bg];
|
||||
if (c == '1')
|
||||
DemodBuffer[i] = 1;
|
||||
DemodBuffer[i] = 1;
|
||||
if (c == '0')
|
||||
DemodBuffer[i] = 0;
|
||||
DemodBuffer[i] = 0;
|
||||
|
||||
printf("%c", c);
|
||||
}
|
||||
|
||||
+7
-7
@@ -1174,7 +1174,7 @@ int FSKrawDemod(const char *Cmd, bool verbose) {
|
||||
PrintAndLogEx(DEBUG, "no FSK data found");
|
||||
}
|
||||
|
||||
out:
|
||||
out:
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -1218,7 +1218,7 @@ int PSKDemod(const char *Cmd, bool verbose) {
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
int startIdx = 0;
|
||||
int errCnt = pskRawDemod_ext(bits, &bitlen, &clk, &invert, &startIdx);
|
||||
if (errCnt > maxErr) {
|
||||
@@ -1336,7 +1336,7 @@ int NRZrawDemod(const char *Cmd, bool verbose) {
|
||||
if (bits == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
|
||||
size_t BitLen = getFromGraphBuf(bits);
|
||||
|
||||
if (BitLen == 0) {
|
||||
@@ -1355,7 +1355,7 @@ int NRZrawDemod(const char *Cmd, bool verbose) {
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
if (verbose || g_debugMode) PrintAndLogEx(DEBUG, "DEBUG: (NRZrawDemod) Tried NRZ Demod using Clock: %d - invert: %d - Bits Found: %zu", clk, invert, BitLen);
|
||||
//prime demod buffer for output
|
||||
setDemodBuff(bits, BitLen, 0);
|
||||
@@ -1368,7 +1368,7 @@ int NRZrawDemod(const char *Cmd, bool verbose) {
|
||||
// Now output the bitstream to the scrollback by line of 16 bits
|
||||
printDemodBuff();
|
||||
}
|
||||
|
||||
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
@@ -1673,7 +1673,7 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
uint8_t results[256];
|
||||
} PACKED;
|
||||
|
||||
struct p* package = (struct p*)resp.data.asBytes;
|
||||
struct p *package = (struct p *)resp.data.asBytes;
|
||||
|
||||
if (package->v_lf125 > NON_VOLTAGE)
|
||||
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lf125 * ANTENNA_ERROR) / 1000.0, 12000.0 / (LF_DIVISOR_125 + 1));
|
||||
@@ -1730,7 +1730,7 @@ int CmdTuneSamples(const char *Cmd) {
|
||||
|
||||
if (test1 > 0) {
|
||||
PrintAndLogEx(SUCCESS, "\nDisplaying LF tuning graph. Divisor %d is %.2f kHz, %d is %.2f kHz.\n\n",
|
||||
LF_DIVISOR_134, 12000.0 / (LF_DIVISOR_134 + 1), LF_DIVISOR_125, 12000.0 / (LF_DIVISOR_125 + 1));
|
||||
LF_DIVISOR_134, 12000.0 / (LF_DIVISOR_134 + 1), LF_DIVISOR_125, 12000.0 / (LF_DIVISOR_125 + 1));
|
||||
GraphTraceLen = 256;
|
||||
ShowGraphWindow();
|
||||
RepaintGraphWindow();
|
||||
|
||||
@@ -117,7 +117,7 @@ static int CmdFlashmemSpiBaudrate(const char *Cmd) {
|
||||
usage_flashmem_spibaud();
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
SendCommandNG(CMD_FLASHMEM_SET_SPIBAUDRATE, (uint8_t*)&baudrate, sizeof(uint32_t));
|
||||
SendCommandNG(CMD_FLASHMEM_SET_SPIBAUDRATE, (uint8_t *)&baudrate, sizeof(uint32_t));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1839,7 +1839,7 @@ static int CmdHFiClass_loclass(const char *Cmd) {
|
||||
int errors = testCipherUtils();
|
||||
errors += testMAC();
|
||||
errors += doKeyTests(0);
|
||||
errors += testElite(opt2=='l');
|
||||
errors += testElite(opt2 == 'l');
|
||||
if (errors) PrintAndLogEx(ERR, "There were errors!!!");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1866,7 +1866,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
||||
}
|
||||
if (verbose) PrintAndLogEx(INFO, _YELLOW_("======================= STOP KNOWN KEY ATTACK ======================="));
|
||||
if (num_found_keys == sectors_cnt * 2)
|
||||
goto all_found;
|
||||
goto all_found;
|
||||
}
|
||||
|
||||
bool load_success = true;
|
||||
@@ -2741,7 +2741,7 @@ static int CmdHF14AMfChk(const char *Cmd) {
|
||||
(keyBlock + 6 * keycnt)[3],
|
||||
(keyBlock + 6 * keycnt)[4],
|
||||
(keyBlock + 6 * keycnt)[5]
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
// initialize storage for found keys
|
||||
|
||||
@@ -1654,8 +1654,8 @@ static uint_fast8_t reverse(uint_fast8_t b) {
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
return b;
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
static uint_fast8_t reverse(uint_fast8_t b) {
|
||||
return (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
|
||||
}
|
||||
|
||||
+1
-1
@@ -695,7 +695,7 @@ void pm3_version(bool verbose, bool oneliner) {
|
||||
PrintAndLogEx(NORMAL, " compiled with " PM3CLIENTCOMPILER __VERSION__ PM3HOSTOS PM3HOSTARCH);
|
||||
|
||||
//#if PLATFORM == PM3RDV4
|
||||
if ( IfPm3Flash() == false && IfPm3Smartcard() == false && IfPm3FpcUsartHost() == false) {
|
||||
if (IfPm3Flash() == false && IfPm3Smartcard() == false && IfPm3FpcUsartHost() == false) {
|
||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK3 ]");
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK3 RDV4 ]");
|
||||
|
||||
+14
-11
@@ -337,13 +337,13 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
// bitbang mode
|
||||
if (payload.delay == 0){
|
||||
if (payload.zeros < 7 || payload.ones < 7) {
|
||||
PrintAndLogEx(WARNING, "Warning periods cannot be less than 7us in bit bang mode");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
}
|
||||
// bitbang mode
|
||||
if (payload.delay == 0) {
|
||||
if (payload.zeros < 7 || payload.ones < 7) {
|
||||
PrintAndLogEx(WARNING, "Warning periods cannot be less than 7us in bit bang mode");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
}
|
||||
|
||||
//Validations
|
||||
if (errors || cmdp == 0) return usage_lf_cmdread();
|
||||
@@ -528,7 +528,7 @@ int CmdLFConfig(const char *Cmd) {
|
||||
break;
|
||||
case 's':
|
||||
samples_to_skip = param_get32ex(Cmd, cmdp + 1, 0, 10);
|
||||
cmdp+=2;
|
||||
cmdp += 2;
|
||||
break;
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
@@ -1202,16 +1202,19 @@ int CmdLFfind(const char *Cmd) {
|
||||
|
||||
if (IfPm3Hitag()) {
|
||||
if (readHitagUid()) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Hitag") "found!"); return PM3_SUCCESS;
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Hitag") "found!");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (readMotorolaUid()) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Motorola ID") "found!"); return PM3_SUCCESS;
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Motorola ID") "found!");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
if (readCOTAGUid()) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("COTAG ID") "found!"); return PM3_SUCCESS;
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("COTAG ID") "found!");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
PrintAndLogEx(FAILED, _RED_("No data found!"));
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ static int CmdAWIDClone(const char *Cmd) {
|
||||
blocks[3] = bytebits_to_byte(bits + 64, 32);
|
||||
|
||||
free(bits);
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "Preparing to clone AWID %u to T55x7 with FC: %u, CN: %u", fmtlen, fc, cn);
|
||||
print_blocks(blocks, ARRAYLEN(blocks));
|
||||
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ static int CmdCOTAGDemod(const char *Cmd) {
|
||||
// 2 = raw signal - maxlength bigbuff
|
||||
static int CmdCOTAGRead(const char *Cmd) {
|
||||
|
||||
if ( tolower(Cmd[0]) == 'h') return usage_lf_cotag_read();
|
||||
if (tolower(Cmd[0]) == 'h') return usage_lf_cotag_read();
|
||||
|
||||
uint32_t rawsignal = 1;
|
||||
sscanf(Cmd, "%u", &rawsignal);
|
||||
|
||||
+63
-63
@@ -720,7 +720,7 @@ static bool EM_ColParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t col
|
||||
return true;
|
||||
}
|
||||
|
||||
// even parity ROW
|
||||
// even parity ROW
|
||||
static bool EM_RowParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uint8_t pType) {
|
||||
if (rows * cols > size) return false;
|
||||
uint8_t rowP = 0;
|
||||
@@ -844,14 +844,14 @@ int EM4x50Read(const char *Cmd, bool verbose) {
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
|
||||
if (size < 4000) {
|
||||
if (verbose || g_debugMode) PrintAndLogEx(ERR, "Error: EM4x50 - Too little data in Graphbuffer");
|
||||
return PM3_ESOFT;
|
||||
if (verbose || g_debugMode) PrintAndLogEx(ERR, "Error: EM4x50 - Too little data in Graphbuffer");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
computeSignalProperties(bits, size);
|
||||
|
||||
// get fuzzed HI / LOW limits in signal
|
||||
getHiLo( &high, &low, 75, 75);
|
||||
getHiLo(&high, &low, 75, 75);
|
||||
|
||||
// get to first full low to prime loop and skip incomplete first pulse
|
||||
size_t offset = 0;
|
||||
@@ -866,7 +866,7 @@ int EM4x50Read(const char *Cmd, bool verbose) {
|
||||
DetectASKClock(bits, size, &clk, 0);
|
||||
if (clk == 0) {
|
||||
if (verbose || g_debugMode) PrintAndLogEx(ERR, "Error: EM4x50 - didn't find a clock");
|
||||
return PM3_ESOFT;
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
}
|
||||
// tolerance
|
||||
@@ -1246,7 +1246,7 @@ static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t
|
||||
|
||||
static int CmdEM4x05Demod(const char *Cmd) {
|
||||
// uint8_t ctmp = tolower(param_getchar(Cmd, 0));
|
||||
// if (ctmp == 'h') return usage_lf_em4x05_demod();
|
||||
// if (ctmp == 'h') return usage_lf_em4x05_demod();
|
||||
uint32_t word = 0;
|
||||
return demodEM4x05resp(&word);
|
||||
}
|
||||
@@ -1263,22 +1263,23 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'h': return usage_lf_em4x05_dump();
|
||||
break;
|
||||
case 'h':
|
||||
return usage_lf_em4x05_dump();
|
||||
break;
|
||||
case 'f': // since f could match in password, lets confirm it is 1 character only for an option
|
||||
param_getstr(Cmd, cmdp,optchk,sizeof(optchk));
|
||||
if (strlen (optchk) == 1) {// Have a single character f so filename no password
|
||||
param_getstr(Cmd, cmdp + 1, preferredName, FILE_PATH_SIZE);
|
||||
cmdp+=2;
|
||||
break;
|
||||
} // if not a single 'f' dont break and flow onto default as should be password
|
||||
param_getstr(Cmd, cmdp, optchk, sizeof(optchk));
|
||||
if (strlen(optchk) == 1) { // Have a single character f so filename no password
|
||||
param_getstr(Cmd, cmdp + 1, preferredName, FILE_PATH_SIZE);
|
||||
cmdp += 2;
|
||||
break;
|
||||
} // if not a single 'f' dont break and flow onto default as should be password
|
||||
|
||||
default : // for backwards-compatibility options should be > 'f' else assume its the hex password`
|
||||
// for now use default input of 1 as invalid (unlikely 1 will be a valid password...)
|
||||
pwd = param_get32ex(Cmd, cmdp, 1, 16);
|
||||
if (pwd != 1)
|
||||
usePwd = true;
|
||||
cmdp++;
|
||||
// for now use default input of 1 as invalid (unlikely 1 will be a valid password...)
|
||||
pwd = param_get32ex(Cmd, cmdp, 1, 16);
|
||||
if (pwd != 1)
|
||||
usePwd = true;
|
||||
cmdp++;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1313,7 +1314,7 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||
if (usePwd) {
|
||||
data[addr] = BSWAP_32(pwd);
|
||||
num_to_bytes(pwd, 4, bytes);
|
||||
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %c | password", addr, pwd, sprint_ascii(bytes, 4),((lock_bits >> addr) & 1) ? 'x' : ' ');
|
||||
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %c | password", addr, pwd, sprint_ascii(bytes, 4), ((lock_bits >> addr) & 1) ? 'x' : ' ');
|
||||
} else {
|
||||
data[addr] = 0x00; // Unknown password, but not used to set to zeros
|
||||
PrintAndLogEx(NORMAL, " 02 | | | | " _RED_("cannot read"));
|
||||
@@ -1326,16 +1327,15 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||
data[addr] = BSWAP_32(word);
|
||||
if (status == PM3_SUCCESS) {
|
||||
num_to_bytes(word, 4, bytes);
|
||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %c |", addr, word, sprint_ascii(bytes, 4),((lock_bits >> addr) & 1) ? 'x' : ' ');
|
||||
}
|
||||
else
|
||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %c |", addr, word, sprint_ascii(bytes, 4), ((lock_bits >> addr) & 1) ? 'x' : ' ');
|
||||
} else
|
||||
PrintAndLogEx(NORMAL, " %02d | | | | " _RED_("Fail"), addr);
|
||||
}
|
||||
}
|
||||
// Print blocks 14 and 15
|
||||
// Print blocks 14 and 15
|
||||
// Both lock bits are protected with bit idx 14 (special case)
|
||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %c | Lock", 14, data[14], sprint_ascii(bytes, 4),((lock_bits >> 14) & 1) ? 'x' : ' ');
|
||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %c | Lock", 15, data[15], sprint_ascii(bytes, 4),((lock_bits >> 14) & 1) ? 'x' : ' ');
|
||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %c | Lock", 14, data[14], sprint_ascii(bytes, 4), ((lock_bits >> 14) & 1) ? 'x' : ' ');
|
||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %c | Lock", 15, data[15], sprint_ascii(bytes, 4), ((lock_bits >> 14) & 1) ? 'x' : ' ');
|
||||
// Update endian for files
|
||||
data[14] = BSWAP_32(data[14]);
|
||||
data[15] = BSWAP_32(data[15]);
|
||||
@@ -1343,13 +1343,13 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||
if (success == PM3_SUCCESS) { // all ok save dump to file
|
||||
// saveFileEML will add .eml extension to filename
|
||||
// saveFile (binary) passes in the .bin extension.
|
||||
if (strcmp (preferredName,"") == 0) // Set default filename, if not set by user
|
||||
sprintf (preferredName,"lf-4x05-%08X-data",BSWAP_32(data[1]));
|
||||
if (strcmp(preferredName, "") == 0) // Set default filename, if not set by user
|
||||
sprintf(preferredName, "lf-4x05-%08X-data", BSWAP_32(data[1]));
|
||||
|
||||
saveFileEML(preferredName, (uint8_t *)data, 16*sizeof(uint32_t), sizeof(uint32_t));
|
||||
saveFile (preferredName, ".bin", data, sizeof(data));
|
||||
saveFileEML(preferredName, (uint8_t *)data, 16 * sizeof(uint32_t), sizeof(uint32_t));
|
||||
saveFile(preferredName, ".bin", data, sizeof(data));
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -1443,7 +1443,7 @@ static int CmdEM4x05Wipe(const char *Cmd) {
|
||||
uint8_t addr = 0;
|
||||
uint32_t pwd = 0;
|
||||
uint8_t cmdp = 0;
|
||||
uint8_t chipType = 1; // em4305
|
||||
uint8_t chipType = 1; // em4305
|
||||
uint32_t chipInfo = 0x00040072; // Chip info/User Block normal 4305 Chip Type
|
||||
uint32_t chipUID = 0x614739AE; // UID normally readonly, but just in case
|
||||
uint32_t blockData = 0x00000000; // UserBlock/Password (set to 0x00000000 for a wiped card1
|
||||
@@ -1454,60 +1454,60 @@ static int CmdEM4x05Wipe(const char *Cmd) {
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00) {
|
||||
// check if cmd is a 1 byte option
|
||||
param_getstr(Cmd, cmdp,optchk,sizeof(optchk));
|
||||
if (strlen (optchk) == 1) {// Have a single character so option not part of password
|
||||
param_getstr(Cmd, cmdp, optchk, sizeof(optchk));
|
||||
if (strlen(optchk) == 1) { // Have a single character so option not part of password
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'c': // chip type
|
||||
if (param_getchar(Cmd, cmdp) != 0x00)
|
||||
chipType = param_get8ex (Cmd,cmdp+1,0,10);
|
||||
cmdp+=2;
|
||||
break;
|
||||
if (param_getchar(Cmd, cmdp) != 0x00)
|
||||
chipType = param_get8ex(Cmd, cmdp + 1, 0, 10);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'h': // return usage_lf_em4x05_wipe();
|
||||
default : // Unknown or 'h' send help
|
||||
return usage_lf_em4x05_wipe();
|
||||
break;
|
||||
return usage_lf_em4x05_wipe();
|
||||
break;
|
||||
};
|
||||
} else { // Not a single character so assume password
|
||||
} else { // Not a single character so assume password
|
||||
pwd = param_get32ex(Cmd, cmdp, 1, 16);
|
||||
cmdp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (chipType) {
|
||||
case 0 : // em4205
|
||||
chipInfo = 0x00040070;
|
||||
config = 0x0001805F;
|
||||
break;
|
||||
chipInfo = 0x00040070;
|
||||
config = 0x0001805F;
|
||||
break;
|
||||
case 1 : // em4305
|
||||
chipInfo = 0x00040072;
|
||||
config = 0x0001805F;
|
||||
break;
|
||||
chipInfo = 0x00040072;
|
||||
config = 0x0001805F;
|
||||
break;
|
||||
default : // Type 0/Default : EM4305
|
||||
chipInfo = 0x00040072;
|
||||
config = 0x0001805F;
|
||||
chipInfo = 0x00040072;
|
||||
config = 0x0001805F;
|
||||
}
|
||||
|
||||
|
||||
// block 0 : User Data or Chip Info
|
||||
sprintf (cmdStr,"%d %08X %08X",0,chipInfo,pwd);
|
||||
CmdEM4x05Write (cmdStr);
|
||||
sprintf(cmdStr, "%d %08X %08X", 0, chipInfo, pwd);
|
||||
CmdEM4x05Write(cmdStr);
|
||||
// block 1 : UID - this should be read only for EM4205 and EM4305 not sure about others
|
||||
sprintf (cmdStr,"%d %08X %08X",1,chipUID,pwd);
|
||||
CmdEM4x05Write (cmdStr);
|
||||
sprintf(cmdStr, "%d %08X %08X", 1, chipUID, pwd);
|
||||
CmdEM4x05Write(cmdStr);
|
||||
// block 2 : password
|
||||
sprintf (cmdStr,"%d %08X %08X",2,blockData,pwd);
|
||||
CmdEM4x05Write (cmdStr);
|
||||
sprintf(cmdStr, "%d %08X %08X", 2, blockData, pwd);
|
||||
CmdEM4x05Write(cmdStr);
|
||||
pwd = blockData; // Password should now have changed, so use new password
|
||||
// block 3 : user data
|
||||
sprintf (cmdStr,"%d %08X %08X",3,blockData,pwd);
|
||||
CmdEM4x05Write (cmdStr);
|
||||
sprintf(cmdStr, "%d %08X %08X", 3, blockData, pwd);
|
||||
CmdEM4x05Write(cmdStr);
|
||||
// block 4 : config
|
||||
sprintf (cmdStr,"%d %08X %08X",4,config,pwd);
|
||||
CmdEM4x05Write (cmdStr);
|
||||
sprintf(cmdStr, "%d %08X %08X", 4, config, pwd);
|
||||
CmdEM4x05Write(cmdStr);
|
||||
|
||||
// Remainder of user/data blocks
|
||||
for (addr = 5; addr < 14; addr++) {// Clear user data blocks
|
||||
sprintf (cmdStr,"%d %08X %08X",addr,blockData,pwd);
|
||||
CmdEM4x05Write (cmdStr);
|
||||
sprintf(cmdStr, "%d %08X %08X", addr, blockData, pwd);
|
||||
CmdEM4x05Write(cmdStr);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
+3
-3
@@ -264,7 +264,7 @@ static int CmdFdxRead(const char *Cmd) {
|
||||
static int CmdFdxClone(const char *Cmd) {
|
||||
|
||||
uint32_t countryid = 0;
|
||||
uint64_t animalid = 0;
|
||||
uint64_t animalid = 0;
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_fdx_clone();
|
||||
|
||||
@@ -282,7 +282,7 @@ static int CmdFdxClone(const char *Cmd) {
|
||||
}
|
||||
|
||||
uint32_t blocks[5] = {T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT, 0, 0, 0, 0};
|
||||
|
||||
|
||||
//Q5
|
||||
if (param_getchar(Cmd, 2) == 'Q' || param_getchar(Cmd, 2) == 'q')
|
||||
blocks[0] = T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | T5555_SET_BITRATE(32) | 4 << T5555_MAXBLOCK_SHIFT;
|
||||
@@ -294,7 +294,7 @@ static int CmdFdxClone(const char *Cmd) {
|
||||
blocks[4] = bytebits_to_byte(bits + 96, 32);
|
||||
|
||||
free(bits);
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, "Preparing to clone FDX-B to T55x7 with animal ID: %04u-%"PRIu64, countryid, animalid);
|
||||
print_blocks(blocks, ARRAYLEN(blocks));
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ static int CmdGallagherClone(const char *Cmd) {
|
||||
// skip first block, 3*4 = 12 bytes left
|
||||
uint8_t rawhex[12] = {0};
|
||||
int res = param_gethex_to_eol(Cmd, cmdp + 1, rawhex, sizeof(rawhex), &datalen);
|
||||
if ( res != 0 )
|
||||
if (res != 0)
|
||||
errors = true;
|
||||
|
||||
for(uint8_t i = 1; i < ARRAYLEN(blocks); i++) {
|
||||
blocks[i] = bytes_to_num(rawhex + ( (i - 1) * 4 ), sizeof(uint32_t));
|
||||
for (uint8_t i = 1; i < ARRAYLEN(blocks); i++) {
|
||||
blocks[i] = bytes_to_num(rawhex + ((i - 1) * 4), sizeof(uint32_t));
|
||||
}
|
||||
cmdp += 2;
|
||||
break;
|
||||
@@ -157,10 +157,10 @@ int detectGallagher(uint8_t *dest, size_t *size) {
|
||||
if (*size < 96) return -1; //make sure buffer has data
|
||||
size_t startIdx = 0;
|
||||
uint8_t preamble[] = {
|
||||
0, 0, 0, 0, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0, 0,
|
||||
0, 1, 1, 0, 0 ,0 ,0 ,1
|
||||
0, 0, 0, 0, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0, 0,
|
||||
0, 1, 1, 0, 0, 0, 0, 1
|
||||
};
|
||||
if (!preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx))
|
||||
return -2; //preamble not found
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user