This commit is contained in:
iceman1001 2024-05-14 10:04:28 +02:00
parent 72a11cfd89
commit 42f0699c78
17 changed files with 256 additions and 167 deletions

View file

@ -290,7 +290,7 @@ static uint8_t felica_select_card(felica_card_select_t *card) {
Dbhexdump(FelicaFrame.len, FelicaFrame.framebytes, 0);
}
}
// 0. OK
// 0. OK
return 0;
}
@ -589,7 +589,7 @@ void felica_sendraw(const PacketCommandNG *c) {
AddCrc(buf + 2, len);
}
}
if (g_dbglevel >= DBG_DEBUG) {
Dbprintf("Transmit Frame (no CRC shown):");
Dbhexdump(len, buf, 0);

View file

@ -2718,7 +2718,7 @@ int ht2_tx_rx(uint8_t *tx, size_t txlen, uint8_t *rx, size_t *rxlen, bool ledcon
res = PM3_SUCCESS;
out:
out:
if (keep_field_up == false) {
lf_finalize(false);
}

View file

@ -168,7 +168,7 @@ static bool hitag2crack_test_e_p0cmd(uint8_t *keybits, uint8_t *nrar, uint8_t *e
// send extended encrypted cmd
uint8_t resp[4] = {0};
if (hitag2crack_send_e_cmd(resp, nrar, e_ext_cmd, 40)) {
// test if it was valid
if (memcmp(resp, ERROR_RESPONSE, 4)) {
return true;
@ -324,10 +324,10 @@ static bool ht2crack_consume_keystream(lf_hitag_crack2_t *c2, int kslen, int *ks
DbpString("ht2crack_consume_keystream: conlen < 10");
return false;
}
// calculate how many repeated commands to send in this extended command.
int numcmds = conlen / 10;
// xor extended cmd with keybits
hitag2crack_xor(c2->e_ext_cmd, c2->ext_cmd, c2->keybits + *ksoffset, (numcmds * 10));
@ -338,7 +338,7 @@ static bool ht2crack_consume_keystream(lf_hitag_crack2_t *c2, int kslen, int *ks
Dbprintf("ht2crack_consume_keystream: tx/rx cmd failed, got %zu", n);
return false;
}
// test response
if (memcmp(resp, ERROR_RESPONSE, 4) == 0) {
DbpString("ht2crack_consume_keystream: got error response from card");
@ -346,7 +346,7 @@ static bool ht2crack_consume_keystream(lf_hitag_crack2_t *c2, int kslen, int *ks
}
// dont bother decrypting the response - we already know the keybits
// update ksoffset with command length and response
*ksoffset += (numcmds * 10) + 32;
@ -363,14 +363,14 @@ static bool ht2crack_consume_keystream(lf_hitag_crack2_t *c2, int kslen, int *ks
//static bool ht2crack_extend_keystream(uint8_t *keybits, int *kslen, int ksoffset, uint8_t *nrar, uint8_t *uid) {
/*
static bool ht2crack_extend_keystream(lf_hitag_crack2_t *c2, int *kslen, int ksoffset) {
// calc number of command iterations to send
int cmdlen = *kslen - ksoffset;
if (cmdlen < 10) {
DbpString("extend_keystream: cmdlen < 10");
return false;
}
int numcmds = cmdlen / 10;
// xor extended cmd with keybits
@ -388,7 +388,7 @@ static bool ht2crack_extend_keystream(lf_hitag_crack2_t *c2, int *kslen, int kso
// test response
if (memcmp(resp, ERROR_RESPONSE, 4) == 0) {
return false;
}
}
// convert response to binarray
uint8_t e_response[32];
@ -399,7 +399,7 @@ static bool ht2crack_extend_keystream(lf_hitag_crack2_t *c2, int *kslen, int kso
// update kslen
*kslen = ksoffset + (numcmds * 10) + 32;
return true;
}
*/
@ -469,8 +469,8 @@ out:
void ht2_crack2(uint8_t *nrar_hex) {
lf_hitag_crack2_t *c2 = (lf_hitag_crack2_t*)BigBuf_calloc(sizeof(lf_hitag_crack2_t));
lf_hitag_crack_response_t *packet = (lf_hitag_crack_response_t*)BigBuf_calloc(sizeof(lf_hitag_crack_response_t));
lf_hitag_crack2_t *c2 = (lf_hitag_crack2_t *)BigBuf_calloc(sizeof(lf_hitag_crack2_t));
lf_hitag_crack_response_t *packet = (lf_hitag_crack_response_t *)BigBuf_calloc(sizeof(lf_hitag_crack_response_t));
g_logging = false;
LEDsoff();
@ -537,7 +537,7 @@ void ht2_crack2(uint8_t *nrar_hex) {
}
// while we have at least 52 bits of keystream, consume it with
// extended read page 0 commands.
// extended read page 0 commands.
// 52 = 10 (min command len) + 32 (response) + 10 (min command len we'll send)
/*
while ((kslen - ksoffset) >= 52) {
@ -549,7 +549,7 @@ void ht2_crack2(uint8_t *nrar_hex) {
goto out;
}
}
// send an extended command to retrieve more keystream,
// send an extended command to retrieve more keystream,
// updating kslen as we go
if (ht2crack_extend_keystream(c2, &kslen, ksoffset) == false) {
DbpString("ht2crack_extend_keystream failed");
@ -576,7 +576,7 @@ void ht2_crack2(uint8_t *nrar_hex) {
// convert response to binarray
uint8_t e_response[32];
hex2binarray((char*)e_response, (char*)resp);
hex2binarray((char *)e_response, (char *)resp);
// recover keystream from encrypted response
hitag2crack_xor(c2->keybits + kslen + 40, e_response, c2->uid, 32);
@ -587,13 +587,13 @@ void ht2_crack2(uint8_t *nrar_hex) {
Dbprintf("Recovered " _YELLOW_("%i") " bits of keystream", kslen);
}
/*
uint8_t *keybitshex = BigBuf_calloc(64);
for (int i = 0; i < 2048; i += 256) {
binarray2hex(c2->keybits + i, 256, keybitshex);
Dbhexdump(256, keybitshex, false);
}
*/
/*
uint8_t *keybitshex = BigBuf_calloc(64);
for (int i = 0; i < 2048; i += 256) {
binarray2hex(c2->keybits + i, 256, keybitshex);
Dbhexdump(256, keybitshex, false);
}
*/
BigBuf_free();
// copy UID since we already have it...
@ -602,14 +602,14 @@ void ht2_crack2(uint8_t *nrar_hex) {
out:
/*
DbpString("keybits:");
Dbhexdump(2080, c2->keybits, false);
DbpString("uid:");
Dbhexdump(32, c2->uid, false);
DbpString("nrar:");
Dbhexdump(64, c2->nrar, false);
*/
/*
DbpString("keybits:");
Dbhexdump(2080, c2->keybits, false);
DbpString("uid:");
Dbhexdump(32, c2->uid, false);
DbpString("nrar:");
Dbhexdump(64, c2->nrar, false);
*/
reply_ng(CMD_LF_HITAG2_CRACK_2, res, (uint8_t *)packet, sizeof(lf_hitag_crack_response_t));
}

View file

@ -3670,8 +3670,8 @@ static int CmdXor(const char *Cmd) {
static int CmdTestSaveState8(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data test_ss8",
"Tests the implementation of Buffer Save States (8-bit buffer)",
"data test_ss8");
"Tests the implementation of Buffer Save States (8-bit buffer)",
"data test_ss8");
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -3682,10 +3682,10 @@ static int CmdTestSaveState8(const char *Cmd) {
srand(time(NULL));
size_t length = 64;
uint8_t *srcBuffer = (uint8_t*)calloc(length, sizeof(uint8_t));
uint8_t *srcBuffer = (uint8_t *)calloc(length, sizeof(uint8_t));
//Set up the source buffer with random data
for(int i = 0; i < length; i++) {
for (int i = 0; i < length; i++) {
srcBuffer[i] = (rand() % 256);
}
@ -3696,10 +3696,10 @@ static int CmdTestSaveState8(const char *Cmd) {
test8.offset = rand();
PrintAndLogEx(DEBUG, "Save State clock=%u, offset=%u", test8.clock, test8.offset);
uint8_t *destBuffer = (uint8_t*)calloc(length, sizeof(uint8_t));
uint8_t *destBuffer = (uint8_t *)calloc(length, sizeof(uint8_t));
size_t returnedLength = restore_buffer8(test8, destBuffer);
if(returnedLength != length) {
if (returnedLength != length) {
PrintAndLogEx(FAILED, "Return Length != Buffer Length! Expected '%llu', got '%llu", g_DemodBufferLen, returnedLength);
free(srcBuffer);
free(destBuffer);
@ -3707,8 +3707,8 @@ static int CmdTestSaveState8(const char *Cmd) {
}
PrintAndLogEx(DEBUG, _GREEN_("Lengths match!") "\n");
for(size_t i = 0; i < length; i++) {
if(srcBuffer[i] != destBuffer[i]) {
for (size_t i = 0; i < length; i++) {
if (srcBuffer[i] != destBuffer[i]) {
PrintAndLogEx(FAILED, "Buffers don't match at index %lu!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
free(srcBuffer);
free(destBuffer);
@ -3726,8 +3726,8 @@ static int CmdTestSaveState8(const char *Cmd) {
static int CmdTestSaveState32(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data test_ss32",
"Tests the implementation of Buffer Save States (32-bit buffer)",
"data test_ss32");
"Tests the implementation of Buffer Save States (32-bit buffer)",
"data test_ss32");
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -3738,10 +3738,10 @@ static int CmdTestSaveState32(const char *Cmd) {
srand(time(NULL));
size_t length = 64;
uint32_t *srcBuffer = (uint32_t*)calloc(length, sizeof(uint32_t));
uint32_t *srcBuffer = (uint32_t *)calloc(length, sizeof(uint32_t));
//Set up the source buffer with random data
for(size_t i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
srcBuffer[i] = (rand());
}
@ -3752,10 +3752,10 @@ static int CmdTestSaveState32(const char *Cmd) {
test32.offset = rand();
PrintAndLogEx(DEBUG, "Save State clock=%u, offset=%u", test32.clock, test32.offset);
uint32_t *destBuffer = (uint32_t*)calloc(length, sizeof(uint32_t));
uint32_t *destBuffer = (uint32_t *)calloc(length, sizeof(uint32_t));
size_t returnedLength = restore_buffer32(test32, destBuffer);
if(returnedLength != length) {
if (returnedLength != length) {
PrintAndLogEx(FAILED, "Return Length != Buffer Length! Expected '%llu', got '%llu", g_DemodBufferLen, returnedLength);
free(srcBuffer);
free(destBuffer);
@ -3763,8 +3763,8 @@ static int CmdTestSaveState32(const char *Cmd) {
}
PrintAndLogEx(DEBUG, _GREEN_("Lengths match!") "\n");
for(size_t i = 0; i < length; i++) {
if(srcBuffer[i] != destBuffer[i]) {
for (size_t i = 0; i < length; i++) {
if (srcBuffer[i] != destBuffer[i]) {
PrintAndLogEx(FAILED, "Buffers don't match at index %lu!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
free(srcBuffer);
free(destBuffer);
@ -3782,8 +3782,8 @@ static int CmdTestSaveState32(const char *Cmd) {
static int CmdTestSaveState32S(const char *Cmd) {
CLIParserContext *ctx;
CLIParserInit(&ctx, "data test_ss32s",
"Tests the implementation of Buffer Save States (32-bit signed buffer)",
"data test_ss32s");
"Tests the implementation of Buffer Save States (32-bit signed buffer)",
"data test_ss32s");
void *argtable[] = {
arg_param_begin,
arg_param_end
@ -3794,10 +3794,10 @@ static int CmdTestSaveState32S(const char *Cmd) {
srand(time(NULL));
size_t length = 64;
int32_t *srcBuffer = (int32_t*)calloc(length, sizeof(int32_t));
int32_t *srcBuffer = (int32_t *)calloc(length, sizeof(int32_t));
//Set up the source buffer with random data
for(int i = 0; i < length; i++) {
for (int i = 0; i < length; i++) {
srcBuffer[i] = (rand() - 4294967296);
}
@ -3808,10 +3808,10 @@ static int CmdTestSaveState32S(const char *Cmd) {
test32.offset = rand();
PrintAndLogEx(DEBUG, "Save State clock=%u, offset=%u", test32.clock, test32.offset);
int32_t *destBuffer = (int32_t*)calloc(length, sizeof(int32_t));
int32_t *destBuffer = (int32_t *)calloc(length, sizeof(int32_t));
size_t returnedLength = restore_bufferS32(test32, destBuffer);
if(returnedLength != length) {
if (returnedLength != length) {
PrintAndLogEx(FAILED, "Return Length != Buffer Length! Expected '%llu', got '%llu", g_DemodBufferLen, returnedLength);
free(srcBuffer);
free(destBuffer);
@ -3819,8 +3819,8 @@ static int CmdTestSaveState32S(const char *Cmd) {
}
PrintAndLogEx(DEBUG, _GREEN_("Lengths match!") "\n");
for(int i = 0; i < length; i++) {
if(srcBuffer[i] != destBuffer[i]) {
for (int i = 0; i < length; i++) {
if (srcBuffer[i] != destBuffer[i]) {
PrintAndLogEx(FAILED, "Buffers don't match at index %i!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
free(srcBuffer);
free(destBuffer);

View file

@ -2452,9 +2452,9 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
get_compact_tlv(card.ats + pos, calen);
} else {
PrintAndLogEx(SUCCESS, "%s - %s"
, sprint_hex_inrow(card.ats + pos, calen)
, sprint_ascii(card.ats + pos, calen)
);
, sprint_hex_inrow(card.ats + pos, calen)
, sprint_ascii(card.ats + pos, calen)
);
}
PrintAndLogEx(NORMAL, "");

View file

@ -403,7 +403,7 @@ uint8_t *get_uid_from_filename(const char *filename) {
}
// extract uid part from filename
char uidinhex[17] = {0};
char uidinhex[17] = {0};
strncpy(uidinhex, found + 7, 16);
uidinhex[16] = '\0';
@ -2486,16 +2486,16 @@ static int CmdHF14BAPDU(const char *Cmd) {
uint16_t sw = get_sw(data, datalen);
if (sw != ISO7816_OK) {
PrintAndLogEx(SUCCESS, "APDU response: " _YELLOW_("%02x %02x") " - %s"
, data[datalen - 2]
, data[datalen - 1]
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
);
, data[datalen - 2]
, data[datalen - 1]
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
);
} else {
PrintAndLogEx(SUCCESS, "APDU response: " _GREEN_("%02x %02x") " - %s"
, data[datalen - 2]
, data[datalen - 1]
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
);
, data[datalen - 2]
, data[datalen - 1]
, GetAPDUCodeDescription(data[datalen - 2], data[datalen - 1])
);
}
// TLV decoder
@ -2708,30 +2708,30 @@ static int CmdHF14BCalypsoRead(const char *Cmd) {
{"19.SpecEv1", "\x94\xb2\x01\x04\x1d", 5},
};
/*
local CLA = '94'
local _calypso_cmds = {
/*
local CLA = '94'
local _calypso_cmds = {
-- Break down of command bytes:
-- A4 = select
-- Master File 3F00
-- 0x3F = master file
-- 0x00 = master file id, is constant to 0x00.
-- Break down of command bytes:
-- A4 = select
-- Master File 3F00
-- 0x3F = master file
-- 0x00 = master file id, is constant to 0x00.
-- DF Dedicated File 38nn
-- can be seen as directories
-- 0x38
-- 0xNN id
-- ["01.Select ICC file"] = '0294 a4 080004 3f00 0002',
-- DF Dedicated File 38nn
-- can be seen as directories
-- 0x38
-- 0xNN id
-- ["01.Select ICC file"] = '0294 a4 080004 3f00 0002',
-- EF Elementary File
-- EF1 Pin file
-- EF2 Key file
-- Grey Lock file
-- Electronic deposit file
-- Electronic Purse file
-- Electronic Transaction log file
*/
-- EF Elementary File
-- EF1 Pin file
-- EF2 Key file
-- Grey Lock file
-- Electronic deposit file
-- Electronic Purse file
-- Electronic Transaction log file
*/
bool activate_field = true;
bool leave_signal_on = true;
uint8_t response[PM3_CMD_DATA_SIZE] = { 0x00 };
@ -2741,15 +2741,15 @@ local _calypso_cmds = {
int user_timeout = -1;
int resplen = 0;
int res = exchange_14b_apdu(
(uint8_t*)cmds[i].apdu,
cmds[i].apdulen,
activate_field,
leave_signal_on,
response,
PM3_CMD_DATA_SIZE,
&resplen,
user_timeout
);
(uint8_t *)cmds[i].apdu,
cmds[i].apdulen,
activate_field,
leave_signal_on,
response,
PM3_CMD_DATA_SIZE,
&resplen,
user_timeout
);
if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "sending command failed, aborting!");
@ -2846,15 +2846,15 @@ static int CmdHF14BMobibRead(const char *Cmd) {
int user_timeout = -1;
int resplen = 0;
int res = exchange_14b_apdu(
(uint8_t*)cmds[i].apdu,
cmds[i].apdulen,
activate_field,
leave_signal_on,
response,
PM3_CMD_DATA_SIZE,
&resplen,
user_timeout
);
(uint8_t *)cmds[i].apdu,
cmds[i].apdulen,
activate_field,
leave_signal_on,
response,
PM3_CMD_DATA_SIZE,
&resplen,
user_timeout
);
if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "sending command failed, aborting!");

View file

@ -130,15 +130,15 @@ static const productName_t uidmapping[] = {
{ 0xe002480000000000LL, 24, "ST Microelectronics; ST25TV16K"},
{ 0xe002480000000000LL, 24, "ST Microelectronics; ST25TV64K"},
/*
ST25TV02K 0xe0 02 23
ST25TV512 0xe0 02 23
ST25TV02KC 0xe00208
ST25TV512C 0xe00208
ST25TV04K-P 0xe00235
ST25TV16K 0xe00248
ST25TV64K 0xe00248
*/
/*
ST25TV02K 0xe0 02 23
ST25TV512 0xe0 02 23
ST25TV02KC 0xe00208
ST25TV512C 0xe00208
ST25TV04K-P 0xe00235
ST25TV16K 0xe00248
ST25TV64K 0xe00248
*/
{ 0xE003000000000000LL, 16, "Hitachi, Ltd Japan" },
@ -480,7 +480,7 @@ static int iso15_error_handling_card_response(uint8_t *d, uint16_t n) {
return PM3_ECRC;
}
if ( (d[0] & ISO15_RES_ERROR) == ISO15_RES_ERROR ) {
if ((d[0] & ISO15_RES_ERROR) == ISO15_RES_ERROR) {
if (d[1] == 0x0F || d[1] == 0x10) {
return PM3_EOUTOFBOUND;
}
@ -1911,7 +1911,7 @@ static int CmdHF15Dump(const char *Cmd) {
uint8_t dCpt = 10;
int res = iso15_error_handling_card_response(d, resp.length);
if ( res != PM3_SUCCESS ) {
if (res != PM3_SUCCESS) {
free(tag);
free(packet);
return res;

View file

@ -4858,10 +4858,10 @@ static int DesfileReadFileAndPrint(DesfireContext_t *dctx,
if (verbose) {
PrintAndLogEx(INFO, _CYAN_("File type:") " %s Option: %s comm mode: %s",
GetDesfireFileType(fsettings.fileType),
CLIGetOptionListStr(DesfireReadFileTypeOpts, filetype),
CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode)
);
GetDesfireFileType(fsettings.fileType),
CLIGetOptionListStr(DesfireReadFileTypeOpts, filetype),
CLIGetOptionListStr(DesfireCommunicationModeOpts, fsettings.commMode)
);
}
} else {
PrintAndLogEx(WARNING, "GetFileSettings error. Can't get file type.");

View file

@ -42,7 +42,7 @@ const char *get_st_chip_model(uint8_t pc) {
return "SRT512";
case 0xC4:
return "ST25TA64K";
case 0xC5:
case 0xC5:
return "ST25TA16K";
case 0xE2:
return "ST25??? IKEA Rothult";

View file

@ -190,13 +190,13 @@ static int print_st25ta_signature(uint8_t *uid, uint8_t *signature) {
}
static int st25ta_get_signature(uint8_t *signature) {
/*
/*
hf 14a raw -sck 0200A4040007D276000085010100
hf 14a raw -ck 0300A4000C020001
hf 14a raw -c 02a2b000e020
*/
*/
typedef struct {
const char* apdu;
const char *apdu;
uint8_t apdulen;
} transport_st25a_apdu_t;
@ -211,7 +211,7 @@ static int st25ta_get_signature(uint8_t *signature) {
bool activate_field = true;
for (uint8_t i = 0; i < ARRAYLEN(cmds); i++) {
int res = ExchangeAPDU14a( (uint8_t*)cmds[i].apdu, cmds[i].apdulen, activate_field, true, resp, sizeof(resp), &resplen);
int res = ExchangeAPDU14a((uint8_t *)cmds[i].apdu, cmds[i].apdulen, activate_field, true, resp, sizeof(resp), &resplen);
if (res != PM3_SUCCESS) {
DropField();
return res;

View file

@ -1587,7 +1587,7 @@ out:
restore_bufferS32(saveState_gb, g_GraphBuffer);
g_GridOffset = saveState_gb.offset;
return retval;
}

View file

@ -1107,7 +1107,7 @@ static int CmdEM4x70AutoRecover_ParseArgs(const char *Cmd, em4x70_cmd_input_reco
,
"lf em 4x70 autorecover --rnd 45F54ADA252AAC --frn 4866BB70 --grn 9BD180 (pm3 test key)\n"
"lf em 4x70 autorecover --rnd 3FFE1FB6CC513F --frn F355F1A0 --grn 609D60 (research paper key)\n"
"lf em 4x70 autorecover --rnd 7D5167003571F8 --frn 982DBCC0 --grn 36C0E0 (autorecovery test key)\n"
"lf em 4x70 autorecover --rnd 7D5167003571F8 --frn 982DBCC0 --grn 36C0E0 (autorecovery test key)\n"
);
void *argtable[] = {

View file

@ -127,7 +127,7 @@ size_t getFromGraphBuffer(uint8_t *dest) {
}
size_t getFromGraphBufferEx(uint8_t *dest, size_t maxLen) {
if (dest == NULL){
if (dest == NULL) {
return 0;
}
@ -511,7 +511,7 @@ void remove_temporary_markers(void) {
buffer_savestate_t save_buffer32(uint32_t *src, size_t length) {
//calloc the memory needed
uint32_t* savedBuffer = (uint32_t*)calloc(length, sizeof(uint32_t));
uint32_t *savedBuffer = (uint32_t *)calloc(length, sizeof(uint32_t));
//Make a copy of the source buffer
memcpy(savedBuffer, src, (length * sizeof(uint32_t)));
@ -527,7 +527,7 @@ buffer_savestate_t save_buffer32(uint32_t *src, size_t length) {
buffer_savestate_t save_bufferS32(int32_t *src, size_t length) {
//calloc the memory needed
uint32_t* savedBuffer = (uint32_t*)calloc(length, (sizeof(uint32_t)));
uint32_t *savedBuffer = (uint32_t *)calloc(length, (sizeof(uint32_t)));
//Make a copy of the source buffer
memcpy(savedBuffer, src, (length * sizeof(uint32_t)));
@ -552,15 +552,15 @@ buffer_savestate_t save_buffer8(uint8_t *src, size_t length) {
}
// calloc the memory needed
uint32_t* savedBuffer = (uint32_t*)calloc(buffSize, sizeof(uint32_t));
uint32_t *savedBuffer = (uint32_t *)calloc(buffSize, sizeof(uint32_t));
size_t index = 0;
// Pack the source array into the backing array
for(size_t i = 0; i < length; i += 4) {
for (size_t i = 0; i < length; i += 4) {
savedBuffer[index] = MemLeToUint4byte(src + i);
index++;
}
buffer_savestate_t bst = {
.type = sizeof(uint8_t),
.bufferSize = buffSize,
@ -571,7 +571,7 @@ buffer_savestate_t save_buffer8(uint8_t *src, size_t length) {
}
size_t restore_buffer32(buffer_savestate_t saveState, uint32_t *dest) {
if(saveState.type != sizeof(uint32_t)) {
if (saveState.type != sizeof(uint32_t)) {
PrintAndLogEx(WARNING, "Invalid Save State type! Expected uint32_t!");
PrintAndLogEx(WARNING, "Buffer not modified!\n");
return 0;
@ -583,7 +583,7 @@ size_t restore_buffer32(buffer_savestate_t saveState, uint32_t *dest) {
}
size_t restore_bufferS32(buffer_savestate_t saveState, int32_t *dest) {
if(saveState.type != (sizeof(int32_t) >> 8)) {
if (saveState.type != (sizeof(int32_t) >> 8)) {
PrintAndLogEx(WARNING, "Invalid Save State type! Expected int32_t");
PrintAndLogEx(WARNING, "Buffer not modified!\n");
return 0;
@ -595,7 +595,7 @@ size_t restore_bufferS32(buffer_savestate_t saveState, int32_t *dest) {
}
size_t restore_buffer8(buffer_savestate_t saveState, uint8_t *dest) {
if(saveState.type != sizeof(uint8_t)) {
if (saveState.type != sizeof(uint8_t)) {
PrintAndLogEx(WARNING, "Invalid Save State type! Expected uint8_t!");
PrintAndLogEx(WARNING, "Buffer not modified!\n");
return 0;
@ -604,7 +604,7 @@ size_t restore_buffer8(buffer_savestate_t saveState, uint8_t *dest) {
size_t index = 0;
// Unpack the array
for(size_t i = 0; i < saveState.bufferSize; i++) {
for (size_t i = 0; i < saveState.bufferSize; i++) {
dest[index++] = saveState.buffer[i];
dest[index++] = (saveState.buffer[i] >> 8) & 0xFF;
dest[index++] = (saveState.buffer[i] >> 16) & 0xFF;

View file

@ -118,6 +118,9 @@ const static vocabulary_t vocabulary[] = {
{ 1, "data diff" },
{ 0, "data hexsamples" },
{ 0, "data samples" },
{ 0, "data test_ss8" },
{ 0, "data test_ss32" },
{ 0, "data test_ss32s" },
{ 1, "emv help" },
{ 1, "emv list" },
{ 1, "emv test" },
@ -170,6 +173,8 @@ const static vocabulary_t vocabulary[] = {
{ 0, "hf 14b wrbl" },
{ 1, "hf 14b view" },
{ 1, "hf 14b valid" },
{ 0, "hf 14b calypso" },
{ 0, "hf 14b mobib" },
{ 1, "hf 15 help" },
{ 1, "hf 15 list" },
{ 1, "hf 15 demod" },
@ -645,7 +650,7 @@ const static vocabulary_t vocabulary[] = {
{ 1, "lf hitag help" },
{ 1, "lf hitag list" },
{ 0, "lf hitag info" },
{ 1, "lf hitag selftest" },
{ 1, "lf hitag test" },
{ 0, "lf hitag dump" },
{ 0, "lf hitag read" },
{ 0, "lf hitag sniff" },
@ -655,6 +660,7 @@ const static vocabulary_t vocabulary[] = {
{ 0, "lf hitag eview" },
{ 0, "lf hitag sim" },
{ 0, "lf hitag cc" },
{ 0, "lf hitag crack2" },
{ 0, "lf hitag chk" },
{ 1, "lf hitag lookup" },
{ 0, "lf hitag ta" },

View file

@ -1270,14 +1270,14 @@ void Plot::mouseMoveEvent(QMouseEvent *event) {
int x = event->x();
//Only run the marker place code if a mouse button is pressed
if((event->buttons() & Qt::LeftButton) || (event->buttons() & Qt::RightButton)) {
if ((event->buttons() & Qt::LeftButton) || (event->buttons() & Qt::RightButton)) {
x -= WIDTH_AXES;
x = (int)(x / g_GraphPixelsPerPoint);
x += g_GraphStart;
if(x > (int)g_GraphTraceLen) x = 0; // Set to 0 if the number is stupidly big
else if(x < (int)g_GraphStart) x = (int)g_GraphStart; // Bounds checking for the start of the Graph Window
else if(x > (int)g_GraphStop) x = (int)g_GraphStop; // Bounds checking for the end of the Graph Window
if (x > (int)g_GraphTraceLen) x = 0; // Set to 0 if the number is stupidly big
else if (x < (int)g_GraphStart) x = (int)g_GraphStart; // Bounds checking for the start of the Graph Window
else if (x > (int)g_GraphStop) x = (int)g_GraphStop; // Bounds checking for the end of the Graph Window
if ((event->buttons() & Qt::LeftButton)) { // True for left click, false otherwise
g_MarkerA.pos = x;

View file

@ -720,7 +720,7 @@
"-h, --help This help",
"--keep keep the current values of the markers",
"-a <dec> yellow marker",
"-b <dec> pink marker",
"-b <dec> purple marker",
"-c <dec> orange marker",
"-d <dec> blue marker"
],
@ -740,6 +740,42 @@
],
"usage": "data shiftgraphzero [-h] -n <dec>"
},
"data test_ss32": {
"command": "data test_ss32",
"description": "Tests the implementation of Buffer Save States (32-bit buffer)",
"notes": [
"data test_ss32"
],
"offline": false,
"options": [
"-h, --help This help"
],
"usage": "data test_ss32 [-h]"
},
"data test_ss32s": {
"command": "data test_ss32s",
"description": "Tests the implementation of Buffer Save States (32-bit signed buffer)",
"notes": [
"data test_ss32s"
],
"offline": false,
"options": [
"-h, --help This help"
],
"usage": "data test_ss32s [-h]"
},
"data test_ss8": {
"command": "data test_ss8",
"description": "Tests the implementation of Buffer Save States (8-bit buffer)",
"notes": [
"data test_ss8"
],
"offline": false,
"options": [
"-h, --help This help"
],
"usage": "data test_ss8 [-h]"
},
"data timescale": {
"command": "data timescale",
"description": "Set cursor display timescale. Setting the timescale makes the differential `dt` reading between the yellow and purple markers meaningful. once the timescale is set, the differential reading between brackets can become a time duration.",
@ -1386,6 +1422,18 @@
],
"usage": "hf 14b apdu [-hskte] [--decode] [-m <hex>] [-l <int>] -d <hex> [--timeout <dec>]"
},
"hf 14b calypso": {
"command": "hf 14b calypso",
"description": "Reads out the contents of a ISO14443B Calypso card",
"notes": [
"hf 14b calypso"
],
"offline": false,
"options": [
"-h, --help This help"
],
"usage": "hf 14b calypso [-h]"
},
"hf 14b dump": {
"command": "hf 14b dump",
"description": "This command dumps the contents of a ISO-14443-B tag and save it to file Tries to autodetect cardtype, memory size defaults to SRI4K",
@ -1404,7 +1452,7 @@
},
"hf 14b help": {
"command": "hf 14b help",
"description": "--------- ----------------------- General ----------------------- help This help list List ISO-14443-B history --------- ----------------------- Operations ----------------------- view Display content from tag dump file valid SRIX4 checksum test --------------------------------------------------------------------------------------- hf 14b list available offline: yes Alias of `trace list -t 14b -c` with selected protocol data to annotate trace buffer You can load a trace from file (see `trace load -h`) or it be downloaded from device by default It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol",
"description": "--------- ----------------------- General ----------------------- help This help list List ISO-14443-B history --------- ----------------------- Operations ----------------------- view Display content from tag dump file valid SRIX4 checksum test --------- ------------------ Calypso / Mobib ------------------ --------------------------------------------------------------------------------------- hf 14b list available offline: yes Alias of `trace list -t 14b -c` with selected protocol data to annotate trace buffer You can load a trace from file (see `trace load -h`) or it be downloaded from device by default It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol",
"notes": [
"hf 14b list --frame -> show frame delay times",
"hf 14b list -1 -> use trace buffer"
@ -1437,6 +1485,18 @@
],
"usage": "hf 14b info [-hsv]"
},
"hf 14b mobib": {
"command": "hf 14b mobib",
"description": "Reads out the contents of a ISO14443B Mobib card",
"notes": [
"hf 14b mobib"
],
"offline": false,
"options": [
"-h, --help This help"
],
"usage": "hf 14b mobib [-h]"
},
"hf 14b ndefread": {
"command": "hf 14b ndefread",
"description": "Print NFC Data Exchange Format (NDEF)",
@ -1501,10 +1561,11 @@
"offline": false,
"options": [
"-h, --help This help",
"--plot show anticollision signal trace in plot window",
"-v, --verbose verbose output",
"-@ optional - continuous reader mode"
],
"usage": "hf 14b reader [-hv@]"
"usage": "hf 14b reader [-hv@] [--plot]"
},
"hf 14b restore": {
"command": "hf 14b restore",
@ -3102,7 +3163,7 @@
"description": "Checkkeys loads a dictionary text file with 8byte hex keys to test authenticating against a iClass tag",
"notes": [
"hf iclass chk -f iclass_default_keys.dic",
"hf iclass chk -f iclass_default_keys.dic --elite"
"hf iclass chk -f iclass_elite_keys.dic --elite"
],
"offline": false,
"options": [
@ -8925,7 +8986,8 @@
"description": "Authenticate against an EM4x70 by sending random number (RN) and F(RN) If F(RN) is incorrect based on the tag key, the tag will not respond If F(RN) is correct based on the tag key, the tag will give a 20-bit response",
"notes": [
"lf em 4x70 auth --rnd 45F54ADA252AAC --frn 4866BB70 -> (using pm3 test key)",
"lf em 4x70 auth --rnd 3FFE1FB6CC513F --frn F355F1A0 -> (using research paper key)"
"lf em 4x70 auth --rnd 3FFE1FB6CC513F --frn F355F1A0 -> (using research paper key)",
"lf em 4x70 auth --rnd 7D5167003571F8 --frn 982DBCC0 -> (autorecovery test key)"
],
"offline": false,
"options": [
@ -8941,7 +9003,8 @@
"description": "This command will perform automatic recovery of the key from a writable tag. All steps are possible to do manually. The corresponding sequence, if done manually, is as follows: 1. Verify passed parameters authenticate with the tag (safety check) lf em 4x70 auth --rnd <rnd_1> --frn <frn_1> 2. Brute force the key bits in block 9 lf em 4x70 write -b 9 -d 0000 lf em 4x70 recover -b 9 --rnd <rnd_1> --frn <frn_1> lf em 4x70 write -b 9 -d <key_block_9> 3. Brute force the key bits in block 8 lf em 4x70 write -b 8 -d 0000 lf em 4x70 recover -b 8 --rnd <rnd_1> --frn <frn_1> lf em 4x70 write -b 8 -d <key_block_8> 4. Brute force the key bits in block 7 lf em 4x70 write -b 7 -d 0000) lf em 4x70 recover -b 7 --rnd <rnd_1> --frn <frn_1> lf em 4x70 write -b 7 -d <key_block_7> 5. Recover potential values of the lower 48 bits of the key lf em 4x70 recover --key <key_block_9><key_block_8><key_block_7> --rnd <rnd_1> --frn <frn_1> 6. Verify which potential key is actually on the tag (using a different rnd/frn combination) lf em 4x70 auth --rnd <rnd_2> --frn <frn_N> 7. Print the validated key This command simply requires the rnd/frn/grn from a single known-good authentication.",
"notes": [
"lf em 4x70 autorecover --rnd 45F54ADA252AAC --frn 4866BB70 --grn 9BD180 (pm3 test key)",
"lf em 4x70 autorecover --rnd 3FFE1FB6CC513F --frn F355F1A0 --grn 609D60 (research paper key)"
"lf em 4x70 autorecover --rnd 3FFE1FB6CC513F --frn F355F1A0 --grn 609D60 (research paper key)",
"lf em 4x70 autorecover --rnd 7D5167003571F8 --frn 982DBCC0 --grn 36C0E0 (autorecovery test key)"
],
"offline": false,
"options": [
@ -9007,7 +9070,8 @@
"description": "Write new 96-bit key to tag",
"notes": [
"lf em 4x70 setkey -k F32AA98CF5BE4ADFA6D3480B (pm3 test key)",
"lf em 4x70 setkey -k A090A0A02080000000000000 (research paper key)"
"lf em 4x70 setkey -k A090A0A02080000000000000 (research paper key)",
"lf em 4x70 setkey -k 022A028C02BE000102030405 (autorecovery test key)"
],
"offline": false,
"options": [
@ -9443,6 +9507,19 @@
],
"usage": "lf hitag chk [-h] [-f <fn>] [--pwd] [--crypto]"
},
"lf hitag crack2": {
"command": "lf hitag crack2",
"description": "This command tries to recover 2048 bits of Hitag2 crypto stream data.",
"notes": [
"lf hitag crack2 --nrar 73AA5A62EAB8529C"
],
"offline": false,
"options": [
"-h, --help This help",
"--nrar <hex> specify nonce / answer as 8 hex bytes"
],
"usage": "lf hitag lookup [-h] [--nrar <hex>]"
},
"lf hitag dump": {
"command": "lf hitag dump",
"description": "Read all Hitag 2 card memory and save to file Crypto mode key format: ISK high + ISK low, 4F4E4D494B52 (ONMIKR) Password mode, default key 4D494B52 (MIKR)",
@ -9497,7 +9574,7 @@
},
"lf hitag help": {
"command": "lf hitag help",
"description": "help This help list List Hitag trace history selftest Perform self test view Display content from tag dump file lookup Uses authentication trace to check for key in dictionary file --------------------------------------------------------------------------------------- lf hitag list available offline: yes Alias of `trace list -t hitag2` with selected protocol data to annotate trace buffer You can load a trace from file (see `trace load -h`) or it be downloaded from device by default It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol",
"description": "help This help list List Hitag trace history test Perform self tests view Display content from tag dump file lookup Uses authentication trace to check for key in dictionary file --------------------------------------------------------------------------------------- lf hitag list available offline: yes Alias of `trace list -t hitag2` with selected protocol data to annotate trace buffer You can load a trace from file (see `trace load -h`) or it be downloaded from device by default It accepts all other arguments of `trace list`. Note that some might not be relevant for this specific protocol",
"notes": [
"lf hitag list --frame -> show frame delay times",
"lf hitag list -1 -> use trace buffer"
@ -9576,18 +9653,6 @@
],
"usage": "lf hitag read [-hs2] [--pwd] [--nrar <hex>] [--crypto] [-k <hex>]"
},
"lf hitag selftest": {
"command": "lf hitag selftest",
"description": "Perform selftest of Hitag crypto engine",
"notes": [
"lf hitag selftest"
],
"offline": true,
"options": [
"-h, --help This help"
],
"usage": "lf hitag selftest [-h]"
},
"lf hitag sim": {
"command": "lf hitag sim",
"description": "Simulate Hitag transponder You need to `lf hitag eload` first",
@ -9615,6 +9680,18 @@
],
"usage": "lf hitag sniff [-h]"
},
"lf hitag test": {
"command": "lf hitag test",
"description": "Perform self tests of Hitag crypto engine",
"notes": [
"lf hitag test"
],
"offline": true,
"options": [
"-h, --help This help"
],
"usage": "lf hitag test [-h]"
},
"lf hitag view": {
"command": "lf hitag view",
"description": "Print a HITAG dump file (bin/eml/json)",
@ -12622,8 +12699,8 @@
}
},
"metadata": {
"commands_extracted": 729,
"commands_extracted": 735,
"extracted_by": "PM3Help2JSON v1.00",
"extracted_on": "2024-04-22T14:35:02"
"extracted_on": "2024-05-14T08:02:41"
}
}

View file

@ -137,6 +137,9 @@ Check column "offline" for their availability.
|`data diff `|Y |`Diff of input files`
|`data hexsamples `|N |`Dump big buffer as hex bytes`
|`data samples `|N |`Get raw samples for graph window ( GraphBuffer )`
|`data test_ss8 `|N |`Test the implementation of Buffer Save States (8-bit buffer)`
|`data test_ss32 `|N |`Test the implementation of Buffer Save States (32-bit buffer)`
|`data test_ss32s `|N |`Test the implementation of Buffer Save States (32-bit signed buffer)`
### emv
@ -221,6 +224,8 @@ Check column "offline" for their availability.
|`hf 14b wrbl `|N |`Write data to a SRI512/SRIX4 tag`
|`hf 14b view `|Y |`Display content from tag dump file`
|`hf 14b valid `|Y |`SRIX4 checksum test`
|`hf 14b calypso `|N |`Read contents of a Calypso card`
|`hf 14b mobib `|N |`Read contents of a Mobib card`
### hf 15
@ -1041,7 +1046,7 @@ Check column "offline" for their availability.
|`lf hitag help `|Y |`This help`
|`lf hitag list `|Y |`List Hitag trace history`
|`lf hitag info `|N |`Hitag 2 tag information`
|`lf hitag selftest `|Y |`Perform self test`
|`lf hitag test `|Y |`Perform self tests`
|`lf hitag dump `|N |`Dump Hitag 2 tag`
|`lf hitag read `|N |`Read Hitag memory`
|`lf hitag sniff `|N |`Eavesdrop Hitag communication`
@ -1051,6 +1056,7 @@ Check column "offline" for their availability.
|`lf hitag eview `|N |`View emulator memory`
|`lf hitag sim `|N |`Simulate Hitag transponder`
|`lf hitag cc `|N |`Hitag S: test all provided challenges`
|`lf hitag crack2 `|N |`Recover 2048bits of crypto stream`
|`lf hitag chk `|N |`Check keys`
|`lf hitag lookup `|Y |`Uses authentication trace to check for key in dictionary file`
|`lf hitag ta `|N |`Hitag 2: test all recorded authentications`