From f8db7b185d2076e9943d80bb5b16b8be39005739 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 21 Jul 2024 16:24:18 +0200 Subject: [PATCH] added support for --ns the nosave flag in hf iclass dump --- CHANGELOG.md | 4 +++- client/src/cmdhficlass.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bc1502ec..fd86c250a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,9 @@ 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] -- fixed breaking of client when trying to load a non-supported .picopass file (@iceman100) Thanks to Jump for suggested fixes! +- Changed `hf iclass dump --ns` - now supports the nosave flag (@iceman1001) +- Fixed write check in hitag2crack2 buildtables (@mwalker33) +- Fixed breaking of client when trying to load a non-supported .picopass file (@iceman100) Thanks to Jump for suggested fixes! - Changed `mf_nonce_brute` tool to handle the odd case of multiple key candidates (@iceman1001) - Fixed a bad memory erase (@iceman1001) - Fixed BT serial comms (@iceman1001) diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 7af8d69b6..f70aebd31 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -39,6 +39,7 @@ #include "iclass_cmd.h" #include "crypto/asn1utils.h" // ASN1 decoder #include "preferences.h" +#include "generator.h" #define NUM_CSNS 9 @@ -1448,6 +1449,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) { arg_lit0("v", "verbose", "verbose output"), arg_lit0(NULL, "d6", "decode as block 6"), arg_lit0("z", "dense", "dense dump output style"), + arg_lit0(NULL, "ns", "no save to file"), arg_param_end }; CLIExecWithReturn(clictx, Cmd, argtable, false); @@ -1472,6 +1474,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) { bool verbose = arg_get_lit(clictx, 4); bool use_decode6 = arg_get_lit(clictx, 5); bool dense_output = g_session.dense_output || arg_get_lit(clictx, 6); + bool nosave = arg_get_lit(clictx, 7); CLIParserFree(clictx); // sanity checks @@ -1611,6 +1614,11 @@ static int CmdHFiClassDecrypt(const char *Cmd) { } } + if (nosave) { + PrintAndLogEx(INFO, "Called with no save option"); + PrintAndLogEx(NORMAL, ""); + } else { + // use the first block (CSN) for filename char *fptr = calloc(50, sizeof(uint8_t)); if (fptr == false) { @@ -1623,6 +1631,8 @@ static int CmdHFiClassDecrypt(const char *Cmd) { FillFileNameByUID(fptr, hdr->csn, "-dump-decrypted", sizeof(hdr->csn)); pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass); + free(fptr); + } printIclassDumpContents(decrypted, 1, (decryptedlen / 8), decryptedlen, dense_output); @@ -1634,11 +1644,9 @@ static int CmdHFiClassDecrypt(const char *Cmd) { // decode block 6 bool has_values = (memcmp(decrypted + (8 * 6), empty, 8) != 0) && (memcmp(decrypted + (8 * 6), zeros, 8) != 0); - if (has_values) { - if (use_sc) { + if (has_values && use_sc) { DecodeBlock6(decrypted + (8 * 6)); } - } // decode block 7-8-9 iclass_decode_credentials(decrypted); @@ -1664,7 +1672,6 @@ static int CmdHFiClassDecrypt(const char *Cmd) { PrintAndLogEx(INFO, "-----------------------------------------------------------------"); free(decrypted); - free(fptr); } mbedtls_des3_free(&ctx);