diff --git a/armsrc/Standalone/hf_st25_tearoff.c b/armsrc/Standalone/hf_st25_tearoff.c index 0f315e934..65fc2ba52 100644 --- a/armsrc/Standalone/hf_st25_tearoff.c +++ b/armsrc/Standalone/hf_st25_tearoff.c @@ -252,7 +252,7 @@ static void update_leds_mode(standalone_mode_t mode) { */ static void indicate_success(void) { // Blink Green LED (A) 3 times quickly for success - for(int i=0; i<3; ++i) { + for (int i = 0; i < 3; ++i) { LED_A_ON(); SpinDelay(150); LED_A_OFF(); @@ -265,7 +265,7 @@ static void indicate_success(void) { */ static void indicate_failure(void) { // Blink Red LED (B) 3 times quickly for failure - for(int i=0; i<3; ++i) { + for (int i = 0; i < 3; ++i) { LED_B_ON(); SpinDelay(150); LED_B_OFF(); @@ -291,7 +291,7 @@ static bool load_tags_from_flash(st25tb_data_t collection[MAX_SAVED_TAGS]) { // Verify file size uint32_t size = size_in_spiffs(HF_ST25TB_MULTI_SR_FILE); if (size != sizeof(g_stored_tags)) { - Dbprintf(_RED_("Flash file size mismatch (expected %zu, got %u). Wiping old file."), + Dbprintf(_RED_("Flash file size mismatch (expected %zu, got %u). Wiping old file."), sizeof(g_stored_tags), size); // Remove corrupted file rdv40_spiffs_remove(HF_ST25TB_MULTI_SR_FILE, RDV40_SPIFFS_SAFETY_SAFE); @@ -299,8 +299,8 @@ static bool load_tags_from_flash(st25tb_data_t collection[MAX_SAVED_TAGS]) { } // Read file contents - int res = rdv40_spiffs_read(HF_ST25TB_MULTI_SR_FILE, (uint8_t *)collection, - size, RDV40_SPIFFS_SAFETY_SAFE); + int res = rdv40_spiffs_read(HF_ST25TB_MULTI_SR_FILE, (uint8_t *)collection, + size, RDV40_SPIFFS_SAFETY_SAFE); if (res != SPIFFS_OK) { Dbprintf(_RED_("Failed to read tag collection from flash (err %d)"), res); @@ -319,8 +319,8 @@ static bool load_tags_from_flash(st25tb_data_t collection[MAX_SAVED_TAGS]) { * @return true if successful, false otherwise */ static bool save_tags_to_flash(const st25tb_data_t collection[MAX_SAVED_TAGS]) { - int res = rdv40_spiffs_write(HF_ST25TB_MULTI_SR_FILE, (uint8_t *)collection, - sizeof(g_stored_tags), RDV40_SPIFFS_SAFETY_SAFE); + int res = rdv40_spiffs_write(HF_ST25TB_MULTI_SR_FILE, (uint8_t *)collection, + sizeof(g_stored_tags), RDV40_SPIFFS_SAFETY_SAFE); return (res == SPIFFS_OK); } @@ -356,7 +356,7 @@ static int find_free_tag_slot(void) { //============================================================================= /** - * @brief Stripped version of "iso14443b_setup" that avoids unnecessary LED + * @brief Stripped version of "iso14443b_setup" that avoids unnecessary LED * operations and uses shorter delays */ static void iso14443b_setup_light(void) { @@ -417,7 +417,7 @@ static bool st25tb_tag_read(st25tb_data_t *tag_data_slot) { Dbprintf("Found ST tag. Reading %d blocks...", ST25TB_BLOCK_COUNT); tag_data_slot->uid = bytes_to_num_le(card_info.uid, sizeof(tag_data_slot->uid)); - + // Read all data blocks for (uint8_t block_address = 0; block_address < ST25TB_BLOCK_COUNT; block_address++) { WDT_HIT(); @@ -507,7 +507,7 @@ static bool st25tb_tag_restore(const st25tb_data_t *stored_data_slot) { } if (g_dbglevel >= DBG_DEBUG) { - Dbprintf("Counter Block %d: Stored=0x%08X, Current=0x%08X", + Dbprintf("Counter Block %d: Stored=0x%08X, Current=0x%08X", block_address, stored_value, current_value); } @@ -528,7 +528,7 @@ static bool st25tb_tag_restore(const st25tb_data_t *stored_data_slot) { break; } } else { - Dbprintf("Counter block %d already has the target value (0x%08X). Skipping write.", + Dbprintf("Counter block %d already has the target value (0x%08X). Skipping write.", block_address, stored_value); } } else { @@ -658,7 +658,7 @@ static void st25tb_tear_off_write_block(uint8_t block_address, uint32_t data, ui block[0] = (data & 0xFF); block[1] = (data >> 8) & 0xFF; block[2] = (data >> 16) & 0xFF; - block[3] = (data >> 24) & 0xFF; + block[3] = (data >> 24) & 0xFF; iso14b_card_select_t card; int res = iso14443b_select_srx_card(&card); @@ -667,7 +667,7 @@ static void st25tb_tear_off_write_block(uint8_t block_address, uint32_t data, ui } res = st25tb_cmd_write_block(block_address, block); - + // Tear off the communication at precise timing SpinDelayUsPrecision(tearoff_delay_us); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); @@ -685,9 +685,9 @@ out: * @param read_back_value Pointer to store read-back value * @return 0 for success, -1 for failure */ -static int8_t st25tb_tear_off_retry_write_verify(uint8_t block_address, uint32_t target_value, - uint32_t max_try_count, int sleep_time_ms, - uint32_t *read_back_value) { +static int8_t st25tb_tear_off_retry_write_verify(uint8_t block_address, uint32_t target_value, + uint32_t max_try_count, int sleep_time_ms, + uint32_t *read_back_value) { int i = 0; *read_back_value = ~target_value; // Initialize to ensure the loop runs at least once @@ -711,9 +711,9 @@ static int8_t st25tb_tear_off_retry_write_verify(uint8_t block_address, uint32_t * @param read_value Pointer to store read value * @return 0 if consolidated, -1 otherwise */ -static int8_t st25tb_tear_off_is_consolidated(const uint8_t block_address, uint32_t value, - int repeat_read, int sleep_time_ms, - uint32_t *read_value) { +static int8_t st25tb_tear_off_is_consolidated(const uint8_t block_address, uint32_t value, + int repeat_read, int sleep_time_ms, + uint32_t *read_value) { int result; for (int i = 0; i < repeat_read; i++) { if (sleep_time_ms > 0) SpinDelayUsPrecision(sleep_time_ms * 1000); @@ -733,8 +733,8 @@ static int8_t st25tb_tear_off_is_consolidated(const uint8_t block_address, uint3 * @param read_back_value Pointer to store read-back value * @return 0 for success, -1 for failure */ -static int8_t st25tb_tear_off_consolidate_block(const uint8_t block_address, uint32_t current_value, - uint32_t target_value, uint32_t *read_back_value) { +static int8_t st25tb_tear_off_consolidate_block(const uint8_t block_address, uint32_t current_value, + uint32_t target_value, uint32_t *read_back_value) { int8_t result; uint32_t consolidation_value; @@ -746,8 +746,8 @@ static int8_t st25tb_tear_off_consolidate_block(const uint8_t block_address, uin } // Try writing value - 1 - result = st25tb_tear_off_retry_write_verify(block_address, consolidation_value - 1, - TEAR_OFF_WRITE_RETRY_COUNT, 0, read_back_value); + result = st25tb_tear_off_retry_write_verify(block_address, consolidation_value - 1, + TEAR_OFF_WRITE_RETRY_COUNT, 0, read_back_value); if (result != 0) { Dbprintf("Consolidation failed at step 1 (write 0x%08X)", consolidation_value - 1); return -1; @@ -755,8 +755,8 @@ static int8_t st25tb_tear_off_consolidate_block(const uint8_t block_address, uin // If value is not FE or target is not FD, try writing value - 2 if (*read_back_value != 0xFFFFFFFE || (*read_back_value == 0xFFFFFFFE && target_value == 0xFFFFFFFD)) { - result = st25tb_tear_off_retry_write_verify(block_address, consolidation_value - 2, - TEAR_OFF_WRITE_RETRY_COUNT, 0, read_back_value); + result = st25tb_tear_off_retry_write_verify(block_address, consolidation_value - 2, + TEAR_OFF_WRITE_RETRY_COUNT, 0, read_back_value); if (result != 0) { Dbprintf("Consolidation failed at step 2 (write 0x%08X)", consolidation_value - 2); return -1; @@ -765,12 +765,12 @@ static int8_t st25tb_tear_off_consolidate_block(const uint8_t block_address, uin // Final checks for stability of unstable high values (due to internal dual counters) if (result == 0 && target_value > 0xFFFFFFFD && *read_back_value > 0xFFFFFFFD) { - result = st25tb_tear_off_is_consolidated(block_address, *read_back_value, - TEAR_OFF_CONSOLIDATE_READ_COUNT, 0, read_back_value); + result = st25tb_tear_off_is_consolidated(block_address, *read_back_value, + TEAR_OFF_CONSOLIDATE_READ_COUNT, 0, read_back_value); if (result == 0) { - result = st25tb_tear_off_is_consolidated(block_address, *read_back_value, - TEAR_OFF_CONSOLIDATE_WAIT_READ_COUNT, - TEAR_OFF_CONSOLIDATE_WAIT_MS, read_back_value); + result = st25tb_tear_off_is_consolidated(block_address, *read_back_value, + TEAR_OFF_CONSOLIDATE_WAIT_READ_COUNT, + TEAR_OFF_CONSOLIDATE_WAIT_MS, read_back_value); if (result != 0) { Dbprintf("Consolidation failed stability check (long wait)"); return -1; @@ -861,8 +861,8 @@ static void st25tb_tear_off_log(int tear_off_us, char *color, uint32_t value) { * @param safety_value Safety threshold to prevent going below * @return 0 for success, non-zero for failure */ -static int8_t st25tb_tear_off_write_counter(uint8_t block_address, uint32_t target_value, - uint32_t tear_off_adjustment_us, uint32_t safety_value) { +static int8_t st25tb_tear_off_write_counter(uint8_t block_address, uint32_t target_value, + uint32_t tear_off_adjustment_us, uint32_t safety_value) { int result; bool trigger = true; @@ -906,7 +906,7 @@ static int8_t st25tb_tear_off_write_counter(uint8_t block_address, uint32_t targ for (;;) { // Safety check: ensure we don't go below the safety threshold if (tear_off_value < safety_value) { - Dbprintf("Stopped. Safety threshold reached (next value 0x%08X < safety 0x%08X)", + Dbprintf("Stopped. Safety threshold reached (next value 0x%08X < safety 0x%08X)", tear_off_value, safety_value); return -1; } @@ -921,15 +921,15 @@ static int8_t st25tb_tear_off_write_counter(uint8_t block_address, uint32_t targ } // Analyze the result and decide next action - if (read_value > current_value) { + if (read_value > current_value) { // Partial write succeeded (successful tear-off) if (read_value >= 0xFFFFFFFE || - (read_value - 2) > target_value || - read_value != last_consolidated_value || - ((read_value & 0xF0000000) > (current_value & 0xF0000000))) { // Major bit flip - - result = st25tb_tear_off_consolidate_block(block_address, read_value, - target_value, ¤t_value); + (read_value - 2) > target_value || + read_value != last_consolidated_value || + ((read_value & 0xF0000000) > (current_value & 0xF0000000))) { // Major bit flip + + result = st25tb_tear_off_consolidate_block(block_address, read_value, + target_value, ¤t_value); if (result == 0 && current_value == target_value) { st25tb_tear_off_log(tear_off_us, GREEN, read_value); Dbprintf("Target value 0x%08X reached successfully!", target_value); @@ -1004,11 +1004,11 @@ static void run_learn_function(void) { } else { // Only increment if we are adding to a new slot, not overwriting if (!g_stored_tags[slot_index].data_valid) { - g_valid_tag_count++; + g_valid_tag_count++; } } } - + // Store tag data in collection memcpy(&g_stored_tags[slot_index], &temp_tag_data, sizeof(st25tb_data_t)); g_stored_tags[slot_index].data_valid = true; @@ -1020,7 +1020,7 @@ static void run_learn_function(void) { } else { DbpString(_RED_("Failed to save collection to flash!")); } - + current_state = STATE_DONE; // Indicate success } } @@ -1052,8 +1052,8 @@ static void run_restore_function(void) { current_state = STATE_ERROR; } } else { - // Tag found but not in collection, remain busy to scan again - current_state = STATE_BUSY; + // Tag found but not in collection, remain busy to scan again + current_state = STATE_BUSY; } } else { // No tag found, remain busy to scan again @@ -1131,10 +1131,10 @@ void RunMod(void) { // --- Update Display (only if mode changed) --- if (mode_display_update) { if (g_current_mode == MODE_LEARN) { - Dbprintf("Mode: " _YELLOW_("Learn") ". (Cnt: %d/%d)", + Dbprintf("Mode: " _YELLOW_("Learn") ". (Cnt: %d/%d)", g_valid_tag_count, MAX_SAVED_TAGS); } else { - Dbprintf("Mode: " _BLUE_("Restore") ". (Cnt: %d/%d)", + Dbprintf("Mode: " _BLUE_("Restore") ". (Cnt: %d/%d)", g_valid_tag_count, MAX_SAVED_TAGS); } mode_display_update = false; @@ -1142,14 +1142,14 @@ void RunMod(void) { update_leds_mode(g_current_mode); // Process according to current state - if(current_state == STATE_BUSY) { + if (current_state == STATE_BUSY) { // Run appropriate function based on mode if (g_current_mode == MODE_LEARN) { run_learn_function(); } else { // MODE_RESTORE run_restore_function(); } - } else if(current_state == STATE_DONE) { + } else if (current_state == STATE_DONE) { indicate_success(); } else { indicate_failure(); diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index ab144a71e..8bca5d2de 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -524,6 +524,7 @@ RAMFUNC bool MillerDecoding(uint8_t bit, uint32_t non_real_time) { Uart.parityBits |= ((Uart.shiftReg >> 8) & 0x01); // store parity bit Uart.bitCount = 0; Uart.shiftReg = 0; + // Every 8 data bytes, store 8 parity bits into a parity byte if ((Uart.len & 0x0007) == 0) { // every 8 data bytes Uart.parity[Uart.parityLen++] = Uart.parityBits; // store 8 parity bits @@ -1496,6 +1497,7 @@ bool SimulateIso14443aInit(uint8_t tagType, uint16_t flags, uint8_t *data, // "precompiled" responses. // These exist for speed reasons. There are no time in the anti collision phase to calculate responses. // There are 12 predefined responses with a total of 84 bytes data to transmit. + // // Coded responses need one byte per bit to transfer (data, parity, start, stop, correction) // 85 * 8 data bits, 85 * 1 parity bits, 12 start bits, 12 stop bits, 12 correction bits // 85 * 8 + 85 + 12 + 12 + 12 == 801 @@ -2771,19 +2773,19 @@ static void iso14a_set_ATS_times(const uint8_t *ats) { static int GetATQA(uint8_t *resp, uint16_t resp_len, uint8_t *resp_par, const iso14a_polling_parameters_t *polling_parameters) { - #define RETRY_TIMEOUT 10 +#define RETRY_TIMEOUT 10 uint32_t save_iso14a_timeout = iso14a_get_timeout(); iso14a_set_timeout(1236 / 128 + 1); // response to WUPA is expected at exactly 1236/fc. No need to wait longer. // refactored to use local pointer, now no modification of polling_parameters pointer is done - // I don't think the intention was to modify polling_parameters when sending in WUPA_POLLING_PARAMETERS etc. + // I don't think the intention was to modify polling_parameters when sending in WUPA_POLLING_PARAMETERS etc. // Modify polling_params, if null use default values. iso14a_polling_parameters_t p; - memcpy(&p, (uint8_t*)polling_parameters, sizeof(iso14a_polling_parameters_t)); + memcpy(&p, (uint8_t *)polling_parameters, sizeof(iso14a_polling_parameters_t)); if (polling_parameters == NULL) { - memcpy(&p, (uint8_t*)&hf14a_polling_parameters, sizeof(iso14a_polling_parameters_t)); + memcpy(&p, (uint8_t *)&hf14a_polling_parameters, sizeof(iso14a_polling_parameters_t)); } bool first_try = true; diff --git a/client/luascripts/hf_mfu_ultra.lua b/client/luascripts/hf_mfu_ultra.lua index f96becad8..ed6a2b974 100644 --- a/client/luascripts/hf_mfu_ultra.lua +++ b/client/luascripts/hf_mfu_ultra.lua @@ -23,7 +23,7 @@ script run hf_mfu_ultra -h -f -k -w -r ]] arguments = [[ -h this help - -f filename for the datadump to read (bin) + -f filename for the datadump to read (bin) -k pwd to use with the restore and wipe operations -r restore a binary dump to tag -w wipe tag (]]..ansicolors.red..[[Do not use it with UL-5!]]..ansicolors.reset..[[) @@ -50,7 +50,7 @@ local function setPassword(password) _password = nil; elseif #password ~= 8 then return false, 'Password must be 4 hex bytes' - else + else _password = password end return true, 'Sets' @@ -102,7 +102,7 @@ end --- Sends raw data to PM3 and returns parsed response local function sendWithResponse(payload, options) local opts; - if options then + if options then opts = options else opts = {ignore_response = false, keep_signal = true, append_crc = true} @@ -351,7 +351,7 @@ local function main(args) if opt == 'w' then res, err = wipe() end if not res then return error(err) end end - + end main(args) diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index ea0c47993..0cdf49b81 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -600,7 +600,7 @@ static command_t CommandTable[] = { {"texkom", CmdHFTexkom, AlwaysAvailable, "{ Texkom RFIDs... }"}, {"thinfilm", CmdHFThinfilm, AlwaysAvailable, "{ Thinfilm RFIDs... }"}, {"topaz", CmdHFTopaz, AlwaysAvailable, "{ TOPAZ (NFC Type 1) RFIDs... }"}, - {"vas", CmdHFVAS, AlwaysAvailable, "{ Apple Value Added Service }"}, + {"vas", CmdHFVAS, AlwaysAvailable, "{ Apple Value Added Service... }"}, #ifdef HAVE_GD {"waveshare", CmdHFWaveshare, AlwaysAvailable, "{ Waveshare NFC ePaper... }"}, #endif diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index d1bf67562..634e3c0ba 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1403,10 +1403,10 @@ static int CmdHF14AAPDU(const char *Cmd) { CLIParserFree(ctx); return PM3_EINVARG; } - + bool extendedAPDU = arg_get_lit(ctx, 6); int le = arg_get_int_def(ctx, 7, 0); - + uint8_t data[PM3_CMD_DATA_SIZE]; int datalen = 0; diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index cb0482cc3..69011be6c 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -3029,7 +3029,9 @@ int infoHF14B(bool verbose, bool do_aid_search) { // try unknown 14b read commands (to be identified later) // could be read of calypso, CEPAS, moneo, or pico pass. - if (verbose) PrintAndLogEx(FAILED, "no 14443-B tag found"); + if (verbose) { + PrintAndLogEx(FAILED, "no 14443-B tag found"); + } return PM3_EOPABORTED; } diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 16485b262..6c1de1cb1 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -3004,7 +3004,7 @@ static int CmdHFiClass_TearBlock(const char *Cmd) { int tearoff_start = arg_get_int_def(ctx, 12, 5000); int tearoff_increment = arg_get_int_def(ctx, 13, 10); - int tearoff_end = arg_get_int_def(ctx, 14, tearoff_start+tearoff_increment+500); + int tearoff_end = arg_get_int_def(ctx, 14, tearoff_start + tearoff_increment + 500); if (tearoff_end <= tearoff_start) { PrintAndLogEx(ERR, "Tearoff end delay must be bigger than the start delay."); @@ -3063,7 +3063,7 @@ static int CmdHFiClass_TearBlock(const char *Cmd) { params.on = true; params.delay_us = tearoff_start; handle_tearoff(¶ms, false); - PrintAndLogEx(INFO, "Tear off delay: "_YELLOW_("%d")"/"_YELLOW_("%d")" us", tearoff_start,tearoff_end); + PrintAndLogEx(INFO, "Tear off delay: "_YELLOW_("%d")"/"_YELLOW_("%d")" us", tearoff_start, tearoff_end); isok = iclass_write_block(blockno, data, mac, key, use_credit_key, elite, rawkey, use_replay, verbose, auth, shallow_mod); switch (isok) { case PM3_SUCCESS: @@ -3101,24 +3101,24 @@ static int CmdHFiClass_TearBlock(const char *Cmd) { } bool tear_success = true; bool expected_values = true; - if(memcmp(data_read, data, 8) != 0) { + if (memcmp(data_read, data, 8) != 0) { tear_success = false; - }else if ((!tear_success) && (memcmp(data_read, zeros, 8) != 0) && (memcmp(data_read, data_read_orig, 8) != 0)) { //tearoff succeeded (partially) - tear_success = true; - expected_values = false; - PrintAndLogEx(SUCCESS, _GREEN_("Tear-off Success! -> Different values")); - PrintAndLogEx(INFO, "Original: %s", sprint_hex(data_read_orig, sizeof(data_read))); - PrintAndLogEx(INFO, "Expected: %s", sprint_hex(data, sizeof(data))); + } else if ((!tear_success) && (memcmp(data_read, zeros, 8) != 0) && (memcmp(data_read, data_read_orig, 8) != 0)) { //tearoff succeeded (partially) + tear_success = true; + expected_values = false; + PrintAndLogEx(SUCCESS, _GREEN_("Tear-off Success! -> Different values")); + PrintAndLogEx(INFO, "Original: %s", sprint_hex(data_read_orig, sizeof(data_read))); + PrintAndLogEx(INFO, "Expected: %s", sprint_hex(data, sizeof(data))); } if (tear_success) { //tearoff succeeded read_ok = true; - if(expected_values) { + if (expected_values) { PrintAndLogEx(SUCCESS, _GREEN_("Tear-off Success! -> Expected values")); } PrintAndLogEx(INFO, "Read: %s", sprint_hex(data_read, sizeof(data_read))); } else { //tearoff did not succeed PrintAndLogEx(FAILED, _RED_("Tear-off Failed!")); - if(verbose) { + if (verbose) { PrintAndLogEx(INFO, "Read: %s", sprint_hex(data_read, sizeof(data_read))); PrintAndLogEx(INFO, "Expected: %s", sprint_hex(data, sizeof(data))); } diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index b081eb067..f85362a23 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -1684,7 +1684,7 @@ typedef struct { } mfu_otp_identify_t; static mfu_otp_identify_t mfu_otp_ident_table[] = { - { "SALTO Systems card", 12, 4, "534C544F", ul_c_otpgenA, NULL }, + { "SALTO Systems card", 12, 4, "534C544F", ul_c_otpgenA, "report to iceman!" }, { NULL, 0, 0, NULL, NULL, NULL } }; @@ -1963,7 +1963,7 @@ static int mfu_fingerprint(uint64_t tagtype, bool hasAuthKey, const uint8_t *aut // OTP checks mfu_otp_identify_t *item = mfu_match_otp_fingerprint(uid, data); if (item) { - PrintAndLogEx(SUCCESS, _GREEN_("%s"), item->desc); + PrintAndLogEx(SUCCESS, _BACK_GREEN_(" %s "), item->desc); res = PM3_SUCCESS; if (item->hint) { diff --git a/client/src/fileutils.c b/client/src/fileutils.c index 128826c10..f28b2c165 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -165,6 +165,7 @@ static char *filenamemcopy(const char *preferredName, const char *suffix) { char *fileName = (char *) calloc(strlen(preferredName) + strlen(suffix) + 1, sizeof(uint8_t)); if (fileName == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); return NULL; } @@ -993,8 +994,8 @@ int loadFile_safeEx(const char *preferredName, const char *suffix, void **pdata, } *pdata = calloc(fsize, sizeof(uint8_t)); - if (!*pdata) { - PrintAndLogEx(FAILED, "error, cannot allocate memory"); + if (*pdata == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); fclose(f); return PM3_EMALLOC; } @@ -1044,8 +1045,8 @@ int loadFileEML_safe(const char *preferredName, void **pdata, size_t *datalen) { } *pdata = calloc(fsize, sizeof(uint8_t)); - if (!*pdata) { - PrintAndLogEx(FAILED, "error, cannot allocate memory"); + if (*pdata == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); fclose(f); return PM3_EMALLOC; } @@ -1091,6 +1092,7 @@ int loadFileEML_safe(const char *preferredName, void **pdata, size_t *datalen) { uint8_t *newdump = realloc(*pdata, counter); if (newdump == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); free(*pdata); return PM3_EMALLOC; } else { @@ -1366,8 +1368,8 @@ int loadFileMCT_safe(const char *preferredName, void **pdata, size_t *datalen) { } *pdata = calloc(fsize, sizeof(uint8_t)); - if (!*pdata) { - PrintAndLogEx(FAILED, "error, cannot allocate memory"); + if (*pdata == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); fclose(f); return PM3_EMALLOC; } @@ -1414,6 +1416,7 @@ int loadFileMCT_safe(const char *preferredName, void **pdata, size_t *datalen) { uint8_t *newdump = realloc(*pdata, counter); if (newdump == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); free(*pdata); return PM3_EMALLOC; } else { @@ -2358,6 +2361,7 @@ int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, vo // allocate some space for the dictionary *pdata = calloc(block_size, sizeof(uint8_t)); if (*pdata == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); free(path); return PM3_EFILE; } @@ -2377,9 +2381,10 @@ int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, vo if ((*keycnt * (keylen >> 1)) >= mem_size) { mem_size += block_size; - *pdata = realloc(*pdata, mem_size); + *pdata = realloc(*pdata, mem_size); if (*pdata == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); retval = PM3_EFILE; fclose(f); goto out; @@ -2473,7 +2478,7 @@ int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya *keya = calloc(fsize, sizeof(uint8_t)); if (*keya == NULL) { - PrintAndLogEx(FAILED, "error, cannot allocate memory"); + PrintAndLogEx(WARNING, "Failed to allocate memory"); fclose(f); free(path); return PM3_EMALLOC; @@ -2483,7 +2488,7 @@ int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya *keyb = calloc(fsize, sizeof(uint8_t)); if (*keyb == NULL) { - PrintAndLogEx(FAILED, "error, cannot allocate memory"); + PrintAndLogEx(WARNING, "Failed to allocate memory"); fclose(f); free(*keya); free(path); @@ -2663,6 +2668,7 @@ static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) mfu_dump_t *mfu = (mfu_dump_t *) calloc(sizeof(mfu_dump_t), sizeof(uint8_t)); if (mfu == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); return PM3_EMALLOC; } @@ -2700,6 +2706,7 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) { mfu_dump_t *mfu_dump = (mfu_dump_t *) calloc(sizeof(mfu_dump_t), sizeof(uint8_t)); if (mfu_dump == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); return PM3_EMALLOC; } @@ -2846,6 +2853,7 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea // explicit absolute (/) or relative path (./) => try only to match it directly char *filename = calloc(strlen(searchname) + 1, sizeof(char)); if (filename == NULL) { + PrintAndLogEx(WARNING, "Failed to allocate memory"); return PM3_EMALLOC; } @@ -3081,7 +3089,7 @@ int pm3_load_dump(const char *fn, void **pdump, size_t *dumplen, size_t maxdumpl case JSON: { *pdump = calloc(maxdumplen, sizeof(uint8_t)); if (*pdump == NULL) { - PrintAndLogEx(WARNING, "fail, cannot allocate memory"); + PrintAndLogEx(WARNING, "Failed to allocate memory"); return PM3_EMALLOC; } @@ -3121,7 +3129,7 @@ int pm3_load_dump(const char *fn, void **pdump, size_t *dumplen, size_t maxdumpl *pdump = calloc(maxdumplen, sizeof(uint8_t)); if (*pdump == NULL) { - PrintAndLogEx(WARNING, "Fail, cannot allocate memory"); + PrintAndLogEx(WARNING, "Failed to allocate memory"); return PM3_EMALLOC; } res = loadFileNFC_safe(fn, *pdump, maxdumplen, dumplen, dumptype); diff --git a/doc/commands.json b/doc/commands.json index 9fc3e4a6a..4c173f86a 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1342,7 +1342,6 @@ "-t, --timeout Timeout in milliseconds", "-b Number of bits to send. Useful for send partial byte", "-v, --verbose Verbose output", - "--mag Use Apple magsafe polling", "--topaz Use Topaz protocol to send command", "--crypto1 Use crypto1 session", " Raw bytes to send" @@ -1354,8 +1353,7 @@ "description": "Act as a ISO-14443a reader to identify tag. Look for ISO-14443a tags until Enter or the pm3 button is pressed", "notes": [ "hf 14a reader", - "hf 14a reader -@ -> Continuous mode", - "hf 14a reader --mag -> trigger apple magsafe polling" + "hf 14a reader -@ -> Continuous mode" ], "offline": false, "options": [ @@ -1364,7 +1362,6 @@ "-s, --silent silent (no messages)", "--drop just drop the signal field", "--skip ISO14443-3 select only (skip RATS)", - "--mag Use Apple magsafe polling", "-@ continuous reader mode", "-w, --wait wait for card" ], @@ -3204,7 +3201,7 @@ }, "hf help": { "command": "hf help", - "description": "-------- ----------------------- High Frequency ----------------------- 14a { ISO14443A RFIDs... } 14b { ISO14443B RFIDs... } 15 { ISO15693 RFIDs... } cipurse { Cipurse transport Cards... } epa { German Identification Card... } emrtd { Machine Readable Travel Document... } felica { ISO18092 / FeliCa RFIDs... } fido { FIDO and FIDO2 authenticators... } fudan { Fudan RFIDs... } gallagher { Gallagher DESFire RFIDs... } iclass { ICLASS RFIDs... } ict { ICT MFC/DESfire RFIDs... } jooki { Jooki RFIDs... } ksx6924 { KS X 6924 (T-Money, Snapper+) RFIDs } legic { LEGIC RFIDs... } lto { LTO Cartridge Memory RFIDs... } mf { MIFARE RFIDs... } mfp { MIFARE Plus RFIDs... } mfu { MIFARE Ultralight RFIDs... } mfdes { MIFARE Desfire RFIDs... } ntag424 { NXP NTAG 4242 DNA RFIDs... } seos { SEOS RFIDs... } st25ta { ST25TA RFIDs... } tesla { TESLA Cards... } texkom { Texkom RFIDs... } thinfilm { Thinfilm RFIDs... } topaz { TOPAZ (NFC Type 1) RFIDs... } vas { Apple Value Added Service } waveshare { Waveshare NFC ePaper... } xerox { Fuji/Xerox cartridge RFIDs... } ----------- --------------------- General --------------------- help This help list List protocol data in trace buffer search Search for known HF tags --------------------------------------------------------------------------------------- hf list available offline: yes Alias of `trace list -t raw` 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": "-------- ----------------------- High Frequency ----------------------- 14a { ISO14443A RFIDs... } 14b { ISO14443B RFIDs... } 15 { ISO15693 RFIDs... } cipurse { Cipurse transport Cards... } epa { German Identification Card... } emrtd { Machine Readable Travel Document... } felica { ISO18092 / FeliCa RFIDs... } fido { FIDO and FIDO2 authenticators... } fudan { Fudan RFIDs... } gallagher { Gallagher DESFire RFIDs... } iclass { ICLASS RFIDs... } ict { ICT MFC/DESfire RFIDs... } jooki { Jooki RFIDs... } ksx6924 { KS X 6924 (T-Money, Snapper+) RFIDs } legic { LEGIC RFIDs... } lto { LTO Cartridge Memory RFIDs... } mf { MIFARE RFIDs... } mfp { MIFARE Plus RFIDs... } mfu { MIFARE Ultralight RFIDs... } mfdes { MIFARE Desfire RFIDs... } ntag424 { NXP NTAG 4242 DNA RFIDs... } seos { SEOS RFIDs... } st25ta { ST25TA RFIDs... } tesla { TESLA Cards... } texkom { Texkom RFIDs... } thinfilm { Thinfilm RFIDs... } topaz { TOPAZ (NFC Type 1) RFIDs... } vas { Apple Value Added Service... } waveshare { Waveshare NFC ePaper... } xerox { Fuji/Xerox cartridge RFIDs... } ----------- --------------------- General --------------------- help This help list List protocol data in trace buffer search Search for known HF tags --------------------------------------------------------------------------------------- hf list available offline: yes Alias of `trace list -t raw` 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 list --frame -> show frame delay times", "hf list -1 -> use trace buffer" @@ -3741,10 +3738,11 @@ "--nr replay of NR/MAC", "-v, --verbose verbose output", "--shallow use shallow (ASK) reader modulation instead of OOK", - "--tdb tearoff delay start in ms", - "--tde tearoff delay end in ms" + "--tdb tearoff delay start (in us) must be between 1 and 43000 (43ms). Precision is about 1/3us.", + "--incr tearoff delay increment (in us) - default 10.", + "--tde tearoff delay end (in us) must be a higher value than the start delay." ], - "usage": "hf iclass trbl [-hv] [-k ] [--ki ] --blk -d [-m ] [--credit] [--elite] [--raw] [--nr] [--shallow] --tdb --tde " + "usage": "hf iclass trbl [-hv] [-k ] [--ki ] --blk -d [-m ] [--credit] [--elite] [--raw] [--nr] [--shallow] --tdb [--incr ] [--tde ]" }, "hf iclass unhash": { "command": "hf iclass unhash", @@ -13354,6 +13352,6 @@ "metadata": { "commands_extracted": 767, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2025-04-20T09:18:59" + "extracted_on": "2025-05-19T11:17:19" } } diff --git a/doc/commands.md b/doc/commands.md index 12312b7fc..755930dd8 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -786,7 +786,7 @@ Check column "offline" for their availability. ### hf vas - { Apple Value Added Service } + { Apple Value Added Service... } |command |offline |description |------- |------- |-----------