From 309e88ca658f90486c645e471515bc43458083b8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 25 Feb 2024 17:39:28 +0100 Subject: [PATCH] the handle plot was showing the plot window when running hf search etc. now it will be downloaded the plot but plot window is hidden. if you show the plot window before running you will see it --- client/src/cmdhf.c | 8 +++++--- client/src/cmdhf.h | 2 +- client/src/cmdhf14a.c | 10 +++++++--- client/src/cmdhf14b.c | 5 +++-- client/src/cmdhffudan.c | 4 ++-- client/src/cmdhfmf.c | 35 ++++++++++++++++++++--------------- client/src/cmdhfmfu.c | 12 ++++++------ 7 files changed, 44 insertions(+), 32 deletions(-) diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index 888e5ced6..86d1e5c99 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -518,7 +518,7 @@ int CmdHFSniff(const char *Cmd) { return PM3_SUCCESS; } -int handle_hf_plot(void) { +int handle_hf_plot(bool show_plot) { uint8_t buf[FPGA_TRACE_SIZE] = {0}; @@ -534,7 +534,9 @@ int handle_hf_plot(void) { g_GraphTraceLen = FPGA_TRACE_SIZE; - ShowGraphWindow(); + if (show_plot) { + ShowGraphWindow(); + } // remove signal offset CmdHpf(""); @@ -558,7 +560,7 @@ int CmdHFPlot(const char *Cmd) { CLIExecWithReturn(ctx, Cmd, argtable, true); CLIParserFree(ctx); - return handle_hf_plot(); + return handle_hf_plot(true); } static int CmdHFList(const char *Cmd) { diff --git a/client/src/cmdhf.h b/client/src/cmdhf.h index 55f5d081d..12db46c6d 100644 --- a/client/src/cmdhf.h +++ b/client/src/cmdhf.h @@ -27,5 +27,5 @@ int CmdHFSearch(const char *Cmd); int CmdHFSniff(const char *Cmd); int CmdHFPlot(const char *Cmd); -int handle_hf_plot(void); +int handle_hf_plot(bool show_plot); #endif diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 03f479d74..452e174ac 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -642,9 +642,9 @@ static int CmdHF14AReader(const char *Cmd) { } plot: if (continuous) { - res = handle_hf_plot(); + res = handle_hf_plot(false); if (res != PM3_SUCCESS) { - break; + PrintAndLogEx(DEBUG, "plot failed"); } } @@ -2497,7 +2497,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { } if (isMifareUltralight) { - isMagic = ((detect_mf_magic(false, MF_KEY_A, 0) & MAGIC_FLAG_NTAG21X) == MAGIC_FLAG_NTAG21X); + isMagic = detect_mf_magic(false, MF_KEY_A, 0); } if (isMifareClassic) { @@ -2545,6 +2545,10 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { PrintAndLogEx(HINT, "Hint: use `" _YELLOW_("hf mfu *") "` magic commands"); } + if ((isMagic & MAGIC_FLAG_NTAG21X) == MAGIC_FLAG_NTAG21X) { + PrintAndLogEx(HINT, "Hint: use `" _YELLOW_("hf mfu *") "` magic commands"); + } + PrintAndLogEx(HINT, "Hint: try `" _YELLOW_("hf mfu info") "`"); } diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index b62f0e1c1..1409bd2d6 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -2724,9 +2724,10 @@ int readHF14B(bool loop, bool verbose) { if (found) goto plot; plot: - res = handle_hf_plot(); - if (res != PM3_SUCCESS) + res = handle_hf_plot(verbose); + if (res != PM3_SUCCESS) { PrintAndLogEx(DEBUG, "plot failed"); + } } while (loop && kbd_enter_pressed() == false); diff --git a/client/src/cmdhffudan.c b/client/src/cmdhffudan.c index 7a1091395..3cefa86f0 100644 --- a/client/src/cmdhffudan.c +++ b/client/src/cmdhffudan.c @@ -184,9 +184,9 @@ int read_fudan_uid(bool loop, bool verbose) { if (loop) { - res = handle_hf_plot(); + res = handle_hf_plot(verbose); if (res != PM3_SUCCESS) { - break; + PrintAndLogEx(DEBUG, "plot failed"); } } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 0e3a0a08a..09f25e821 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -8446,13 +8446,19 @@ static int CmdHF14AGen4ChangePwd(const char *Cmd) { } static void parse_gdm_cfg(const uint8_t *d) { - PrintAndLogEx(SUCCESS, "Config... " _YELLOW_("%s"), sprint_hex(d, MFBLOCK_SIZE)); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X %02X") " .......................................... %s %s", d[0], d[1], (d[0] == 0x85 && d[1] == 0x00) ? "Magic wakeup disabled" : _GREEN_("Magic wakeup enabled"), (d[0] == 0x85 && d[1] == 0x00) ? "" : ((d[0] == 0x7A && d[1] == 0xFF) ? _GREEN_("with GDM config block access") : _RED_("without GDM config block access"))); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ....................................... Magic wakeup style %s", d[2], ((d[2] == 0x85) ? "GDM 20(7)/23" : "Gen1a 40(7)/43")); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X %02X %02X") " .............................. Unknown", d[3], d[4], d[5]); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ........................... %s", d[6], (d[6] == 0x5A) ? "Key B use blocked when readable by ACL" : "Key B use allowed when readable by ACL"); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ........................ %s", d[7], (d[7] == 0x5A) ? _GREEN_("Block 0 Direct Write Enabled (CUID)") : "Block 0 Direct Write Disabled (CUID)"); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ..................... Unknown", d[8]); + PrintAndLogEx(SUCCESS, "------------------- " _CYAN_("GDM Configuration") " -----------------------------------------"); + PrintAndLogEx(SUCCESS, _YELLOW_("%s"), sprint_hex_inrow(d, MFBLOCK_SIZE)); + PrintAndLogEx(SUCCESS, _YELLOW_("%02X%02X") "............................ %s %s" + , d[0] + , d[1] + , (d[0] == 0x85 && d[1] == 0x00) ? "Magic wakeup disabled" : _GREEN_("Magic wakeup enabled") + , (d[0] == 0x85 && d[1] == 0x00) ? "" : ((d[0] == 0x7A && d[1] == 0xFF) ? _GREEN_("with GDM cfg block access") : _RED_(", no GDM cfg block access")) + ); + PrintAndLogEx(SUCCESS, "...." _YELLOW_("%02X") ".......................... Magic wakeup style %s", d[2], ((d[2] == 0x85) ? "GDM 20(7)/23" : "Gen1a 40(7)/43")); + PrintAndLogEx(SUCCESS, "......" _YELLOW_("%02X%02X%02X") ".................... n/a", d[3], d[4], d[5]); + PrintAndLogEx(SUCCESS, "............" _YELLOW_("%02X") ".................. %s", d[6], (d[6] == 0x5A) ? "Key B use blocked when readable by ACL" : "Key B use allowed when readable by ACL"); + PrintAndLogEx(SUCCESS, ".............." _YELLOW_("%02X") "................ %s", d[7], (d[7] == 0x5A) ? _GREEN_("CUID - Block 0 Direct Write Enabled") : "CUID - Block 0 Direct Write Disabled"); + PrintAndLogEx(SUCCESS, "................" _YELLOW_("%02X") ".............. n/a", d[8]); const char *pers; switch (d[9]) { @@ -8475,14 +8481,13 @@ static void parse_gdm_cfg(const uint8_t *d) { pers = "4B UID from Block 0"; break; } - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " .................. MFC EV1 personalization: %s", d[9], pers); - - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ............... %s", d[10], (d[10] == 0x5A) ? _GREEN_("Shadow mode enabled") : "Shadow mode disabled"); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ............. %s", d[11], (d[11] == 0x5A) ? _GREEN_("Magic auth enabled") : "Magic auth disabled"); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ........... %s", d[12], (d[12] == 0x5A) ? _GREEN_("Static encrypted nonce enabled") : "Static encrypted nonce disabled"); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ......... %s", d[13], (d[13] == 0x5A) ? _GREEN_("MFC EV1 signature enabled") : "MFC EV1 signature disabled"); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ...... Unknown", d[14]); - PrintAndLogEx(SUCCESS, " " _YELLOW_("%02X") " ... SAK", d[15]); + PrintAndLogEx(SUCCESS, ".................." _YELLOW_("%02X") "............ MFC EV1 perso... " _YELLOW_("%s"), d[9], pers); + PrintAndLogEx(SUCCESS, "...................." _YELLOW_("%02X") ".......... %s", d[10], (d[10] == 0x5A) ? _GREEN_("Shadow mode enabled") : "Shadow mode disabled"); + PrintAndLogEx(SUCCESS, "......................" _YELLOW_("%02X") "........ %s", d[11], (d[11] == 0x5A) ? _GREEN_("Magic auth enabled") : "Magic auth disabled"); + PrintAndLogEx(SUCCESS, "........................" _YELLOW_("%02X") "...... %s", d[12], (d[12] == 0x5A) ? _GREEN_("Static encrypted nonce enabled") : "Static encrypted nonce disabled"); + PrintAndLogEx(SUCCESS, ".........................." _YELLOW_("%02X") ".... %s", d[13], (d[13] == 0x5A) ? _GREEN_("MFC EV1 signature enabled") : "MFC EV1 signature disabled"); + PrintAndLogEx(SUCCESS, "............................" _YELLOW_("%02X") ".. n/a", d[14]); + PrintAndLogEx(SUCCESS, ".............................." _YELLOW_("%02X") " SAK", d[15]); } static int CmdHF14AGen4_GDM_ParseCfg(const char *Cmd) { diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index f4aeafb91..bb5155d89 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -1465,7 +1465,7 @@ static int ul_magic_test(void) { return MFU_TT_UNKNOWN; } -static char *GenerateFilename(const char *prefix, const char *suffix) { +static char *mfu_generate_filename(const char *prefix, const char *suffix) { iso14a_card_select_t card; if (ul_select(&card) == false) { PrintAndLogEx(WARNING, "No tag found."); @@ -3329,7 +3329,7 @@ static int CmdHF14AMfURestore(const char *Cmd) { } if (fnlen == 0) { - char *fptr = GenerateFilename("hf-mfu-", "-dump.bin"); + char *fptr = mfu_generate_filename("hf-mfu-", "-dump.bin"); if (fptr != NULL) { strncpy(filename, fptr, sizeof(filename) - 1); } else { @@ -5265,22 +5265,22 @@ static command_t CommandTable[] = { {"otptear", CmdHF14AMfuOtpTearoff, IfPm3Iso14443a, "Tear-off test on OTP bits"}, // {"tear_cnt", CmdHF14AMfuEv1CounterTearoff, IfPm3Iso14443a, "Tear-off test on Ev1/NTAG Counter bits"}, {"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("operations") " -----------------------"}, - {"cauth", CmdHF14AMfUCAuth, IfPm3Iso14443a, "Authentication - Ultralight-C"}, + {"cauth", CmdHF14AMfUCAuth, IfPm3Iso14443a, "Ultralight-C - Authentication"}, + {"setpwd", CmdHF14AMfUCSetPwd, IfPm3Iso14443a, "Ultralight-C - Set 3DES key"}, {"dump", CmdHF14AMfUDump, IfPm3Iso14443a, "Dump MIFARE Ultralight family tag to binary file"}, {"info", CmdHF14AMfUInfo, IfPm3Iso14443a, "Tag information"}, {"ndefread", CmdHF14MfuNDEFRead, IfPm3Iso14443a, "Prints NDEF records from card"}, {"rdbl", CmdHF14AMfURdBl, IfPm3Iso14443a, "Read block"}, - {"restore", CmdHF14AMfURestore, IfPm3Iso14443a, "Restore a dump onto a MFU MAGIC tag"}, + {"restore", CmdHF14AMfURestore, IfPm3Iso14443a, "Restore a dump file onto a tag"}, + {"tamper", CmdHF14MfUTamper, IfPm3Iso14443a, "NTAG 213TT - Configure the tamper feature"}, {"view", CmdHF14AMfuView, AlwaysAvailable, "Display content from tag dump file"}, {"wrbl", CmdHF14AMfUWrBl, IfPm3Iso14443a, "Write block"}, - {"tamper", CmdHF14MfUTamper, IfPm3Iso14443a, "Configure the tamper feature on an NTAG 213TT"}, {"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("simulation") " -----------------------"}, {"eload", CmdHF14AMfUeLoad, IfPm3Iso14443a, "Upload file into emulator memory"}, {"esave", CmdHF14AMfuESave, IfPm3Iso14443a, "Save emulator memory to file"}, {"eview", CmdHF14AMfuEView, IfPm3Iso14443a, "View emulator memory"}, {"sim", CmdHF14AMfUSim, IfPm3Iso14443a, "Simulate MIFARE Ultralight from emulator memory"}, {"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("magic") " ----------------------------"}, - {"setpwd", CmdHF14AMfUCSetPwd, IfPm3Iso14443a, "Set 3DES key - Ultralight-C"}, {"setuid", CmdHF14AMfUCSetUid, IfPm3Iso14443a, "Set UID - MAGIC tags only"}, {"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("amiibo") " ----------------------------"}, {"amiibo", CmdHF14AAmiibo, IfPm3Iso14443a, "Amiibo tag operations"},