From 1a39ec3026a0f185fa9228d38710221af775e376 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 6 Jun 2019 11:31:47 +0200 Subject: [PATCH] hf mf/mfu dbg => hw dbg --- armsrc/appmain.c | 4 ++-- client/cmdhfmf.c | 28 ---------------------------- client/cmdhfmfu.c | 1 - client/cmdhw.c | 29 +++++++++++++++++++++++++++++ client/scripts/didump.lua | 2 +- client/scripts/ntag_3d.lua | 4 ++-- client/scripts/tnp3dump.lua | 2 +- client/scripts/tnp3sim.lua | 2 +- include/pm3_cmd.h | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 916801954..14a14c4dd 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1115,10 +1115,10 @@ static void PacketReceived(PacketCommandNG *packet) { break; } // emulator - case CMD_MIFARE_SET_DBGMODE: + case CMD_SET_DBGMODE: DBGLEVEL = packet->data.asBytes[0]; Dbprintf("Debug level: %d", DBGLEVEL); - reply_ng(CMD_MIFARE_SET_DBGMODE, PM3_SUCCESS, NULL, 0); + reply_ng(CMD_SET_DBGMODE, PM3_SUCCESS, NULL, 0); break; case CMD_MIFARE_EML_MEMCLR: MifareEMemClr(); diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 172d58418..3aaa5187f 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -85,21 +85,6 @@ static int usage_hf14_mfsim(void) { PrintAndLogEx(NORMAL, " hf mf sim u 11223344 i x"); return 0; } -static int usage_hf14_dbg(void) { - PrintAndLogEx(NORMAL, "Usage: hf mf dbg [h] "); - PrintAndLogEx(NORMAL, "Options:"); - PrintAndLogEx(NORMAL, " h this help"); - PrintAndLogEx(NORMAL, " (Optional) see list for valid levels"); - PrintAndLogEx(NORMAL, " 0 - no debug messages"); - PrintAndLogEx(NORMAL, " 1 - error messages"); - PrintAndLogEx(NORMAL, " 2 - plus information messages"); - PrintAndLogEx(NORMAL, " 3 - plus debug messages"); - PrintAndLogEx(NORMAL, " 4 - print even debug messages in timing critical functions"); - PrintAndLogEx(NORMAL, " Note: this option therefore may cause malfunction itself"); - PrintAndLogEx(NORMAL, "Examples:"); - PrintAndLogEx(NORMAL, " hf mf dbg 3"); - return 0; -} /* * static int usage_hf14_sniff(void) { PrintAndLogEx(NORMAL, "It continuously gets data from the field and saves it to: log, emulator, emulator file."); @@ -2475,18 +2460,6 @@ static int CmdHF14AMfSniff(const char *Cmd) { return PM3_SUCCESS; } */ -int CmdHF14AMfDbg(const char *Cmd) { - - char ctmp = tolower(param_getchar(Cmd, 0)); - if (strlen(Cmd) < 1 || ctmp == 'h') return usage_hf14_dbg(); - - uint8_t dbgMode = param_get8ex(Cmd, 0, 0, 10); - if (dbgMode > 4) return usage_hf14_dbg(); - - SendCommandNG(CMD_MIFARE_SET_DBGMODE, &dbgMode, 1); - return PM3_SUCCESS; -} - static int CmdHF14AMfKeyBrute(const char *Cmd) { uint8_t blockNo = 0, keytype = 0; @@ -3640,7 +3613,6 @@ static command_t CommandTable[] = { {"fchk", CmdHF14AMfChk_fast, IfPm3Iso14443a, "Check keys fast, targets all keys on card"}, {"decrypt", CmdHf14AMfDecryptBytes, AlwaysAvailable, "[nt] [ar_enc] [at_enc] [data] - to decrypt sniff or trace"}, {"-----------", CmdHelp, IfPm3Iso14443a, ""}, - {"dbg", CmdHF14AMfDbg, IfPm3Iso14443a, "Set default debug mode"}, {"rdbl", CmdHF14AMfRdBl, IfPm3Iso14443a, "Read MIFARE classic block"}, {"rdsc", CmdHF14AMfRdSc, IfPm3Iso14443a, "Read MIFARE classic sector"}, {"dump", CmdHF14AMfDump, IfPm3Iso14443a, "Dump MIFARE classic tag to binary file"}, diff --git a/client/cmdhfmfu.c b/client/cmdhfmfu.c index fc1c8da75..77624ee59 100644 --- a/client/cmdhfmfu.c +++ b/client/cmdhfmfu.c @@ -2706,7 +2706,6 @@ static int CmdHF14AMfUPwdGen(const char *Cmd) { //------------------------------------ static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, - {"dbg", CmdHF14AMfDbg, IfPm3Iso14443a, "Set default debug mode"}, {"info", CmdHF14AMfUInfo, IfPm3Iso14443a, "Tag information"}, {"dump", CmdHF14AMfUDump, IfPm3Iso14443a, "Dump Ultralight / Ultralight-C / NTAG tag to binary file"}, {"restore", CmdHF14AMfURestore, IfPm3Iso14443a, "Restore a dump onto a MFU MAGIC tag"}, diff --git a/client/cmdhw.c b/client/cmdhw.c index e57899019..008bcfe2d 100644 --- a/client/cmdhw.c +++ b/client/cmdhw.c @@ -22,6 +22,22 @@ static int CmdHelp(const char *Cmd); +static int usage_dbg(void) { + PrintAndLogEx(NORMAL, "Usage: hw dbg [h] "); + PrintAndLogEx(NORMAL, "Options:"); + PrintAndLogEx(NORMAL, " h this help"); + PrintAndLogEx(NORMAL, " (Optional) see list for valid levels"); + PrintAndLogEx(NORMAL, " 0 - no debug messages"); + PrintAndLogEx(NORMAL, " 1 - error messages"); + PrintAndLogEx(NORMAL, " 2 - plus information messages"); + PrintAndLogEx(NORMAL, " 3 - plus debug messages"); + PrintAndLogEx(NORMAL, " 4 - print even debug messages in timing critical functions"); + PrintAndLogEx(NORMAL, " Note: this option therefore may cause malfunction itself"); + PrintAndLogEx(NORMAL, "Examples:"); + PrintAndLogEx(NORMAL, " hw dbg 3"); + return 0; +} + static int usage_hw_detectreader(void) { PrintAndLogEx(NORMAL, "Start to detect presences of reader field"); PrintAndLogEx(NORMAL, "press pm3 button to change modes and finally exit"); @@ -349,6 +365,18 @@ static void lookupChipID(uint32_t iChipID, uint32_t mem_used) { PrintAndLogEx(NORMAL, " --= Nonvolatile Program Memory Type: %s", asBuff); } +int CmdDbg(const char *Cmd) { + + char ctmp = tolower(param_getchar(Cmd, 0)); + if (strlen(Cmd) < 1 || ctmp == 'h') return usage_dbg(); + + uint8_t dbgMode = param_get8ex(Cmd, 0, 0, 10); + if (dbgMode > 4) return usage_dbg(); + + SendCommandNG(CMD_SET_DBGMODE, &dbgMode, 1); + return PM3_SUCCESS; +} + static int CmdDetectReader(const char *Cmd) { uint8_t arg = 0; char c = toupper(Cmd[0]); @@ -552,6 +580,7 @@ static int CmdConnect(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, + {"dbg", CmdDbg, IfPm3Present, "Set Proxmark3 debug level"}, {"connect", CmdConnect, AlwaysAvailable, "connect Proxmark3 to serial port"}, {"detectreader", CmdDetectReader, IfPm3Present, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"}, {"fpgaoff", CmdFPGAOff, IfPm3Present, "Set FPGA off"}, diff --git a/client/scripts/didump.lua b/client/scripts/didump.lua index e85ec8bb9..b0cc964ee 100644 --- a/client/scripts/didump.lua +++ b/client/scripts/didump.lua @@ -551,7 +551,7 @@ local function selftest() print ('VALID KEY :: 29564af75805') end local function setdevicedebug( status ) - local c = 'hf mf dbg ' + local c = 'hw dbg ' if status then c = c..'1' else diff --git a/client/scripts/ntag_3d.lua b/client/scripts/ntag_3d.lua index e5b4205d8..ff2c68d0f 100644 --- a/client/scripts/ntag_3d.lua +++ b/client/scripts/ntag_3d.lua @@ -185,7 +185,7 @@ end local function write_tag(uid, t) print('Writing to tag') - core.console('hf mf dbg 0') + core.console('hw dbg 0') utils.Sleep(0.5) local cmd = '' @@ -203,7 +203,7 @@ local function write_tag(uid, t) --dynamic core.console(('hf mfu wrbl b 40 d %s k %08X'):format(t[40], pwd)) - core.console('hf mf dbg 1') + core.console('hw dbg 1') utils.Sleep(0.5) print('Done') end diff --git a/client/scripts/tnp3dump.lua b/client/scripts/tnp3dump.lua index 9e3c62519..00070eacc 100644 --- a/client/scripts/tnp3dump.lua +++ b/client/scripts/tnp3dump.lua @@ -128,7 +128,7 @@ local function main(args) end -- Turn off Debug - local cmdSetDbgOff = "hf mf dbg 0" + local cmdSetDbgOff = "hw dbg 0" core.console( cmdSetDbgOff) utils.Sleep(0.5) diff --git a/client/scripts/tnp3sim.lua b/client/scripts/tnp3sim.lua index 8e595363e..f1b58f95e 100644 --- a/client/scripts/tnp3sim.lua +++ b/client/scripts/tnp3sim.lua @@ -368,7 +368,7 @@ local function main(args) end -- Turn off Debug - local cmdSetDbgOff = 'hf mf dbg 0' + local cmdSetDbgOff = 'hw dbg 0' core.console( cmdSetDbgOff) utils.Sleep(0.5) diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 9f05f71f3..b8c62dac7 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -234,6 +234,7 @@ typedef struct { #define CMD_DOWNLOADED_EML_BIGBUF 0x0111 #define CMD_CAPABILITIES 0x0112 #define CMD_QUIT_SESSION 0x0113 +#define CMD_SET_DBGMODE 0x0114 // RDV40, Flash memory operations #define CMD_FLASHMEM_READ 0x0120 @@ -378,7 +379,6 @@ typedef struct { #define CMD_FPGA_MAJOR_MODE_OFF 0x0500 // For mifare commands -#define CMD_MIFARE_SET_DBGMODE 0x0600 #define CMD_MIFARE_EML_MEMCLR 0x0601 #define CMD_MIFARE_EML_MEMSET 0x0602 #define CMD_MIFARE_EML_MEMGET 0x0603