From 20a0bc3a81dae95774af1aebe50a1707df44c8b2 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 14 Sep 2024 15:03:29 +0200 Subject: [PATCH] style --- armsrc/hitagS.c | 20 ++++++++++---------- armsrc/mifarecmd.c | 10 +++++----- client/lualibs/trace_parse.lua | 4 ++-- client/src/cmdhf14a.c | 2 +- client/src/cmdhfmf.c | 34 +++++++++++++++++----------------- client/src/cmdhfmfu.c | 2 +- client/src/cmdlfem410x.c | 2 +- client/src/cmdlfhitaghts.c | 4 ++-- client/src/cmdscript.c | 4 ++-- client/src/emv/emv_pk.c | 15 +++++++++++---- client/src/emv/emv_pk.h | 5 +++-- client/src/mifare/mifarehost.c | 2 +- 12 files changed, 56 insertions(+), 48 deletions(-) diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c index ed5595be7..3a7b52e4b 100644 --- a/armsrc/hitagS.c +++ b/armsrc/hitagS.c @@ -39,16 +39,16 @@ static struct hitagS_tag tag = { .pages = - { - // Plain mode: | Authentication mode: - [0] = {0x88, 0xcd, 0x6d, 0xf3}, // UID | UID - [1] = {0xca, 0x24, 0x00, 0x00}, // CON0 CON1 CON2 Reserved | CON0 CON1 CON2 PWDH0 - [2] = {0xaa, 0xaa, 0xaa, 0xaa}, // Data | PWDL0 PWDL1 KEYH0 KEYH1 - [3] = {0x55, 0x55, 0x55, 0x55}, // Data | KEYL0 KEYL1 KEYL2 KEYL3 - [4] = {0xff, 0x80, 0x00, 0x00}, // Data - [5] = {0x00, 0x00, 0x00, 0x00}, // Data - // up to index 63 for HITAG S2048 public data - }, + { + // Plain mode: | Authentication mode: + [0] = {0x88, 0xcd, 0x6d, 0xf3}, // UID | UID + [1] = {0xca, 0x24, 0x00, 0x00}, // CON0 CON1 CON2 Reserved | CON0 CON1 CON2 PWDH0 + [2] = {0xaa, 0xaa, 0xaa, 0xaa}, // Data | PWDL0 PWDL1 KEYH0 KEYH1 + [3] = {0x55, 0x55, 0x55, 0x55}, // Data | KEYL0 KEYL1 KEYL2 KEYL3 + [4] = {0xff, 0x80, 0x00, 0x00}, // Data + [5] = {0x00, 0x00, 0x00, 0x00}, // Data + // up to index 63 for HITAG S2048 public data + }, }; static uint8_t page_to_be_written = 0; static int block_data_left = 0; diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 0736b0e02..0b6c2544b 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -2400,12 +2400,12 @@ int MifareECardLoad(uint8_t sectorcnt, uint8_t keytype) { ui64Key = emlGetKey(s, MF_KEY_B); if (mifare_classic_auth(pcs, cuid, FirstBlockOfSector(s), MF_KEY_B, ui64Key, AUTH_FIRST)) { - retval = PM3_EPARTIAL; - if (g_dbglevel >= DBG_ERROR) { - Dbprintf("Sector %2d - Auth error", s); + retval = PM3_EPARTIAL; + if (g_dbglevel >= DBG_ERROR) { + Dbprintf("Sector %2d - Auth error", s); + } + continue; } - continue; - } } diff --git a/client/lualibs/trace_parse.lua b/client/lualibs/trace_parse.lua index c47d7f993..5e132936a 100644 --- a/client/lualibs/trace_parse.lua +++ b/client/lualibs/trace_parse.lua @@ -1,5 +1,5 @@ ---[[ - Simple Trace Parser library +--[[ + Simple Trace Parser library -- fair warning, this is best to just get trace data values, I didn't see any better implementation for this, so I just made one myself diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 861745ec8..7ed0dd88d 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -2264,7 +2264,7 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) { card.ats_len = resp.oldarg[0]; // note: ats_len includes CRC Bytes if (card.ats_len > 3) { select_status = 1; - } + } } if (card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 9382c45af..cf162b19a 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -3646,7 +3646,7 @@ static int CmdHF14AMfSmartBrute(const char *Cmd) { PrintAndLogEx(INFO, "Current cracking speed (keys/s): %lu", keys_checked / ((msclock() - t1) / 1000) - ); + ); t1 = msclock(); keys_checked = 0; @@ -7881,8 +7881,8 @@ static int parse_gtu_cfg(uint8_t *d, size_t n) { PrintAndLogEx(INFO, _CYAN_("Config 2 - ATS")); PrintAndLogEx(INFO, "%s", sprint_hex_inrow(d + 8, 16)); if (atslen <= 16) { - PrintAndLogEx(INFO, "%s.............. ATS ( %d bytes )", sprint_hex_inrow(&d[8], d[7]), d[7]); - PrintAndLogEx(INFO, "..................%s Reserved for ATS", sprint_hex_inrow(d + 8 + d[7], 16 - d[7])); + PrintAndLogEx(INFO, "%s.............. ATS ( %d bytes )", sprint_hex_inrow(&d[8], d[7]), d[7]); + PrintAndLogEx(INFO, "..................%s Reserved for ATS", sprint_hex_inrow(d + 8 + d[7], 16 - d[7])); } else { PrintAndLogEx(INFO, "%s.............. %u Reserved for ATS", sprint_hex_inrow(&d[8], 16), 16); } @@ -9631,20 +9631,20 @@ static int CmdHF14AMfInfo(const char *Cmd) { } else if (fKeyType == MF_KEY_BD08 || fKeyType == MF_KEY_BD08S || fKeyType == MF_KEY_BD32) { PrintAndLogEx(SUCCESS, _RED_("Unknown card with backdoor, please report details!")); } else - // other cards - if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x46", 4) == 0) { - PrintAndLogEx(SUCCESS, "NXP MF1ICS5005"); - } else if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x47", 4) == 0) { - PrintAndLogEx(SUCCESS, "NXP MF1ICS5006"); - } else if (card.sak == 0x09 && memcmp(blockdata + 5, "\x89\x04\x00\x47", 4) == 0) { - PrintAndLogEx(SUCCESS, "NXP MF1ICS2006"); - } else if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x48", 4) == 0) { - PrintAndLogEx(SUCCESS, "NXP MF1ICS5007"); - } else if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\xc0", 4) == 0) { - PrintAndLogEx(SUCCESS, "NXP MF1ICS5035"); - } else { - PrintAndLogEx(SUCCESS, "unknown"); - } + // other cards + if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x46", 4) == 0) { + PrintAndLogEx(SUCCESS, "NXP MF1ICS5005"); + } else if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x47", 4) == 0) { + PrintAndLogEx(SUCCESS, "NXP MF1ICS5006"); + } else if (card.sak == 0x09 && memcmp(blockdata + 5, "\x89\x04\x00\x47", 4) == 0) { + PrintAndLogEx(SUCCESS, "NXP MF1ICS2006"); + } else if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\x48", 4) == 0) { + PrintAndLogEx(SUCCESS, "NXP MF1ICS5007"); + } else if (card.sak == 0x08 && memcmp(blockdata + 5, "\x88\x04\x00\xc0", 4) == 0) { + PrintAndLogEx(SUCCESS, "NXP MF1ICS5035"); + } else { + PrintAndLogEx(SUCCESS, "unknown"); + } if (e_sector[1].foundKey[MF_KEY_A] && (e_sector[1].Key[MF_KEY_A] == 0x2A2C13CC242A)) { PrintAndLogEx(SUCCESS, "Dorma Kaba SAFLOK detected"); diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index f92b04db2..deb5da915 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -4130,7 +4130,7 @@ static int CmdHF14AMfUCSetUid(const char *Cmd) { SendCommandNG(CMD_HF_ISO14443A_GET_CONFIG, NULL, 0); if (!WaitForResponseTimeout(CMD_HF_ISO14443A_GET_CONFIG, &resp, 2000)) { PrintAndLogEx(WARNING, "command execution time out); - return PM3_ETIMEOUT; + return PM3_ETIMEOUT; } memcpy(&config, resp.data.asBytes, sizeof(hf14a_config)); int8_t oldconfig_bcc = config.forcebcc; diff --git a/client/src/cmdlfem410x.c b/client/src/cmdlfem410x.c index 9355479cb..a541bf9f0 100644 --- a/client/src/cmdlfem410x.c +++ b/client/src/cmdlfem410x.c @@ -792,7 +792,7 @@ static int CmdEM410xClone(const char *Cmd) { } packet.cmd = WHTSF_82xx; - memcpy(packet.pwd, (uint8_t[]){0xBB, 0xDD, 0x33, 0x99}, 4); + memcpy(packet.pwd, (uint8_t[]) {0xBB, 0xDD, 0x33, 0x99}, 4); SendCommandNG(CMD_LF_HITAGS_WRITE, (uint8_t *)&packet, sizeof(packet)); if (WaitForResponseTimeout(CMD_LF_HITAGS_WRITE, &resp, 4000) == false) { PrintAndLogEx(WARNING, "timeout while waiting for reply."); diff --git a/client/src/cmdlfhitaghts.c b/client/src/cmdlfhitaghts.c index 01f368bd3..2fe40238b 100644 --- a/client/src/cmdlfhitaghts.c +++ b/client/src/cmdlfhitaghts.c @@ -107,7 +107,7 @@ static int CmdLFHitagSRead(const char *Cmd) { use_crypto = true; } if ((key_len == 0) && use_82xx) { - memcpy(key, (uint8_t[]){0xBB, 0xDD, 0x33, 0x99}, 4); + memcpy(key, (uint8_t[]) {0xBB, 0xDD, 0x33, 0x99}, 4); key_len = 4; } if ((key_len == 0) && use_crypto) { @@ -266,7 +266,7 @@ static int CmdLFHitagSWrite(const char *Cmd) { use_crypto = true; } if ((key_len == 0) && use_82xx) { - memcpy(key, (uint8_t[]){0xBB, 0xDD, 0x33, 0x99}, 4); + memcpy(key, (uint8_t[]) {0xBB, 0xDD, 0x33, 0x99}, 4); key_len = 4; } if ((key_len == 0) && use_crypto) { diff --git a/client/src/cmdscript.c b/client/src/cmdscript.c index a28aadc77..8929cea68 100644 --- a/client/src/cmdscript.c +++ b/client/src/cmdscript.c @@ -301,8 +301,8 @@ static int CmdScriptRun(const char *Cmd) { // and be able to send in parameters into script meanwhile // being able to "-h" here too. if ((strlen(filename) == 0) || - (strcmp(filename, "-h") == 0) || - (strcmp(filename, "--help") == 0)) { + (strcmp(filename, "-h") == 0) || + (strcmp(filename, "--help") == 0)) { ctx->argtable = argtable; ctx->argtableLen = arg_getsize(argtable); CLIParserPrintHelp(ctx); diff --git a/client/src/emv/emv_pk.c b/client/src/emv/emv_pk.c index 8df7a2067..48a209fbb 100644 --- a/client/src/emv/emv_pk.c +++ b/client/src/emv/emv_pk.c @@ -448,9 +448,12 @@ static struct emv_pk *emv_pk_get_ca_pk_from_file(const char *fname, return NULL; } +// not used +/* char *emv_pk_get_ca_pk_file(const char *dirname, const unsigned char *rid, unsigned char idx) { - if (!dirname) + if (dirname == NULL) { dirname = ".";//openemv_config_get_str("capk.dir", NULL); + } char *filename; int ret = asprintf(&filename, "%s/%02hhx%02hhx%02hhx%02hhx%02hhx_%02hhx.0", @@ -462,15 +465,17 @@ char *emv_pk_get_ca_pk_file(const char *dirname, const unsigned char *rid, unsig rid[4], idx); - if (ret <= 0) + if (ret <= 0) { return NULL; + } return filename; } char *emv_pk_get_ca_pk_rid_file(const char *dirname, const unsigned char *rid) { - if (!dirname) + if (dirname == NULL) { dirname = "."; //openemv_config_get_str("capk.dir", NULL); + } char *filename; int ret = asprintf(&filename, "%s/%02hhx%02hhx%02hhx%02hhx%02hhx.pks", @@ -481,11 +486,13 @@ char *emv_pk_get_ca_pk_rid_file(const char *dirname, const unsigned char *rid) { rid[3], rid[4]); - if (ret <= 0) + if (ret <= 0) { return NULL; + } return filename; } +*/ struct emv_pk *emv_pk_get_ca_pk(const unsigned char *rid, unsigned char idx) { struct emv_pk *pk = NULL; diff --git a/client/src/emv/emv_pk.h b/client/src/emv/emv_pk.h index 83628bbc2..01a3a1358 100644 --- a/client/src/emv/emv_pk.h +++ b/client/src/emv/emv_pk.h @@ -22,6 +22,7 @@ #define EMV_PK_H #include "common.h" +#include struct emv_pk { unsigned char rid[5]; @@ -46,7 +47,7 @@ void emv_pk_free(struct emv_pk *pk); char *emv_pk_dump_pk(const struct emv_pk *pk); bool emv_pk_verify(const struct emv_pk *pk); -char *emv_pk_get_ca_pk_file(const char *dirname, const unsigned char *rid, unsigned char idx); -char *emv_pk_get_ca_pk_rid_file(const char *dirname, const unsigned char *rid); +// char *emv_pk_get_ca_pk_file(const char *dirname, const unsigned char *rid, unsigned char idx); +// char *emv_pk_get_ca_pk_rid_file(const char *dirname, const unsigned char *rid); struct emv_pk *emv_pk_get_ca_pk(const unsigned char *rid, unsigned char idx); #endif diff --git a/client/src/mifare/mifarehost.c b/client/src/mifare/mifarehost.c index 42ca4eeec..063cc9a58 100644 --- a/client/src/mifare/mifarehost.c +++ b/client/src/mifare/mifarehost.c @@ -52,7 +52,7 @@ int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key) { bool first_run = true; // message - PrintAndLogEx(INFO, "Expected execution time is about 25seconds on average"); + PrintAndLogEx(INFO, "Expected execution time is about " _YELLOW_("25") " seconds on average"); PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " to abort"); while (true) {