From 5133d4a512be5cffb579e0e55e6aee2ad6362bf4 Mon Sep 17 00:00:00 2001 From: Nate Sales Date: Wed, 8 Feb 2023 19:58:07 -0500 Subject: [PATCH] feat: add -v verbose flag to "hf iclass encode" --- CHANGELOG.md | 1 + client/src/cmdhficlass.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81df05142..e1ef467cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 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] + - Added verbose flag to `hf iclass encode` (@natesales) - Fixed `lf em 4x70 brute` - now works as expected (@adite) - Fixed the lf sampling when bits_per_sample is less than 8 (@wh201906) - Added `lf em 4x70 brute` command (@adite) diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 94d710f98..36bd3b3d2 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -3832,6 +3832,7 @@ static int CmdHFiClassEncode(const char *Cmd) { arg_u64_0(NULL, "cn", "", "card number"), arg_str0("w", "wiegand", "", "see " _YELLOW_("`wiegand list`") " for available formats"), arg_lit0(NULL, "shallow", "use shallow (ASK) reader modulation instead of OOK"), + arg_lit0("v", NULL, "verbose (print encoded blocks)"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -3877,6 +3878,7 @@ static int CmdHFiClassEncode(const char *Cmd) { CLIParamStrToBuf(arg_get_str(ctx, 9), (uint8_t *)format, sizeof(format), &format_len); bool shallow_mod = arg_get_lit(ctx, 10); + bool verbose = arg_get_lit(ctx, 11); CLIParserFree(ctx); @@ -3996,6 +3998,17 @@ static int CmdHFiClassEncode(const char *Cmd) { iclass_encrypt_block_data(credential + 24, enc_key); } + if (verbose) { + for (uint8_t i = 0; i < 4; i++) { + PrintAndLogEx(INFO, "Block %d/0x0%x -> " _YELLOW_("%s"), 6 + i, 6 + i, sprint_hex_inrow(credential + (i * 8), 8)); + } + } + + if (!g_session.pm3_present) { + PrintAndLogEx(ERR, "Device offline\n"); + return PM3_EFAILED; + } + int isok = PM3_SUCCESS; // write for (uint8_t i = 0; i < 4; i++) {