mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 02:27:26 -07:00
fix and style
This commit is contained in:
parent
715f149413
commit
72900d1bf9
10 changed files with 79 additions and 28 deletions
|
@ -2341,6 +2341,7 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) {
|
||||||
|
|
||||||
uint64_t ui64Key = emlGetKey(s, keytype);
|
uint64_t ui64Key = emlGetKey(s, keytype);
|
||||||
|
|
||||||
|
// MIFARE Classic 1K Ev1 , MIFARE Classic MINI Ev1
|
||||||
if (sectorcnt == 18) {
|
if (sectorcnt == 18) {
|
||||||
// MFC 1K EV1, skip sector 16 since its lockdown
|
// MFC 1K EV1, skip sector 16 since its lockdown
|
||||||
if (s == 16) {
|
if (s == 16) {
|
||||||
|
@ -2355,7 +2356,7 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) {
|
||||||
// ICEMAN: ugly hack, we don't want to trigger the partial load message
|
// ICEMAN: ugly hack, we don't want to trigger the partial load message
|
||||||
// MFC 1K EV1 sector 17 don't use key A.
|
// MFC 1K EV1 sector 17 don't use key A.
|
||||||
// not mention we don't save signatures in our MFC dump files.
|
// not mention we don't save signatures in our MFC dump files.
|
||||||
if (s == 17 && keytype == 0) {
|
if (s == 17 && keytype == MF_KEY_A) {
|
||||||
ui64Key = 0x4B791BEA7BCC;
|
ui64Key = 0x4B791BEA7BCC;
|
||||||
keytype = 1;
|
keytype = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "crapto1/crapto1.h"
|
#include "crapto1/crapto1.h"
|
||||||
#include "protocols.h"
|
#include "protocols.h"
|
||||||
#include "cmdhficlass.h"
|
#include "cmdhficlass.h"
|
||||||
|
#include "mifare/mifaredefault.h" // mifare consts
|
||||||
|
|
||||||
enum MifareAuthSeq {
|
enum MifareAuthSeq {
|
||||||
masNone,
|
masNone,
|
||||||
|
@ -382,7 +383,7 @@ int applyIso14443a(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize, bool i
|
||||||
snprintf(exp, size, "WRITEBLOCK(" _MAGENTA_("%d") ")", cmd[1]);
|
snprintf(exp, size, "WRITEBLOCK(" _MAGENTA_("%d") ")", cmd[1]);
|
||||||
else
|
else
|
||||||
// outside limits, useful for some tags...
|
// outside limits, useful for some tags...
|
||||||
snprintf(exp, size, "WRITEBLOCK(" _MAGENTA_("%d") ") (?)", cmd[1]);
|
snprintf(exp, size, "WRITEBLOCK(" _MAGENTA_("%d") ") (%s)", cmd[1], sprint_hex_inrow(cmd + 2, 4));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MIFARE_ULEV1_READ_CNT : {
|
case MIFARE_ULEV1_READ_CNT : {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define CMDHFLIST_H
|
#define CMDHFLIST_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "mifare/mifaredefault.h" // mifare consts
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t uid; // UID
|
uint32_t uid; // UID
|
||||||
|
@ -34,6 +35,7 @@ typedef struct {
|
||||||
bool first_auth; // is first authentication
|
bool first_auth; // is first authentication
|
||||||
uint32_t ks2; // ar ^ ar_enc
|
uint32_t ks2; // ar ^ ar_enc
|
||||||
uint32_t ks3; // at ^ at_enc
|
uint32_t ks3; // at ^ at_enc
|
||||||
|
uint8_t mem[MIFARE_4K_MAX_BYTES];
|
||||||
} AuthData_t;
|
} AuthData_t;
|
||||||
|
|
||||||
void ClearAuthData(void);
|
void ClearAuthData(void);
|
||||||
|
|
|
@ -898,12 +898,12 @@ static int CmdHF14AMfDarkside(const char *Cmd) {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_int0(NULL, "blk", "<dec> ", "Target block"),
|
arg_int0(NULL, "blk", "<dec> ", "Target block"),
|
||||||
arg_lit0("b", NULL, "Target key B instead of default key A"),
|
arg_lit0("b", NULL, "Target key B instead of default key A"),
|
||||||
|
arg_int0("c", NULL, "<dec>", "Target Auth 6x"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
};
|
};
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
|
|
||||||
uint8_t blockno = arg_get_u32_def(ctx, 1, 0);
|
uint8_t blockno = arg_get_u32_def(ctx, 1, 0) & 0xFF;
|
||||||
|
|
||||||
uint8_t key_type = MIFARE_AUTH_KEYA;
|
uint8_t key_type = MIFARE_AUTH_KEYA;
|
||||||
|
|
||||||
if (arg_get_lit(ctx, 2)) {
|
if (arg_get_lit(ctx, 2)) {
|
||||||
|
@ -911,6 +911,11 @@ static int CmdHF14AMfDarkside(const char *Cmd) {
|
||||||
key_type = MIFARE_AUTH_KEYB;
|
key_type = MIFARE_AUTH_KEYB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t ctype = arg_get_u32_def(ctx, 3, 0) & 0xFF;
|
||||||
|
if ((ctype & 0x60) == 0x60) {
|
||||||
|
key_type = ctype;
|
||||||
|
}
|
||||||
|
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
uint64_t key = 0;
|
uint64_t key = 0;
|
||||||
|
@ -3610,26 +3615,34 @@ static int CmdHF14AMfSmartBrute(const char *Cmd) {
|
||||||
|
|
||||||
// generate block of keys from generator
|
// generate block of keys from generator
|
||||||
memset(keyBlock, 0, MIFARE_KEY_SIZE * chunksize);
|
memset(keyBlock, 0, MIFARE_KEY_SIZE * chunksize);
|
||||||
|
|
||||||
for (i = 0; i < chunksize; i++) {
|
for (i = 0; i < chunksize; i++) {
|
||||||
|
|
||||||
ret = bf_generate(&bctx);
|
ret = bf_generate(&bctx);
|
||||||
|
|
||||||
if (ret == BF_GENERATOR_ERROR) {
|
if (ret == BF_GENERATOR_ERROR) {
|
||||||
PrintAndLogEx(ERR, "Internal bruteforce generator error");
|
PrintAndLogEx(ERR, "Internal bruteforce generator error");
|
||||||
free(keyBlock);
|
free(keyBlock);
|
||||||
free(e_sector);
|
free(e_sector);
|
||||||
return PM3_EFAILED;
|
return PM3_EFAILED;
|
||||||
|
|
||||||
} else if (ret == BF_GENERATOR_END) {
|
} else if (ret == BF_GENERATOR_END) {
|
||||||
|
|
||||||
lastChunk = true;
|
lastChunk = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else if (ret == BF_GENERATOR_NEXT) {
|
} else if (ret == BF_GENERATOR_NEXT) {
|
||||||
generator_key = bf_get_key48(&bctx);
|
generator_key = bf_get_key48(&bctx);
|
||||||
num_to_bytes(generator_key, MIFARE_KEY_SIZE, keyBlock + (i * MIFARE_KEY_SIZE));
|
num_to_bytes(generator_key, MIFARE_KEY_SIZE, keyBlock + (i * MIFARE_KEY_SIZE));
|
||||||
keycnt++;
|
keycnt++;
|
||||||
|
|
||||||
if (smart_mode_stage != bctx.smart_mode_stage) {
|
if (smart_mode_stage != bctx.smart_mode_stage) {
|
||||||
|
|
||||||
smart_mode_stage = bctx.smart_mode_stage;
|
smart_mode_stage = bctx.smart_mode_stage;
|
||||||
PrintAndLogEx(INFO, "Running bruteforce stage %d", smart_mode_stage);
|
PrintAndLogEx(INFO, "Running bruteforce stage %d", smart_mode_stage);
|
||||||
|
|
||||||
if (msclock() - t1 > 0 && keys_checked > 0) {
|
if (msclock() - t1 > 0 && keys_checked > 0) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Current cracking speed (keys/s): %lu",
|
PrintAndLogEx(INFO, "Current cracking speed (keys/s): %lu",
|
||||||
keys_checked / ((msclock() - t1) / 1000));
|
keys_checked / ((msclock() - t1) / 1000));
|
||||||
|
|
||||||
|
@ -3661,11 +3674,13 @@ out:
|
||||||
uint8_t found_keys = 0;
|
uint8_t found_keys = 0;
|
||||||
for (i = 0; i < sectorsCnt; ++i) {
|
for (i = 0; i < sectorsCnt; ++i) {
|
||||||
|
|
||||||
if (e_sector[i].foundKey[0])
|
if (e_sector[i].foundKey[0]) {
|
||||||
found_keys++;
|
found_keys++;
|
||||||
|
}
|
||||||
|
|
||||||
if (e_sector[i].foundKey[1])
|
if (e_sector[i].foundKey[1]) {
|
||||||
found_keys++;
|
found_keys++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_keys == 0) {
|
if (found_keys == 0) {
|
||||||
|
@ -6469,12 +6484,16 @@ int CmdHFMFNDEFRead(const char *Cmd) {
|
||||||
res = NDEFRecordsDecodeAndPrint(data, datalen, verbose);
|
res = NDEFRecordsDecodeAndPrint(data, datalen, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if given a filename, save it
|
||||||
|
if (fnlen) {
|
||||||
// get total NDEF length before save. If fails, we save it all
|
// get total NDEF length before save. If fails, we save it all
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (NDEFGetTotalLength(data, datalen, &n) != PM3_SUCCESS)
|
if (NDEFGetTotalLength(data, datalen, &n) != PM3_SUCCESS) {
|
||||||
n = datalen;
|
n = datalen;
|
||||||
|
}
|
||||||
|
|
||||||
pm3_save_dump(filename, data, n, jsfNDEF);
|
pm3_save_dump(filename, data, n, jsfNDEF);
|
||||||
|
}
|
||||||
|
|
||||||
if (verbose == false) {
|
if (verbose == false) {
|
||||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -v`") " for more details");
|
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndefread -v`") " for more details");
|
||||||
|
@ -7564,6 +7583,14 @@ static int CmdHF14AMfWipe(const char *Cmd) {
|
||||||
memcpy(mf, "\x11\x22\x33\x44\x44\x09\x04\x00\x62\x63\x64\x65\x66\x67\x68\x69", MFBLOCK_SIZE);
|
memcpy(mf, "\x11\x22\x33\x44\x44\x09\x04\x00\x62\x63\x64\x65\x66\x67\x68\x69", MFBLOCK_SIZE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case (MIFARE_1K_EV1_MAX_KEY_SIZE): {
|
||||||
|
PrintAndLogEx(INFO, "Loaded keys matching MIFARE Classic 1K Ev1");
|
||||||
|
memcpy(keyA, keys, MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE);
|
||||||
|
memcpy(keyB, keys + (MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE), (MIFARE_1K_EV1_MAXSECTOR * MIFARE_KEY_SIZE));
|
||||||
|
num_sectors = NumOfSectors('1');
|
||||||
|
memcpy(mf, "\x11\x22\x33\x44\x44\x08\x04\x00\x62\x63\x64\x65\x66\x67\x68\x69", MFBLOCK_SIZE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case (MIFARE_1K_MAX_KEY_SIZE): {
|
case (MIFARE_1K_MAX_KEY_SIZE): {
|
||||||
PrintAndLogEx(INFO, "Loaded keys matching MIFARE Classic 1K");
|
PrintAndLogEx(INFO, "Loaded keys matching MIFARE Classic 1K");
|
||||||
memcpy(keyA, keys, (MIFARE_1K_MAXSECTOR * MIFARE_KEY_SIZE));
|
memcpy(keyA, keys, (MIFARE_1K_MAXSECTOR * MIFARE_KEY_SIZE));
|
||||||
|
@ -7582,7 +7609,7 @@ static int CmdHF14AMfWipe(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
PrintAndLogEx(INFO, "wrong key file size");
|
PrintAndLogEx(INFO, "wrong key file size. got %zu", keyslen);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7641,12 +7668,12 @@ static int CmdHF14AMfWipe(const char *Cmd) {
|
||||||
SendCommandMIX(CMD_HF_MIFARE_WRITEBL, mfFirstBlockOfSector(s) + b, kt, 0, data, sizeof(data));
|
SendCommandMIX(CMD_HF_MIFARE_WRITEBL, mfFirstBlockOfSector(s) + b, kt, 0, data, sizeof(data));
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {
|
||||||
int isOK = resp.oldarg[0];
|
int8_t isOK = resp.oldarg[0];
|
||||||
if (isOK > 0) {
|
if (isOK == 1) {
|
||||||
PrintAndLogEx(NORMAL, "( " _GREEN_("ok") " )");
|
PrintAndLogEx(NORMAL, "- key %c ( " _GREEN_("ok") " )", (kt== MF_KEY_A) ? 'A' : 'B');
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, "( " _RED_("fail") " )");
|
PrintAndLogEx(NORMAL, "- key %c ( " _RED_("fail") " )", (kt== MF_KEY_A) ? 'A' : 'B');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "Command execute timeout");
|
PrintAndLogEx(WARNING, "Command execute timeout");
|
||||||
|
|
|
@ -468,14 +468,16 @@ int ecdsa_signature_verify(mbedtls_ecp_group_id curveid, uint8_t *key_xy, uint8_
|
||||||
uint8_t shahash[32] = {0};
|
uint8_t shahash[32] = {0};
|
||||||
if (hash) {
|
if (hash) {
|
||||||
res = sha256hash(input, length, shahash);
|
res = sha256hash(input, length, shahash);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_ecdsa_context ctx;
|
mbedtls_ecdsa_context ctx;
|
||||||
res = ecdsa_init(&ctx, curveid, NULL, key_xy);
|
res = ecdsa_init(&ctx, curveid, NULL, key_xy);
|
||||||
if (res)
|
if (res) {
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
res = mbedtls_ecdsa_read_signature(
|
res = mbedtls_ecdsa_read_signature(
|
||||||
&ctx,
|
&ctx,
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#define MIFARE_4K_MAXSECTOR 40
|
#define MIFARE_4K_MAXSECTOR 40
|
||||||
#define MIFARE_2K_MAXSECTOR 32
|
#define MIFARE_2K_MAXSECTOR 32
|
||||||
#define MIFARE_1K_MAXSECTOR 16
|
#define MIFARE_1K_MAXSECTOR 16
|
||||||
|
#define MIFARE_1K_EV1_MAXSECTOR (MIFARE_1K_MAXSECTOR + 2)
|
||||||
#define MIFARE_MINI_MAXSECTOR 5
|
#define MIFARE_MINI_MAXSECTOR 5
|
||||||
|
|
||||||
#define MIFARE_4K_MAX_BYTES 4096
|
#define MIFARE_4K_MAX_BYTES 4096
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
|
|
||||||
#define MIFARE_MINI_MAX_KEY_SIZE (MIFARE_MINI_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
#define MIFARE_MINI_MAX_KEY_SIZE (MIFARE_MINI_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
||||||
#define MIFARE_1K_MAX_KEY_SIZE (MIFARE_1K_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
#define MIFARE_1K_MAX_KEY_SIZE (MIFARE_1K_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
||||||
|
#define MIFARE_1K_EV1_MAX_KEY_SIZE (MIFARE_1K_EV1_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
||||||
#define MIFARE_2K_MAX_KEY_SIZE (MIFARE_2K_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
#define MIFARE_2K_MAX_KEY_SIZE (MIFARE_2K_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
||||||
#define MIFARE_4K_MAX_KEY_SIZE (MIFARE_4K_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
#define MIFARE_4K_MAX_KEY_SIZE (MIFARE_4K_MAXSECTOR * 2 * MIFARE_KEY_SIZE)
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keyc
|
||||||
SendCommandNG(CMD_HF_MIFARE_CHKKEYS, data, (5 + 6 * keycnt));
|
SendCommandNG(CMD_HF_MIFARE_CHKKEYS, data, (5 + 6 * keycnt));
|
||||||
|
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_HF_MIFARE_CHKKEYS, &resp, 2500)) {
|
if (WaitForResponseTimeout(CMD_HF_MIFARE_CHKKEYS, &resp, 2500) == false) {
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
if (resp.status != PM3_SUCCESS) {
|
if (resp.status != PM3_SUCCESS) {
|
||||||
|
@ -233,11 +233,13 @@ int mfCheckKeys(uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keyc
|
||||||
bool found;
|
bool found;
|
||||||
} PACKED;
|
} PACKED;
|
||||||
struct kr *keyresult = (struct kr *)&resp.data.asBytes;
|
struct kr *keyresult = (struct kr *)&resp.data.asBytes;
|
||||||
if (!keyresult->found) {
|
if (keyresult->found == false) {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
*key = bytes_to_num(keyresult->key, sizeof(keyresult->key));
|
if (key) {
|
||||||
|
*key = bytes_to_num(keyresult->key, sizeof(keyresult->key));
|
||||||
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,9 @@ uint32_t uart_get_timeouts(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uart_reconfigure_timeouts_polling(serial_port sp) {
|
static int uart_reconfigure_timeouts_polling(serial_port sp) {
|
||||||
if (newtimeout_pending == false)
|
if (newtimeout_pending == false) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
}
|
||||||
newtimeout_pending = false;
|
newtimeout_pending = false;
|
||||||
|
|
||||||
serial_port_windows_t *spw = (serial_port_windows_t *)sp;
|
serial_port_windows_t *spw = (serial_port_windows_t *)sp;
|
||||||
|
|
|
@ -131,17 +131,18 @@ bool Encrypt(uint8_t *src, uint8_t *dest) {
|
||||||
|
|
||||||
// Call with block6
|
// Call with block6
|
||||||
void DecodeBlock6(uint8_t *src) {
|
void DecodeBlock6(uint8_t *src) {
|
||||||
int resp_len = 0;
|
|
||||||
uint8_t resp[254] = {0};
|
|
||||||
|
|
||||||
uint8_t c[] = {0x96, CARD_INS_DECODE, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
uint8_t c[] = {0x96, CARD_INS_DECODE, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
memcpy(c + 6, src, 8);
|
memcpy(c + 6, src, 8);
|
||||||
|
|
||||||
|
int resp_len = 0;
|
||||||
|
uint8_t resp[254] = {0};
|
||||||
|
|
||||||
// first part
|
// first part
|
||||||
ExchangeAPDUSC(false, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len);
|
ExchangeAPDUSC(false, c, sizeof(c), false, true, resp, sizeof(resp), &resp_len);
|
||||||
|
|
||||||
|
|
||||||
if (resp_len < 11) {
|
if (resp_len < 11) {
|
||||||
|
PrintAndLogEx(DEBUG, "decodeblock6, wrong response len, expected 11 got ( " _RED_("%d") " )", resp_len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,10 +152,11 @@ void DecodeBlock6(uint8_t *src) {
|
||||||
c[5] = 0x02;
|
c[5] = 0x02;
|
||||||
ExchangeAPDUSC(false, c, sizeof(c), false, false, resp, sizeof(resp), &resp_len);
|
ExchangeAPDUSC(false, c, sizeof(c), false, false, resp, sizeof(resp), &resp_len);
|
||||||
|
|
||||||
|
|
||||||
if (resp_len < 11) {
|
if (resp_len < 11) {
|
||||||
|
PrintAndLogEx(DEBUG, "decodeblock6, wrong response len, expected 11 got ( " _RED_("%d") " )", resp_len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "%.*s", resp_len - 11, resp + 9);
|
PrintAndLogEx(SUCCESS, "%.*s", resp_len - 11, resp + 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +168,6 @@ uint8_t GetNumberBlocksForUserId(uint8_t *src) {
|
||||||
memcpy(c + 5, src, 8);
|
memcpy(c + 5, src, 8);
|
||||||
ExchangeAPDUSC(false, c, sizeof(c), false, false, resp, sizeof(resp), &resp_len);
|
ExchangeAPDUSC(false, c, sizeof(c), false, false, resp, sizeof(resp), &resp_len);
|
||||||
|
|
||||||
|
|
||||||
if (resp_len < 8) {
|
if (resp_len < 8) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -192,8 +193,9 @@ uint8_t GetPinSize(uint8_t *src) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetConfigCardByIdx(uint8_t typ, uint8_t *blocks) {
|
int GetConfigCardByIdx(uint8_t typ, uint8_t *blocks) {
|
||||||
if (blocks == NULL)
|
if (blocks == NULL) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
int resp_len = 0;
|
int resp_len = 0;
|
||||||
uint8_t resp[254] = {0};
|
uint8_t resp[254] = {0};
|
||||||
|
@ -212,8 +214,9 @@ int GetConfigCardByIdx(uint8_t typ, uint8_t *blocks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetConfigCardStrByIdx(uint8_t typ, uint8_t *out) {
|
int GetConfigCardStrByIdx(uint8_t typ, uint8_t *out) {
|
||||||
if (out == NULL)
|
if (out == NULL) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
int resp_len = 0;
|
int resp_len = 0;
|
||||||
uint8_t resp[254] = {0};
|
uint8_t resp[254] = {0};
|
||||||
|
@ -232,8 +235,9 @@ int GetConfigCardStrByIdx(uint8_t typ, uint8_t *out) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerifyRdv4Signature(uint8_t *memid, uint8_t *signature) {
|
int VerifyRdv4Signature(uint8_t *memid, uint8_t *signature) {
|
||||||
if (memid == NULL || signature == NULL)
|
if (memid == NULL || signature == NULL) {
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
|
}
|
||||||
|
|
||||||
int resp_len = 0;
|
int resp_len = 0;
|
||||||
uint8_t resp[254] = {0};
|
uint8_t resp[254] = {0};
|
||||||
|
|
|
@ -152,7 +152,9 @@ void computeSignalProperties(const uint8_t *samples, uint32_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeSignalOffset(uint8_t *samples, uint32_t size) {
|
void removeSignalOffset(uint8_t *samples, uint32_t size) {
|
||||||
if (samples == NULL || size < SIGNAL_MIN_SAMPLES) return;
|
if (samples == NULL || size < SIGNAL_MIN_SAMPLES) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int acc_off = 0;
|
int acc_off = 0;
|
||||||
uint32_t offset_size = size - SIGNAL_IGNORE_FIRST_SAMPLES;
|
uint32_t offset_size = size - SIGNAL_IGNORE_FIRST_SAMPLES;
|
||||||
|
@ -458,7 +460,14 @@ static size_t findModStart(const uint8_t *src, size_t size, uint8_t expWaveSize)
|
||||||
} else {
|
} else {
|
||||||
waveSizeCnt++;
|
waveSizeCnt++;
|
||||||
}
|
}
|
||||||
if (thresholdCnt > 10) break;
|
|
||||||
|
if (thresholdCnt > 10) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_debugMode == 2) {
|
||||||
|
prnt("DEBUG: threshold Count reached at index %zu, count: %u", i, thresholdCnt);
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue