From ed78bca62b32345796d33a903e22ff35927cc4dc Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 18 Apr 2021 18:31:51 +0200 Subject: [PATCH] style --- client/luascripts/hf_mf_autopwn.lua | 2 +- client/src/aidsearch.c | 2 +- client/src/cmddata.c | 210 ++++++++++++++-------------- client/src/cmdhficlass.c | 4 +- client/src/cmdhflist.c | 4 +- client/src/cmdlfpac.c | 4 +- 6 files changed, 113 insertions(+), 113 deletions(-) diff --git a/client/luascripts/hf_mf_autopwn.lua b/client/luascripts/hf_mf_autopwn.lua index 09df92b9d..b5d6f850d 100644 --- a/client/luascripts/hf_mf_autopwn.lua +++ b/client/luascripts/hf_mf_autopwn.lua @@ -113,7 +113,7 @@ end local function dump_tag(uid, sak) dbg('dumping tag memory') - + if utils.confirm('Do you wish to create a memory dump of tag?') then local dumpfile = 'hf-mf-'..uid..'-dump' diff --git a/client/src/aidsearch.c b/client/src/aidsearch.c index 360353fe0..377bc2f9e 100644 --- a/client/src/aidsearch.c +++ b/client/src/aidsearch.c @@ -24,7 +24,7 @@ static int openAIDFile(json_t **root, bool verbose) { int retval = PM3_SUCCESS; *root = json_load_file(path, 0, &error); - if (!*root) { + if (!*root) { PrintAndLogEx(ERR, "json (%s) error on line %d: %s", path, error.line, error.text); retval = PM3_ESOFT; goto out; diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 3b6a8164a..ad67126be 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -365,18 +365,18 @@ static int CmdConvertBitStream(const char *Cmd) { // askType switches decode: ask/raw = 0, ask/manchester = 1 int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, bool verbose, bool emSearch, uint8_t askType, bool *stCheck) { PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) clk %i invert %i maxErr %i maxLen %zu amplify %i verbose %i emSearch %i askType %i " - , clk - , invert - , maxErr - , maxlen - , amplify - , verbose - , emSearch - , askType - ); + , clk + , invert + , maxErr + , maxlen + , amplify + , verbose + , emSearch + , askType + ); uint8_t askamp = 0; - if (maxlen == 0) + if (maxlen == 0) maxlen = pm3_capabilities.bigbuf_size; uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t)); @@ -427,32 +427,32 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b if (errCnt < 0 || bitlen < 16) { //if fatal error (or -1) PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) No data found errors:%d, %s bitlen:%zu, clock:%d" - , errCnt - , (invert) ? "inverted," : "" - , bitlen - , clk - ); + , errCnt + , (invert) ? "inverted," : "" + , bitlen + , clk + ); free(bits); return PM3_ESOFT; } if (errCnt > maxErr) { PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) Too many errors found, errors:%d, bits:%zu, clock:%d" - , errCnt - , bitlen - , clk - ); + , errCnt + , bitlen + , clk + ); free(bits); return PM3_ESOFT; } if (verbose) { PrintAndLogEx(DEBUG, "DEBUG: (ASKDemod_ext) using clock:%d, %sbits found:%zu, start index %d" - , clk - , (invert) ? "inverted, " : "" - , bitlen - , start_idx - ); + , clk + , (invert) ? "inverted, " : "" + , bitlen + , start_idx + ); } //output @@ -465,10 +465,10 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b if (askType) { PrintAndLogEx(SUCCESS, _YELLOW_("ASK/Manchester") " - clock %d - decoded bitstream", clk); - PrintAndLogEx(INFO,"---------------------------------------------"); + PrintAndLogEx(INFO, "---------------------------------------------"); } else { PrintAndLogEx(SUCCESS, _YELLOW_("ASK/Raw") " - clock %d - decoded bitstream", clk); - PrintAndLogEx(INFO,"--------------------------------------"); + PrintAndLogEx(INFO, "--------------------------------------"); } printDemodBuff(0, false, false, false); @@ -493,18 +493,18 @@ int ASKDemod(int clk, int invert, int maxErr, size_t maxlen, bool amplify, bool static int Cmdaskmandemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --am", - "ASK/MANCHESTER demodulate the data in the GraphBuffer and output binary", - "data rawdemod --am --> demod a ask/manchester tag, using autodetect\n" - "data rawdemod --am -c 32 --> demod a ask/manchester tag, using a clock of RF/32\n" - "data rawdemod --am -i --> demod a ask/manchester tag, using autodetect, invert output\n" - "data rawdemod --am -c 32 -i --> demod a ask/manchester tag, using a clock of RF/32, invert output\n" - "data rawdemod --am -c 64 -i --max 0 --> demod a ask/manchester tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" - ); + "ASK/MANCHESTER demodulate the data in the GraphBuffer and output binary", + "data rawdemod --am --> demod a ask/manchester tag, using autodetect\n" + "data rawdemod --am -c 32 --> demod a ask/manchester tag, using a clock of RF/32\n" + "data rawdemod --am -i --> demod a ask/manchester tag, using autodetect, invert output\n" + "data rawdemod --am -c 32 -i --> demod a ask/manchester tag, using a clock of RF/32, invert output\n" + "data rawdemod --am -c 64 -i --max 0 --> demod a ask/manchester tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" + ); void *argtable[] = { arg_param_begin, arg_lit0("a", "amp", "try attempt demod with ask amplification (def no amp)"), arg_int0("c", "clk", "", "set clock manually (def autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_lit0("s", "st", "check for sequence terminator"), arg_int0(NULL, "max", "", "maximum allowed errors (def 100)"), arg_int0(NULL, "samples", "", "maximum samples to read (def 32768) [512 bits at RF/64]"), @@ -708,18 +708,18 @@ int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose) { static int Cmdaskbiphdemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --ab", - "ASK/BIPHASE demodulate the data in the GraphBuffer and output binary\n" - "NOTE, `--invert` for Conditional Dephase Encoding (CDP) AKA Differential Manchester\n", - "data rawdemod --ab --> demod a ask/biphase tag, using autodetect\n" - "data rawdemod --ab -c 32 --> demod a ask/biphase tag, using a clock of RF/32\n" - "data rawdemod --ab -i --> demod a ask/biphase tag, using autodetect, invert output\n" - "data rawdemod --ab -c 32 -i --> demod a ask/biphase tag, using a clock of RF/32, invert output\n" - "data rawdemod --ab -c 64 -i --max 0 --> demod a ask/biphase tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" - ); + "ASK/BIPHASE demodulate the data in the GraphBuffer and output binary\n" + "NOTE, `--invert` for Conditional Dephase Encoding (CDP) AKA Differential Manchester\n", + "data rawdemod --ab --> demod a ask/biphase tag, using autodetect\n" + "data rawdemod --ab -c 32 --> demod a ask/biphase tag, using a clock of RF/32\n" + "data rawdemod --ab -i --> demod a ask/biphase tag, using autodetect, invert output\n" + "data rawdemod --ab -c 32 -i --> demod a ask/biphase tag, using a clock of RF/32, invert output\n" + "data rawdemod --ab -c 64 -i --max 0 --> demod a ask/biphase tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" + ); void *argtable[] = { arg_param_begin, arg_int0("c", "clk", "", "set clock manually (def autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_int0("o", "offset", "", "offset to begin biphase (def 0)"), arg_int0(NULL, "max", "", "maximum allowed errors (def 50)"), arg_param_end @@ -739,18 +739,18 @@ static int Cmdaskbiphdemod(const char *Cmd) { static int Cmdaskrawdemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --ar", - "ASK/RAW demodulate the data in the GraphBuffer and output binary", - "data rawdemod --ar -a --> demod a ask tag, using autodetect, amplified\n" - "data rawdemod --ar -c 32 --> demod a ask tag, using a clock of RF/32\n" - "data rawdemod --ar -i --> demod a ask tag, using autodetect, invert output\n" - "data rawdemod --ar -c 32 -i --> demod a ask tag, using a clock of RF/32, invert output\n" - "data rawdemod --ar -c 64 -i --max 0 --> demod a ask tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" - ); + "ASK/RAW demodulate the data in the GraphBuffer and output binary", + "data rawdemod --ar -a --> demod a ask tag, using autodetect, amplified\n" + "data rawdemod --ar -c 32 --> demod a ask tag, using a clock of RF/32\n" + "data rawdemod --ar -i --> demod a ask tag, using autodetect, invert output\n" + "data rawdemod --ar -c 32 -i --> demod a ask tag, using a clock of RF/32, invert output\n" + "data rawdemod --ar -c 64 -i --max 0 --> demod a ask tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" + ); void *argtable[] = { arg_param_begin, arg_lit0("a", "amp", "try attempt demod with ask amplification (def no amp)"), arg_int0("c", "clk", "", "set clock manually (def autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_lit0("s", "st", "check for sequence terminator"), arg_int0(NULL, "max", "", "maximum allowed errors (def 100)"), arg_int0(NULL, "samples", "", "maximum samples to read (def 32768) [512 bits at RF/64]"), @@ -1179,7 +1179,7 @@ int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bo size_t bitlen = getFromGraphBuf(bits); if (bitlen == 0) { - PrintAndLogEx(DEBUG, "DEBUG: no data in graphbuf"); + PrintAndLogEx(DEBUG, "DEBUG: no data in graphbuf"); free(bits); return PM3_ESOFT; } @@ -1211,14 +1211,14 @@ int FSKrawDemod(uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, bo // Now output the bitstream to the scrollback by line of 16 bits if (verbose || g_debugMode) { PrintAndLogEx(DEBUG, "DEBUG: (FSKrawDemod) using clock:%u, %sfc high:%u, fc low:%u" - , rfLen - , (invert) ? "inverted, " : "" - , fchigh - , fclow - ); + , rfLen + , (invert) ? "inverted, " : "" + , fchigh + , fclow + ); PrintAndLogEx(NORMAL, ""); PrintAndLogEx(SUCCESS, _YELLOW_("%s") " decoded bitstream", GetFSKType(fchigh, fclow, invert)); - PrintAndLogEx(INFO,"-----------------------"); + PrintAndLogEx(INFO, "-----------------------"); printDemodBuff(0, false, invert, false); } goto out; @@ -1237,19 +1237,19 @@ out: static int CmdFSKrawdemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --fs", - "FSK demodulate the data in the GraphBuffer and output binary", - "data rawdemod --fs --> demod an fsk tag, using autodetect\n" - "data rawdemod --fs -c 32 --> demod an fsk tag, using a clock of RF/32, autodetect fc\n" - "data rawdemod --fs -i --> demod an fsk tag, using autodetect, invert output\n" - "data rawdemod --fs -c 32 -i --> demod an fsk tag, using a clock of RF/32, invert output, autodetect fc\n" - "data rawdemod --fs -c 64 --hi 8 --lo 5 --> demod an fsk1 RF/64 tag\n" - "data rawdemod --fs -c 50 --hi 10 --lo 8 --> demod an fsk2 RF/50 tag\n" - "data rawdemod --fs -c 50 -i --hi 10 --lo 8 --> demod an fsk2a RF/50 tag\n" - ); + "FSK demodulate the data in the GraphBuffer and output binary", + "data rawdemod --fs --> demod an fsk tag, using autodetect\n" + "data rawdemod --fs -c 32 --> demod an fsk tag, using a clock of RF/32, autodetect fc\n" + "data rawdemod --fs -i --> demod an fsk tag, using autodetect, invert output\n" + "data rawdemod --fs -c 32 -i --> demod an fsk tag, using a clock of RF/32, invert output, autodetect fc\n" + "data rawdemod --fs -c 64 --hi 8 --lo 5 --> demod an fsk1 RF/64 tag\n" + "data rawdemod --fs -c 50 --hi 10 --lo 8 --> demod an fsk2 RF/50 tag\n" + "data rawdemod --fs -c 50 -i --hi 10 --lo 8 --> demod an fsk2a RF/50 tag\n" + ); void *argtable[] = { arg_param_begin, arg_int0("c", "clk", "", "set clock manually (def: autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_int0(NULL, "hi", "", "larger field clock length (def: autodetect)"), arg_int0(NULL, "lo", "", "small field clock length (def: autodetect)"), arg_param_end @@ -1318,7 +1318,7 @@ int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) { int errCnt = 0, clkStartIdx = 0; if (getSignalProperties()->isnoise) { - if (verbose) { + if (verbose) { PrintAndLogEx(INFO, "signal looks like noise"); } return PM3_ESOFT; @@ -1369,17 +1369,17 @@ int NRZrawDemod(int clk, int invert, int maxErr, bool verbose) { static int CmdNRZrawDemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --nr", - "NRZ/DIRECT demodulate the data in the GraphBuffer and output binary", - "data rawdemod --nr --> demod a nrz/direct tag, using autodetect\n" - "data rawdemod --nr -c 32 --> demod a nrz/direct tag, using a clock of RF/32\n" - "data rawdemod --nr -i --> demod a nrz/direct tag, using autodetect, invert output\n" - "data rawdemod --nr -c 32 -i --> demod a nrz/direct tag, using a clock of RF/32, invert output\n" - "data rawdemod --nr -c 64 -i --max 0 --> demod a nrz/direct tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" - ); + "NRZ/DIRECT demodulate the data in the GraphBuffer and output binary", + "data rawdemod --nr --> demod a nrz/direct tag, using autodetect\n" + "data rawdemod --nr -c 32 --> demod a nrz/direct tag, using a clock of RF/32\n" + "data rawdemod --nr -i --> demod a nrz/direct tag, using autodetect, invert output\n" + "data rawdemod --nr -c 32 -i --> demod a nrz/direct tag, using a clock of RF/32, invert output\n" + "data rawdemod --nr -c 64 -i --max 0 --> demod a nrz/direct tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" + ); void *argtable[] = { arg_param_begin, arg_int0("c", "clk", "", "set clock manually (def autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_int0(NULL, "max", "", "maximum allowed errors (def 100)"), arg_param_end }; @@ -1399,17 +1399,17 @@ static int CmdNRZrawDemod(const char *Cmd) { int CmdPSK1rawDemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --p1", - "PSK1 demodulate the data in the GraphBuffer and output binary", - "data rawdemod --p1 --> demod a psk1 tag, using autodetect\n" - "data rawdemod --p1 -c 32 --> demod a psk1 tag, using a clock of RF/32\n" - "data rawdemod --p1 -i --> demod a psk1 tag, using autodetect, invert output\n" - "data rawdemod --p1 -c 32 -i --> demod a psk1 tag, using a clock of RF/32, invert output\n" - "data rawdemod --p1 -c 64 -i --max 0 --> demod a psk1 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" - ); + "PSK1 demodulate the data in the GraphBuffer and output binary", + "data rawdemod --p1 --> demod a psk1 tag, using autodetect\n" + "data rawdemod --p1 -c 32 --> demod a psk1 tag, using a clock of RF/32\n" + "data rawdemod --p1 -i --> demod a psk1 tag, using autodetect, invert output\n" + "data rawdemod --p1 -c 32 -i --> demod a psk1 tag, using a clock of RF/32, invert output\n" + "data rawdemod --p1 -c 64 -i --max 0 --> demod a psk1 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" + ); void *argtable[] = { arg_param_begin, arg_int0("c", "clk", "", "set clock manually (def autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_int0(NULL, "max", "", "maximum allowed errors (def 100)"), arg_param_end }; @@ -1437,17 +1437,17 @@ int CmdPSK1rawDemod(const char *Cmd) { static int CmdPSK2rawDemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod --p2", - "PSK2 demodulate the data in the GraphBuffer and output binary", - "data rawdemod --p2 --> demod a psk2 tag, using autodetect\n" - "data rawdemod --p2 -c 32 --> demod a psk2 tag, using a clock of RF/32\n" - "data rawdemod --p2 -i --> demod a psk2 tag, using autodetect, invert output\n" - "data rawdemod --p2 -c 32 -i --> demod a psk2 tag, using a clock of RF/32, invert output\n" - "data rawdemod --p2 -c 64 -i --max 0 --> demod a psk2 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" - ); + "PSK2 demodulate the data in the GraphBuffer and output binary", + "data rawdemod --p2 --> demod a psk2 tag, using autodetect\n" + "data rawdemod --p2 -c 32 --> demod a psk2 tag, using a clock of RF/32\n" + "data rawdemod --p2 -i --> demod a psk2 tag, using autodetect, invert output\n" + "data rawdemod --p2 -c 32 -i --> demod a psk2 tag, using a clock of RF/32, invert output\n" + "data rawdemod --p2 -c 64 -i --max 0 --> demod a psk2 tag, using a clock of RF/64, inverting and allowing 0 demod errors\n" + ); void *argtable[] = { arg_param_begin, arg_int0("c", "clk", "", "set clock manually (def autodetect)"), - arg_lit0("i","inv", "invert output"), + arg_lit0("i", "inv", "invert output"), arg_int0(NULL, "max", "", "maximum allowed errors (def 100)"), arg_param_end }; @@ -1476,15 +1476,15 @@ static int CmdRawDemod(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data rawdemod", - "Demodulate the data in the GraphBuffer and output binary", - "data rawdemod --fs --> demod FSK - autodetect\n" - "data rawdemod --ab --> demod ASK/BIPHASE - autodetect\n" - "data rawdemod --am --> demod ASK/MANCHESTER - autodetect\n" - "data rawdemod --ar --> demod ASK/RAW - autodetect\n" - "data rawdemod --nr --> demod NRZ/DIRECT - autodetect\n" - "data rawdemod --p1 --> demod PSK1 - autodetect\n" - "data rawdemod --p2 --> demod PSK2 - autodetect\n" - ); + "Demodulate the data in the GraphBuffer and output binary", + "data rawdemod --fs --> demod FSK - autodetect\n" + "data rawdemod --ab --> demod ASK/BIPHASE - autodetect\n" + "data rawdemod --am --> demod ASK/MANCHESTER - autodetect\n" + "data rawdemod --ar --> demod ASK/RAW - autodetect\n" + "data rawdemod --nr --> demod NRZ/DIRECT - autodetect\n" + "data rawdemod --p1 --> demod PSK1 - autodetect\n" + "data rawdemod --p2 --> demod PSK2 - autodetect\n" + ); void *argtable[] = { arg_param_begin, arg_lit0(NULL, "ab", "ASK/Biphase demodulation"), @@ -1515,18 +1515,18 @@ static int CmdRawDemod(const char *Cmd) { CLIParserFree(ctx); int foo = (ab + am + ar + fs + nr + p1 + p2); - if ( foo > 1 ) { + if (foo > 1) { PrintAndLogEx(WARNING, "please, select only one modulation"); return PM3_EINVARG; } - if ( foo == 0 ) { + if (foo == 0) { PrintAndLogEx(WARNING, "please, select a modulation"); return PM3_EINVARG; } int ans = 0; const char *s = Cmd + n; - if (fs) + if (fs) ans = CmdFSKrawdemod(s); else if (ab) ans = Cmdaskbiphdemod(s); diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 5108cde5e..d6888cf80 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -114,7 +114,7 @@ static inline uint32_t leadingzeros(uint64_t a) { } static void iclass_upload_emul(uint8_t *d, uint32_t n, uint32_t *bytes_sent) { - // fast push mode + // fast push mode conn.block_after_ACK = true; //Send to device @@ -265,7 +265,7 @@ static int generate_config_card(const iclass_config_card_item_t *o, uint8_t *ke HFiClassCalcDivKey(iclass_last_known_card.csn, iClass_Key_Table[0], iclass_last_known_card.key_d, false); memset(data, 0x00, tot_bytes); - memcpy(data, (uint8_t*)&iclass_last_known_card, sizeof(picopass_hdr_t)); + memcpy(data, (uint8_t *)&iclass_last_known_card, sizeof(picopass_hdr_t)); // Keyrolling configuration cards are special. if (strstr(o->desc, "Keyroll") != NULL) { diff --git a/client/src/cmdhflist.c b/client/src/cmdhflist.c index be2dfa4eb..279d75ecb 100644 --- a/client/src/cmdhflist.c +++ b/client/src/cmdhflist.c @@ -777,7 +777,7 @@ void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { for (uint8_t i = 0; i < 2; i++, pos++) { bool found_annotation = true; - + switch (cmd[pos]) { case MFDES_CREATE_APPLICATION: snprintf(exp, size, "CREATE APPLICATION"); @@ -897,7 +897,7 @@ void annotateMfDesfire(char *exp, size_t size, uint8_t *cmd, uint8_t cmdsize) { found_annotation = false; break; } - + if (found_annotation) { break; } diff --git a/client/src/cmdlfpac.c b/client/src/cmdlfpac.c index f9d6b098c..65a3c04a9 100644 --- a/client/src/cmdlfpac.c +++ b/client/src/cmdlfpac.c @@ -403,7 +403,7 @@ int CmdLFPac(const char *Cmd) { // find PAC preamble in already demoded data int detectPac(uint8_t *dest, size_t *size, bool *invert) { // make sure buffer has data - if (*size < 128) + if (*size < 128) return -1; size_t startIdx = 0; @@ -422,7 +422,7 @@ int detectPac(uint8_t *dest, size_t *size, bool *invert) { // wrong demoded size if (*size != 128) return -3; - + // return start position return (int)startIdx; }