added support for --ns the nosave flag in hf iclass dump

This commit is contained in:
iceman1001 2024-07-21 16:24:18 +02:00
commit f8db7b185d
2 changed files with 14 additions and 5 deletions

View file

@ -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... 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] ## [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) - Changed `mf_nonce_brute` tool to handle the odd case of multiple key candidates (@iceman1001)
- Fixed a bad memory erase (@iceman1001) - Fixed a bad memory erase (@iceman1001)
- Fixed BT serial comms (@iceman1001) - Fixed BT serial comms (@iceman1001)

View file

@ -39,6 +39,7 @@
#include "iclass_cmd.h" #include "iclass_cmd.h"
#include "crypto/asn1utils.h" // ASN1 decoder #include "crypto/asn1utils.h" // ASN1 decoder
#include "preferences.h" #include "preferences.h"
#include "generator.h"
#define NUM_CSNS 9 #define NUM_CSNS 9
@ -1448,6 +1449,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
arg_lit0("v", "verbose", "verbose output"), arg_lit0("v", "verbose", "verbose output"),
arg_lit0(NULL, "d6", "decode as block 6"), arg_lit0(NULL, "d6", "decode as block 6"),
arg_lit0("z", "dense", "dense dump output style"), arg_lit0("z", "dense", "dense dump output style"),
arg_lit0(NULL, "ns", "no save to file"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(clictx, Cmd, argtable, false); CLIExecWithReturn(clictx, Cmd, argtable, false);
@ -1472,6 +1474,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
bool verbose = arg_get_lit(clictx, 4); bool verbose = arg_get_lit(clictx, 4);
bool use_decode6 = arg_get_lit(clictx, 5); bool use_decode6 = arg_get_lit(clictx, 5);
bool dense_output = g_session.dense_output || arg_get_lit(clictx, 6); bool dense_output = g_session.dense_output || arg_get_lit(clictx, 6);
bool nosave = arg_get_lit(clictx, 7);
CLIParserFree(clictx); CLIParserFree(clictx);
// sanity checks // 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 // use the first block (CSN) for filename
char *fptr = calloc(50, sizeof(uint8_t)); char *fptr = calloc(50, sizeof(uint8_t));
if (fptr == false) { if (fptr == false) {
@ -1623,6 +1631,8 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
FillFileNameByUID(fptr, hdr->csn, "-dump-decrypted", sizeof(hdr->csn)); FillFileNameByUID(fptr, hdr->csn, "-dump-decrypted", sizeof(hdr->csn));
pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass); pm3_save_dump(fptr, decrypted, decryptedlen, jsfIclass);
free(fptr);
}
printIclassDumpContents(decrypted, 1, (decryptedlen / 8), decryptedlen, dense_output); printIclassDumpContents(decrypted, 1, (decryptedlen / 8), decryptedlen, dense_output);
@ -1634,11 +1644,9 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
// decode block 6 // decode block 6
bool has_values = (memcmp(decrypted + (8 * 6), empty, 8) != 0) && (memcmp(decrypted + (8 * 6), zeros, 8) != 0); bool has_values = (memcmp(decrypted + (8 * 6), empty, 8) != 0) && (memcmp(decrypted + (8 * 6), zeros, 8) != 0);
if (has_values) { if (has_values && use_sc) {
if (use_sc) {
DecodeBlock6(decrypted + (8 * 6)); DecodeBlock6(decrypted + (8 * 6));
} }
}
// decode block 7-8-9 // decode block 7-8-9
iclass_decode_credentials(decrypted); iclass_decode_credentials(decrypted);
@ -1664,7 +1672,6 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
PrintAndLogEx(INFO, "-----------------------------------------------------------------"); PrintAndLogEx(INFO, "-----------------------------------------------------------------");
free(decrypted); free(decrypted);
free(fptr);
} }
mbedtls_des3_free(&ctx); mbedtls_des3_free(&ctx);