From 5470e507b2675f68c9f8b857a5e20d68fc201d6a Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Thu, 18 Oct 2018 20:23:25 +0300 Subject: [PATCH] key number not mandatory --- client/cmdhfmfp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/cmdhfmfp.c b/client/cmdhfmfp.c index 6e092266..92c0be9d 100644 --- a/client/cmdhfmfp.c +++ b/client/cmdhfmfp.c @@ -23,6 +23,8 @@ #include "mifare.h" #include "cliparser/cliparser.h" +static const uint8_t DefaultKey[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + static int CmdHelp(const char *Cmd); int CmdHFMFPInfo(const char *cmd) { @@ -112,13 +114,14 @@ int CmdHFMFPWritePerso(const char *cmd) { CLIParserInit("hf mfp wrp", "Executes Write Perso command. Can be used in SL0 mode only.", - "Usage:\n\thf mfp wrp 4000 000102030405060708090a0b0c0d0e0f -> write key (00..0f) to key number 4000 \n"); + "Usage:\n\thf mfp wrp 4000 000102030405060708090a0b0c0d0e0f -> write key (00..0f) to key number 4000 \n" + "\thf mfp wrp 4000 -> write default key(0xff..0xff) to key number 4000"); void* argtable[] = { arg_param_begin, arg_lit0("vV", "verbose", "show internal data."), arg_str1(NULL, NULL, "", NULL), - arg_strx1(NULL, NULL, "", NULL), + arg_strx0(NULL, NULL, "", NULL), arg_param_end }; CLIExecWithReturn(cmd, argtable, true); @@ -128,6 +131,11 @@ int CmdHFMFPWritePerso(const char *cmd) { CLIGetHexWithReturn(3, key, &keyLen); CLIParserFree(); + if (!keyLen) { + memmove(key, DefaultKey, 16); + keyLen = 16; + } + if (keyNumLen != 2) { PrintAndLog("Key number length must be 2 bytes instead of: %d", keyNumLen); return 1;