From e67215fe490107399f8f6cb8371bc96c386867ef Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 17 Feb 2022 12:30:43 +0100 Subject: [PATCH 01/21] reuse MAX macro --- client/src/cmdhfmf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index d9c30286e..d9b5eb1a3 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -48,11 +48,6 @@ #define MIFARE_2K_MAXSECTOR 32 #define MIFARE_4K_MAXSECTOR 40 -/* On some platforms, max() may already be defined */ -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) -#endif - static int CmdHelp(const char *Cmd); /* @@ -1243,7 +1238,7 @@ static int CmdHF14AMfNested(const char *Cmd) { //TODO: single mode broken? can't if (singleSector) { uint8_t MinSectorsCnt = 0; // find a MIFARE type that can accommodate the provided block number - uint8_t s = max(mfSectorNum(trgBlockNo), mfSectorNum(blockNo)); + uint8_t s = MAX(mfSectorNum(trgBlockNo), mfSectorNum(blockNo)); if (s < MIFARE_MINI_MAXSECTOR) { MinSectorsCnt = MIFARE_MINI_MAXSECTOR; } else if (s < MIFARE_1K_MAXSECTOR) { From 3ff4c8ac166e1c0769c78f711b87d2ae47fb30b8 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 17 Feb 2022 15:03:05 +0100 Subject: [PATCH 02/21] hf mf emrtd: clarify warning when we're voluntarily skipping dump --- client/src/cmdhfemrtd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/cmdhfemrtd.c b/client/src/cmdhfemrtd.c index c52f34120..99ab68e5a 100644 --- a/client/src/cmdhfemrtd.c +++ b/client/src/cmdhfemrtd.c @@ -1817,7 +1817,7 @@ static int emrtd_parse_ef_sod_hashes(uint8_t *data, size_t datalen, uint8_t *has return PM3_SUCCESS; } -static int emrtd_print_ef_sod_info(uint8_t *dg_hashes_calc, uint8_t *dg_hashes_sod, int hash_algo) { +static int emrtd_print_ef_sod_info(uint8_t *dg_hashes_calc, uint8_t *dg_hashes_sod, int hash_algo, bool fastdump) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(INFO, "-------------------- " _CYAN_("EF_SOD") " --------------------"); @@ -1835,7 +1835,11 @@ static int emrtd_print_ef_sod_info(uint8_t *dg_hashes_calc, uint8_t *dg_hashes_s if (calc_all_zero == true && sod_all_zero == true) { continue; } else if (calc_all_zero == true) { - PrintAndLogEx(SUCCESS, "EF_DG%i: " _YELLOW_("File couldn't be read, but is in EF_SOD."), i); + if (fastdump && !dg_table[i].fastdump && !dg_table[i].pace && !dg_table[i].eac) { + PrintAndLogEx(SUCCESS, "EF_DG%i: " _YELLOW_("File was skipped, but is in EF_SOD."), i); + } else { + PrintAndLogEx(SUCCESS, "EF_DG%i: " _YELLOW_("File couldn't be read, but is in EF_SOD."), i); + } } else if (sod_all_zero == true) { PrintAndLogEx(SUCCESS, "EF_DG%i: " _YELLOW_("File is not in EF_SOD."), i); } else if (hash_matches == false) { @@ -2010,7 +2014,7 @@ int infoHF_EMRTD(char *documentnumber, char *dob, char *expiry, bool BAC_availab } DropField(); - emrtd_print_ef_sod_info(*dg_hashes_calc, *dg_hashes_sod, hash_algo); + emrtd_print_ef_sod_info(*dg_hashes_calc, *dg_hashes_sod, hash_algo, true); return PM3_SUCCESS; } @@ -2110,7 +2114,7 @@ int infoHF_EMRTD_offline(const char *path) { } free(filepath); - emrtd_print_ef_sod_info(*dg_hashes_calc, *dg_hashes_sod, hash_algo); + emrtd_print_ef_sod_info(*dg_hashes_calc, *dg_hashes_sod, hash_algo, false); return PM3_SUCCESS; } From d00e138a319815af63cf00b89096d5e1887515ff Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 18 Feb 2022 06:19:44 +0100 Subject: [PATCH 03/21] added a mifare value block decoder --- CHANGELOG.md | 1 + client/src/cmdhfmf.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39aba3c9b..913654326 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 `hf mf value` - decode a value block (@iceman1001) - Changed `hf mf nested`: removed option `--single` redundant with usage of `--tblk` (@doegox) - Fixed `hf mf chk` single block mode (@doegox) - Fixed `hf mf fchk/chk` internal logic to load keys (@doegox) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index d9b5eb1a3..cdd1bf278 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -6201,6 +6201,54 @@ static int CmdHF14AGen4View(const char *Cmd) { return PM3_SUCCESS; } +static bool mfc_value(const uint8_t *d, uint32_t *val) { + // values + uint32_t a = MemLeToUint4byte(d); + uint32_t a_inv = MemLeToUint4byte(d + 4); + uint32_t b = MemLeToUint4byte(d + 8); + + int val_checks = ( + (a == b) && (a == ~a_inv) && + (d[12] == (~d[13] & 0xFF)) && + (d[14] == (~d[15] & 0xFF)) + ); + + if (val) { + *val = a; + } + return (val_checks); +} + +static int CmdHF14AMfValue(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf mf value", + "Decode of a MIFARE value block", + "hf mf value -d 87D612007829EDFF87D6120011EE11EE\n" + ); + void *argtable[] = { + arg_param_begin, + arg_str1("d", "data", "", "16 hex bytes"), + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, false); + + int dlen = 0; + uint8_t data[16] = {0}; + CLIGetHexWithReturn(ctx, 1, data, &dlen); + CLIParserFree(ctx); + + + uint32_t value = 0; + + if (mfc_value(data, &value)) { + PrintAndLogEx(SUCCESS, "Dec... " _YELLOW_("%" PRIu32 ), value); + PrintAndLogEx(SUCCESS, "Hex... " _YELLOW_("0x%" PRIX32), value); + } else { + PrintAndLogEx(FAILED, "No value block detected"); + } + return PM3_SUCCESS; +} + static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, {"list", CmdHF14AMfList, AlwaysAvailable, "List MIFARE history"}, @@ -6227,6 +6275,7 @@ static command_t CommandTable[] = { {"rdsc", CmdHF14AMfRdSc, IfPm3Iso14443a, "Read MIFARE Classic sector"}, {"restore", CmdHF14AMfRestore, IfPm3Iso14443a, "Restore MIFARE Classic binary file to BLANK tag"}, {"setmod", CmdHf14AMfSetMod, IfPm3Iso14443a, "Set MIFARE Classic EV1 load modulation strength"}, + {"value", CmdHF14AMfValue, AlwaysAvailable, "Decode a value block"}, {"view", CmdHF14AMfView, AlwaysAvailable, "Display content from tag dump file"}, {"wipe", CmdHF14AMfWipe, IfPm3Iso14443a, "Wipe card to zeros and default keys/acc"}, {"wrbl", CmdHF14AMfWrBl, IfPm3Iso14443a, "Write MIFARE Classic block"}, From 85aeb9da509fb12408b2ccd64ce47cc79d15f2f8 Mon Sep 17 00:00:00 2001 From: Eric Betts Date: Thu, 17 Feb 2022 22:00:48 -0800 Subject: [PATCH 04/21] typo --- client/src/cmdlfem4x05.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index e86e7f28d..735b2051d 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -871,7 +871,7 @@ int CmdEM4x05Wipe(const char *Cmd) { arg_lit0(NULL, "4205", "target chip type EM 4205"), arg_lit0(NULL, "4305", "target chip type EM 4305 (default)"), arg_lit0(NULL, "4369", "target chip type EM 4369"), - arg_lit0(NULL, "4369", "target chip type EM 4469"), + arg_lit0(NULL, "4469", "target chip type EM 4469"), arg_str0("p", "pwd", "", "optional - password, 4 bytes hex"), arg_param_end }; From 61f3398fdc9cc19a9ab47e9c622868e6e38f968b Mon Sep 17 00:00:00 2001 From: r1ddl3rz Date: Fri, 18 Feb 2022 11:47:20 +0100 Subject: [PATCH 05/21] fix slixdisable pass id --- armsrc/iso15693.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index 77c67c3cf..c89bc6699 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -2254,7 +2254,7 @@ void DisablePrivacySlixLIso15693(uint8_t *password) { StartCountSspClk(); uint32_t start_time = 0, eof_time = 0; // 4 == pass id. - int res = set_pass_15693_slixl(start_time, &eof_time, 0x10, password); + int res = set_pass_15693_slixl(start_time, &eof_time, 0x04, password); reply_ng(CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY, res, NULL, 0); switch_off(); } From 241a3b70fa6eeb3732dd3ef09271dab9ceceeaa7 Mon Sep 17 00:00:00 2001 From: r1ddl3rz Date: Fri, 18 Feb 2022 11:57:26 +0100 Subject: [PATCH 06/21] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 913654326..b4ec94ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Added `nfc decode` - now NDEF vCard messages with a PHOTO in base64 format is shown (@iceman1001) - Changed - AID limitations when using Gallagher key diversification (@DarkMatterMatt) - Added new standalone mode `lf_em4100rsww` (@zabszk) + - Fixed `hf 15 slixdisable` wrong pass id (@r1ddl3rz) ## [Frostbit.4.14831] [2022-01-11] - Changed Wiegand format lookup - now case-insensitive (@iceman1001) From 638e8920882f3461ec60f1ee8405c47cfff11f2f Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 18 Feb 2022 18:23:53 +0100 Subject: [PATCH 07/21] added device side option to disable EAS/AFI password. Sets to all ZEROS --- armsrc/appmain.c | 8 ++++++++ armsrc/iso15693.c | 23 ++++++++++++++++++++++- armsrc/iso15693.h | 1 + include/pm3_cmd.h | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index afe10694c..5176b7367 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1271,6 +1271,14 @@ static void PacketReceived(PacketCommandNG *packet) { DisablePrivacySlixLIso15693(payload->pwd); break; } + case CMD_HF_ISO15693_SLIX_L_DISABLE_AESAFI: { + struct p { + uint8_t pwd[4]; + } PACKED; + struct p *payload = (struct p *) packet->data.asBytes; + DisableEAS_AFISlixLIso15693(payload->pwd); + break; + } #endif diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index c89bc6699..aa3929d73 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -2248,15 +2248,36 @@ static uint32_t destroy_15693_slixl(uint32_t start_time, uint32_t *eof_time, uin } */ + +// Sets a PRIVACY password to all ZEROS void DisablePrivacySlixLIso15693(uint8_t *password) { LED_D_ON(); Iso15693InitReader(); StartCountSspClk(); uint32_t start_time = 0, eof_time = 0; - // 4 == pass id. + + // Password identifier Password byte + // 0x04 Privacy + // 0x08 Destroy SLIX-L + // 0x10 EAS/AFI int res = set_pass_15693_slixl(start_time, &eof_time, 0x04, password); reply_ng(CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY, res, NULL, 0); switch_off(); } +// Sets a EAS/AFI password to all ZEROS +void DisableEAS_AFISlixLIso15693(uint8_t *password) { + LED_D_ON(); + Iso15693InitReader(); + StartCountSspClk(); + uint32_t start_time = 0, eof_time = 0; + + // Password identifier Password byte + // 0x04 Privacy + // 0x08 Destroy SLIX-L + // 0x10 EAS/AFI + int res = set_pass_15693_slixl(start_time, &eof_time, 0x10, password); + reply_ng(CMD_HF_ISO15693_SLIX_L_DISABLE_AESAFI, res, NULL, 0); + switch_off(); +} diff --git a/armsrc/iso15693.h b/armsrc/iso15693.h index b4f634fff..29d266709 100644 --- a/armsrc/iso15693.h +++ b/armsrc/iso15693.h @@ -60,4 +60,5 @@ int SendDataTagEOF(uint8_t *recv, uint16_t max_recv_len, uint32_t start_time, ui void SetTag15693Uid(const uint8_t *uid); void DisablePrivacySlixLIso15693(uint8_t *password); +void DisableEAS_AFISlixLIso15693(uint8_t *password); #endif diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 94eb4d9c0..c97124cc0 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -519,6 +519,7 @@ typedef struct { #define CMD_HF_ISO15693_FINDAFI 0x0315 #define CMD_HF_ISO15693_CSETUID 0x0316 #define CMD_HF_ISO15693_SLIX_L_DISABLE_PRIVACY 0x0317 +#define CMD_HF_ISO15693_SLIX_L_DISABLE_AESAFI 0x0318 #define CMD_LF_SNIFF_RAW_ADC 0x0360 From 1f470483ec473e88424c7e6540b61056bb143e86 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 18 Feb 2022 22:31:34 +0100 Subject: [PATCH 08/21] make style --- client/src/cmdhfmf.c | 10 +++++----- client/src/pm3line_vocabulory.h | 1 + doc/commands.json | 23 ++++++++++++++++++----- doc/commands.md | 1 + 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index cdd1bf278..b8275f4b2 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -6208,10 +6208,10 @@ static bool mfc_value(const uint8_t *d, uint32_t *val) { uint32_t b = MemLeToUint4byte(d + 8); int val_checks = ( - (a == b) && (a == ~a_inv) && - (d[12] == (~d[13] & 0xFF)) && - (d[14] == (~d[15] & 0xFF)) - ); + (a == b) && (a == ~a_inv) && + (d[12] == (~d[13] & 0xFF)) && + (d[14] == (~d[15] & 0xFF)) + ); if (val) { *val = a; @@ -6241,7 +6241,7 @@ static int CmdHF14AMfValue(const char *Cmd) { uint32_t value = 0; if (mfc_value(data, &value)) { - PrintAndLogEx(SUCCESS, "Dec... " _YELLOW_("%" PRIu32 ), value); + PrintAndLogEx(SUCCESS, "Dec... " _YELLOW_("%" PRIu32), value); PrintAndLogEx(SUCCESS, "Hex... " _YELLOW_("0x%" PRIX32), value); } else { PrintAndLogEx(FAILED, "No value block detected"); diff --git a/client/src/pm3line_vocabulory.h b/client/src/pm3line_vocabulory.h index 8590b0b26..2c514f7cb 100644 --- a/client/src/pm3line_vocabulory.h +++ b/client/src/pm3line_vocabulory.h @@ -305,6 +305,7 @@ const static vocabulory_t vocabulory[] = { { 0, "hf mf rdsc" }, { 0, "hf mf restore" }, { 0, "hf mf setmod" }, + { 1, "hf mf value" }, { 1, "hf mf view" }, { 0, "hf mf wipe" }, { 0, "hf mf wrbl" }, diff --git a/doc/commands.json b/doc/commands.json index 1e63c0baf..829e4c93d 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -4098,7 +4098,7 @@ }, "hf mf help": { "command": "hf mf help", - "description": "help this help list list mifare history hardnested nested attack for hardened mifare classic cards decrypt [nt] [ar_enc] [at_enc] [data] - to decrypt sniff or trace acl decode and print mifare classic access rights bytes view display content from tag dump file", + "description": "help this help list list mifare history hardnested nested attack for hardened mifare classic cards decrypt [nt] [ar_enc] [at_enc] [data] - to decrypt sniff or trace acl decode and print mifare classic access rights bytes value decode a value block view display content from tag dump file", "notes": [], "offline": true, "options": [], @@ -4358,6 +4358,19 @@ ], "usage": "hf mf supercard [-hr]" }, + "hf mf value": { + "command": "hf mf value", + "description": "decode of a mifare value block", + "notes": [ + "hf mf value -d 87d612007829edff87d6120011ee11ee" + ], + "offline": true, + "options": [ + "-h, --help this help", + "-d, --data 16 hex bytes" + ], + "usage": "hf mf value [-h] -d " + }, "hf mf view": { "command": "hf mf view", "description": "print a mifare classic dump file (bin/eml/json)", @@ -7162,10 +7175,10 @@ "--4205 target chip type em 4205", "--4305 target chip type em 4305 (default)", "--4369 target chip type em 4369", - "--4369 target chip type em 4469", + "--4469 target chip type em 4469", "-p, --pwd optional - password, 4 bytes hex" ], - "usage": "lf em 4x05 wipe [-h] [--4205] [--4305] [--4369] [--4369] [-p ]" + "usage": "lf em 4x05 wipe [-h] [--4205] [--4305] [--4369] [--4469] [-p ]" }, "lf em 4x05 write": { "command": "lf em 4x05 write", @@ -10887,8 +10900,8 @@ } }, "metadata": { - "commands_extracted": 687, + "commands_extracted": 688, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2022-02-17T00:41:11" + "extracted_on": "2022-02-18T21:30:00" } } \ No newline at end of file diff --git a/doc/commands.md b/doc/commands.md index cf1be550e..6437758bd 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -460,6 +460,7 @@ Check column "offline" for their availability. |`hf mf rdsc `|N |`Read MIFARE Classic sector` |`hf mf restore `|N |`Restore MIFARE Classic binary file to BLANK tag` |`hf mf setmod `|N |`Set MIFARE Classic EV1 load modulation strength` +|`hf mf value `|Y |`Decode a value block` |`hf mf view `|Y |`Display content from tag dump file` |`hf mf wipe `|N |`Wipe card to zeros and default keys/acc` |`hf mf wrbl `|N |`Write MIFARE Classic block` From 7310834b69197efdaa9302aa83a510fafb295e04 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 19 Feb 2022 00:15:34 +0100 Subject: [PATCH 09/21] added a compact tlv decoder for ATR historical bytes in 14a info --- CHANGELOG.md | 19 +++++----- client/src/cmdhf14a.c | 82 ++++++++++++++++++++++++++++++++++++++++--- include/common.h | 4 +-- 3 files changed, 90 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ec94ce5..7279766f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,16 +3,17 @@ 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 `hf mf value` - decode a value block (@iceman1001) - - Changed `hf mf nested`: removed option `--single` redundant with usage of `--tblk` (@doegox) - - Fixed `hf mf chk` single block mode (@doegox) - - Fixed `hf mf fchk/chk` internal logic to load keys (@doegox) - - Changed `hf mf *` printKeyTable: now display sector trailer info too (@doegox) - - Changed `hf mf chk` option `--blk` into `--tblk` (as for nested) (@doegox) + - Changed `hf 14a info` - added a ATR historical compact TLV decoder (@iceman1001) + - Added `hf mf value` - decode a value block (@iceman1001) + - Changed `hf mf nested` - removed option `--single` redundant with usage of `--tblk` (@doegox) + - Fixed `hf mf chk` - single block mode (@doegox) + - Fixed `hf mf fchk/chk` - internal logic to load keys (@doegox) + - Changed `hf mf *` - printKeyTable: now display sector trailer info too (@doegox) + - Changed `hf mf chk` - option `--blk` into `--tblk` (as for nested) (@doegox) - Added new tool `mfd_multi_brute` - MIFARE DESfire / UL-C key recovery (@iceman1001) - - Fixed `hf emrtd info` segfault on some platforms (@doegox) - - Fixed `hf emrtd info` when offline (@doegox) - - Fixed `commands.json` generation (@doegox) + - Fixed `hf emrtd info` - segfault on some platforms (@doegox) + - Fixed `hf emrtd info` - when offline (@doegox) + - Fixed `commands.json` - generation (@doegox) - Added new standalone mode `hf_legicsim` (@uhei) - Changed `hf legic *` - now uses NG instead (@iceman1001) - Added `hf legic view` - view contents of LEGIC Prime dump files (@iceman1001) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index ef2c3a03d..81de6b35e 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1638,6 +1638,78 @@ static void getTagLabel(uint8_t uid0, uint8_t uid1) { } } +static void get_compact_tlv(uint8_t* d, uint8_t n) { + d++; + n--; + + while (n > 0) { + uint8_t tag = NIBBLE_HIGH(d[0]); + uint8_t len = NIBBLE_LOW(d[0]); + + switch(tag) { + case 1: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Country code in (ISO 3166-1)", tag, len, sprint_hex_inrow(d + 1, len)); + // iso3166 script in cmdlffdb.c is buggy, Åland, Australia not showing. getline issues + break; + case 2: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Issuer identification number (ISO 7812-1)", tag, len, sprint_hex_inrow(d + 1, len)); + break; + case 3: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Card service data byte", tag, len, sprint_hex_inrow(d + 1, len)); + PrintAndLogEx(INFO, " %c....... Application selection: by full DF name", (d[1] & 0x80) ? '1' : '0'); + PrintAndLogEx(INFO, " .%c...... Application selection: by partial DF name", (d[1] & 0x40) ? '1' : '0'); + PrintAndLogEx(INFO, " ..%c..... BER-TLV data objects available in EF.DIR", (d[1] & 0x20) ? '1' : '0'); + PrintAndLogEx(INFO, " ...%c.... BER-TLV data objects available in EF.ATR", (d[1] & 0x10) ? '1' : '0'); + PrintAndLogEx(INFO, " ....%c... EF.DIR and EF.ATR access services: by READ BINARY command", (d[1] & 0x08) ? '1' : '0'); + PrintAndLogEx(INFO, " .....%c.. EF.DIR and EF.ATR access services: by GET DATA command", (d[1] & 0x04) ? '1' : '0'); + PrintAndLogEx(INFO, " ......%c. EF.DIR and EF.ATR access services: by GET RECORD(s) command", (d[1] & 0x02) ? '1' : '0'); + PrintAndLogEx(INFO, " .......%c EF.DIR and EF.ATR access services: RFU", (d[1] & 0x01) ? '1' : '0'); + break; + case 4: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Initial access data", tag, len, sprint_hex_inrow(d + 1, len)); + break; + case 5: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Card issuer data", tag, len, sprint_hex_inrow(d + 1, len)); + break; + case 6: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Pre-issuing data", tag, len, sprint_hex_inrow(d + 1, len)); + break; + case 7: + PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Card capabilities", tag, len, sprint_hex_inrow(d + 1, len)); + + PrintAndLogEx(INFO, " " _YELLOW_("%02X") " - Selection methods", d[1]); + PrintAndLogEx(INFO, " %c....... DF selection by full DF name", (d[1] & 0x80) ? '1' : '0'); + PrintAndLogEx(INFO, " .%c...... DF selection by partial DF name", (d[1] & 0x40) ? '1' : '0'); + PrintAndLogEx(INFO, " ..%c..... DF selection by path", (d[1] & 0x20) ? '1' : '0'); + PrintAndLogEx(INFO, " ...%c.... DF selection by file identifier", (d[1] & 0x10) ? '1' : '0'); + PrintAndLogEx(INFO, " ....%c... Implicit DF selection", (d[1] & 0x08) ? '1' : '0'); + PrintAndLogEx(INFO, " .....%c.. Short EF identifier supported", (d[1] & 0x04) ? '1' : '0'); + PrintAndLogEx(INFO, " ......%c. Record number supported", (d[1] & 0x02) ? '1' : '0'); + PrintAndLogEx(INFO, " .......%c Record identifier supported", (d[1] & 0x01) ? '1' : '0'); + + if (len > 1) { + PrintAndLogEx(INFO, " " _YELLOW_("%02X") " - Data coding byte", d[2]); + } + if (len > 2) { + PrintAndLogEx(INFO, " " _YELLOW_("%02X") " - Command chaining, length fields and logical channels", d[3]); + } + break; + case 8: + PrintAndLogEx(INFO, " %1x%1x ... " _YELLOW_("%s") " Status indicator", tag, len, sprint_hex_inrow(d + 1, len)); + break; + case 0xE: + PrintAndLogEx(INFO, " %1x%1x ... " _YELLOW_("%s") " Application identifier", tag, len, sprint_hex_inrow(d + 1, len)); + break; + } + + if (len > n) + break; + + n -= (1 + len); + d += (1 + len); + } +} + int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { clearCommandBuffer(); SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_CONNECT | ISO14A_NO_DISCONNECT, 0, 0, NULL, 0); @@ -2034,10 +2106,12 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { } } else { - if (card.ats[pos] == 0x80) - PrintAndLogEx(SUCCESS, " %s (compact TLV data object)", sprint_hex_inrow(card.ats + pos, calen)); - else - PrintAndLogEx(SUCCESS, " %s", sprint_hex_inrow(card.ats + pos, calen)); + if (card.ats[pos] == 0x80 || card.ats[pos] == 0x00) { + PrintAndLogEx(SUCCESS, " %s (compact TLV data object)", sprint_hex_inrow(&card.ats[pos], calen)); + get_compact_tlv(card.ats + pos, calen); + } else { + PrintAndLogEx(SUCCESS, " %s", sprint_hex_inrow(card.ats + pos, calen)); + } PrintAndLogEx(NORMAL, ""); } diff --git a/include/common.h b/include/common.h index 314b67b57..2e245da43 100644 --- a/include/common.h +++ b/include/common.h @@ -158,11 +158,11 @@ extern bool g_tearoff_enabled; // Nibble logic #ifndef NIBBLE_HIGH -# define NIBBLE_HIGH(b) ( (b & 0xF0) >> 4 ) +# define NIBBLE_HIGH(b) ( ((b) & 0xF0) >> 4 ) #endif #ifndef NIBBLE_LOW -# define NIBBLE_LOW(b) ( b & 0x0F ) +# define NIBBLE_LOW(b) ((b) & 0x0F ) #endif #ifndef CRUMB From 04b86073b2546c442813e3741f231eefe70971d2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 21 Feb 2022 15:56:49 +0100 Subject: [PATCH 10/21] ndef simple wifi record decoder --- client/src/nfc/ndef.c | 327 +++++++++++++++++++++++++++++++++++------- 1 file changed, 274 insertions(+), 53 deletions(-) diff --git a/client/src/nfc/ndef.c b/client/src/nfc/ndef.c index 014e6b688..32ffe0c79 100644 --- a/client/src/nfc/ndef.c +++ b/client/src/nfc/ndef.c @@ -32,11 +32,12 @@ #define STRBOOL(p) ((p) ? "1" : "0") -#define NDEF_WIFIAPPL "application/vnd.wfa" -#define NDEF_BLUEAPPL "application/vnd.bluetooth" -#define NDEF_JSONAPPL "application/json" -#define NDEF_VCARDTEXT "text/vcard" -#define NDEF_XVCARDTEXT "text/x-vcard" +#define NDEF_WIFIAPPL_WSC "application/vnd.wfa.wsc" +#define NDEF_WIFIAPPL_P2P "application/vnd.wfa.p2p" +#define NDEF_BLUEAPPL "application/vnd.bluetooth" +#define NDEF_JSONAPPL "application/json" +#define NDEF_VCARDTEXT "text/vcard" +#define NDEF_XVCARDTEXT "text/x-vcard" static const char *TypeNameFormat_s[] = { @@ -512,11 +513,221 @@ static int ndefDecodePayloadSmartPoster(uint8_t *ndef, size_t ndeflen, bool prin return PM3_SUCCESS; } -static int ndefDecodeMime_wifi(NDEFHeader_t *ndef) { - PrintAndLogEx(INFO, _CYAN_("WiFi details")); - if (ndef->PayloadLen > 1) { - PrintAndLogEx(INFO, ">>> decorder, to be implemented <<<"); + +typedef struct ndef_wifi_type_s { + const char* description; + uint8_t bytes[2]; +} ndef_wifi_type_t; + +static const ndef_wifi_type_t wifi_crypt_types[] = { + {"NONE", {0x00, 0x01}}, + {"WEP", {0x00, 0x02}}, + {"TKIP", {0x00, 0x04}}, + {"AES", {0x00, 0x08}}, + {"AES/TKIP", {0x00, 0x0C}} +}; + +static const char* ndef_wifi_crypt_lookup(uint8_t *d) { + for (int i = 0; i < ARRAYLEN(wifi_crypt_types); ++i) { + if ( memcmp(d, wifi_crypt_types[i].bytes, 2) == 0) { + return wifi_crypt_types[i].description; + } } + return ""; +} + +static const ndef_wifi_type_t wifi_auth_types[] = { + {"OPEN", {0x00, 0x01}}, + {"WPA PERSONAL", {0x00, 0x02}}, + {"SHARED", {0x00, 0x04}}, + {"WPA ENTERPRISE", {0x00, 0x08}}, + {"WPA2 ENTERPRISE", {0x00, 0x10}}, + {"WPA2 PERSONAL", {0x00, 0x20}}, + {"WPA/WPA2 PERSONAL", {0x00, 0x22}} +}; + +static const char* ndef_wifi_auth_lookup(uint8_t *d) { + for (int i = 0; i < ARRAYLEN(wifi_auth_types); ++i) { + if ( memcmp(d, wifi_auth_types[i].bytes, 2) == 0) { + return wifi_auth_types[i].description; + } + } + return ""; +} + +static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { + if (ndef->PayloadLen == 0) { + PrintAndLogEx(INFO, "no payload"); + return PM3_SUCCESS; + } + + PrintAndLogEx(INFO, _CYAN_("NDEF Wifi Simple Config Record")); + PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type); + + size_t n = ndef->PayloadLen; + size_t pos = 0; + while (n) { + + if ( ndef->Payload[pos] != 0x10 ) { + n -= 1; + pos -= 1; + continue; + } + + // VERSION + if (memcmp(&ndef->Payload[pos], "\x10\x4A", 2) == 0) { + uint8_t len = 1; + PrintAndLogEx(INFO, "Version......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + + // CREDENTIAL + if (memcmp(&ndef->Payload[pos], "\x10\x0E", 2) == 0) { + // 10 0E 00 39 + uint8_t len = 2; + PrintAndLogEx(INFO, "Credential...... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + + // AUTH_TYPE + if (memcmp(&ndef->Payload[pos], "\x10\x03", 2) == 0) { + // 10 03 00 02 00 20 + uint8_t len = 4; + PrintAndLogEx(INFO, "Auth type....... %s ( " _YELLOW_("%s")" )", + sprint_hex(&ndef->Payload[pos + 2], len), + ndef_wifi_auth_lookup(&ndef->Payload[pos + 2]) + ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + + // CRYPT_TYPE + if (memcmp(&ndef->Payload[pos], "\x10\x0F", 2) == 0) { + // 10 0F 00 02 00 04 + uint8_t len = 4; + PrintAndLogEx(INFO, "Crypt type...... %s ( " _YELLOW_("%s")" )", + sprint_hex(&ndef->Payload[pos + 2], len), + ndef_wifi_crypt_lookup(&ndef->Payload[pos + 2]) + ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + + // MAC_ADDRESS + if (memcmp(&ndef->Payload[pos], "\x10\x20", 2) == 0) { + // 10 20 00 06 FF FF FF FF FF FF + uint8_t len = ndef->Payload[pos + 3]; + PrintAndLogEx(INFO, "MAC Address..... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len) ); + n -= 4; + n -= len; + pos += 4; + pos += len; + } + + // NETWORK_IDX + if (memcmp(&ndef->Payload[pos], "\x10\x26", 2) == 0) { + // 10 26 00 01 01 + uint8_t len = 3; + PrintAndLogEx(INFO, "Network Index... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + + // NETWORK_KEY + if (memcmp(&ndef->Payload[pos], "\x10\x27", 2) == 0) { + // 10 27 00 10 74 72 69 73 74 61 6E 2D 73 70 72 69 6E 67 65 72 + uint8_t len = ndef->Payload[pos + 3]; + PrintAndLogEx(INFO, "Network key..... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len) ); + n -= 4; + n -= len; + pos += 4; + pos += len; + } + // NETWORK_NAME + if (memcmp(&ndef->Payload[pos], "\x10\x45", 2) == 0) { + // 10 45 00 06 69 63 65 73 71 6C + uint8_t len = ndef->Payload[pos + 3]; + PrintAndLogEx(INFO, "Network Name.... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len) ); + n -= 4; + n -= len; + pos += 4; + pos += len; + } + + // OOB_PASSWORD + // unknown the length. + if (memcmp(&ndef->Payload[pos], "\x10\x2C", 2) == 0) { + uint8_t len = 1; + PrintAndLogEx(INFO, "OOB Password......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + // VENDOR_EXT + // unknown the length. + if (memcmp(&ndef->Payload[pos], "\x10\x49", 2) == 0) { + uint8_t len = 1; + PrintAndLogEx(INFO, "Vendor Ext......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + // VENDOR_WFA + // unknown the length. + if (memcmp(&ndef->Payload[pos], "\x10\x30\x2A", 3) == 0) { + uint8_t len = 1; + PrintAndLogEx(INFO, "Vendor WFA......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + n -= 2; + n -= len; + pos += 2; + pos += len; + } + } + + /* + ap-channel 0, 6 ++ credential + device-name + mac-address + manufacturer + model-name + model-number ++ oob-password + primary-device-type + rf-bands + secondary-device-type-list + serial-number + ssid + uuid-enrollee + uuid-registrar ++ vendor-extension + version-1 + */ + + return PM3_SUCCESS; +} +static int ndefDecodeMime_wifi_p2p(NDEFHeader_t *ndef) { + if (ndef->PayloadLen == 0) { + PrintAndLogEx(INFO, "no payload"); + return PM3_SUCCESS; + } + + PrintAndLogEx(INFO, _CYAN_("NDEF Wifi Peer To Peer Record")); + PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type); return PM3_SUCCESS; } @@ -554,55 +765,62 @@ static int ndefDecodeMime_vcard(NDEFHeader_t *ndef) { } return PM3_SUCCESS; } + static int ndefDecodeMime_json(NDEFHeader_t *ndef) { - PrintAndLogEx(INFO, _CYAN_("JSON details")); - if (ndef->PayloadLen > 1) { - PrintAndLogEx(INFO, ""); - PrintAndLogEx(INFO, _GREEN_("%.*s"), (int)ndef->PayloadLen, ndef->Payload); + if (ndef->PayloadLen == 0) { + PrintAndLogEx(INFO, "no payload"); + return PM3_SUCCESS; } + + PrintAndLogEx(INFO, _CYAN_("JSON details")); + PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type); + PrintAndLogEx(INFO, ""); + PrintAndLogEx(INFO, _GREEN_("%.*s"), (int)ndef->PayloadLen, ndef->Payload); return PM3_SUCCESS; } static int ndefDecodeMime_bt(NDEFHeader_t *ndef) { - PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type); - if (ndef->PayloadLen > 1) { - uint16_t ooblen = (ndef->Payload[1] << 8 | ndef->Payload[0]); - PrintAndLogEx(INFO, "OOB data len.... %u", ooblen); - PrintAndLogEx(INFO, "BT MAC.......... " _YELLOW_("%s"), sprint_hex(ndef->Payload + 2, 6)); - // Let's check payload[8]. Tells us a bit about the UUID's. If 0x07 then it tells us a service UUID is 128bit - switch (ndef->Payload[8]) { - case 0x02: - PrintAndLogEx(INFO, "Optional Data... incomplete list 16-bit UUID's"); - break; - case 0x03: - PrintAndLogEx(INFO, "Optional Data... complete list 16-bit UUID's"); - break; - case 0x04: - PrintAndLogEx(INFO, "Optional Data... incomplete list 32-bit UUID's"); - break; - case 0x05: - PrintAndLogEx(INFO, "Optional Data... complete list 32-bit UUID's"); - break; - case 0x06: - PrintAndLogEx(INFO, "Optional Data... incomplete list 128-bit UUID's"); - break; - case 0x07: - PrintAndLogEx(INFO, "Optional Data... complete list 128-bit UUID's"); - break; - default: - PrintAndLogEx(INFO, "Optional Data... [ %02x ]", ndef->Payload[8]); - break; - } - // Let's check payload[9]. If 0x08 then SHORT_NAME or if 0x09 then COMPLETE_NAME - if (ndef->Payload[9] == 0x08) { - PrintAndLogEx(INFO, "Short name...... " _YELLOW_("%.*s"), (int)(ndef->PayloadLen - 10), ndef->Payload + 10); - } else if (ndef->Payload[9] == 0x09) { - PrintAndLogEx(INFO, "Complete name... " _YELLOW_("%.*s"), (int)(ndef->PayloadLen - 10), ndef->Payload + 10); - } else { - PrintAndLogEx(INFO, "[ %02x ]", ndef->Payload[9]); - } - PrintAndLogEx(NORMAL, ""); + if (ndef->PayloadLen == 0) { + PrintAndLogEx(INFO, "no payload"); + return PM3_SUCCESS; } + PrintAndLogEx(INFO, "Type............ " _YELLOW_("%.*s"), (int)ndef->TypeLen, ndef->Type); + uint16_t ooblen = (ndef->Payload[1] << 8 | ndef->Payload[0]); + PrintAndLogEx(INFO, "OOB data len.... %u", ooblen); + PrintAndLogEx(INFO, "BT MAC.......... " _YELLOW_("%s"), sprint_hex(ndef->Payload + 2, 6)); + // Let's check payload[8]. Tells us a bit about the UUID's. If 0x07 then it tells us a service UUID is 128bit + switch (ndef->Payload[8]) { + case 0x02: + PrintAndLogEx(INFO, "Optional Data... incomplete list 16-bit UUID's"); + break; + case 0x03: + PrintAndLogEx(INFO, "Optional Data... complete list 16-bit UUID's"); + break; + case 0x04: + PrintAndLogEx(INFO, "Optional Data... incomplete list 32-bit UUID's"); + break; + case 0x05: + PrintAndLogEx(INFO, "Optional Data... complete list 32-bit UUID's"); + break; + case 0x06: + PrintAndLogEx(INFO, "Optional Data... incomplete list 128-bit UUID's"); + break; + case 0x07: + PrintAndLogEx(INFO, "Optional Data... complete list 128-bit UUID's"); + break; + default: + PrintAndLogEx(INFO, "Optional Data... [ %02x ]", ndef->Payload[8]); + break; + } + // Let's check payload[9]. If 0x08 then SHORT_NAME or if 0x09 then COMPLETE_NAME + if (ndef->Payload[9] == 0x08) { + PrintAndLogEx(INFO, "Short name...... " _YELLOW_("%.*s"), (int)(ndef->PayloadLen - 10), ndef->Payload + 10); + } else if (ndef->Payload[9] == 0x09) { + PrintAndLogEx(INFO, "Complete name... " _YELLOW_("%.*s"), (int)(ndef->PayloadLen - 10), ndef->Payload + 10); + } else { + PrintAndLogEx(INFO, "[ %02x ]", ndef->Payload[9]); + } + PrintAndLogEx(NORMAL, ""); return PM3_SUCCESS; } @@ -687,8 +905,11 @@ static int ndefDecodePayload(NDEFHeader_t *ndef) { memcpy(begin, ndef->Type, ndef->TypeLen); str_lower(begin); - if (str_startswith(begin, NDEF_WIFIAPPL)) { - ndefDecodeMime_wifi(ndef); + if (str_startswith(begin, NDEF_WIFIAPPL_WSC)) { + ndefDecodeMime_wifi_wsc(ndef); + } + if (str_startswith(begin, NDEF_WIFIAPPL_P2P)) { + ndefDecodeMime_wifi_p2p(ndef); } if (str_startswith(begin, NDEF_VCARDTEXT) || str_startswith(begin, NDEF_XVCARDTEXT)) { ndefDecodeMime_vcard(ndef); From 06ccaf555c7a9f0617c5426d0b8e5787869c99fd Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 21 Feb 2022 21:41:11 +0100 Subject: [PATCH 11/21] coverity cid #386958 - tainted value --- tools/mfd_aes_brute/mfd_multi_brute.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/mfd_aes_brute/mfd_multi_brute.c b/tools/mfd_aes_brute/mfd_multi_brute.c index 413c47a17..c819415ad 100644 --- a/tools/mfd_aes_brute/mfd_multi_brute.c +++ b/tools/mfd_aes_brute/mfd_multi_brute.c @@ -365,6 +365,13 @@ int main(int argc, char *argv[]) { } uint8_t g_idx = atoi(argv[2]); + + // -2 (zero index and last item is NULL); + if (g_idx > ARRAYLEN(generators) - 2) { + printf("generator index is out-of-range\n"); + return 1; + } + uint64_t start_time = atoi(argv[3]); const bool support_aesni = platform_aes_hw_available(); From a852f88a6e244493906bc39924283cf3b77e4070 Mon Sep 17 00:00:00 2001 From: Benjamin DELPY Date: Wed, 23 Feb 2022 23:37:47 +0100 Subject: [PATCH 12/21] Fix support for more Mifare Desfire EV2 cards Was tempted to make a `major` mask with 0x0f == 1,2,3,... but... --- client/src/cmdhfmfdes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index fa445d501..b589fa26c 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -247,6 +247,8 @@ static char *getVersionStr(uint8_t major, uint8_t minor) { snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV1") " )", major, minor); else if (major == 0x12 && minor == 0x00) snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV2") " )", major, minor); + else if (major == 0x22 && minor == 0x00) + snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV2") " )", major, minor); else if (major == 0x42 && minor == 0x00) snprintf(retStr, sizeof(buf), "%x.%x ( " _GREEN_("DESFire EV2") " )", major, minor); else if (major == 0x33 && minor == 0x00) @@ -280,11 +282,15 @@ static nxp_cardtype_t getCardType(uint8_t major, uint8_t minor) { return DESFIRE_EV1; if (major == 0x12 && minor == 0x00) return DESFIRE_EV2; + if (major == 0x22 && minor == 0x00) + return DESFIRE_EV2; + if (major == 0x42 && minor == 0x00) + return DESFIRE_EV2; if (major == 0x33 && minor == 0x00) return DESFIRE_EV3; if (major == 0x30 && minor == 0x00) return DESFIRE_LIGHT; - if (major == 0x11 && minor == 0x00) + if (major == 0x11 && minor == 0x00) return PLUS_EV1; if (major == 0x10 && minor == 0x00) return NTAG413DNA; From c98bdfe8578b92337676981a52025dbb20e82a58 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 17:16:31 +0100 Subject: [PATCH 13/21] fixes to "hf cipurse info" --- client/src/cipurse/cipursecore.c | 25 ++++++++++++------------- client/src/cipurse/cipursecore.h | 2 +- client/src/cmdhfcipurse.c | 28 +++++++++++++++++++--------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/client/src/cipurse/cipursecore.c b/client/src/cipurse/cipursecore.c index 738839b00..fc20c4854 100644 --- a/client/src/cipurse/cipursecore.c +++ b/client/src/cipurse/cipursecore.c @@ -17,16 +17,15 @@ //----------------------------------------------------------------------------- #include "cipursecore.h" +#include // memcpy memset #include "commonutil.h" // ARRAYLEN #include "comms.h" // DropField #include "util_posix.h" // msleep -#include // memcpy memset - #include "cmdhf14a.h" -#include "emv/emvcore.h" -#include "emv/emvjson.h" -#include "iso7816/apduinfo.h" +#include "../emv/emvcore.h" +#include "../emv/emvjson.h" +#include "../iso7816/apduinfo.h" // sAPDU_t #include "ui.h" #include "util.h" @@ -299,21 +298,21 @@ void CIPURSECSetActChannelSecurityLevels(CipurseChannelSecurityLevel req, Cipurs static void CIPURSEPrintPersoMode(uint8_t data) { if ((data & 0x01) == 0x01) - PrintAndLogEx(INFO, "Perso... " _YELLOW_("filesystem")); + PrintAndLogEx(INFO, "Perso.......... " _YELLOW_("filesystem")); if ((data & 0x02) == 0x02) - PrintAndLogEx(INFO, "Perso... " _YELLOW_("EMV")); + PrintAndLogEx(INFO, "Perso.......... " _YELLOW_("EMV")); if ((data & 0x04) == 0x04) - PrintAndLogEx(INFO, "Perso... " _YELLOW_("transaction supported")); + PrintAndLogEx(INFO, "Perso.......... " _YELLOW_("transaction supported")); } // 2021 iceman: what is the description text of profile L,S,T ? static void CIPURSEPrintProfileInfo(uint8_t data) { if ((data & 0x01) == 0x01) - PrintAndLogEx(INFO, "Profile... L"); + PrintAndLogEx(INFO, "Profile........ L"); if ((data & 0x02) == 0x02) - PrintAndLogEx(INFO, "Profile... S"); + PrintAndLogEx(INFO, "Profile........ S"); if ((data & 0x04) == 0x04) - PrintAndLogEx(INFO, "Profile... T"); + PrintAndLogEx(INFO, "Profile........ T"); } static void CIPURSEPrintManufacturerInfo(uint8_t data) { @@ -330,8 +329,8 @@ void CIPURSEPrintInfoFile(uint8_t *data, size_t len) { } PrintAndLogEx(INFO, "--- " _CYAN_("CIPURSE Information") "---------------------"); - PrintAndLogEx(INFO, "version.... " _YELLOW_("%d"), data[0]); - PrintAndLogEx(INFO, "revision... " _YELLOW_("%d"), data[1]); + PrintAndLogEx(INFO, "version........ " _YELLOW_("%d"), data[0]); + PrintAndLogEx(INFO, "revision....... " _YELLOW_("%d"), data[1]); if (len >= 3) CIPURSEPrintPersoMode(data[2]); diff --git a/client/src/cipurse/cipursecore.h b/client/src/cipurse/cipursecore.h index 603bab765..f7bdd9be0 100644 --- a/client/src/cipurse/cipursecore.h +++ b/client/src/cipurse/cipursecore.h @@ -22,7 +22,7 @@ #include #include #include "common.h" -#include "iso7816/apduinfo.h" // sAPDU_t +#include "../iso7816/apduinfo.h" // sAPDU_t #include "cipurse/cipursecrypto.h" diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index ffbed5bd4..eb3453eec 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -113,7 +113,11 @@ static int SelectAndPrintInfoFile(void) { if (len > 0) { PrintAndLogEx(INFO, "Info file ( " _GREEN_("ok") " )"); - PrintAndLogEx(INFO, "[%zu]: %s", len, sprint_hex(buf, len)); + + PrintAndLogEx(INFO, " # | bytes | ascii"); + PrintAndLogEx(INFO, "---+-------------------------------------------------+-----------------"); + print_hex_break(buf, len, 16); + PrintAndLogEx(NORMAL, ""); CIPURSEPrintInfoFile(buf, len); PrintAndLogEx(INFO, ""); } @@ -149,7 +153,7 @@ static int CmdHFCipurseInfo(const char *Cmd) { int res = CIPURSESelectMFEx(true, true, buf, sizeof(buf), &len, &sw); if (res == PM3_SUCCESS && sw == 0x9000) { mfExist = true; - PrintAndLogEx(INFO, _CYAN_("MasterFile") " exist and can be selected."); + PrintAndLogEx(INFO, _YELLOW_("MasterFile") " exist and can be selected."); res = SelectAndPrintInfoFile(); infoPrinted = (res == PM3_SUCCESS); @@ -173,7 +177,7 @@ static int CmdHFCipurseInfo(const char *Cmd) { DropField(); return res; } - PrintAndLogEx(INFO, "Application `AF F1` selected " _GREEN_("successfully")); + PrintAndLogEx(INFO, "Application `" _YELLOW_("AF F1") "` selected " _GREEN_("successfully")); if (sw != 0x9000) { if (sw == 0x0000) { @@ -1276,7 +1280,8 @@ static int CmdHFCipurseCreateDGI(const char *Cmd) { res = CIPURSECreateFile(hdata, hdatalen, buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { - PrintAndLogEx(ERR, "Create file command " _RED_("ERROR") ". Card returns:\n 0x%04x - %s", sw, + PrintAndLogEx(ERR, "Create file command " _RED_("ERROR")); + PrintAndLogEx(ERR, "0x%04x - %s", sw, GetSpecificAPDUCodeDesc(SelectAPDUCodeDescriptions, ARRAYLEN(SelectAPDUCodeDescriptions), sw)); DropField(); return PM3_ESOFT; @@ -1403,7 +1408,8 @@ static int CmdHFCipurseDeleteFile(const char *Cmd) { if (useChildFID) { res = CIPURSEDeleteFile(childFileId, buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { - PrintAndLogEx(ERR, "Delete child file " _CYAN_("%04x ") _RED_("ERROR") ". Card returns:\n 0x%04x - %s", childFileId, sw, + PrintAndLogEx(ERR, "Delete child file " _CYAN_("%04x ") _RED_("ERROR")); + PrintAndLogEx(ERR, "0x%04x - %s", childFileId, sw, GetSpecificAPDUCodeDesc(DeleteAPDUCodeDescriptions, ARRAYLEN(DeleteAPDUCodeDescriptions), sw)); DropField(); return PM3_ESOFT; @@ -1412,7 +1418,8 @@ static int CmdHFCipurseDeleteFile(const char *Cmd) { } else if (useFID) { res = CIPURSEDeleteFile(fileId, buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { - PrintAndLogEx(ERR, "Delete file " _CYAN_("%04x ") _RED_("ERROR") ". Card returns:\n 0x%04x - %s", fileId, sw, + PrintAndLogEx(ERR, "Delete file " _CYAN_("%04x ") _RED_("ERROR")); + PrintAndLogEx(ERR, "0x%04x - %s", fileId, sw, GetSpecificAPDUCodeDesc(DeleteAPDUCodeDescriptions, ARRAYLEN(DeleteAPDUCodeDescriptions), sw)); DropField(); return PM3_ESOFT; @@ -1421,7 +1428,8 @@ static int CmdHFCipurseDeleteFile(const char *Cmd) { } else { res = CIPURSEDeleteFileAID(aid, aidLen, buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { - PrintAndLogEx(ERR, "Delete application " _CYAN_("%s ") _RED_("ERROR") ". Card returns:\n 0x%04x - %s", + PrintAndLogEx(ERR, "Delete application " _CYAN_("%s ") _RED_("ERROR")); + PrintAndLogEx(ERR, "0x%04x - %s", sprint_hex_inrow(aid, aidLen), sw, GetSpecificAPDUCodeDesc(DeleteAPDUCodeDescriptions, ARRAYLEN(DeleteAPDUCodeDescriptions), sw)); @@ -1617,7 +1625,8 @@ static int CmdHFCipurseUpdateKey(const char *Cmd) { res = CIPURSEUpdateKey(encKeyId, newKeyId, keydata, sizeof(keydata), buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { - PrintAndLogEx(ERR, "Update key command " _RED_("ERROR") ". Card returns:\n 0x%04x - %s", sw, + PrintAndLogEx(ERR, "Update key command " _RED_("ERROR")); + PrintAndLogEx(ERR, "0x%04x - %s", sw, GetSpecificAPDUCodeDesc(UAPDpdateKeyCodeDescriptions, ARRAYLEN(UAPDpdateKeyCodeDescriptions), sw)); DropField(); return PM3_ESOFT; @@ -1764,7 +1773,8 @@ static int CmdHFCipurseUpdateKeyAttr(const char *Cmd) { res = CIPURSEUpdateKeyAttrib(trgKeyId, hdata[0], buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { - PrintAndLogEx(ERR, "Update key attributes command " _RED_("ERROR") ". Card returns:\n 0x%04x - %s", sw, + PrintAndLogEx(ERR, "Update key attributes command " _RED_("ERROR")); + PrintAndLogEx(ERR, "0x%04x - %s", sw, GetSpecificAPDUCodeDesc(UAPDpdateKeyAttrCodeDescriptions, ARRAYLEN(UAPDpdateKeyAttrCodeDescriptions), sw)); DropField(); return PM3_ESOFT; From 4bd6e8f61c3f6fb6de16fd3159b153bd58ca3fde Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 17:20:27 +0100 Subject: [PATCH 14/21] fixes to "hf cipurse info" --- client/src/cipurse/cipursecore.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/cipurse/cipursecore.c b/client/src/cipurse/cipursecore.c index fc20c4854..cce2d0484 100644 --- a/client/src/cipurse/cipursecore.c +++ b/client/src/cipurse/cipursecore.c @@ -307,12 +307,15 @@ static void CIPURSEPrintPersoMode(uint8_t data) { // 2021 iceman: what is the description text of profile L,S,T ? static void CIPURSEPrintProfileInfo(uint8_t data) { + + PrintAndLogEx(INFO, "Profile........" NOLF); if ((data & 0x01) == 0x01) - PrintAndLogEx(INFO, "Profile........ L"); + PrintAndLogEx(NORMAL, " L" NOLF); if ((data & 0x02) == 0x02) - PrintAndLogEx(INFO, "Profile........ S"); + PrintAndLogEx(NORMAL, ", S" NOLF); if ((data & 0x04) == 0x04) - PrintAndLogEx(INFO, "Profile........ T"); + PrintAndLogEx(NORMAL, ", T" NOLF); + PrintAndLogEx(NORMAL, ""); } static void CIPURSEPrintManufacturerInfo(uint8_t data) { From bb1a51988cf08d3bef272aad1df61c2b09db82d4 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 17:24:42 +0100 Subject: [PATCH 15/21] fixes to "hf cipurse info" --- client/src/cipurse/cipursecore.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/src/cipurse/cipursecore.c b/client/src/cipurse/cipursecore.c index cce2d0484..76b9d9b8d 100644 --- a/client/src/cipurse/cipursecore.c +++ b/client/src/cipurse/cipursecore.c @@ -332,8 +332,7 @@ void CIPURSEPrintInfoFile(uint8_t *data, size_t len) { } PrintAndLogEx(INFO, "--- " _CYAN_("CIPURSE Information") "---------------------"); - PrintAndLogEx(INFO, "version........ " _YELLOW_("%d"), data[0]); - PrintAndLogEx(INFO, "revision....... " _YELLOW_("%d"), data[1]); + PrintAndLogEx(INFO, "Version........ " _YELLOW_("v%d.%d"), data[0], data[1]); if (len >= 3) CIPURSEPrintPersoMode(data[2]); From 2879b23a1ca353a0c319fbd0be16cbe1cf4a5ce2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 17:38:01 +0100 Subject: [PATCH 16/21] unify text --- client/src/cmdhfcipurse.c | 5 +++-- client/src/cmdlfem4x50.c | 10 +++++----- client/src/cmdlffdxb.c | 2 +- client/src/cmdlfio.c | 4 ++-- client/src/cmdlfjablotron.c | 2 +- client/src/cmdlfnedap.c | 2 +- client/src/cmdlfnexwatch.c | 6 +++--- client/src/cmdlfpyramid.c | 2 +- client/src/cmdlfsecurakey.c | 2 +- client/src/cmdlfti.c | 2 +- client/src/emv/emvcore.c | 8 ++++---- client/src/emv/emvjson.c | 2 +- client/src/flash.c | 2 +- tools/pm3_tests.sh | 2 +- 14 files changed, 26 insertions(+), 25 deletions(-) diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index eb3453eec..4e91d5d69 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -377,12 +377,13 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si res = CIPURSESelectFileEx(true, true, fileId, buf, bufSize, len, sw); if (res != 0 || *sw != 0x9000) { if (verbose) { - PrintAndLogEx(ERR, "Cipurse select file 0x%04x " _RED_("error") ". Card returns 0x%04x", fileId, *sw); + PrintAndLogEx(ERR, "Cipurse select file 0x%04x " _RED_("error")); + PrintAndLogEx(ERR, "Card returns 0x%04x", fileId, *sw); } return PM3_ESOFT; } if (verbose) { - PrintAndLogEx(INFO, "Cipurse select file " _CYAN_("0x%04x ") _GREEN_("OK"), fileId); + PrintAndLogEx(INFO, "Cipurse select file " _YELLOW_("0x%04X ") " ( " _GREEN_("ok") " )", fileId); } } else if (selectDefaultFile) { diff --git a/client/src/cmdlfem4x50.c b/client/src/cmdlfem4x50.c index 15c6bf783..3c0bee80b 100644 --- a/client/src/cmdlfem4x50.c +++ b/client/src/cmdlfem4x50.c @@ -359,9 +359,9 @@ int CmdEM4x50Login(const char *Cmd) { // print response if (resp.status == PM3_SUCCESS) - PrintAndLogEx(SUCCESS, "Login " _GREEN_("ok")); + PrintAndLogEx(SUCCESS, "Login ( " _GREEN_("ok") " )"); else - PrintAndLogEx(FAILED, "Login " _RED_("failed")); + PrintAndLogEx(FAILED, "Login ( " _RED_("failed") " )"); return resp.status; } @@ -966,7 +966,7 @@ int CmdEM4x50WritePwd(const char *Cmd) { return PM3_EFAILED; } - PrintAndLogEx(SUCCESS, "Writing new password %s (%s)" + PrintAndLogEx(SUCCESS, "Writing new password %s ( %s )" , sprint_hex_inrow(npwd, sizeof(npwd)) , _GREEN_("ok") ); @@ -1015,9 +1015,9 @@ int CmdEM4x50Wipe(const char *Cmd) { } if (resp.status == PM3_SUCCESS) { - PrintAndLogEx(SUCCESS, "Resetting password to 00000000 (" _GREEN_("ok") ")"); + PrintAndLogEx(SUCCESS, "Resetting password to 00000000 ( " _GREEN_("ok") " )"); } else { - PrintAndLogEx(FAILED, "Resetting password " _RED_("failed")); + PrintAndLogEx(FAILED, "Resetting password ( " _RED_("failed") " )"); return PM3_ESOFT; } diff --git a/client/src/cmdlffdxb.c b/client/src/cmdlffdxb.c index 495c867a3..1d406ea20 100644 --- a/client/src/cmdlffdxb.c +++ b/client/src/cmdlffdxb.c @@ -581,7 +581,7 @@ int demodFDXB(bool verbose) { uint8_t c[] = {0, 0}; compute_crc(CRC_11784, raw, sizeof(raw), &c[0], &c[1]); - PrintAndLogEx(SUCCESS, "CRC-16 0x%04X (%s)", crc, (crc == (c[1] << 8 | c[0])) ? _GREEN_("ok") : _RED_("fail")); + PrintAndLogEx(SUCCESS, "CRC-16 0x%04X ( %s )", crc, (crc == (c[1] << 8 | c[0])) ? _GREEN_("ok") : _RED_("fail")); // iceman: crc doesn't protect the extended data? PrintAndLogEx(SUCCESS, "Raw " _GREEN_("%s"), sprint_hex(raw, 8)); diff --git a/client/src/cmdlfio.c b/client/src/cmdlfio.c index 924608dcb..429b1ef8e 100644 --- a/client/src/cmdlfio.c +++ b/client/src/cmdlfio.c @@ -140,9 +140,9 @@ int demodIOProx(bool verbose) { char crc_str[36] = {0}; if (crc == calccrc) { - snprintf(crc_str, sizeof(crc_str), "(" _GREEN_("ok") ")"); + snprintf(crc_str, sizeof(crc_str), "( " _GREEN_("ok") " )"); } else { - snprintf(crc_str, sizeof(crc_str), "(" _RED_("fail") ") 0x%02X != 0x%02X", crc, calccrc); + snprintf(crc_str, sizeof(crc_str), "( " _RED_("fail") " ) 0x%02X != 0x%02X", crc, calccrc); retval = PM3_ESOFT; } diff --git a/client/src/cmdlfjablotron.c b/client/src/cmdlfjablotron.c index 0e886cf53..cac3a1329 100644 --- a/client/src/cmdlfjablotron.c +++ b/client/src/cmdlfjablotron.c @@ -100,7 +100,7 @@ int demodJablotron(bool verbose) { uint8_t chksum = raw2 & 0xFF; bool isok = (chksum == jablontron_chksum(g_DemodBuffer)); - PrintAndLogEx(DEBUG, "Checksum: %02X (%s)", chksum, isok ? _GREEN_("ok") : _RED_("Fail")); + PrintAndLogEx(DEBUG, "Checksum: %02X ( %s )", chksum, isok ? _GREEN_("ok") : _RED_("Fail")); id = DEC2BCD(id); // Printed format: 1410-nn-nnnn-nnnn diff --git a/client/src/cmdlfnedap.c b/client/src/cmdlfnedap.c index fb990be72..acb68c406 100644 --- a/client/src/cmdlfnedap.c +++ b/client/src/cmdlfnedap.c @@ -151,7 +151,7 @@ int demodNedap(bool verbose) { , customerCode , sprint_hex_inrow(data, size / 8) ); - PrintAndLogEx(DEBUG, "Checksum (%s) 0x%04X", _GREEN_("ok"), checksum); + PrintAndLogEx(DEBUG, "Checksum ( %s ) 0x%04X", _GREEN_("ok"), checksum); } else { PrintAndLogEx(ERR, "Invalid idx (1:%02x - 2:%02x - 3:%02x - 4:%02x - 5:%02x)", idxC1, idxC2, idxC3, idxC4, idxC5); diff --git a/client/src/cmdlfnexwatch.c b/client/src/cmdlfnexwatch.c index ccf98961b..9f24a87b4 100644 --- a/client/src/cmdlfnexwatch.c +++ b/client/src/cmdlfnexwatch.c @@ -237,12 +237,12 @@ int demodNexWatch(bool verbose) { if (parity == calc_parity) { - PrintAndLogEx(DEBUG, " parity : %s (0x%X)", _GREEN_("ok"), parity); + PrintAndLogEx(DEBUG, " parity : ( %s ) 0x%X", _GREEN_("ok"), parity); } else { - PrintAndLogEx(DEBUG, " parity : %s (0x%X != 0x%X)", _RED_("fail"), parity, calc_parity); + PrintAndLogEx(DEBUG, " parity : ( %s ) 0x%X != 0x%X", _RED_("fail"), parity, calc_parity); } - PrintAndLogEx(DEBUG, " checksum : %s (0x%02X)", (m_idx < ARRAYLEN(items)) ? _GREEN_("ok") : _RED_("fail"), chk); + PrintAndLogEx(DEBUG, " checksum : ( %s ) 0x%02X", (m_idx < ARRAYLEN(items)) ? _GREEN_("ok") : _RED_("fail"), chk); PrintAndLogEx(INFO, " Raw : " _YELLOW_("%08"PRIX32"%08"PRIX32"%08"PRIX32), raw1, raw2, raw3); return PM3_SUCCESS; diff --git a/client/src/cmdlfpyramid.c b/client/src/cmdlfpyramid.c index bad1afaf0..8f9e5fccb 100644 --- a/client/src/cmdlfpyramid.c +++ b/client/src/cmdlfpyramid.c @@ -170,7 +170,7 @@ int demodPyramid(bool verbose) { PrintAndLogEx(SUCCESS, "Pyramid - len: " _GREEN_("%d") " -unknown- Card: " _GREEN_("%d") ", Raw: %08x%08x%08x%08x", fmtLen, cardnum, rawHi3, rawHi2, rawHi, rawLo); } - PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - 0x%02X - %s" + PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - 0x%02X ( %s )" , checksum , checkCS , (checksum == checkCS) ? _GREEN_("ok") : _RED_("fail") diff --git a/client/src/cmdlfsecurakey.c b/client/src/cmdlfsecurakey.c index aae0a7f73..5a109e2d9 100644 --- a/client/src/cmdlfsecurakey.c +++ b/client/src/cmdlfsecurakey.c @@ -112,7 +112,7 @@ int demodSecurakey(bool verbose) { PrintAndLogEx(SUCCESS, "Securakey - len: " _GREEN_("%u") " FC: " _GREEN_("0x%X")" Card: " _GREEN_("%u") ", Raw: %08X%08X%08X", bitLen, fc, cardid, raw1, raw2, raw3); if (bitLen <= 32) - PrintAndLogEx(SUCCESS, "Wiegand: " _GREEN_("%08X") " parity (%s)", (lWiegand << (bitLen / 2)) | rWiegand, parity ? _GREEN_("ok") : _RED_("fail")); + PrintAndLogEx(SUCCESS, "Wiegand: " _GREEN_("%08X") " parity ( %s )", (lWiegand << (bitLen / 2)) | rWiegand, parity ? _GREEN_("ok") : _RED_("fail")); if (verbose) { PrintAndLogEx(INFO, "\nHow the FC translates to printed FC is unknown"); diff --git a/client/src/cmdlfti.c b/client/src/cmdlfti.c index cd339b087..beb0d4ae4 100644 --- a/client/src/cmdlfti.c +++ b/client/src/cmdlfti.c @@ -264,7 +264,7 @@ int demodTI(bool verbose) { init_table(CRC_KERMIT); uint16_t calccrc = crc16_kermit(raw, sizeof(raw)); const char *crc_str = (calccrc == (shift2 & 0xFFFF)) ? _GREEN_("ok") : _RED_("fail"); - PrintAndLogEx(INFO, "Tag data = %08X%08X [%04X] (%s)", shift1, shift0, calccrc, crc_str); + PrintAndLogEx(INFO, "Tag data = %08X%08X [%04X] ( %s )", shift1, shift0, calccrc, crc_str); if (calccrc != (shift2 & 0xFFFF)) PrintAndLogEx(WARNING, "Warning: CRC mismatch, calculated %04X, got %04X", calccrc, shift2 & 0xFFFF); diff --git a/client/src/emv/emvcore.c b/client/src/emv/emvcore.c index 324ffe097..63e0c14dc 100644 --- a/client/src/emv/emvcore.c +++ b/client/src/emv/emvcore.c @@ -652,7 +652,7 @@ int trSDA(struct tlvdb *tlv) { struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv); if (dac_db) { const struct tlv *dac_tlv = tlvdb_get(dac_db, 0x9f45, NULL); - PrintAndLogEx(INFO, "SDA verified (%s) (Data Authentication Code: %02hhx:%02hhx)", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); + PrintAndLogEx(INFO, "SDA verified ( %s ) (Data Authentication Code: %02hhx:%02hhx)", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); tlvdb_add(tlv, dac_db); } else { emv_pk_free(issuer_pk); @@ -771,7 +771,7 @@ int trDDA(Iso7816CommandChannel channel, bool decodeTLV, struct tlvdb *tlv) { struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv); if (dac_db) { const struct tlv *dac_tlv = tlvdb_get(dac_db, 0x9f45, NULL); - PrintAndLogEx(INFO, "SDAD verified (%s) (Data Authentication Code: %02hhx:%02hhx)\n", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); + PrintAndLogEx(INFO, "SDAD verified ( %s ) (Data Authentication Code: %02hhx:%02hhx)\n", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); tlvdb_add(tlv, dac_db); } else { PrintAndLogEx(ERR, "Error: SSAD verify error"); @@ -930,7 +930,7 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv); if (dac_db) { const struct tlv *dac_tlv = tlvdb_get(dac_db, 0x9f45, NULL); - PrintAndLogEx(SUCCESS, "Signed Static Application Data (SSAD) verified (%s) (%02hhx:%02hhx)", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); + PrintAndLogEx(SUCCESS, "Signed Static Application Data (SSAD) verified ( %s ) (%02hhx:%02hhx)", _GREEN_("ok"), dac_tlv->value[0], dac_tlv->value[1]); tlvdb_add(tlv, dac_db); } else { PrintAndLogEx(ERR, "Error: Signed Static Application Data (SSAD) verify error"); @@ -950,7 +950,7 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st if (idn_db) { const struct tlv *idn_tlv = tlvdb_get(idn_db, 0x9f4c, NULL); PrintAndLogEx(INFO, "IDN (ICC Dynamic Number) [%zu] %s", idn_tlv->len, sprint_hex_inrow(idn_tlv->value, idn_tlv->len)); - PrintAndLogEx(SUCCESS, "CDA verified (%s)", _GREEN_("ok")); + PrintAndLogEx(SUCCESS, "CDA verified ( %s )", _GREEN_("ok")); tlvdb_add(tlv, idn_db); } else { PrintAndLogEx(ERR, "ERROR: CDA verify error"); diff --git a/client/src/emv/emvjson.c b/client/src/emv/emvjson.c index 072473a31..0b4b74297 100644 --- a/client/src/emv/emvjson.c +++ b/client/src/emv/emvjson.c @@ -331,7 +331,7 @@ bool ParamLoadFromJson(struct tlvdb *tlv) { return false; } - PrintAndLogEx(SUCCESS, "Load params: json(%zu) (%s)", json_array_size(root), _GREEN_("OK")); + PrintAndLogEx(SUCCESS, "Load params: json(%zu) ( %s )", json_array_size(root), _GREEN_("ok")); for (int i = 0; i < json_array_size(root); i++) { json_t *data, *jtag, *jlength, *jvalue; diff --git a/client/src/flash.c b/client/src/flash.c index 5bc6fbcab..df115b7d0 100644 --- a/client/src/flash.c +++ b/client/src/flash.c @@ -608,7 +608,7 @@ int flash_write(flash_file_t *ctx) { } fflush(stdout); } - PrintAndLogEx(NORMAL, " " _GREEN_("OK")); + PrintAndLogEx(NORMAL, " " _GREEN_("ok")); fflush(stdout); } return PM3_SUCCESS; diff --git a/tools/pm3_tests.sh b/tools/pm3_tests.sh index d0c77a465..ee1794bde 100755 --- a/tools/pm3_tests.sh +++ b/tools/pm3_tests.sh @@ -445,7 +445,7 @@ while true; do "Indala (len 224) Raw: 80000001b23523a6c2e31eba3cbee4afb3c6ad1fcf649393928c14e5"; then break; fi if ! CheckExecute slow "lf T55 io test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_io.pm3; lf search -1'" "IO Prox ID found"; then break; fi if ! CheckExecute slow "lf T55 io test2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_io.pm3; lf io demod'" \ - "IO Prox - XSF(01)01:01337, Raw: 007840603059cf3f (ok)"; then break; fi + "IO Prox - XSF(01)01:01337, Raw: 007840603059cf3f ( ok )"; then break; fi if ! CheckExecute slow "lf T55 jablotron test" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_jablotron.pm3; lf search -1'" "Jablotron ID found"; then break; fi if ! CheckExecute slow "lf T55 jablotron test2" "$CLIENTBIN -c 'data load -f traces/lf_ATA5577_jablotron.pm3; lf jablotron demod'" \ "Printed: 1410-00-0011-2233"; then break; fi From 07855611e4f60dc26bb89cce3d2bef2c2d64a8fd Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 18:03:19 +0100 Subject: [PATCH 17/21] unify text --- armsrc/Standalone/hf_iceclass.c | 2 +- armsrc/iso15693.c | 4 ++-- client/src/cmdhf14b.c | 2 +- client/src/cmdhfcipurse.c | 40 ++++++++++++++++----------------- client/src/cmdhflegic.c | 8 +++---- client/src/cmdhfmf.c | 6 ++--- client/src/cmdhfmfdes.c | 32 +++++++++++++------------- client/src/cmdhfmfu.c | 8 +++---- client/src/cmdhfthinfilm.c | 4 ++-- client/src/cmdhw.c | 2 +- 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/armsrc/Standalone/hf_iceclass.c b/armsrc/Standalone/hf_iceclass.c index cdaa4f220..7aa53dba5 100644 --- a/armsrc/Standalone/hf_iceclass.c +++ b/armsrc/Standalone/hf_iceclass.c @@ -252,7 +252,7 @@ static int reader_attack_mode(void) { bool success = (mac_response_len == MAC_RESPONSES_SIZE); uint8_t num_mac = (mac_response_len >> 4); - Dbprintf("%u out of %d MAC obtained [%s]", num_mac, NUM_CSNS, (success) ? _GREEN_("ok") : _RED_("fail")); + Dbprintf("%u out of %d MAC obtained ( %s )", num_mac, NUM_CSNS, (success) ? _GREEN_("ok") : _RED_("fail")); size_t dumplen = NUM_CSNS * 24; diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index aa3929d73..c08d6130f 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -1589,9 +1589,9 @@ static void DbdecodeIso15693Answer(int len, uint8_t *d) { } if (CheckCrc15(d, len)) - strncat(status, "[+] crc (" _GREEN_("OK") ")", DBD15STATLEN - strlen(status)); + strncat(status, "[+] crc ( " _GREEN_("ok") " )", DBD15STATLEN - strlen(status)); else - strncat(status, "[!] crc (" _RED_("fail") ")", DBD15STATLEN - strlen(status)); + strncat(status, "[!] crc ( " _RED_("fail") " )", DBD15STATLEN - strlen(status)); if (g_dbglevel >= DBG_ERROR) Dbprintf("%s", status); } diff --git a/client/src/cmdhf14b.c b/client/src/cmdhf14b.c index 28f4ec9ee..baea0126a 100644 --- a/client/src/cmdhf14b.c +++ b/client/src/cmdhf14b.c @@ -191,7 +191,7 @@ static bool wait_cmd_14b(bool verbose, bool is_select, uint32_t timeout) { bool crc = check_crc(CRC_14443_B, data, len); PrintAndLogEx(SUCCESS, "received " _YELLOW_("%u") " bytes", len); - PrintAndLogEx(SUCCESS, "%s[%02X %02X] %s", + PrintAndLogEx(SUCCESS, "%s[%02X %02X] ( %s )", sprint_hex(data, len - 2), data[len - 2], data[len - 1], diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index 4e91d5d69..3c2791cb9 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -369,7 +369,7 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si return PM3_ESOFT; } if (verbose) { - PrintAndLogEx(INFO, "Cipurse select application " _CYAN_("%s ") _GREEN_("OK"), sprint_hex_inrow(aid, aidLen)); + PrintAndLogEx(INFO, "Cipurse select application " _YELLOW_("%s ") " ( %s )", sprint_hex_inrow(aid, aidLen), _GREEN_("ok")); } } else if (useFID) { @@ -377,7 +377,7 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si res = CIPURSESelectFileEx(true, true, fileId, buf, bufSize, len, sw); if (res != 0 || *sw != 0x9000) { if (verbose) { - PrintAndLogEx(ERR, "Cipurse select file 0x%04x " _RED_("error")); + PrintAndLogEx(ERR, "Cipurse select file 0x%04x ( %s )", _RED_("fail")); PrintAndLogEx(ERR, "Card returns 0x%04x", fileId, *sw); } return PM3_ESOFT; @@ -396,7 +396,7 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si return PM3_ESOFT; } if (verbose) { - PrintAndLogEx(INFO, "Cipurse select default file " _GREEN_("OK")); + PrintAndLogEx(INFO, "Cipurse select default file ( " _GREEN_("ok") " )"); } } else { @@ -409,7 +409,7 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si return PM3_ESOFT; } if (verbose) { - PrintAndLogEx(INFO, "Cipurse select default application " _GREEN_("OK")); + PrintAndLogEx(INFO, "Cipurse select default application ( " _GREEN_("ok") " )"); } } @@ -426,7 +426,7 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si return PM3_ESOFT; } if (verbose) { - PrintAndLogEx(INFO, "Select child file " _CYAN_("0x%04x ") _GREEN_("OK"), childFileId); + PrintAndLogEx(INFO, "Select child file " _CYAN_("0x%04x ") " ( " _GREEN_("ok") " )", childFileId); } } @@ -645,7 +645,7 @@ static int CmdHFCipurseReadFile(const char *Cmd) { } if (verbose) { - PrintAndLogEx(INFO, "Cipurse select application " _CYAN_("%s") " ( " _GREEN_("ok") " )", sprint_hex_inrow(aid, aidLen)); + PrintAndLogEx(INFO, "Cipurse select application " _CYAN_("%s") " ( %s )", sprint_hex_inrow(aid, aidLen), _GREEN_("ok")); PrintAndLogEx(INFO, "File id " _YELLOW_("%x") " offset " _YELLOW_("%zu") " key id " _YELLOW_("%d") " key " _YELLOW_("%s"), fileId, offset, keyId, sprint_hex(key, CIPURSE_AES_KEY_LENGTH)); } @@ -671,7 +671,7 @@ static int CmdHFCipurseReadFile(const char *Cmd) { } if (verbose) - PrintAndLogEx(INFO, "Select file 0x%x ( " _GREEN_("ok") " )", fileId); + PrintAndLogEx(INFO, "Select file 0x%x ( %s )", fileId, _GREEN_("ok")); res = CIPURSEReadBinary(offset, buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { @@ -768,7 +768,7 @@ static int CmdHFCipurseWriteFile(const char *Cmd) { } if (verbose) { - PrintAndLogEx(INFO, "Cipurse select application " _CYAN_("%s") " ( " _GREEN_("ok") " )", sprint_hex_inrow(aid, aidLen)); + PrintAndLogEx(INFO, "Cipurse select application " _CYAN_("%s") " ( %s )", sprint_hex_inrow(aid, aidLen), _GREEN_("ok")); PrintAndLogEx(INFO, "File id " _YELLOW_("%x") " offset " _YELLOW_("%zu") " key id " _YELLOW_("%d") " key " _YELLOW_("%s") , fileId , offset @@ -800,7 +800,7 @@ static int CmdHFCipurseWriteFile(const char *Cmd) { } if (verbose) - PrintAndLogEx(INFO, "Select file 0x%x ( " _GREEN_("ok") " )", fileId); + PrintAndLogEx(INFO, "Select file 0x%x ( %s )", fileId, _GREEN_("ok")); res = CIPURSEUpdateBinary(offset, hdata, hdatalen, buf, sizeof(buf), &len, &sw); if (res != 0 || sw != 0x9000) { @@ -816,7 +816,7 @@ static int CmdHFCipurseWriteFile(const char *Cmd) { sw = 0; res = CIPURSECommitTransaction(&sw); if (res != 0 || sw != 0x9000) - PrintAndLogEx(WARNING, "Commit " _YELLOW_("ERROR") ". Card returns 0x%04x", sw); + PrintAndLogEx(WARNING, "Commit ( " _YELLOW_("fail") " ) Card returns 0x%04x", sw); if (verbose) PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); @@ -1074,7 +1074,7 @@ static int CmdHFCipurseWriteFileAttr(const char *Cmd) { sw = 0; res = CIPURSECommitTransaction(&sw); if (res != 0 || sw != 0x9000) - PrintAndLogEx(WARNING, "Commit " _YELLOW_("ERROR") ". Card returns 0x%04x", sw); + PrintAndLogEx(WARNING, "Commit ( " _YELLOW_("fail") " ) Card returns 0x%04x", sw); if (verbose) PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); @@ -1293,10 +1293,10 @@ static int CmdHFCipurseCreateDGI(const char *Cmd) { sw = 0; res = CIPURSECommitTransaction(&sw); if (res != 0 || sw != 0x9000) - PrintAndLogEx(WARNING, "Commit " _YELLOW_("ERROR") ". Card returns 0x%04x", sw); + PrintAndLogEx(WARNING, "Commit ( " _YELLOW_("fail") " ) Card returns 0x%04x", sw); if (verbose) - PrintAndLogEx(INFO, "Commit " _GREEN_("OK")); + PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); } DropField(); @@ -1437,17 +1437,17 @@ static int CmdHFCipurseDeleteFile(const char *Cmd) { DropField(); return PM3_ESOFT; } - PrintAndLogEx(INFO, "Delete application " _CYAN_("%s ") _GREEN_("OK"), sprint_hex_inrow(aid, aidLen)); + PrintAndLogEx(INFO, "Delete application " _CYAN_("%s") " ( %s )",sprint_hex_inrow(aid, aidLen), _GREEN_("ok")); } if (needCommit) { sw = 0; res = CIPURSECommitTransaction(&sw); if (res != 0 || sw != 0x9000) - PrintAndLogEx(WARNING, "Commit " _YELLOW_("ERROR") ". Card returns 0x%04x", sw); + PrintAndLogEx(WARNING, "Commit ( " _YELLOW_("fail") " ) Card returns 0x%04x", sw); if (verbose) - PrintAndLogEx(INFO, "Commit " _GREEN_("OK")); + PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); } DropField(); @@ -1638,10 +1638,10 @@ static int CmdHFCipurseUpdateKey(const char *Cmd) { sw = 0; res = CIPURSECommitTransaction(&sw); if (res != 0 || sw != 0x9000) - PrintAndLogEx(WARNING, "Commit " _YELLOW_("ERROR") ". Card returns 0x%04x", sw); + PrintAndLogEx(WARNING, "Commit ( " _YELLOW_("fail") " ) Card returns 0x%04x", sw); if (verbose) - PrintAndLogEx(INFO, "Commit " _GREEN_("OK")); + PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); } DropField(); @@ -1786,10 +1786,10 @@ static int CmdHFCipurseUpdateKeyAttr(const char *Cmd) { sw = 0; res = CIPURSECommitTransaction(&sw); if (res != 0 || sw != 0x9000) - PrintAndLogEx(WARNING, "Commit " _YELLOW_("ERROR") ". Card returns 0x%04x", sw); + PrintAndLogEx(WARNING, "Commit ( " _YELLOW_("fail") " ) Card returns 0x%04x", sw); if (verbose) - PrintAndLogEx(INFO, "Commit " _GREEN_("OK")); + PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); } DropField(); diff --git a/client/src/cmdhflegic.c b/client/src/cmdhflegic.c index 9763292b2..da3f34a06 100644 --- a/client/src/cmdhflegic.c +++ b/client/src/cmdhflegic.c @@ -110,11 +110,11 @@ static int CmdLegicInfo(const char *Cmd) { PrintAndLogEx(SUCCESS, " " _CYAN_("CDF: System Area")); PrintAndLogEx(NORMAL, "------------------------------------------------------"); - PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " (%s)", + PrintAndLogEx(SUCCESS, "MCD: " _GREEN_("%02X") " MSN: " _GREEN_("%s") " MCC: " _GREEN_("%02X") " ( %s )", data[0], sprint_hex(data + 1, 3), data[4], - (calc_crc == crc) ? _GREEN_("OK") : _RED_("Fail") + (calc_crc == crc) ? _GREEN_("ok") : _RED_("fail") ); // MCD = Manufacturer ID (should be list meaning something?) @@ -265,12 +265,12 @@ static int CmdLegicInfo(const char *Cmd) { (segment_flag & 0x4) >> 2, (segment_flag & 0x8) >> 3 ); - PrintAndLogEx(SUCCESS, " | WRP: %02u, WRC: %02u, RD: %01u, CRC: 0x%02X (%s)", + PrintAndLogEx(SUCCESS, " | WRP: %02u, WRC: %02u, RD: %01u, CRC: 0x%02X ( %s )", wrp, wrc, ((data[i + 3] ^ crc) & 0x80) >> 7, segCRC, - (segCRC == segCalcCRC) ? _GREEN_("OK") : _RED_("Fail") + (segCRC == segCalcCRC) ? _GREEN_("ok") : _RED_("fail") ); i += 5; diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index b8275f4b2..aebdd7ef5 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -5281,7 +5281,7 @@ static int CmdHF14AMfMAD(const char *Cmd) { PrintAndLogEx(WARNING, "error, read sector 0. card doesn't have MAD or doesn't have MAD on default keys"); got_first = false; } else { - PrintAndLogEx(INFO, "Authentication ( " _GREEN_("OK") " )"); + PrintAndLogEx(INFO, "Authentication ( " _GREEN_("ok") " )"); } // User supplied key @@ -5290,7 +5290,7 @@ static int CmdHF14AMfMAD(const char *Cmd) { if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, userkey, sector0) != PM3_SUCCESS) { PrintAndLogEx(ERR, "error, read sector 0. card doesn't have MAD or the custom key is wrong"); } else { - PrintAndLogEx(INFO, "Authentication ( " _GREEN_("OK") " )"); + PrintAndLogEx(INFO, "Authentication ( " _GREEN_("ok") " )"); got_first = true; } } @@ -5765,7 +5765,7 @@ static int CmdHf14AMfSuperCard(const char *Cmd) { DropField(); return res; } - PrintAndLogEx(SUCCESS, "Super card reset [ " _GREEN_("ok") " ]"); + PrintAndLogEx(SUCCESS, "Super card reset ( " _GREEN_("ok") " )"); return PM3_SUCCESS; } diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index b589fa26c..d7f6b62e2 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -2188,15 +2188,15 @@ static int CmdHF14ADesSetConfiguration(const char *Cmd) { res = DesfireSelectAndAuthenticateAppW(&dctx, securechann, selectway, id, false, verbose); if (res != PM3_SUCCESS) { DropField(); - PrintAndLogEx(FAILED, "Select or authentication %s " _RED_("failed") ". Result [%d] %s", DesfireWayIDStr(selectway, id), res, DesfireAuthErrorToStr(res)); + PrintAndLogEx(FAILED, "Select or authentication ( %s )" _RED_("failed") " Result [%d] %s", DesfireWayIDStr(selectway, id), res, DesfireAuthErrorToStr(res)); return res; } res = DesfireSetConfiguration(&dctx, paramid, param, paramlen); if (res == PM3_SUCCESS) { - PrintAndLogEx(SUCCESS, "Set configuration 0x%02x " _GREEN_("ok") " ", paramid); + PrintAndLogEx(SUCCESS, "Set configuration 0x%02x ( %s )", _GREEN_("ok"), paramid); } else { - PrintAndLogEx(FAILED, "Set configuration 0x%02x " _RED_("failed") " ", paramid); + PrintAndLogEx(FAILED, "Set configuration 0x%02x ( %s )", _RED_("failed"), paramid); } DropField(); @@ -2332,9 +2332,9 @@ static int CmdHF14ADesChangeKey(const char *Cmd) { DesfireSetCommMode(&dctx, DCMEncryptedPlain); res = DesfireChangeKey(&dctx, (DesfireMFSelected(selectway, id)) && (newkeynum == 0) && (dctx.keyNum == 0), newkeynum, newkeytype, newkeyver, newkey, oldkeytype, oldkey, true); if (res == PM3_SUCCESS) { - PrintAndLogEx(SUCCESS, "Change key " _GREEN_("ok") " "); + PrintAndLogEx(SUCCESS, "Change key ( " _GREEN_("ok") " )"); } else { - PrintAndLogEx(FAILED, "Change key " _RED_("failed") " "); + PrintAndLogEx(FAILED, "Change key ( " _RED_("failed") " )"); } DesfireSetCommMode(&dctx, DCMEncrypted); @@ -4304,7 +4304,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { res = DesfireSelectAndAuthenticateAppW(&dctx, securechann, selectway, id, noauth, verbose); if (res != PM3_SUCCESS) { DropField(); - PrintAndLogEx(FAILED, "Select or authentication %s " _RED_("failed") ". Result [%d] %s", DesfireWayIDStr(selectway, id), res, DesfireAuthErrorToStr(res)); + PrintAndLogEx(FAILED, "Select or authentication ( %s )" _RED_("failed") " Result [%d] %s", DesfireWayIDStr(selectway, id), res, DesfireAuthErrorToStr(res)); return res; } @@ -4314,12 +4314,12 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { if (op != 0xff) { res = DesfireValueFileOperations(&dctx, fileid, op, &value); if (res != PM3_SUCCESS) { - PrintAndLogEx(ERR, "Desfire ValueFileOperations (0x%02x) command " _RED_("error") ". Result: %d", op, res); + PrintAndLogEx(ERR, "Desfire ValueFileOperations (0x%02x) command ( " _RED_("error") " ) Result: %d", op, res); DropField(); return PM3_ESOFT; } if (verbose) - PrintAndLogEx(INFO, "Operation %s " _GREEN_("OK"), CLIGetOptionListStr(DesfireValueFileOperOpts, op)); + PrintAndLogEx(INFO, "Operation ( %s )" _GREEN_("ok"), CLIGetOptionListStr(DesfireValueFileOperOpts, op)); if (op == MFDES_GET_VALUE) { PrintAndLogEx(SUCCESS, "Value: " _GREEN_("%d (0x%08x)"), value, value); @@ -4327,19 +4327,19 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { DesfireSetCommMode(&dctx, DCMMACed); res = DesfireCommitTransaction(&dctx, false, 0); if (res != PM3_SUCCESS) { - PrintAndLogEx(ERR, "Desfire CommitTransaction command " _RED_("error") ". Result: %d", res); + PrintAndLogEx(ERR, "Desfire CommitTransaction command ( " _RED_("error") ") Result: %d", res); DropField(); return PM3_ESOFT; } if (verbose) - PrintAndLogEx(INFO, "Commit " _GREEN_("OK")); + PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); PrintAndLogEx(SUCCESS, "Value changed " _GREEN_("successfully")); } } else { res = DesfireValueFileOperations(&dctx, fileid, MFDES_GET_VALUE, &value); if (res != PM3_SUCCESS) { - PrintAndLogEx(ERR, "Desfire GetValue command " _RED_("error") ". Result: %d", res); + PrintAndLogEx(ERR, "Desfire GetValue command ( " _RED_("error") ") Result: %d", res); DropField(); return PM3_ESOFT; } @@ -4351,7 +4351,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { res = DesfireGetFileSettings(&dctx, fileid, buf, &buflen); if (res != PM3_SUCCESS) { - PrintAndLogEx(ERR, "Desfire GetFileSettings command " _RED_("error") ". Result: %d", res); + PrintAndLogEx(ERR, "Desfire GetFileSettings command ( " _RED_("error") " ) Result: %d", res); DropField(); return PM3_ESOFT; } @@ -4375,7 +4375,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { if (delta > 0) { res = DesfireValueFileOperations(&dctx, fileid, MFDES_DEBIT, &delta); if (res != PM3_SUCCESS) { - PrintAndLogEx(ERR, "Desfire Debit operation " _RED_("error") ". Result: %d", res); + PrintAndLogEx(ERR, "Desfire Debit operation ( " _RED_("error") " ) Result: %d", res); DropField(); return PM3_ESOFT; } @@ -4386,7 +4386,7 @@ static int CmdHF14ADesValueOperations(const char *Cmd) { DesfireSetCommMode(&dctx, DCMMACed); res = DesfireCommitTransaction(&dctx, false, 0); if (res != PM3_SUCCESS) { - PrintAndLogEx(ERR, "Desfire CommitTransaction command " _RED_("error") ". Result: %d", res); + PrintAndLogEx(ERR, "Desfire CommitTransaction command ( " _RED_("error") " ) Result: %d", res); DropField(); return PM3_ESOFT; } @@ -5200,7 +5200,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) { readeridpushed = true; if (verbose) - PrintAndLogEx(INFO, "CommitReaderID " _GREEN_("OK")); + PrintAndLogEx(INFO, "CommitReaderID ( " _GREEN_("ok") " )"); } else PrintAndLogEx(WARNING, "Desfire CommitReaderID command " _RED_("error") ". Result: %d", res); } @@ -5287,7 +5287,7 @@ static int CmdHF14ADesWriteData(const char *Cmd) { if (verbose) { if (readeridpushed) PrintAndLogEx(INFO, "TMC and TMV[%zu]: %s", resplen, sprint_hex(resp, resplen)); - PrintAndLogEx(INFO, "Commit " _GREEN_("OK")); + PrintAndLogEx(INFO, "Commit ( " _GREEN_("ok") " )"); } if (resplen == 4 + 8) { diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index d67840ac9..2821ba42d 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -3815,7 +3815,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) { , poststr , pre_tear , post_tear - , post_tear_check ? _GREEN_("OK") : _RED_("DETECTED") + , post_tear_check ? _GREEN_("ok") : _RED_("DETECTED") ); break; } @@ -3826,7 +3826,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) { , poststr , pre_tear , post_tear - , post_tear_check ? _GREEN_("OK") : _RED_("DETECTED") + , post_tear_check ? _GREEN_("ok") : _RED_("DETECTED") ); @@ -3860,7 +3860,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) { , poststr , pre_tear , post_tear - , post_tear_check ? _GREEN_("OK") : _RED_("DETECTED") + , post_tear_check ? _GREEN_("ok") : _RED_("DETECTED") ); if ( post_tear_check && b == initial_value) { @@ -3908,7 +3908,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) { , poststr , pre_tear , post_tear - , post_tear_check ? _GREEN_("OK") : _RED_("DETECTED") + , post_tear_check ? _GREEN_("ok") : _RED_("DETECTED") ); if ( post_tear_check ) { diff --git a/client/src/cmdhfthinfilm.c b/client/src/cmdhfthinfilm.c index 89520d8e3..92c82f3f3 100644 --- a/client/src/cmdhfthinfilm.c +++ b/client/src/cmdhfthinfilm.c @@ -47,11 +47,11 @@ static int print_barcode(uint8_t *barcode, const size_t barcode_len, bool verbos compute_crc(CRC_14443_A, barcode, barcode_len - 2, &b1, &b2); bool isok = (barcode[barcode_len - 1] == b1 && barcode[barcode_len - 2] == b2); - PrintAndLogEx(SUCCESS, " Checksum : "_YELLOW_("%02X %02X")" - %s", b2, b1, (isok) ? _GREEN_("OK") : _RED_("fail")); + PrintAndLogEx(SUCCESS, " Checksum : "_YELLOW_("%02X %02X")" ( %s )", b2, b1, (isok) ? _GREEN_("ok") : _RED_("fail")); } else { PrintAndLogEx(SUCCESS, " Checksum : "_YELLOW_("too few data for checksum")" - " _RED_("fail")); } - PrintAndLogEx(SUCCESS, " Data len (bits) : "_YELLOW_("%zu")" - %s", barcode_len * 8, (barcode_len == 16 || barcode_len == 32) ? _GREEN_("OK") : _YELLOW_("warning")); + PrintAndLogEx(SUCCESS, " Data len (bits) : "_YELLOW_("%zu")" ( %s )", barcode_len * 8, (barcode_len == 16 || barcode_len == 32) ? _GREEN_("ok") : _YELLOW_("warning")); PrintAndLogEx(SUCCESS, " Raw data : "_YELLOW_("%s"), sprint_hex(barcode, barcode_len)); if (barcode_len < 4) // too few to go to next decoding stages return PM3_ESOFT; diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index b228a5c91..c6b763c08 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -804,7 +804,7 @@ static int CmdPing(const char *Cmd) { if (WaitForResponseTimeout(CMD_PING, &resp, 1000)) { if (len) { bool error = (memcmp(data, resp.data.asBytes, len) != 0); - PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received") " and content is %s", error ? _RED_("NOT ok") : _GREEN_("OK")); + PrintAndLogEx((error) ? ERR : SUCCESS, "Ping response " _GREEN_("received") " and content () %s )", error ? _RED_("fail") : _GREEN_("ok")); } else { PrintAndLogEx(SUCCESS, "Ping response " _GREEN_("received")); } From 8141752d695fc44316a15fe7ff11df538dea5ab9 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 19:19:07 +0100 Subject: [PATCH 18/21] texts --- client/src/cmdhfcipurse.c | 77 +++++++++++++++---------------- client/src/mifare/desfirecrypto.c | 12 +++-- client/src/mifare/desfiretest.c | 50 ++++++++++---------- 3 files changed, 70 insertions(+), 69 deletions(-) diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index 3c2791cb9..9db4d1cc4 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -571,10 +571,7 @@ static int CmdHFCipurseAuth(const char *Cmd) { bool bres = CIPURSEChannelAuthenticate(keyId, key, verbose); if (verbose == false) { - if (bres) - PrintAndLogEx(INFO, "Authentication ( " _GREEN_("ok") " )"); - else - PrintAndLogEx(ERR, "Authentication ( " _RED_("fail") " )"); + PrintAndLogEx(INFO, "Authentication ( %s ) ", (bres) ? _GREEN_("ok") : _RED_("fail")); } DropField(); @@ -709,8 +706,8 @@ static int CmdHFCipurseWriteFile(const char *Cmd) { arg_str0(NULL, "fid", "", "File ID"), arg_int0("o", "offset", "", "Offset for reading data from file"), arg_lit0(NULL, "noauth", "Read file without authentication"), - arg_str0(NULL, "sreq", "", "communication reader-PICC security level (def: mac)"), - arg_str0(NULL, "sresp", "", "communication PICC-reader security level (def: mac)"), + arg_str0(NULL, "sreq", "", "Communication reader-PICC security level (def: mac)"), + arg_str0(NULL, "sresp", "", "Communication PICC-reader security level (def: mac)"), arg_str0("d", "data", "", "Data to write to new file"), arg_lit0(NULL, "commit", "Commit after write"), arg_param_end @@ -775,7 +772,7 @@ static int CmdHFCipurseWriteFile(const char *Cmd) { , keyId , sprint_hex(key, CIPURSE_AES_KEY_LENGTH) ); - PrintAndLogEx(INFO, "data[%d]: %s", hdatalen, sprint_hex(hdata, hdatalen)); + PrintAndLogEx(INFO, "Data [%d]: %s", hdatalen, sprint_hex(hdata, hdatalen)); } if (noAuth == false) { @@ -1014,7 +1011,7 @@ static int CmdHFCipurseWriteFileAttr(const char *Cmd) { SetAPDULogging(APDULogging); if (verbose) { - PrintAndLogEx(INFO, "attribtes data[%d]: %s", hdatalen, sprint_hex(hdata, hdatalen)); + PrintAndLogEx(INFO, "Attribtes data[%d]: %s", hdatalen, sprint_hex(hdata, hdatalen)); CIPURSEPrintFileUpdateAttr(hdata, hdatalen); } @@ -1185,7 +1182,7 @@ static int CmdHFCipurseCreateDGI(const char *Cmd) { arg_str0("k", "key", "", "Auth key"), arg_str0(NULL, "aid", "", "Application ID (AID) ( 1..16 bytes )"), - arg_str0(NULL, "fid", "", "file ID (FID) ( 2 bytes )"), + arg_str0(NULL, "fid", "", "File ID (FID) ( 2 bytes )"), arg_lit0(NULL, "mfd", "Select masterfile by empty id"), arg_str0("d", "data", "", "Data with DGI for create"), @@ -1260,7 +1257,7 @@ static int CmdHFCipurseCreateDGI(const char *Cmd) { if (verbose) { if (!noauth) - PrintAndLogEx(INFO, "key id " _YELLOW_("%d") " key " _YELLOW_("%s") + PrintAndLogEx(INFO, "Key id " _YELLOW_("%d") " key " _YELLOW_("%s") , keyId , sprint_hex(key, CIPURSE_AES_KEY_LENGTH) ); @@ -1367,7 +1364,7 @@ static int CmdHFCipurseDeleteFile(const char *Cmd) { PrintAndLogEx(INFO, "Child file id " _CYAN_("%x"), childFileId); if (!noauth) - PrintAndLogEx(INFO, "key id " _YELLOW_("%d") " key " _YELLOW_("%s") + PrintAndLogEx(INFO, "Key id " _YELLOW_("%d") " key " _YELLOW_("%s") , keyId , sprint_hex(key, CIPURSE_AES_KEY_LENGTH) ); @@ -1463,26 +1460,26 @@ static int CmdHFCipurseUpdateKey(const char *Cmd) { void *argtable[] = { arg_param_begin, - arg_lit0("a", "apdu", "show APDU requests and responses"), - arg_lit0("v", "verbose", "show technical data"), - arg_int0("n", NULL, "", "key ID for authentication"), + arg_lit0("a", "apdu", "Show APDU requests and responses"), + arg_lit0("v", "verbose", "Show technical data"), + arg_int0("n", NULL, "", "Key ID for authentication"), arg_str0("k", "key", "", "Auth key"), - arg_str0(NULL, "aid", "", "application ID (AID)"), - arg_str0(NULL, "fid", "", "file ID (FID)"), - arg_lit0(NULL, "mfd", "select masterfile by empty id"), + arg_str0(NULL, "aid", "", "Application ID (AID)"), + arg_str0(NULL, "fid", "", "File ID (FID)"), + arg_lit0(NULL, "mfd", "Select masterfile by empty id"), - arg_int0(NULL, "newkeyn", "", "target key ID"), - arg_str0(NULL, "newkey", "", "new key"), - arg_str0(NULL, "newkeya", "", "new key additional info. 0x00 by default"), + arg_int0(NULL, "newkeyn", "", "Target key ID"), + arg_str0(NULL, "newkey", "", "New key"), + arg_str0(NULL, "newkeya", "", "New key additional info (def: 0x00)"), - arg_int0(NULL, "enckeyn", "", "encrypt key ID (must be equal to the key on the card)"), - arg_str0(NULL, "enckey", "", "encrypt key (must be equal to the key on the card)"), + arg_int0(NULL, "enckeyn", "", "Encrypt key ID (must be equal to the key on the card)"), + arg_str0(NULL, "enckey", "", "Encrypt key (must be equal to the key on the card)"), - arg_str0(NULL, "sreq", "", "communication reader-PICC security level"), - arg_str0(NULL, "sresp", "", "communication PICC-reader security level"), - arg_lit0(NULL, "no-auth", "execute without authentication"), - arg_lit0(NULL, "commit", "commit "), + arg_str0(NULL, "sreq", "", "Communication reader-PICC security level"), + arg_str0(NULL, "sresp", "", "Communication PICC-reader security level"), + arg_lit0(NULL, "no-auth", "Execute without authentication"), + arg_lit0(NULL, "commit", "Commit "), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -1605,7 +1602,7 @@ static int CmdHFCipurseUpdateKey(const char *Cmd) { if (verbose) { if (!noauth) - PrintAndLogEx(INFO, "key id " _YELLOW_("%d") " key " _YELLOW_("%s") + PrintAndLogEx(INFO, "Key id " _YELLOW_("%d") " key " _YELLOW_("%s") , keyId , sprint_hex(key, CIPURSE_AES_KEY_LENGTH) ); @@ -1661,21 +1658,21 @@ static int CmdHFCipurseUpdateKeyAttr(const char *Cmd) { void *argtable[] = { arg_param_begin, - arg_lit0("a", "apdu", "show APDU requests and responses"), - arg_lit0("v", "verbose", "show technical data"), - arg_int0("n", NULL, "", "key ID for authentication"), + arg_lit0("a", "apdu", "Show APDU requests and responses"), + arg_lit0("v", "verbose", "Show technical data"), + arg_int0("n", NULL, "", "Key ID for authentication"), arg_str0("k", "key", "", "Auth key"), - arg_str0(NULL, "aid", "", "application ID (AID)"), - arg_str0(NULL, "fid", "", "file ID (FID)"), - arg_lit0(NULL, "mfd", "select masterfile by empty id"), + arg_str0(NULL, "aid", "", "Application ID (AID)"), + arg_str0(NULL, "fid", "", "File ID (FID)"), + arg_lit0(NULL, "mfd", "Select masterfile by empty id"), - arg_int0(NULL, "trgkeyn", "", "target key ID"), - arg_str0(NULL, "attr", "", "key attributes 1 byte"), - arg_str0(NULL, "sreq", "", "communication reader-PICC security level"), - arg_str0(NULL, "sresp", "", "communication PICC-reader security level"), - arg_lit0(NULL, "no-auth", "execute without authentication"), - arg_lit0(NULL, "commit", "commit "), + arg_int0(NULL, "trgkeyn", "", "Target key ID"), + arg_str0(NULL, "attr", "", "Key attributes 1 byte"), + arg_str0(NULL, "sreq", "", "Communication reader-PICC security level"), + arg_str0(NULL, "sresp", "", "Communication PICC-reader security level"), + arg_lit0(NULL, "no-auth", "Execute without authentication"), + arg_lit0(NULL, "commit", "Commit "), arg_param_end }; CLIExecWithReturn(ctx, Cmd, argtable, false); @@ -1753,7 +1750,7 @@ static int CmdHFCipurseUpdateKeyAttr(const char *Cmd) { if (verbose) { if (!noauth) - PrintAndLogEx(INFO, "key id " _YELLOW_("%d") " key " _YELLOW_("%s") + PrintAndLogEx(INFO, "Key id " _YELLOW_("%d") " key " _YELLOW_("%s") , keyId , sprint_hex(key, CIPURSE_AES_KEY_LENGTH) ); diff --git a/client/src/mifare/desfirecrypto.c b/client/src/mifare/desfirecrypto.c index 96a7caa79..48126ae50 100644 --- a/client/src/mifare/desfirecrypto.c +++ b/client/src/mifare/desfirecrypto.c @@ -133,14 +133,18 @@ size_t DesfireGetMACLength(DesfireContext_t *ctx) { size_t DesfireSearchCRCPos(uint8_t *data, size_t datalen, uint8_t respcode, uint8_t crclen) { size_t crcpos = datalen - 1; - while (crcpos > 0) - if (data[crcpos] == 0) + + while (crcpos > 0) { + if (data[crcpos] == 0) { crcpos--; - else + } else { break; + } + } + crcpos++; // crc may be 0x00000000 or 0x0000 if (crcpos < crclen) { - PrintAndLogEx(WARNING, "No space for crc. pos: %zu", crcpos); + PrintAndLogEx(WARNING, "No space for crc. pos %zu", crcpos); return 0; } diff --git a/client/src/mifare/desfiretest.c b/client/src/mifare/desfiretest.c index b37fd7fd8..75a9ef781 100644 --- a/client/src/mifare/desfiretest.c +++ b/client/src/mifare/desfiretest.c @@ -54,9 +54,9 @@ static bool TestCRC16(void) { res = res && (len == 0); if (res) - PrintAndLogEx(INFO, "crc16............. " _GREEN_("passed")); + PrintAndLogEx(INFO, "CRC16............. " _GREEN_("ok")); else - PrintAndLogEx(ERR, "crc16............. " _RED_("fail")); + PrintAndLogEx(ERR, "CRC16............. " _RED_("fail")); return res; } @@ -81,9 +81,9 @@ static bool TestCRC32(void) { res = res && (len == 0); if (res) - PrintAndLogEx(INFO, "crc32............. " _GREEN_("passed")); + PrintAndLogEx(INFO, "CRC32............. " _GREEN_("ok")); else - PrintAndLogEx(ERR, "crc32............. " _RED_("fail")); + PrintAndLogEx(ERR, "CRC32............. " _RED_("fail")); return res; } @@ -132,7 +132,7 @@ static bool TestCMACSubkeys(void) { res = res && (memcmp(sk2, sk2_3tdea, sizeof(sk2_3tdea)) == 0); if (res) - PrintAndLogEx(INFO, "CMAC subkeys...... " _GREEN_("passed")); + PrintAndLogEx(INFO, "CMAC subkeys...... " _GREEN_("ok")); else PrintAndLogEx(ERR, "CMAC subkeys...... " _RED_("fail")); @@ -156,7 +156,7 @@ static bool TestAn10922KDFAES(void) { res = res && (memcmp(dctx.key, dkey, sizeof(dkey)) == 0); if (res) - PrintAndLogEx(INFO, "An10922 AES....... " _GREEN_("passed")); + PrintAndLogEx(INFO, "An10922 AES....... " _GREEN_("ok")); else PrintAndLogEx(ERR, "An10922 AES....... " _RED_("fail")); @@ -178,7 +178,7 @@ static bool TestAn10922KDF2TDEA(void) { res = res && (memcmp(dctx.key, dkey, sizeof(dkey)) == 0); if (res) - PrintAndLogEx(INFO, "An10922 2TDEA..... " _GREEN_("passed")); + PrintAndLogEx(INFO, "An10922 2TDEA..... " _GREEN_("ok")); else PrintAndLogEx(ERR, "An10922 2TDEA..... " _RED_("fail")); @@ -202,7 +202,7 @@ static bool TestAn10922KDF3TDEA(void) { res = res && (memcmp(dctx.key, dkey, sizeof(dkey)) == 0); if (res) - PrintAndLogEx(INFO, "An10922 3TDEA..... " _GREEN_("passed")); + PrintAndLogEx(INFO, "An10922 3TDEA..... " _GREEN_("ok")); else PrintAndLogEx(ERR, "An10922 3TDEA..... " _RED_("fail")); @@ -246,7 +246,7 @@ static bool TestCMAC3TDEA(void) { res = res && (memcmp(cmac, cmac4, sizeof(cmac1)) == 0); if (res) - PrintAndLogEx(INFO, "CMAC 3TDEA........ " _GREEN_("passed")); + PrintAndLogEx(INFO, "CMAC 3TDEA........ " _GREEN_("ok")); else PrintAndLogEx(ERR, "CMAC 3TDEA........ " _RED_("fail")); @@ -290,7 +290,7 @@ static bool TestCMAC2TDEA(void) { res = res && (memcmp(cmac, cmac4, sizeof(cmac1)) == 0); if (res) - PrintAndLogEx(INFO, "CMAC 2TDEA........ " _GREEN_("passed")); + PrintAndLogEx(INFO, "CMAC 2TDEA........ " _GREEN_("ok")); else PrintAndLogEx(ERR, "CMAC 2TDEA........ " _RED_("fail")); @@ -330,7 +330,7 @@ static bool TestCMACDES(void) { res = res && (memcmp(cmac, cmac4, sizeof(cmac1)) == 0); if (res) - PrintAndLogEx(INFO, "CMAC DES.......... " _GREEN_("passed")); + PrintAndLogEx(INFO, "CMAC DES.......... " _GREEN_("ok")); else PrintAndLogEx(ERR, "CMAC DES.......... " _RED_("fail")); @@ -357,7 +357,7 @@ static bool TestEV2SessionKeys(void) { res = res && (memcmp(sessionkey, sessionkeymac, sizeof(sessionkeymac)) == 0); if (res) - PrintAndLogEx(INFO, "EV2 session keys.. " _GREEN_("passed")); + PrintAndLogEx(INFO, "EV2 session keys.. " _GREEN_("ok")); else PrintAndLogEx(ERR, "EV2 session keys.. " _RED_("fail")); @@ -393,7 +393,7 @@ static bool TestEV2IVEncode(void) { res = res && (memcmp(iv, ivres2, sizeof(ivres2)) == 0); if (res) - PrintAndLogEx(INFO, "EV2 IV calc....... " _GREEN_("passed")); + PrintAndLogEx(INFO, "EV2 IV calc....... " _GREEN_("ok")); else PrintAndLogEx(ERR, "EV2 IV calc....... " _RED_("fail")); @@ -453,7 +453,7 @@ static bool TestEV2MAC(void) { res = res && (memcmp(mac, macres4, sizeof(macres4)) == 0); if (res) - PrintAndLogEx(INFO, "EV2 MAC calc...... " _GREEN_("passed")); + PrintAndLogEx(INFO, "EV2 MAC calc...... " _GREEN_("ok")); else PrintAndLogEx(ERR, "EV2 MAC calc...... " _RED_("fail")); @@ -477,7 +477,7 @@ static bool TestTransSessionKeys(void) { res = res && (memcmp(sessionkey, keyenc, sizeof(keyenc)) == 0); if (res) - PrintAndLogEx(INFO, "Trans session key. " _GREEN_("passed")); + PrintAndLogEx(INFO, "Trans session key. " _GREEN_("ok")); else PrintAndLogEx(ERR, "Trans session key. " _RED_("fail")); @@ -506,7 +506,7 @@ static bool TestLRPPlaintexts(void) { res = res && (memcmp(ctx.plaintexts[15], pt15, sizeof(pt15)) == 0); if (res) - PrintAndLogEx(INFO, "LRP plaintexts.... " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP plaintexts.... " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP plaintexts.... " _RED_("fail")); @@ -532,7 +532,7 @@ static bool TestLRPUpdatedKeys(void) { res = res && (memcmp(ctx.updatedKeys[2], key2, sizeof(key2)) == 0); if (res) - PrintAndLogEx(INFO, "LRP updated keys.. " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP updated keys.. " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP updated keys.. " _RED_("fail")); @@ -588,7 +588,7 @@ static bool TestLRPEval(void) { res = res && (memcmp(y, y5, sizeof(y5)) == 0); if (res) - PrintAndLogEx(INFO, "LRP eval.......... " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP eval.......... " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP eval.......... " _RED_("fail")); @@ -619,7 +619,7 @@ static bool TestLRPIncCounter(void) { res = res && (memcmp(ctr4, ctrr4, sizeof(ctrr4)) == 0); if (res) - PrintAndLogEx(INFO, "LRP inc counter... " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP inc counter... " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP inc counter... " _RED_("fail")); @@ -687,7 +687,7 @@ static bool TestLRPEncode(void) { res = res && (memcmp(resp, res5, sizeof(res5)) == 0); if (res) - PrintAndLogEx(INFO, "LRP encode........ " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP encode........ " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP encode........ " _RED_("fail")); @@ -754,7 +754,7 @@ static bool TestLRPDecode(void) { res = res && (memcmp(resp, res5, sizeof(res5)) == 0); if (res) - PrintAndLogEx(INFO, "LRP decode........ " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP decode........ " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP decode........ " _RED_("fail")); @@ -794,7 +794,7 @@ static bool TestLRPSubkeys(void) { res = res && (memcmp(sk2, sk2r3, sizeof(sk2r3)) == 0); if (res) - PrintAndLogEx(INFO, "LRP subkeys....... " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP subkeys....... " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP subkeys....... " _RED_("fail")); @@ -856,7 +856,7 @@ static bool TestLRPCMAC(void) { res = res && (memcmp(cmac, cmacres6, sizeof(cmacres6)) == 0); if (res) - PrintAndLogEx(INFO, "LRP CMAC.......... " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP CMAC.......... " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP CMAC.......... " _RED_("fail")); @@ -878,7 +878,7 @@ static bool TestLRPSessionKeys(void) { res = res && (memcmp(sessionkey, sessionkeyres, sizeof(sessionkeyres)) == 0); if (res) - PrintAndLogEx(INFO, "LRP session keys.. " _GREEN_("passed")); + PrintAndLogEx(INFO, "LRP session keys.. " _GREEN_("ok")); else PrintAndLogEx(ERR, "LRP session keys.. " _RED_("fail")); @@ -888,7 +888,7 @@ static bool TestLRPSessionKeys(void) { bool DesfireTest(bool verbose) { bool res = true; - PrintAndLogEx(INFO, "------ " _CYAN_("Desfire Tests") " ------"); + PrintAndLogEx(INFO, "------ " _CYAN_("MIFARE DESFire tests") " ------"); res = res && TestCRC16(); res = res && TestCRC32(); From 3b5a1e8de5381ca76cc775ac9788a561bd03ae37 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 19:31:47 +0100 Subject: [PATCH 19/21] added some helptexts --- armsrc/iso14443b.c | 4 ++-- client/src/cipurse/cipursetest.c | 2 +- client/src/cmdhfcipurse.c | 13 ++++++++++++- client/src/cmdhfmfdes.c | 13 ++++++++++++- client/src/cmdlffdxb.c | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index f6304fcb5..655ed367e 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -864,7 +864,7 @@ void SimulateIso14443bTag(uint8_t *pupi) { } } else { if (g_dbglevel >= DBG_DEBUG) { - DbpString("CRC passed"); + DbpString("CRC ok"); } } cardSTATE = SIM_IDLE; @@ -1064,7 +1064,7 @@ void Simulate_iso14443b_srx_tag(uint8_t *uid) { } } else { if (g_dbglevel >= DBG_DEBUG) { - DbpString("CRC passed"); + DbpString("CRC ok"); } } cardSTATE = SIM_IDLE; diff --git a/client/src/cipurse/cipursetest.c b/client/src/cipurse/cipursetest.c index 6e1ba9609..5632145f7 100644 --- a/client/src/cipurse/cipursetest.c +++ b/client/src/cipurse/cipursetest.c @@ -362,7 +362,7 @@ static bool TestAPDU(void) { bool CIPURSETest(bool verbose) { bool res = true; - PrintAndLogEx(INFO, "------ " _CYAN_("CIPURSE Tests") " ------"); + PrintAndLogEx(INFO, "------ " _CYAN_("CIPURSE tests") " ------"); res = res && TestKVV(); res = res && TestISO9797M2(); diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index 9db4d1cc4..ba3f2d956 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -1803,6 +1803,17 @@ bool CheckCardCipurse(void) { } static int CmdHFCipurseTest(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf cipurse test", + "Regression tests", + "hf cipurse test"); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); CIPURSETest(true); return PM3_SUCCESS; } @@ -1885,7 +1896,7 @@ static command_t CommandTable[] = { {"updkey", CmdHFCipurseUpdateKey, IfPm3Iso14443a, "Update key"}, {"updakey", CmdHFCipurseUpdateKeyAttr, IfPm3Iso14443a, "Update key attributes"}, {"default", CmdHFCipurseDefault, IfPm3Iso14443a, "Set default key and file id for all the other commands"}, - {"test", CmdHFCipurseTest, AlwaysAvailable, "Tests"}, + {"test", CmdHFCipurseTest, AlwaysAvailable, "Regression tests"}, {NULL, NULL, 0, NULL} }; diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index d7f6b62e2..5b9b851c2 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -5561,6 +5561,17 @@ static int CmdHF14ADesDump(const char *Cmd) { } static int CmdHF14ADesTest(const char *Cmd) { + CLIParserContext *ctx; + CLIParserInit(&ctx, "hf mfdes test", + "Regression crypto tests", + "hf mfdes test"); + + void *argtable[] = { + arg_param_begin, + arg_param_end + }; + CLIExecWithReturn(ctx, Cmd, argtable, true); + CLIParserFree(ctx); DesfireTest(true); return PM3_SUCCESS; } @@ -5609,7 +5620,7 @@ static command_t CommandTable[] = { {"value", CmdHF14ADesValueOperations, IfPm3Iso14443a, "Operations with value file (get/credit/limited credit/debit/clear)"}, {"clearrecfile", CmdHF14ADesClearRecordFile, IfPm3Iso14443a, "Clear record File"}, {"-----------", CmdHelp, IfPm3Iso14443a, "----------------------- " _CYAN_("System") " -----------------------"}, - {"test", CmdHF14ADesTest, AlwaysAvailable, "Test crypto"}, + {"test", CmdHF14ADesTest, AlwaysAvailable, "Regression crypto tests"}, {NULL, NULL, NULL, NULL} }; diff --git a/client/src/cmdlffdxb.c b/client/src/cmdlffdxb.c index 1d406ea20..f7726c54f 100644 --- a/client/src/cmdlffdxb.c +++ b/client/src/cmdlffdxb.c @@ -208,7 +208,7 @@ static int CmdFDXBdemodBI(const char *Cmd) { PrintAndLogEx(SUCCESS, "Reserved/RFU: %u", reservedCode); PrintAndLogEx(SUCCESS, "Animal Tag: %s", animalBit ? _YELLOW_("True") : "False"); PrintAndLogEx(SUCCESS, "Has extended data: %s [0x%X]", dataBlockBit ? _YELLOW_("True") : "False", extended); - PrintAndLogEx(SUCCESS, "CRC: 0x%04X - [%04X] - %s", crc_16, calcCrc, (calcCrc == crc_16) ? _GREEN_("Passed") : _RED_("Fail") ); + PrintAndLogEx(SUCCESS, "CRC: 0x%04X - [%04X] - %s", crc_16, calcCrc, (calcCrc == crc_16) ? _GREEN_("ok") : _RED_("fail") ); if (g_debugMode) { PrintAndLogEx(DEBUG, "Start marker %d; Size %d", preambleIndex, size); From dfcb83a15407617d73ba191f171bdbe0ef8c78d7 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 19:36:26 +0100 Subject: [PATCH 20/21] make style --- client/src/cmdhf14a.c | 4 +-- client/src/cmdhfcipurse.c | 4 +-- client/src/nfc/ndef.c | 66 +++++++++++++++++++-------------------- doc/commands.json | 32 ++++++++++++------- doc/commands.md | 4 +-- 5 files changed, 59 insertions(+), 51 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 81de6b35e..0f7a2ccc3 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -1638,7 +1638,7 @@ static void getTagLabel(uint8_t uid0, uint8_t uid1) { } } -static void get_compact_tlv(uint8_t* d, uint8_t n) { +static void get_compact_tlv(uint8_t *d, uint8_t n) { d++; n--; @@ -1646,7 +1646,7 @@ static void get_compact_tlv(uint8_t* d, uint8_t n) { uint8_t tag = NIBBLE_HIGH(d[0]); uint8_t len = NIBBLE_LOW(d[0]); - switch(tag) { + switch (tag) { case 1: PrintAndLogEx(INFO, " %1x%1x " _YELLOW_("%s") " Country code in (ISO 3166-1)", tag, len, sprint_hex_inrow(d + 1, len)); // iso3166 script in cmdlffdb.c is buggy, Åland, Australia not showing. getline issues diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index ba3f2d956..2ad4499bb 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -378,7 +378,7 @@ static int SelectCommandEx(bool selectDefaultFile, bool useAID, uint8_t *aid, si if (res != 0 || *sw != 0x9000) { if (verbose) { PrintAndLogEx(ERR, "Cipurse select file 0x%04x ( %s )", _RED_("fail")); - PrintAndLogEx(ERR, "Card returns 0x%04x", fileId, *sw); + PrintAndLogEx(ERR, "Card returns 0x%04x", fileId, *sw); } return PM3_ESOFT; } @@ -1434,7 +1434,7 @@ static int CmdHFCipurseDeleteFile(const char *Cmd) { DropField(); return PM3_ESOFT; } - PrintAndLogEx(INFO, "Delete application " _CYAN_("%s") " ( %s )",sprint_hex_inrow(aid, aidLen), _GREEN_("ok")); + PrintAndLogEx(INFO, "Delete application " _CYAN_("%s") " ( %s )", sprint_hex_inrow(aid, aidLen), _GREEN_("ok")); } if (needCommit) { diff --git a/client/src/nfc/ndef.c b/client/src/nfc/ndef.c index 32ffe0c79..c9a74ad75 100644 --- a/client/src/nfc/ndef.c +++ b/client/src/nfc/ndef.c @@ -515,7 +515,7 @@ static int ndefDecodePayloadSmartPoster(uint8_t *ndef, size_t ndeflen, bool prin typedef struct ndef_wifi_type_s { - const char* description; + const char *description; uint8_t bytes[2]; } ndef_wifi_type_t; @@ -527,9 +527,9 @@ static const ndef_wifi_type_t wifi_crypt_types[] = { {"AES/TKIP", {0x00, 0x0C}} }; -static const char* ndef_wifi_crypt_lookup(uint8_t *d) { +static const char *ndef_wifi_crypt_lookup(uint8_t *d) { for (int i = 0; i < ARRAYLEN(wifi_crypt_types); ++i) { - if ( memcmp(d, wifi_crypt_types[i].bytes, 2) == 0) { + if (memcmp(d, wifi_crypt_types[i].bytes, 2) == 0) { return wifi_crypt_types[i].description; } } @@ -546,9 +546,9 @@ static const ndef_wifi_type_t wifi_auth_types[] = { {"WPA/WPA2 PERSONAL", {0x00, 0x22}} }; -static const char* ndef_wifi_auth_lookup(uint8_t *d) { +static const char *ndef_wifi_auth_lookup(uint8_t *d) { for (int i = 0; i < ARRAYLEN(wifi_auth_types); ++i) { - if ( memcmp(d, wifi_auth_types[i].bytes, 2) == 0) { + if (memcmp(d, wifi_auth_types[i].bytes, 2) == 0) { return wifi_auth_types[i].description; } } @@ -568,16 +568,16 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { size_t pos = 0; while (n) { - if ( ndef->Payload[pos] != 0x10 ) { + if (ndef->Payload[pos] != 0x10) { n -= 1; pos -= 1; continue; } - // VERSION + // VERSION if (memcmp(&ndef->Payload[pos], "\x10\x4A", 2) == 0) { uint8_t len = 1; - PrintAndLogEx(INFO, "Version......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + PrintAndLogEx(INFO, "Version......... %s", sprint_hex(&ndef->Payload[pos + 2], len)); n -= 2; n -= len; pos += 2; @@ -588,21 +588,21 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { if (memcmp(&ndef->Payload[pos], "\x10\x0E", 2) == 0) { // 10 0E 00 39 uint8_t len = 2; - PrintAndLogEx(INFO, "Credential...... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + PrintAndLogEx(INFO, "Credential...... %s", sprint_hex(&ndef->Payload[pos + 2], len)); n -= 2; n -= len; pos += 2; pos += len; } - // AUTH_TYPE + // AUTH_TYPE if (memcmp(&ndef->Payload[pos], "\x10\x03", 2) == 0) { - // 10 03 00 02 00 20 + // 10 03 00 02 00 20 uint8_t len = 4; PrintAndLogEx(INFO, "Auth type....... %s ( " _YELLOW_("%s")" )", - sprint_hex(&ndef->Payload[pos + 2], len), - ndef_wifi_auth_lookup(&ndef->Payload[pos + 2]) - ); + sprint_hex(&ndef->Payload[pos + 2], len), + ndef_wifi_auth_lookup(&ndef->Payload[pos + 2]) + ); n -= 2; n -= len; pos += 2; @@ -614,9 +614,9 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { // 10 0F 00 02 00 04 uint8_t len = 4; PrintAndLogEx(INFO, "Crypt type...... %s ( " _YELLOW_("%s")" )", - sprint_hex(&ndef->Payload[pos + 2], len), - ndef_wifi_crypt_lookup(&ndef->Payload[pos + 2]) - ); + sprint_hex(&ndef->Payload[pos + 2], len), + ndef_wifi_crypt_lookup(&ndef->Payload[pos + 2]) + ); n -= 2; n -= len; pos += 2; @@ -627,7 +627,7 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { if (memcmp(&ndef->Payload[pos], "\x10\x20", 2) == 0) { // 10 20 00 06 FF FF FF FF FF FF uint8_t len = ndef->Payload[pos + 3]; - PrintAndLogEx(INFO, "MAC Address..... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len) ); + PrintAndLogEx(INFO, "MAC Address..... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len)); n -= 4; n -= len; pos += 4; @@ -636,9 +636,9 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { // NETWORK_IDX if (memcmp(&ndef->Payload[pos], "\x10\x26", 2) == 0) { - // 10 26 00 01 01 + // 10 26 00 01 01 uint8_t len = 3; - PrintAndLogEx(INFO, "Network Index... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + PrintAndLogEx(INFO, "Network Index... %s", sprint_hex(&ndef->Payload[pos + 2], len)); n -= 2; n -= len; pos += 2; @@ -647,9 +647,9 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { // NETWORK_KEY if (memcmp(&ndef->Payload[pos], "\x10\x27", 2) == 0) { - // 10 27 00 10 74 72 69 73 74 61 6E 2D 73 70 72 69 6E 67 65 72 + // 10 27 00 10 74 72 69 73 74 61 6E 2D 73 70 72 69 6E 67 65 72 uint8_t len = ndef->Payload[pos + 3]; - PrintAndLogEx(INFO, "Network key..... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len) ); + PrintAndLogEx(INFO, "Network key..... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len)); n -= 4; n -= len; pos += 4; @@ -657,9 +657,9 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { } // NETWORK_NAME if (memcmp(&ndef->Payload[pos], "\x10\x45", 2) == 0) { - // 10 45 00 06 69 63 65 73 71 6C + // 10 45 00 06 69 63 65 73 71 6C uint8_t len = ndef->Payload[pos + 3]; - PrintAndLogEx(INFO, "Network Name.... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len) ); + PrintAndLogEx(INFO, "Network Name.... %s", sprint_hex_ascii(&ndef->Payload[pos + 4], len)); n -= 4; n -= len; pos += 4; @@ -670,27 +670,27 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { // unknown the length. if (memcmp(&ndef->Payload[pos], "\x10\x2C", 2) == 0) { uint8_t len = 1; - PrintAndLogEx(INFO, "OOB Password......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + PrintAndLogEx(INFO, "OOB Password......... %s", sprint_hex(&ndef->Payload[pos + 2], len)); n -= 2; n -= len; pos += 2; pos += len; } // VENDOR_EXT - // unknown the length. + // unknown the length. if (memcmp(&ndef->Payload[pos], "\x10\x49", 2) == 0) { uint8_t len = 1; - PrintAndLogEx(INFO, "Vendor Ext......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + PrintAndLogEx(INFO, "Vendor Ext......... %s", sprint_hex(&ndef->Payload[pos + 2], len)); n -= 2; n -= len; pos += 2; pos += len; } // VENDOR_WFA - // unknown the length. + // unknown the length. if (memcmp(&ndef->Payload[pos], "\x10\x30\x2A", 3) == 0) { uint8_t len = 1; - PrintAndLogEx(INFO, "Vendor WFA......... %s", sprint_hex(&ndef->Payload[pos + 2], len) ); + PrintAndLogEx(INFO, "Vendor WFA......... %s", sprint_hex(&ndef->Payload[pos + 2], len)); n -= 2; n -= len; pos += 2; @@ -699,14 +699,14 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { } /* - ap-channel 0, 6 -+ credential + ap-channel 0, 6 + + credential device-name mac-address manufacturer model-name model-number -+ oob-password + + oob-password primary-device-type rf-bands secondary-device-type-list @@ -714,7 +714,7 @@ static int ndefDecodeMime_wifi_wsc(NDEFHeader_t *ndef) { ssid uuid-enrollee uuid-registrar -+ vendor-extension + + vendor-extension version-1 */ diff --git a/doc/commands.json b/doc/commands.json index 829e4c93d..6fa197fd8 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -1899,7 +1899,7 @@ }, "hf cipurse help": { "command": "hf cipurse help", - "description": "help this help. test tests", + "description": "help this help. test regression tests", "notes": [], "offline": true, "options": [], @@ -1965,11 +1965,15 @@ }, "hf cipurse test": { "command": "hf cipurse test", - "description": "[=] ------ cipurse tests ------ [=] kvv.............. passed [=] iso9797m2........ passed [=] smi.............. passed [=] mic.............. passed [=] auth............. passed [=] channel mac...... passed [=] channel encdec... passed [=] apdu............. passed [=] --------------------------- [+] tests [ ok ]", - "notes": [], + "description": "regression tests", + "notes": [ + "hf cipurse test" + ], "offline": true, - "options": [], - "usage": "" + "options": [ + "-h, --help this help" + ], + "usage": "hf cipurse test [-h]" }, "hf cipurse updakey": { "command": "hf cipurse updakey", @@ -2016,7 +2020,7 @@ "--mfd select masterfile by empty id", "--newkeyn target key id", "--newkey new key", - "--newkeya new key additional info. 0x00 by default", + "--newkeya new key additional info (def: 0x00)", "--enckeyn encrypt key id (must be equal to the key on the card)", "--enckey encrypt key (must be equal to the key on the card)", "--sreq communication reader-picc security level", @@ -5220,7 +5224,7 @@ }, "hf mfdes help": { "command": "hf mfdes help", - "description": "help this help list list desfire (iso 14443a) history test test crypto", + "description": "help this help list list desfire (iso 14443a) history test regression crypto tests", "notes": [], "offline": true, "options": [], @@ -5459,11 +5463,15 @@ }, "hf mfdes test": { "command": "hf mfdes test", - "description": "[=] ------ desfire tests ------ [!] no space for crc. pos: 1 [=] crc16............. passed [!] no space for crc. pos: 2 [=] crc32............. passed [=] cmac subkeys...... passed [=] an10922 aes....... passed [=] an10922 2tdea..... passed [=] an10922 3tdea..... passed [=] cmac 3tdea........ passed [=] cmac 2tdea........ passed [=] cmac des.......... passed [=] ev2 session keys.. passed [=] ev2 iv calc....... passed [=] ev2 mac calc...... passed [=] trans session key. passed [=] lrp plaintexts.... passed [=] lrp updated keys.. passed [=] lrp eval.......... passed [=] lrp inc counter... passed [=] lrp encode........ passed [=] lrp decode........ passed [=] lrp subkeys....... passed [=] lrp cmac.......... passed [=] lrp session keys.. passed [=] --------------------------- [+] tests [ ok ]", - "notes": [], + "description": "regression crypto tests", + "notes": [ + "hf mfdes test" + ], "offline": true, - "options": [], - "usage": "" + "options": [ + "-h, --help this help" + ], + "usage": "hf mfdes test [-h]" }, "hf mfdes value": { "command": "hf mfdes value", @@ -10902,6 +10910,6 @@ "metadata": { "commands_extracted": 688, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2022-02-18T21:30:00" + "extracted_on": "2022-02-24T18:33:33" } } \ No newline at end of file diff --git a/doc/commands.md b/doc/commands.md index 6437758bd..ff41afea3 100644 --- a/doc/commands.md +++ b/doc/commands.md @@ -255,7 +255,7 @@ Check column "offline" for their availability. |`hf cipurse updkey `|N |`Update key` |`hf cipurse updakey `|N |`Update key attributes` |`hf cipurse default `|N |`Set default key and file id for all the other commands` -|`hf cipurse test `|Y |`Tests` +|`hf cipurse test `|Y |`Regression tests` ### hf epa @@ -577,7 +577,7 @@ Check column "offline" for their availability. |`hf mfdes write `|N |`Write data to standard/backup/record/value file` |`hf mfdes value `|N |`Operations with value file (get/credit/limited credit/debit/clear)` |`hf mfdes clearrecfile `|N |`Clear record File` -|`hf mfdes test `|Y |`Test crypto` +|`hf mfdes test `|Y |`Regression crypto tests` ### hf seos From a932251908e15ebb75cba58ec089aa35b9d9a297 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 24 Feb 2022 23:38:51 +0100 Subject: [PATCH 21/21] text --- client/src/cmdhfcipurse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhfcipurse.c b/client/src/cmdhfcipurse.c index 2ad4499bb..95e6e7bad 100644 --- a/client/src/cmdhfcipurse.c +++ b/client/src/cmdhfcipurse.c @@ -83,9 +83,9 @@ static const APDUSpcCodeDescription_t UAPDpdateKeyAttrCodeDescriptions[] = { static const APDUSpcCodeDescription_t UAPDpdateKeyCodeDescriptions[] = { {0x6982, "Key is frozen or only the key itself has the rights to update" }, - {0x6984, "key enc key is blocked or invalid" }, + {0x6984, "Enc key is blocked or invalid" }, {0x6985, "Deactivated file" }, - {0x6A80, "invalid algo, key length or kvv" }, + {0x6A80, "Invalid algo, key length or kvv" }, {0x6A88, "Invalid key number (outside the range supported by the current DF)" } };