From 8bed10029e0c30efbfae2f6ab27b7cd610442537 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 14:46:02 +0300 Subject: [PATCH 1/8] cli update --- client/src/cmdhfmfdes.c | 81 +++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 3d6aa95c9..1648ef359 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -173,6 +173,28 @@ typedef struct aidhdr { static int CmdHelp(const char *Cmd); +static int CLIGetUint32Hex(CLIParserContext *ctx, uint8_t paramnum, uint32_t defaultValue, uint32_t *value, bool *valuePresent, uint8_t nlen, const char *lengthErrorStr) { + if (value != NULL) + *value = defaultValue; + if (valuePresent != NULL) + *valuePresent = false; + + int res = arg_get_u32_hexstr_def_nlen(ctx, paramnum, defaultValue, value, nlen, true); + + if (valuePresent != NULL) + *valuePresent = (res == 1); + + if (res == 2) { + PrintAndLogEx(ERR, lengthErrorStr); + return PM3_EINVARG; + } + if (res == 0) { + return PM3_EINVARG; + } + + return PM3_SUCCESS; +} + /* The 7 MSBits (= n) code the storage size itself based on 2^n, the LSBit is set to '0' if the size is exactly 2^n @@ -2194,13 +2216,8 @@ static int CmdDesGetSessionParameters(CLIParserContext *ctx, DesfireContext *dct if (appid && aid) { *aid = 0x000000; - int res = arg_get_u32_hexstr_def_nlen(ctx, appid, 0x000000, aid, 3, true); - if (res == 0) - return PM3_ESOFT; - if (res == 2) { - PrintAndLogEx(ERR, "AID length must have 3 bytes length"); + if (CLIGetUint32Hex(ctx, appid, 0x000000, aid, NULL, 3, "AID must have 3 bytes length")) return PM3_EINVARG; - } } DesfireSetKey(dctx, keynum, algores, key); @@ -4728,9 +4745,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { } uint32_t fileid = 1; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 1, &fileid, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 1, &fileid, NULL, 1, "File ID must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -4888,9 +4903,7 @@ static int CmdHF14ADesClearRecordFile(const char *Cmd) { } uint32_t fnum = 1; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 1, &fnum, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 1, &fnum, NULL, 1, "File ID must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -5228,9 +5241,7 @@ static int CmdHF14ADesReadData(const char *Cmd) { } uint32_t fnum = 1; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 1, &fnum, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 1, &fnum, NULL, 1, "File ID must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -5242,35 +5253,27 @@ static int CmdHF14ADesReadData(const char *Cmd) { } uint32_t offset = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 15, 0, &offset, 3, true); - if (res == 2) { - PrintAndLogEx(ERR, "Offset must have 3 byte length"); + if (CLIGetUint32Hex(ctx, 15, 0, &offset, NULL, 3, "Offset must have 3 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t length = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 16, 0, &length, 3, true); - if (res == 2) { - PrintAndLogEx(ERR, "Length must have 3 byte length"); + if (CLIGetUint32Hex(ctx, 16, 0, &length, NULL, 3, "Length parameter must have 3 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t appisoid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 17, 0x0000, &appisoid, 2, true); - bool isoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "Application ISO ID (for EF) must have 2 bytes length"); + bool isoidpresent = false; + if (CLIGetUint32Hex(ctx, 17, 0x0000, &appisoid, &isoidpresent, 2, "Application ISO ID (for EF) must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t fileisoid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 18, 0x0000, &fileisoid, 2, true); - bool fileisoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "File ISO ID (for DF) must have 2 bytes length"); + bool fileisoidpresent = false; + if (CLIGetUint32Hex(ctx, 18, 0x0000, &fileisoid, &fileisoidpresent, 2, "File ISO ID (for DF) must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -5414,9 +5417,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) { } uint32_t fnum = 1; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 1, &fnum, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 1, &fnum, NULL, 1, "File ID must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -5428,9 +5429,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) { } uint32_t offset = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 15, 0, &offset, 3, true); - if (res == 2) { - PrintAndLogEx(ERR, "Offset must have 3 byte length"); + if (CLIGetUint32Hex(ctx, 15, 0, &offset, NULL, 3, "Offset must have 3 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -5450,19 +5449,15 @@ static int CmdHF14ADesWriteData(const char *Cmd) { int updaterecno = arg_get_int_def(ctx, 19, -1); uint32_t appisoid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 20, 0x0000, &appisoid, 2, true); - bool isoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "Application ISO ID (for EF) must have 2 bytes length"); + bool isoidpresent = false; + if (CLIGetUint32Hex(ctx, 20, 0x0000, &appisoid, &isoidpresent, 2, "Application ISO ID (for EF) must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t fileisoid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 21, 0x0000, &fileisoid, 2, true); - bool fileisoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "File ISO ID (for DF) must have 2 bytes length"); + bool fileisoidpresent = false; + if (CLIGetUint32Hex(ctx, 21, 0x0000, &fileisoid, &fileisoidpresent, 2, "File ISO ID (for DF) must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } From 33c79942c96a01ff1286fc08e09fb5d8b7e7c4fe Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 14:48:42 +0300 Subject: [PATCH 2/8] CmdHF14ADesValueOperations --- client/src/cmdhfmfdes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 1648ef359..a6c4c0200 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -4757,9 +4757,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { } uint32_t value = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 14, 0, &value, 4, true); - if (res == 2) { - PrintAndLogEx(ERR, "Value must have 4 byte length"); + if (CLIGetUint32Hex(ctx, 14, 0, &value, NULL, 4, "Value must have 4 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } From 282ea59cc64c0d46b685bcd5d3296254a5a8ea68 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:05:44 +0300 Subject: [PATCH 3/8] file id --- client/src/cmdhfmfdes.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index a6c4c0200..02c14cceb 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -3840,9 +3840,7 @@ static int CmdHF14ADesGetFileSettings(const char *Cmd) { } uint32_t fileid = 1; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 1, &fileid, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 1, &fileid, NULL, 1, "File ID must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -3891,20 +3889,14 @@ static int DesfireCreateFileParameters( uint32_t fileid = 1; if (pfileid) { - res = arg_get_u32_hexstr_def_nlen(ctx, pfileid, 1, &fileid, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, pfileid, 1, &fileid, NULL, 1, "File ID must have 1 byte length")) return PM3_EINVARG; - } } uint32_t isofileid = 0; if (pisofileid) { - res = arg_get_u32_hexstr_def_nlen(ctx, pisofileid, 0, &isofileid, 2, true); - if (res == 2) { - PrintAndLogEx(ERR, "ISO file ID must have 2 bytes length"); + if (CLIGetUint32Hex(ctx, pisofileid, 0, &isofileid, NULL, 2, "ISO file ID must have 2 bytes length")) return PM3_EINVARG; - } } data[0] = fileid; @@ -4668,9 +4660,7 @@ static int CmdHF14ADesDeleteFile(const char *Cmd) { } uint32_t fnum = 1; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 1, &fnum, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "File ID must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 1, &fnum, NULL, 1, "File ID must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } From f50b98ece5e386cf00becc137a3d9744a8b2d6ac Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:12:07 +0300 Subject: [PATCH 4/8] isoid --- client/src/cmdhfmfdes.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 02c14cceb..72af400ff 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -2330,14 +2330,12 @@ static int CmdHF14ADesSelectApp(const char *Cmd) { CLIGetStrWithReturn(ctx, 12, dfname, &dfnamelen); uint32_t isoid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 13, 0x0000, &isoid, 2, true); - bool idsoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "ISO ID for EF or DF must have 2 bytes length"); + bool isoidpresent = false; + if (CLIGetUint32Hex(ctx, 13, 0x0000, &isoid, &isoidpresent, 2, "ISO ID for EF or DF must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } - + bool selectmf = arg_get_lit(ctx, 14); SetAPDULogging(APDULogging); From 1865b6037497c580e72f9961548828f88cb52505 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:19:31 +0300 Subject: [PATCH 5/8] part 1 --- client/src/cmdhfmfdes.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 72af400ff..ad3db3586 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -2356,7 +2356,7 @@ static int CmdHF14ADesSelectApp(const char *Cmd) { PrintAndLogEx(FAILED, "Application " _CYAN_("FCI template") " [%zu]%s", resplen, sprint_hex(resp, resplen)); PrintAndLogEx(SUCCESS, "PICC MF selected " _GREEN_("succesfully")); - } else if (idsoidpresent) { + } else if (isoidpresent) { uint8_t data[2] = {0}; Uint2byteToMemLe(data, isoid); res = DesfireISOSelect(&dctx, ISSMFDFEF, data, 2, resp, &resplen); @@ -2619,9 +2619,7 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { } uint32_t paramid = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 0, ¶mid, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "Parameter ID must have 1 bytes length"); + if (CLIGetUint32Hex(ctx, 12, 0, ¶mid, NULL, 1, "Parameter ID must have 1 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -2753,9 +2751,7 @@ static int CmdHF14ADesChangeKey(const char *Cmd) { memcpy(newkey, keydata, keylen); uint32_t newkeyver = 0x100; - res = arg_get_u32_hexstr_def_nlen(ctx, 17, 0x100, &newkeyver, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "Key version must have 1 bytes length"); + if (CLIGetUint32Hex(ctx, 17, 0x100, &newkeyver, NULL, 1, "Key version must have 1 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -2881,10 +2877,8 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { CLIGetHexWithReturn(ctx, 11, rawdata, &rawdatalen); uint32_t fileid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 13, 0x0000, &fileid, 2, true); - bool fileidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "ISO file ID must have 2 bytes length"); + bool fileidpresent = false; + if (CLIGetUint32Hex(ctx, 13, 0x0000, &fileid, &fileidpresent, 2, "ISO file ID must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -2894,18 +2888,14 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { CLIGetStrWithReturn(ctx, 14, dfname, &dfnamelen); uint32_t ks1 = 0x0f; - res = arg_get_u32_hexstr_def_nlen(ctx, 15, 0x0f, &ks1, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "Key settings 1 must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 15, 0x0f, &ks1, NULL, 1, "Key settings 1 must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t ks2 = 0x0e; - res = arg_get_u32_hexstr_def_nlen(ctx, 16, 0x0e, &ks2, 1, true); - bool ks2present = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "Key settings 2 must have 1 byte length"); + bool ks2present = false; + if (CLIGetUint32Hex(ctx, 16, 0x0e, &ks2, &ks2present, 1, "Key settings 2 must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } From 530c0d73368cd356107228b9d53de1e9bdd5046e Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:36:31 +0300 Subject: [PATCH 6/8] part 2 --- client/src/cmdhfmfdes.c | 61 ++++++++++------------------------------- 1 file changed, 14 insertions(+), 47 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index ad3db3586..5b6511ef1 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -3287,13 +3287,7 @@ static int CmdHF14ADesChKeySettings(const char *Cmd) { } uint32_t ksett32 = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 0x0f, &ksett32, 1, false); - if (res == 0) { - CLIParserFree(ctx); - return PM3_ESOFT; - } - if (res == 2) { - PrintAndLogEx(ERR, "Key settings must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 0x0f, &ksett32, NULL, 1, "Key settings must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -3366,24 +3360,14 @@ static int CmdHF14ADesGetKeyVersions(const char *Cmd) { } uint32_t keynum32 = 0x00; - res = arg_get_u32_hexstr_def_nlen(ctx, 12, 0x00, &keynum32, 1, false); - if (res == 0) { - keynum32 = 0x00; - } - if (res == 2) { - PrintAndLogEx(ERR, "Key number must have 1 byte length"); + if (CLIGetUint32Hex(ctx, 12, 0x00, &keynum32, NULL, 1, "Key number must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t keysetnum32 = 0x00; - bool keysetpresent = true; - res = arg_get_u32_hexstr_def_nlen(ctx, 13, 0x00, &keysetnum32, 1, false); - if (res == 0) { - keysetpresent = false; - } - if (res == 2) { - PrintAndLogEx(ERR, "Keyset number must have 1 byte length"); + bool keysetpresent = false; + if (CLIGetUint32Hex(ctx, 13, 0x00, &keysetnum32, &keysetpresent, 1, "Keyset number must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -3873,7 +3857,6 @@ static int DesfireCreateFileParameters( size_t *datalen ) { *datalen = 0; - int res = 0; uint32_t fileid = 1; if (pfileid) { @@ -3918,10 +3901,8 @@ static int DesfireCreateFileParameters( uint32_t frights = 0xeeee; bool userawfrights = false; if (frightsid) { - res = arg_get_u32_hexstr_def_nlen(ctx, frightsid, 0xeeee, &frights, 2, true); - userawfrights = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "File rights must have 2 bytes length"); + if (CLIGetUint32Hex(ctx, frightsid, 0xeeee, &frights, &userawfrights, 2, "File rights must have 2 bytes length")) { + CLIParserFree(ctx); return PM3_EINVARG; } } @@ -4168,10 +4149,8 @@ static int CmdHF14ADesCreateFile(const char *Cmd) { } uint32_t rawftype = 0x00; - res = arg_get_u32_hexstr_def_nlen(ctx, 14, 0x00, &rawftype, 1, true); - bool useraw = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "Raw file type must have 1 byte length"); + bool useraw = false; + if (CLIGetUint32Hex(ctx, 14, 0x00, &rawftype, &useraw, 1, "Raw file type must have 1 byte length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -4195,9 +4174,7 @@ static int CmdHF14ADesCreateFile(const char *Cmd) { if (useraw == false) { uint32_t filesize = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 23, 0, &filesize, 3, true); - if (res == 2) { - PrintAndLogEx(ERR, "File size must have 3 bytes length"); + if (CLIGetUint32Hex(ctx, 23, 0, &filesize, NULL, 3, "File size must have 3 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -4309,25 +4286,19 @@ static int CmdHF14ADesCreateValueFile(const char *Cmd) { } uint32_t lowerlimit = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 20, 0, &lowerlimit, 4, true); - if (res == 2) { - PrintAndLogEx(ERR, "Lower limit value must have 4 bytes length"); + if (CLIGetUint32Hex(ctx, 20, 0, &lowerlimit, NULL, 4, "Lower limit value must have 4 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t upperlimit = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 21, 0, &upperlimit, 4, true); - if (res == 2) { - PrintAndLogEx(ERR, "Upper limit value must have 4 bytes length"); + if (CLIGetUint32Hex(ctx, 21, 0, &upperlimit, NULL, 4, "Upper limit value must have 4 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t value = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 22, 0, &value, 4, true); - if (res == 2) { - PrintAndLogEx(ERR, "Lower limit value must have 4 bytes length"); + if (CLIGetUint32Hex(ctx, 22, 0, &value, NULL, 4, "Value must have 4 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } @@ -4442,17 +4413,13 @@ static int CmdHF14ADesCreateRecordFile(const char *Cmd) { } uint32_t size = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 21, 0, &size, 3, true); - if (res == 2) { - PrintAndLogEx(ERR, "Record size must have 3 bytes length"); + if (CLIGetUint32Hex(ctx, 21, 0, &size, NULL, 3, "Record size must have 3 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } uint32_t maxrecord = 0; - res = arg_get_u32_hexstr_def_nlen(ctx, 22, 0, &maxrecord, 3, true); - if (res == 2) { - PrintAndLogEx(ERR, "Max number of records must have 3 bytes length"); + if (CLIGetUint32Hex(ctx, 22, 0, &maxrecord, NULL, 3, "Max number of records must have 3 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } From d939d025b005636bbb4f3d320632c79026603549 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:44:13 +0300 Subject: [PATCH 7/8] fix --- client/src/cmdhfmfdes.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 4c53f2e50..6e7f80aa0 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -2335,24 +2335,14 @@ static int CmdHF14ADesSelectApp(const char *Cmd) { uint32_t isoid = 0x0000; bool isoidpresent = false; - if (CLIGetUint32Hex(ctx, 13, 0x0000, &isoid, &isoidpresent, 2, "ISO ID for EF or DF must have 2 bytes length")) { + if (CLIGetUint32Hex(ctx, 14, 0x0000, &isoid, &isoidpresent, 2, "ISO ID for EF or DF must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } - res = arg_get_u32_hexstr_def_nlen(ctx, 14, 0x0000, &isoid, 2, true); - bool idsoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "ISO ID for EF or DF must have 2 bytes length"); - CLIParserFree(ctx); - return PM3_EINVARG; - } - uint32_t fileisoid = 0x0000; - res = arg_get_u32_hexstr_def_nlen(ctx, 15, 0x0000, &fileisoid, 2, true); - bool fileisoidpresent = (res == 1); - if (res == 2) { - PrintAndLogEx(ERR, "ISO ID for EF or DF must have 2 bytes length"); + bool fileisoidpresent = false; + if (CLIGetUint32Hex(ctx, 15, 0x0000, &fileisoid, &fileisoidpresent, 2, "ISO ID for EF or DF must have 2 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; } From 09320b911ea17a68693f520e97c55240c5ea8d12 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 15:46:44 +0300 Subject: [PATCH 8/8] the last part --- client/src/cmdhfmfdes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 6e7f80aa0..0a3a6c798 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -4553,9 +4553,7 @@ static int CmdHF14ADesCreateTrMACFile(const char *Cmd) { } uint32_t keyver = 0x00; - res = arg_get_u32_hexstr_def_nlen(ctx, 21, 0x00, &keyver, 1, true); - if (res == 2) { - PrintAndLogEx(ERR, "Key version must be 1 byte length"); + if (CLIGetUint32Hex(ctx, 21, 0x00, &keyver, NULL, 1, "Key version must have 1 bytes length")) { CLIParserFree(ctx); return PM3_EINVARG; }