From 272cb2bbc57f28c5185491cd9c8d2acae9d4e434 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 20 Oct 2023 16:54:44 +0200 Subject: [PATCH] added no save parameter to iclass dump. Also adjusted the text for the other places. --- CHANGELOG.md | 3 ++- client/src/cmdhf14b.c | 24 ++++++++++++++---------- client/src/cmdhficlass.c | 8 ++++++++ client/src/cmdhfmfu.c | 34 +++++++++++++++++++--------------- client/src/cmdlft55xx.c | 8 +++++++- 5 files changed, 50 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9336c352..6bbf83804 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] - - Modified `hf iclass calcnewkey` - Added calculations for old key elite and new key non elite (@Antiklesys) + - Changed `hf iclass dump` - now allow no save of dumped data (@iceman1001) + - Changed `hf iclass calcnewkey` - Added calculations for old key elite and new key non elite (@Antiklesys) - Changed the CLI prompt to show tcp/udp if used (@iceman1001) - Changed `hw ping` - now shows transfer time (@doegox) - Added `hf mf encodehid` - writes HID legacy credential to a empty MFC (@iceman1001) diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index a762f3525..c60f1a683 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -1537,17 +1537,21 @@ static int CmdHF14BDump(const char *Cmd) { print_sr_blocks(data, cardsize, card.uid); - if (nosave == false) { - // save to file - if (fnlen < 1) { - PrintAndLogEx(INFO, "using UID as filename"); - char *fptr = filename + snprintf(filename, sizeof(filename), "hf-14b-"); - FillFileNameByUID(fptr, SwapEndian64(card.uid, card.uidlen, 8), "-dump", card.uidlen); - } - - size_t datalen = (lastblock + 2) * ST25TB_SR_BLOCK_SIZE; - pm3_save_dump(filename, data, datalen, jsf14b_v2); + if (nosave) { + PrintAndLogEx(INFO, "Called with no save option"); + PrintAndLogEx(NORMAL, ""); + return PM3_SUCCESS; } + + // save to file + if (fnlen < 1) { + PrintAndLogEx(INFO, "using UID as filename"); + char *fptr = filename + snprintf(filename, sizeof(filename), "hf-14b-"); + FillFileNameByUID(fptr, SwapEndian64(card.uid, card.uidlen, 8), "-dump", card.uidlen); + } + + size_t datalen = (lastblock + 2) * ST25TB_SR_BLOCK_SIZE; + pm3_save_dump(filename, data, datalen, jsf14b_v2); } return switch_off_field_14b(); diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 2a66634ac..f5dfe4145 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -1754,6 +1754,7 @@ static int CmdHFiClassDump(const char *Cmd) { arg_lit0("z", "dense", "dense dump output style"), arg_lit0(NULL, "force", "force unsecure card read"), arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"), + arg_lit0(NULL, "ns", "no save to file"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -1840,6 +1841,7 @@ static int CmdHFiClassDump(const char *Cmd) { bool dense_output = g_session.dense_output || arg_get_lit(ctx, 9); bool force = arg_get_lit(ctx, 10); bool shallow_mod = arg_get_lit(ctx, 11); + bool nosave = arg_get_lit(ctx, 12); CLIParserFree(ctx); @@ -2085,6 +2087,12 @@ write_dump: // print the dump printIclassDumpContents(tag_data, 1, (bytes_got / 8), bytes_got, dense_output); + if (nosave) { + PrintAndLogEx(INFO, "Called with no save option"); + PrintAndLogEx(NORMAL, ""); + return PM3_SUCCESS; + } + // use CSN as filename if (filename[0] == 0) { strcat(filename, "hf-iclass-"); diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index c15ad1b74..99c0223a4 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2665,23 +2665,27 @@ static int CmdHF14AMfUDump(const char *Cmd) { printMFUdumpEx(&dump_file_data, pages, start_page); - if (nosave == false) { - // user supplied filename? - if (fnlen < 1) { - PrintAndLogEx(INFO, "Using UID as filename"); - uint8_t uid[7] = {0}; - memcpy(uid, (uint8_t *)&dump_file_data.data, 3); - memcpy(uid + 3, (uint8_t *)&dump_file_data.data + 4, 4); - strcat(filename, "hf-mfu-"); - FillFileNameByUID(filename, uid, "-dump", sizeof(uid)); - } + if (nosave) { + PrintAndLogEx(INFO, "Called with no save option"); + PrintAndLogEx(NORMAL, ""); + return PM3_SUCCESS; + } - uint16_t datalen = pages * MFU_BLOCK_SIZE + MFU_DUMP_PREFIX_LENGTH; - pm3_save_dump(filename, (uint8_t *)&dump_file_data, datalen, jsfMfuMemory); + // user supplied filename? + if (fnlen < 1) { + PrintAndLogEx(INFO, "Using UID as filename"); + uint8_t uid[7] = {0}; + memcpy(uid, (uint8_t *)&dump_file_data.data, 3); + memcpy(uid + 3, (uint8_t *)&dump_file_data.data + 4, 4); + strcat(filename, "hf-mfu-"); + FillFileNameByUID(filename, uid, "-dump", sizeof(uid)); + } - if (is_partial) { - PrintAndLogEx(WARNING, "Partial dump created. (%d of %d blocks)", pages, card_mem_size); - } + uint16_t datalen = pages * MFU_BLOCK_SIZE + MFU_DUMP_PREFIX_LENGTH; + pm3_save_dump(filename, (uint8_t *)&dump_file_data, datalen, jsfMfuMemory); + + if (is_partial) { + PrintAndLogEx(WARNING, "Partial dump created. (%d of %d blocks)", pages, card_mem_size); } return PM3_SUCCESS; diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 89a060a8e..e181f8667 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -2298,8 +2298,14 @@ static int CmdT55xxDump(const char *Cmd) { } } + if (nosave) { + PrintAndLogEx(INFO, "Called with no save option"); + PrintAndLogEx(NORMAL, ""); + return PM3_SUCCESS; + } + // all ok, save dump to file - if (success && nosave == false) { + if (success) { // set default filename, if not set by user if (strlen(filename) == 0) {