From fd121bab4ffd02516ae0921171968d7f94b8caad Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 22 Oct 2023 18:56:19 +0200 Subject: [PATCH 1/5] added nosave parameter to lf em 4x05 dump --- CHANGELOG.md | 1 + client/src/cmdlfem4x05.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 084441cc8..7b5156d96 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] + - Changed `lf em 4x05 dump` - now supports the `--ns` nosave parameter (@iceman1001) - Added new command `data bmap` - breaks down a hexvalue to a binary template (@iceman1001) - Changed aid_desfire.json - added entreis from the Metrodroid project (@iceman1001) - Changed mad.json - added entries from the Metrodroid project (@iceman1001) diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index f548d98e3..423afbab7 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -514,6 +514,7 @@ int CmdEM4x05Dump(const char *Cmd) { arg_param_begin, arg_str0("p", "pwd", "", "password (00000000)"), arg_str0("f", "file", "", "override filename prefix (optional). Default is based on UID"), + arg_lit0(NULL, "ns", "no save to file"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, true); @@ -522,6 +523,7 @@ int CmdEM4x05Dump(const char *Cmd) { int fnlen = 0; char filename[FILE_PATH_SIZE] = {0}; CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t *)filename, FILE_PATH_SIZE, &fnlen); + bool nosave = arg_get_lit(ctx, 3); CLIParserFree(ctx); uint8_t addr = 0; @@ -693,6 +695,13 @@ int CmdEM4x05Dump(const char *Cmd) { } else { } + if (nosave) { + PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(INFO, "Called with no save option"); + PrintAndLogEx(NORMAL, ""); + return PM3_SUCCESS; + } + // all ok save dump to file if (success == PM3_SUCCESS) { From 3a2b2dffae37b6fafe82e61a6d94a92f3e4698b8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sun, 22 Oct 2023 19:57:48 +0200 Subject: [PATCH 2/5] add some colors --- client/src/cmdlfem4x05.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index 423afbab7..9b0e69753 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -750,16 +750,16 @@ int CmdEM4x05Read(const char *Cmd) { bool use_pwd = false; if (addr > 15) { - PrintAndLogEx(ERR, "Address must be between 0 and 15"); + PrintAndLogEx(ERR, "Address must be between 0 and 15, got " _RED_("%d"), addr); return PM3_EINVARG; } if (inputpwd == 0xFFFFFFFFFFFFFFFF) { - PrintAndLogEx(INFO, "Reading address %02u", addr); + PrintAndLogEx(INFO, "Reading address " _YELLOW_("%02u"), addr); } else { pwd = (inputpwd & 0xFFFFFFFF); use_pwd = true; - PrintAndLogEx(INFO, "Reading address %02u using password %08X", addr, pwd); + PrintAndLogEx(INFO, "Reading address " _YELLOW_("%02u") " using password " _YELLOW_("%08X"), addr, pwd); } uint32_t word = 0; @@ -827,14 +827,14 @@ int CmdEM4x05Write(const char *Cmd) { if (use_pwd) { if (protect_operation) - PrintAndLogEx(INFO, "Writing protection words data %08X using password %08X", data, pwd); + PrintAndLogEx(INFO, "Writing protection words data " _YELLOW_("%08X") " using password " _YELLOW_("%08X"), data, pwd); else - PrintAndLogEx(INFO, "Writing address %d data %08X using password %08X", addr, data, pwd); + PrintAndLogEx(INFO, "Writing address " _YELLOW_("%d") " data " _YELLOW_("%08X") " using password " _YELLOW_("%08X"), addr, data, pwd); } else { if (protect_operation) - PrintAndLogEx(INFO, "Writing protection words data %08X", data); + PrintAndLogEx(INFO, "Writing protection words data " _YELLOW_("%08X") , data); else - PrintAndLogEx(INFO, "Writing address %d data %08X", addr, data); + PrintAndLogEx(INFO, "Writing address " _YELLOW_("%d") " data " _YELLOW_("%08X") , addr, data); } res = PM3_SUCCESS; @@ -859,7 +859,7 @@ int CmdEM4x05Write(const char *Cmd) { if (status == PM3_SUCCESS) PrintAndLogEx(SUCCESS, "Data written and verified"); else if (status == PM3_EFAILED) - PrintAndLogEx(ERR, "Tag denied %s operation", protect_operation ? "Protect" : "Write"); + PrintAndLogEx(ERR, "Tag denied " _RED_("%s") " operation", protect_operation ? "Protect" : "Write"); else PrintAndLogEx(DEBUG, "No answer from tag"); From baecf198013e59f0cf444ffe496657672f373299 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 22 Oct 2023 21:02:01 +0200 Subject: [PATCH 3/5] fix lf_em_tearoff --- client/luascripts/lf_em_tearoff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/luascripts/lf_em_tearoff.lua b/client/luascripts/lf_em_tearoff.lua index 2aa0dd5ee..8c56eaede 100644 --- a/client/luascripts/lf_em_tearoff.lua +++ b/client/luascripts/lf_em_tearoff.lua @@ -114,7 +114,7 @@ local function main(args) local set_tearoff_delay = 'hw tearoff --delay %d' local enable_tearoff = 'hw tearoff --on' - local wr_template = 'lf em 4x05_write %s %s %s' + local wr_template = 'lf em 4x05 write --addr %s --data %s --pwd %s' -- init addr to value core.console(wr_template:format(addr, wr_value, password)) From 675c86ec98a5395c0dcedd0fb1ab437b375f8436 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 22 Oct 2023 22:06:13 +0200 Subject: [PATCH 4/5] lf_em_tearoff: better safe than sorry --- client/luascripts/lf_em_tearoff.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/luascripts/lf_em_tearoff.lua b/client/luascripts/lf_em_tearoff.lua index 8c56eaede..ee8acfa70 100644 --- a/client/luascripts/lf_em_tearoff.lua +++ b/client/luascripts/lf_em_tearoff.lua @@ -83,15 +83,15 @@ local function main(args) ed = ed or 2100 if #password ~= 8 then - password = '' + return oops('password must be 4 hex bytes') end if #wr_value ~= 8 then - wr_value = 'FFFFFFFF' + return oops('write value must be 4 hex bytes') end if #rd_value ~= 8 then - rd_value = 'FFFFFFFF' + return oops('read value must be 4 hex bytes') end if sd > ed then From e20742dd0420b101499a31e04e3a4960473e88ea Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 22 Oct 2023 22:39:01 +0200 Subject: [PATCH 5/5] lf_em_tearoff: oops accept absence of pwd --- client/luascripts/lf_em_tearoff.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/luascripts/lf_em_tearoff.lua b/client/luascripts/lf_em_tearoff.lua index ee8acfa70..c26979d9a 100644 --- a/client/luascripts/lf_em_tearoff.lua +++ b/client/luascripts/lf_em_tearoff.lua @@ -82,7 +82,7 @@ local function main(args) sd = sd or 2000 ed = ed or 2100 - if #password ~= 8 then + if password ~= '' and #password ~= 8 then return oops('password must be 4 hex bytes') end