From 16a7cfd7b2066c46ba2a6e527e4721677127a596 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Mon, 26 Aug 2019 22:28:39 +0200 Subject: [PATCH] make style (excepted cmdhficlass...) --- armsrc/mifarecmd.c | 6 +- armsrc/pcf7931.c | 3 +- client/cmdhfmf.c | 176 +++++++++++++++------------- client/fileutils.c | 18 ++- client/fileutils.h | 2 +- client/loclass/cipherutils.c | 2 +- client/loclass/elite_crack.c | 20 ++-- client/scripting.c | 4 +- tools/fpga_compress/fpga_compress.c | 4 +- 9 files changed, 120 insertions(+), 115 deletions(-) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 985a787ca..63cf1128d 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1992,9 +1992,9 @@ TEST2: int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true); if (res == 2) { - if (cuid == 0xAA55C396 ) { - isGen = GEN_UNFUSED; - goto OUT; + if (cuid == 0xAA55C396) { + isGen = GEN_UNFUSED; + goto OUT; } ReaderTransmit(rats, sizeof(rats), NULL); diff --git a/armsrc/pcf7931.c b/armsrc/pcf7931.c index 9f1283b8c..82865b311 100644 --- a/armsrc/pcf7931.c +++ b/armsrc/pcf7931.c @@ -232,8 +232,7 @@ void ReadPCF7931() { } Dbprintf("(dbg) got %d blocks (%d/%d found) (%d tries, %d errors)", n, found_blocks, (max_blocks == 0 ? found_blocks : max_blocks), tries, errors); - for (i = 0; i < n; ++i) - { + for (i = 0; i < n; ++i) { print_result("got consecutive blocks", tmp_blocks[i], 16); } diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 32aa03c73..0783f5d3f 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -1601,7 +1601,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { uint8_t block[16] = {0x00}; uint8_t *dump; int bytes; - char* fnameptr = filename; + char *fnameptr = filename; // Settings bool slow = false; bool legacy_mfchk = false; @@ -1616,7 +1616,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { case 'h': return usage_hf14_autopwn(); case 'f': - if (param_getstr(Cmd, cmdp +1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) { + if (param_getstr(Cmd, cmdp + 1, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) { PrintAndLogEx(FAILED, "Filename too long"); } cmdp ++; @@ -1699,8 +1699,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { e_sector = calloc(sectors_cnt, sizeof(sector_t)); if (e_sector == NULL) return PM3_EMALLOC; // Clear the key storage datastructure - for (i=0; i just be nice and correct it ;) if (know_target_key == false) { num_to_bytes(e_sector[i].Key[i2], 6, key); know_target_key = true; - blockNo = i; keyType = i2; + blockNo = i; + keyType = i2; PrintAndLogEx(SUCCESS, "[ SETTINGS ] The following key will be used for the nested / hardnested attack: sector:" - _RED_("%3d") " key type:"_RED_("%c") " key: " _RED_("0x%02x%02x%02x%02x%02x%02x"), - blockNo, - keyType ? 'B' : 'A', - key[0], key[1], key[2], key[3], key[4], key[5]); + _RED_("%3d") " key type:"_RED_("%c") " key: " _RED_("0x%02x%02x%02x%02x%02x%02x"), + blockNo, + keyType ? 'B' : 'A', + key[0], key[1], key[2], key[3], key[4], key[5]); } - } + } } } } @@ -1793,24 +1794,25 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { for (int cnt = 0; cnt < ARRAYLEN(g_mifare_default_keys); cnt++) { num_to_bytes(g_mifare_default_keys[cnt], 6, keyBlock + cnt * 6); } - key_cnt = ARRAYLEN(g_mifare_default_keys); - } - + key_cnt = ARRAYLEN(g_mifare_default_keys); + } + // Start the timer t1 = msclock(); // Use the dictionary to find sector keys on the card PrintAndLogEx(INFO, "Enumerating the card keys with the dictionary!"); if (legacy_mfchk) { - // Check all the sectors - for (i=0; i (PM3_CMD_DATA_SIZE / 6) ? (PM3_CMD_DATA_SIZE / 6) : key_cnt; bool firstChunk = true, lastChunk = false; @@ -1829,7 +1832,9 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { if (kbd_enter_pressed()) { PrintAndLogEx(WARNING, "\naborted via keyboard!\n"); - i = key_cnt; strategy = 3; break; // Exit the loop + i = key_cnt; + strategy = 3; + break; // Exit the loop } uint32_t size = ((key_cnt - i) > chunksize) ? chunksize : key_cnt - i; // last chunk? @@ -1840,7 +1845,9 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { firstChunk = false; // all keys, aborted if (res == 0 || res == 2) { - i = key_cnt; strategy = 3; break; // Exit the loop + i = key_cnt; + strategy = 3; + break; // Exit the loop } } // end chunks of keys firstChunk = true; @@ -1849,25 +1856,26 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) { } // Analyse the dictionary attack - for (i=0; i The fast check --> mfCheckKeys_fast(sectors_cnt, true, true, 2, 1, tmp_key, e_sector, false); // Returns false keys, so we just stick to the slower mfchk. - for (i=0; id_name[0] != '.')) || (str_endswith(namelist[i]->d_name, ext))) { - PrintAndLogEx(NORMAL, "%s   %s── %-21s", last ? " ":"│", i == n-1 ? "└" : "├", namelist[i]->d_name); + PrintAndLogEx(NORMAL, "%s   %s── %-21s", last ? " " : "│", i == n - 1 ? "└" : "├", namelist[i]->d_name); } free(namelist[i]); } @@ -727,19 +727,17 @@ int searchAndList(const char *pm3dir, const char *ext) { } static int searchFinalFile(char **foundpath, const char *pm3dir, const char *searchname) { - if ((foundpath == NULL)||(pm3dir == NULL)||(searchname == NULL)) return PM3_ESOFT; + if ((foundpath == NULL) || (pm3dir == NULL) || (searchname == NULL)) return PM3_ESOFT; // explicit absolute (/) or relative path (./) => try only to match it directly char *filename = calloc(strlen(searchname) + 1, sizeof(char)); if (filename == NULL) return PM3_EMALLOC; strcpy(filename, searchname); if (((strlen(filename) > 1) && (filename[0] == '/')) || - ((strlen(filename) > 2) && (filename[0] == '.') && (filename[1] == '/'))) - { + ((strlen(filename) > 2) && (filename[0] == '.') && (filename[1] == '/'))) { if (fileExists(filename)) { *foundpath = filename; return PM3_SUCCESS; - } - else { + } else { goto out; } } diff --git a/client/fileutils.h b/client/fileutils.h index 25fe0a885..03a47112e 100644 --- a/client/fileutils.h +++ b/client/fileutils.h @@ -111,7 +111,7 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s * @param fptr string pointer to the filename * @return 0 for ok, 1 for failz */ -int createMfcKeyDump(uint8_t sectorsCnt, sector_t *e_sector, char* fptr); +int createMfcKeyDump(uint8_t sectorsCnt, sector_t *e_sector, char *fptr); /** STUB * @brief Utility function to load data from a binary file. This method takes a preferred name. diff --git a/client/loclass/cipherutils.c b/client/loclass/cipherutils.c index 52ac82f94..ee440fb73 100644 --- a/client/loclass/cipherutils.c +++ b/client/loclass/cipherutils.c @@ -160,7 +160,7 @@ void printarr(const char *name, uint8_t *arr, int len) { } void printvar(const char *name, uint8_t *arr, int len) { - PrintAndLogEx(NORMAL, "%s = " _YELLOW_("%s"), name, sprint_hex(arr, len) ); + PrintAndLogEx(NORMAL, "%s = " _YELLOW_("%s"), name, sprint_hex(arr, len)); } void printarr_human_readable(const char *title, uint8_t *arr, int len) { diff --git a/client/loclass/elite_crack.c b/client/loclass/elite_crack.c index 74ebfe608..69b17c50f 100644 --- a/client/loclass/elite_crack.c +++ b/client/loclass/elite_crack.c @@ -479,7 +479,7 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[]) { return 1; } else { PrintAndLogEx(NORMAL, "\n"); - PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!") ); + PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!")); } return 0; } @@ -502,18 +502,18 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) { for (i = 0 ; i * itemsize < dumpsize ; i++) { memcpy(attack, dump + i * itemsize, itemsize); errors += bruteforceItem(*attack, keytable); - if ( errors ) - break; + if (errors) + break; } free(attack); t1 = msclock() - t1; PrintAndLogEx(SUCCESS, "time: %" PRIu64 " seconds", t1 / 1000); - - if ( errors ) { - PrintAndLogEx(ERR, "loclass exiting. Try run " _YELLOW_("`hf iclass sim 2`") "again and collect new data"); - return 1; - } + + if (errors) { + PrintAndLogEx(ERR, "loclass exiting. Try run " _YELLOW_("`hf iclass sim 2`") "again and collect new data"); + return 1; + } // Pick out the first 16 bytes of the keytable. // The keytable is now in 16-bit ints, where the upper 8 bits @@ -526,8 +526,8 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) { if (!(keytable[i] & CRACKED)) { PrintAndLogEx(WARNING, "Warning: we are missing byte %d, custom key calculation will fail...", i); - return 1; - } + return 1; + } } errors += calculateMasterKey(first16bytes, NULL); return errors; diff --git a/client/scripting.c b/client/scripting.c index dc3051207..5a3eaed61 100644 --- a/client/scripting.c +++ b/client/scripting.c @@ -1158,7 +1158,7 @@ int set_pm3_libraries(lua_State *L) { strcat(scripts_path, LUA_LIBRARIES_WILDCARD); setLuaPath(L, scripts_path); - // from the ~/.proxmark3/lualib/ directory + // from the ~/.proxmark3/lualib/ directory char libraries_path[strlen(user_path) + strlen(PM3_USER_DIRECTORY) + strlen(LUA_LIBRARIES_SUBDIR) + strlen(LUA_LIBRARIES_WILDCARD) + 1]; strcpy(libraries_path, user_path); strcat(libraries_path, PM3_USER_DIRECTORY); @@ -1167,7 +1167,7 @@ int set_pm3_libraries(lua_State *L) { setLuaPath(L, libraries_path); } - if (strlen(PM3_SHARE_PATH) != 0 || strlen(LUA_SCRIPTS_SUBDIR) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0 ) { + if (strlen(PM3_SHARE_PATH) != 0 || strlen(LUA_SCRIPTS_SUBDIR) != 0 || strlen(LUA_LIBRARIES_WILDCARD) != 0) { // from the /usr/local/share/proxmark3/luascripts/ directory char scripts_path[strlen(PM3_SHARE_PATH) + strlen(LUA_SCRIPTS_SUBDIR) + strlen(LUA_LIBRARIES_WILDCARD) + 1]; strcpy(scripts_path, PM3_SHARE_PATH); diff --git a/tools/fpga_compress/fpga_compress.c b/tools/fpga_compress/fpga_compress.c index bac6a1670..54d2438d2 100644 --- a/tools/fpga_compress/fpga_compress.c +++ b/tools/fpga_compress/fpga_compress.c @@ -337,8 +337,8 @@ static int FpgaGatherVersion(FILE *infile, char *infile_name, char *dst, int len for (uint16_t i = 0; i < fpga_info_len; i++) { char c = (char)fgetc(infile); if (i < sizeof(tempstr)) { - if ( c == '/' ) c = '-'; - if ( c == ' ' ) c = '0'; + if (c == '/') c = '-'; + if (c == ' ') c = '0'; tempstr[i] = c; } }