From ba83ac065eeed01b436470d0f8ae04543a1c43a1 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Wed, 13 Mar 2024 09:25:43 -0700 Subject: [PATCH] `lf em 4x70 writepin` --> `lf em 4x70 setpin` --- armsrc/appmain.c | 2 +- armsrc/em4x70.c | 2 +- client/src/cmdlfem4x70.c | 28 ++++++++++++++-------------- client/src/cmdlfem4x70.h | 2 +- client/src/pm3line_vocabulary.h | 2 +- doc/commands.json | 10 +++++----- doc/commands.md | 4 ++-- include/pm3_cmd.h | 2 +- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 6fad3c6ee..8f83e9817 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1249,7 +1249,7 @@ static void PacketReceived(PacketCommandNG *packet) { em4x70_auth((em4x70_data_t *)packet->data.asBytes, true); break; } - case CMD_LF_EM4X70_WRITEPIN: { + case CMD_LF_EM4X70_SETPIN: { em4x70_write_pin((em4x70_data_t *)packet->data.asBytes, true); break; } diff --git a/armsrc/em4x70.c b/armsrc/em4x70.c index 1ab415dae..f6e1335f3 100644 --- a/armsrc/em4x70.c +++ b/armsrc/em4x70.c @@ -879,7 +879,7 @@ void em4x70_write_pin(const em4x70_data_t *etd, bool ledcontrol) { StopTicks(); lf_finalize(ledcontrol); - reply_ng(CMD_LF_EM4X70_WRITEPIN, status, tag.data, sizeof(tag.data)); + reply_ng(CMD_LF_EM4X70_SETPIN, status, tag.data, sizeof(tag.data)); } void em4x70_write_key(const em4x70_data_t *etd, bool ledcontrol) { diff --git a/client/src/cmdlfem4x70.c b/client/src/cmdlfem4x70.c index b9d632703..d6fa3da10 100644 --- a/client/src/cmdlfem4x70.c +++ b/client/src/cmdlfem4x70.c @@ -126,10 +126,10 @@ typedef struct _em4x70_cmd_output_auth_t { ID48LIB_GRN grn; } em4x70_cmd_output_auth_t; -typedef struct _em4x70_cmd_input_writepin_t { +typedef struct _em4x70_cmd_input_setpin_t { uint8_t use_parity; uint8_t pin[4]; -} em4x70_cmd_input_writepin_t; +} em4x70_cmd_input_setpin_t; typedef struct _em4x70_cmd_input_writekey_t { uint8_t use_parity; @@ -369,7 +369,7 @@ static int unlock_em4x70(const em4x70_cmd_input_unlock_t *opts, em4x70_tag_info_ return PM3_ESOFT; } -static int writepin_em4x70(const em4x70_cmd_input_writepin_t *opts, em4x70_tag_info_t *data_out) { +static int setpin_em4x70(const em4x70_cmd_input_setpin_t *opts, em4x70_tag_info_t *data_out) { memset(data_out, 0, sizeof(em4x70_tag_info_t)); // TODO: change firmware to use per-cmd structures @@ -378,10 +378,10 @@ static int writepin_em4x70(const em4x70_cmd_input_writepin_t *opts, em4x70_tag_i etd.pin = BYTES2UINT32(opts->pin); clearCommandBuffer(); - SendCommandNG(CMD_LF_EM4X70_WRITEPIN, (uint8_t *)&etd, sizeof(etd)); + SendCommandNG(CMD_LF_EM4X70_SETPIN, (uint8_t *)&etd, sizeof(etd)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_LF_EM4X70_WRITEPIN, &resp, TIMEOUT)) { + if (!WaitForResponseTimeout(CMD_LF_EM4X70_SETPIN, &resp, TIMEOUT)) { return PM3_ETIMEOUT; } if (resp.status) { @@ -724,12 +724,12 @@ int CmdEM4x70Auth(const char *Cmd) { return result; } -int CmdEM4x70WritePIN(const char *Cmd) { +int CmdEM4x70SetPIN(const char *Cmd) { CLIParserContext *ctx; - CLIParserInit(&ctx, "lf em 4x70 writepin", - "Write PIN\n", - "lf em 4x70 writepin -p 11223344 -> Write PIN\n" - "lf em 4x70 writepin -p 11223344 --par -> Write PIN using parity commands\n" + CLIParserInit(&ctx, "lf em 4x70 setpin", + "Write new PIN\n", + "lf em 4x70 setpin -p 11223344 -> Write new PIN\n" + "lf em 4x70 setpin -p 11223344 --par -> Write new PIN using parity commands\n" ); void *argtable[] = { arg_param_begin, @@ -739,7 +739,7 @@ int CmdEM4x70WritePIN(const char *Cmd) { }; CLIExecWithReturn(ctx, Cmd, argtable, true); - em4x70_cmd_input_writepin_t opts = { + em4x70_cmd_input_setpin_t opts = { .use_parity = arg_get_lit(ctx, 1), .pin = {0}, // hex value macro exits function, so cannot be initialized here }; @@ -755,7 +755,7 @@ int CmdEM4x70WritePIN(const char *Cmd) { // Client command line parsing and validation complete ... now use the helper function em4x70_tag_info_t info; - int result = writepin_em4x70(&opts, &info); + int result = setpin_em4x70(&opts, &info); if (result == PM3_ETIMEOUT) { PrintAndLogEx(WARNING, "Timeout while waiting for reply."); } else if (result == PM3_SUCCESS) { @@ -1392,9 +1392,9 @@ static command_t CommandTable[] = { {"write", CmdEM4x70Write, IfPm3EM4x70, "Write EM4x70"}, {"unlock", CmdEM4x70Unlock, IfPm3EM4x70, "Unlock EM4x70 for writing"}, {"auth", CmdEM4x70Auth, IfPm3EM4x70, "Authenticate EM4x70"}, - {"writepin", CmdEM4x70WritePIN, IfPm3EM4x70, "Write PIN"}, + {"setpin", CmdEM4x70SetPIN, IfPm3EM4x70, "Write PIN"}, {"writekey", CmdEM4x70WriteKey, IfPm3EM4x70, "Write key"}, - {"recover", CmdEM4x70Recover, IfPm3EM4x70, "Recover remaining key from partial key"}, + {"recover", CmdEM4x70Recover, AlwaysAvailable, "Recover remaining key from partial key"}, {"autorecover", CmdEM4x70AutoRecover, IfPm3EM4x70, "Recover entire key from writable tag"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/src/cmdlfem4x70.h b/client/src/cmdlfem4x70.h index 1158321a3..dbe5bb4ce 100644 --- a/client/src/cmdlfem4x70.h +++ b/client/src/cmdlfem4x70.h @@ -29,7 +29,7 @@ int CmdEM4x70Write(const char *Cmd); int CmdEM4x70Brute(const char *Cmd); int CmdEM4x70Unlock(const char *Cmd); int CmdEM4x70Auth(const char *Cmd); -int CmdEM4x70WritePIN(const char *Cmd); +int CmdEM4x70SetPIN(const char *Cmd); int CmdEM4x70WriteKey(const char *Cmd); int CmdEM4x70Recover(const char *Cmd); diff --git a/client/src/pm3line_vocabulary.h b/client/src/pm3line_vocabulary.h index 98b6e5ec6..44d9d8aa7 100644 --- a/client/src/pm3line_vocabulary.h +++ b/client/src/pm3line_vocabulary.h @@ -613,7 +613,7 @@ const static vocabulary_t vocabulary[] = { { 0, "lf em 4x70 write" }, { 0, "lf em 4x70 unlock" }, { 0, "lf em 4x70 auth" }, - { 0, "lf em 4x70 writepin" }, + { 0, "lf em 4x70 setpin" }, { 0, "lf em 4x70 writekey" }, { 0, "lf em 4x70 recover" }, { 0, "lf em 4x70 autorecover" }, diff --git a/doc/commands.json b/doc/commands.json index 401c20e1d..fe722101f 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -8982,12 +8982,12 @@ ], "usage": "lf em 4x70 writekey [-h] [--par] -k " }, - "lf em 4x70 writepin": { - "command": "lf em 4x70 writepin", + "lf em 4x70 setpin": { + "command": "lf em 4x70 setpin", "description": "Write PIN", "notes": [ - "lf em 4x70 writepin -p 11223344 -> Write PIN", - "lf em 4x70 writepin -p 11223344 --par -> Write PIN using parity commands" + "lf em 4x70 setpin -p 11223344 -> Write new PIN", + "lf em 4x70 setpin -p 11223344 --par -> Write new PIN using parity commands" ], "offline": false, "options": [ @@ -8995,7 +8995,7 @@ "--par Add parity bit when sending commands", "-p, --pin pin, 4 bytes" ], - "usage": "lf em 4x70 writepin [-h] [--par] -p " + "usage": "lf em 4x70 setpin [-h] [--par] -p " }, "lf em help": { "command": "lf em help", diff --git a/doc/commands.md b/doc/commands.md index 25624d7f0..83d1ddc14 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -960,8 +960,8 @@ Check column "offline" for their availability. |`lf em 4x70 write `|N |`Write EM4x70` |`lf em 4x70 unlock `|N |`Unlock EM4x70 for writing` |`lf em 4x70 auth `|N |`Authenticate EM4x70` -|`lf em 4x70 writepin `|N |`Write PIN` -|`lf em 4x70 writekey `|N |`Write key` +|`lf em 4x70 setpin `|N |`Write new PIN` +|`lf em 4x70 writekey `|N |`Write new key` |`lf em 4x70 recover `|N |`Recover remaining key from partial key` |`lf em 4x70 autorecover `|N |`Recover entire key from writable tag` diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index e8fe0f4f9..8a1140a2f 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -527,7 +527,7 @@ typedef struct { #define CMD_LF_EM4X70_WRITE 0x0261 #define CMD_LF_EM4X70_UNLOCK 0x0262 #define CMD_LF_EM4X70_AUTH 0x0263 -#define CMD_LF_EM4X70_WRITEPIN 0x0264 +#define CMD_LF_EM4X70_SETPIN 0x0264 #define CMD_LF_EM4X70_WRITEKEY 0x0265 #define CMD_LF_EM4X70_BRUTE 0x0266 // Sampling configuration for LF reader/sniffer