From a99eb7bf5b8d0c0602d29d5120256b14a9d5149e Mon Sep 17 00:00:00 2001 From: mwalker33 <51802811+mwalker33@users.noreply.github.com> Date: Sat, 15 May 2021 15:31:36 +1000 Subject: [PATCH 1/2] Update cmdlfem410x.c Draft EM4100 sim fix --- client/src/cmdlfem410x.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/client/src/cmdlfem410x.c b/client/src/cmdlfem410x.c index 435421663..74b16bc98 100644 --- a/client/src/cmdlfem410x.c +++ b/client/src/cmdlfem410x.c @@ -48,13 +48,13 @@ static int CmdHelp(const char *Cmd); */ // Construct the graph for emulating an EM410X tag -static void em410x_construct_emul_graph(uint8_t *uid, uint8_t clock) { +static void em410x_construct_emul_graph(uint8_t *uid, uint8_t clock, uint8_t zeros) { // clear our graph ClearGraph(true); // write 16 zero bit sledge - for (uint8_t i = 0; i < 20; i++) + for (uint8_t i = 0; i < zeros; i++) AppendGraph(false, clock, 0); // write 9 start bits @@ -410,6 +410,7 @@ static int CmdEM410xSim(const char *Cmd) { arg_param_begin, arg_u64_0(NULL, "clk", "", "<32|64> clock (default 64)"), arg_str1(NULL, "id", "", "ID number (5 hex bytes)"), + arg_u64_0(NULL, "zeros", "", "number of 0's between ID repeats (default 20)"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -417,6 +418,7 @@ static int CmdEM410xSim(const char *Cmd) { // clock is 64 in EM410x tags int clk = arg_get_u32_def(ctx, 1, 64); int uid_len = 0; + int zeros = arg_get_u32_def(ctx,3,20); uint8_t uid[5] = {0}; CLIGetHexWithReturn(ctx, 2, uid, &uid_len); CLIParserFree(ctx); @@ -427,7 +429,7 @@ static int CmdEM410xSim(const char *Cmd) { } PrintAndLogEx(SUCCESS, "Starting simulating UID "_YELLOW_("%s")" clock: "_YELLOW_("%d"), sprint_hex_inrow(uid, sizeof(uid)), clk); - em410x_construct_emul_graph(uid, clk); + em410x_construct_emul_graph(uid, clk, zeros); CmdLFSim(""); return PM3_SUCCESS; } @@ -453,7 +455,7 @@ static int CmdEM410xBrute(const char *Cmd) { // clock default 64 in EM410x uint32_t clk = arg_get_u32_def(ctx, 1, 64); - + int zeros = 20; // Should add argument to set.... // default pause time: 1 second uint32_t delay = arg_get_u32_def(ctx, 2, 1000); @@ -548,7 +550,7 @@ static int CmdEM410xBrute(const char *Cmd) { , sprint_hex_inrow(testuid, sizeof(testuid)) ); - em410x_construct_emul_graph(testuid, clk); + em410x_construct_emul_graph(testuid, clk, zeros); lfsim_upload_gb(); From 2e347393e148fe372bee53bd0a93d5ff7241ec69 Mon Sep 17 00:00:00 2001 From: mwalker33 <51802811+mwalker33@users.noreply.github.com> Date: Sat, 15 May 2021 15:59:43 +1000 Subject: [PATCH 2/2] option rename renamed option to --gap extended option to em410x reader brute updated change log --- CHANGELOG.md | 1 + client/src/cmdlfem410x.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80a923eda..5e09e96b1 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 '--gap' option to lf em 410x sim for more control over sim data (@mwalker) - Changed `hf fido` - refactored load/save json objects (@iceman1001) - Moved / renamed `fido2.json` -> `client/resource/fido2_defparams.json` (@iceman1001) - Added openocd shikra support based on @ninjastyle82 patch to deprecated iceman fork (@iceman1001) diff --git a/client/src/cmdlfem410x.c b/client/src/cmdlfem410x.c index 74b16bc98..bb8bdd46b 100644 --- a/client/src/cmdlfem410x.c +++ b/client/src/cmdlfem410x.c @@ -48,13 +48,13 @@ static int CmdHelp(const char *Cmd); */ // Construct the graph for emulating an EM410X tag -static void em410x_construct_emul_graph(uint8_t *uid, uint8_t clock, uint8_t zeros) { +static void em410x_construct_emul_graph(uint8_t *uid, uint8_t clock, uint8_t gap) { // clear our graph ClearGraph(true); // write 16 zero bit sledge - for (uint8_t i = 0; i < zeros; i++) + for (uint8_t i = 0; i < gap; i++) AppendGraph(false, clock, 0); // write 9 start bits @@ -403,14 +403,15 @@ static int CmdEM410xSim(const char *Cmd) { "Enables simulation of EM 410x card.\n" "Simulation runs until the button is pressed or another USB command is issued.", "lf em 410x sim --id 0F0368568B\n" - "lf em 410x sim --id 0F0368568B --clk 32" + "lf em 410x sim --id 0F0368568B --clk 32\n" + "lf em 410x sim --id 0F0368568B --gap 0" ); void *argtable[] = { arg_param_begin, arg_u64_0(NULL, "clk", "", "<32|64> clock (default 64)"), arg_str1(NULL, "id", "", "ID number (5 hex bytes)"), - arg_u64_0(NULL, "zeros", "", "number of 0's between ID repeats (default 20)"), + arg_u64_0(NULL, "gap", "", "gap (0's) between ID repeats (default 20)"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -418,7 +419,7 @@ static int CmdEM410xSim(const char *Cmd) { // clock is 64 in EM410x tags int clk = arg_get_u32_def(ctx, 1, 64); int uid_len = 0; - int zeros = arg_get_u32_def(ctx,3,20); + int gap = arg_get_u32_def(ctx,3,20); uint8_t uid[5] = {0}; CLIGetHexWithReturn(ctx, 2, uid, &uid_len); CLIParserFree(ctx); @@ -429,7 +430,7 @@ static int CmdEM410xSim(const char *Cmd) { } PrintAndLogEx(SUCCESS, "Starting simulating UID "_YELLOW_("%s")" clock: "_YELLOW_("%d"), sprint_hex_inrow(uid, sizeof(uid)), clk); - em410x_construct_emul_graph(uid, clk, zeros); + em410x_construct_emul_graph(uid, clk, gap); CmdLFSim(""); return PM3_SUCCESS; } @@ -449,13 +450,14 @@ static int CmdEM410xBrute(const char *Cmd) { arg_u64_0(NULL, "clk", "", "<32|64> clock (default 64)"), arg_u64_0(NULL, "delay", "", "pause delay in milliseconds between UIDs simulation (default 1000ms)"), arg_str1("f", "file", "", "file with UIDs in HEX format, one per line"), + arg_u64_0(NULL, "gap", "", "gap (0's) between ID repeats (default 20)"), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); // clock default 64 in EM410x uint32_t clk = arg_get_u32_def(ctx, 1, 64); - int zeros = 20; // Should add argument to set.... + int gap = arg_get_u32_def(ctx, 4, 20); // default pause time: 1 second uint32_t delay = arg_get_u32_def(ctx, 2, 1000); @@ -550,7 +552,7 @@ static int CmdEM410xBrute(const char *Cmd) { , sprint_hex_inrow(testuid, sizeof(testuid)) ); - em410x_construct_emul_graph(testuid, clk, zeros); + em410x_construct_emul_graph(testuid, clk, gap); lfsim_upload_gb();