Merge pull request #1272 from mwalker33/EM410x-Sim

Update cmdlfem410x.c
This commit is contained in:
Iceman 2021-05-15 09:24:34 +02:00 committed by GitHub
commit 71504daea2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -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... 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] ## [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) - Changed `hf fido` - refactored load/save json objects (@iceman1001)
- Moved / renamed `fido2.json` -> `client/resource/fido2_defparams.json` (@iceman1001) - Moved / renamed `fido2.json` -> `client/resource/fido2_defparams.json` (@iceman1001)
- Added openocd shikra support based on @ninjastyle82 patch to deprecated iceman fork (@iceman1001) - Added openocd shikra support based on @ninjastyle82 patch to deprecated iceman fork (@iceman1001)

View file

@ -48,13 +48,13 @@ static int CmdHelp(const char *Cmd);
*/ */
// Construct the graph for emulating an EM410X tag // 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 gap) {
// clear our graph // clear our graph
ClearGraph(true); ClearGraph(true);
// write 16 zero bit sledge // write 16 zero bit sledge
for (uint8_t i = 0; i < 20; i++) for (uint8_t i = 0; i < gap; i++)
AppendGraph(false, clock, 0); AppendGraph(false, clock, 0);
// write 9 start bits // write 9 start bits
@ -403,13 +403,15 @@ static int CmdEM410xSim(const char *Cmd) {
"Enables simulation of EM 410x card.\n" "Enables simulation of EM 410x card.\n"
"Simulation runs until the button is pressed or another USB command is issued.", "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\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[] = { void *argtable[] = {
arg_param_begin, arg_param_begin,
arg_u64_0(NULL, "clk", "<dec>", "<32|64> clock (default 64)"), arg_u64_0(NULL, "clk", "<dec>", "<32|64> clock (default 64)"),
arg_str1(NULL, "id", "<hex>", "ID number (5 hex bytes)"), arg_str1(NULL, "id", "<hex>", "ID number (5 hex bytes)"),
arg_u64_0(NULL, "gap", "<dec>", "gap (0's) between ID repeats (default 20)"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
@ -417,6 +419,7 @@ static int CmdEM410xSim(const char *Cmd) {
// clock is 64 in EM410x tags // clock is 64 in EM410x tags
int clk = arg_get_u32_def(ctx, 1, 64); int clk = arg_get_u32_def(ctx, 1, 64);
int uid_len = 0; int uid_len = 0;
int gap = arg_get_u32_def(ctx,3,20);
uint8_t uid[5] = {0}; uint8_t uid[5] = {0};
CLIGetHexWithReturn(ctx, 2, uid, &uid_len); CLIGetHexWithReturn(ctx, 2, uid, &uid_len);
CLIParserFree(ctx); CLIParserFree(ctx);
@ -427,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); 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, gap);
CmdLFSim(""); CmdLFSim("");
return PM3_SUCCESS; return PM3_SUCCESS;
} }
@ -447,13 +450,14 @@ static int CmdEM410xBrute(const char *Cmd) {
arg_u64_0(NULL, "clk", "<dec>", "<32|64> clock (default 64)"), arg_u64_0(NULL, "clk", "<dec>", "<32|64> clock (default 64)"),
arg_u64_0(NULL, "delay", "<dec>", "pause delay in milliseconds between UIDs simulation (default 1000ms)"), arg_u64_0(NULL, "delay", "<dec>", "pause delay in milliseconds between UIDs simulation (default 1000ms)"),
arg_str1("f", "file", "<hex>", "file with UIDs in HEX format, one per line"), arg_str1("f", "file", "<hex>", "file with UIDs in HEX format, one per line"),
arg_u64_0(NULL, "gap", "<dec>", "gap (0's) between ID repeats (default 20)"),
arg_param_end arg_param_end
}; };
CLIExecWithReturn(ctx, Cmd, argtable, false); CLIExecWithReturn(ctx, Cmd, argtable, false);
// clock default 64 in EM410x // clock default 64 in EM410x
uint32_t clk = arg_get_u32_def(ctx, 1, 64); uint32_t clk = arg_get_u32_def(ctx, 1, 64);
int gap = arg_get_u32_def(ctx, 4, 20);
// default pause time: 1 second // default pause time: 1 second
uint32_t delay = arg_get_u32_def(ctx, 2, 1000); uint32_t delay = arg_get_u32_def(ctx, 2, 1000);
@ -548,7 +552,7 @@ static int CmdEM410xBrute(const char *Cmd) {
, sprint_hex_inrow(testuid, sizeof(testuid)) , sprint_hex_inrow(testuid, sizeof(testuid))
); );
em410x_construct_emul_graph(testuid, clk); em410x_construct_emul_graph(testuid, clk, gap);
lfsim_upload_gb(); lfsim_upload_gb();