make style (excepted cmdhficlass...)

This commit is contained in:
Philippe Teuwen 2019-08-26 22:28:39 +02:00
parent 9c677e045e
commit 16a7cfd7b2
9 changed files with 120 additions and 115 deletions

View file

@ -1992,7 +1992,7 @@ TEST2:
int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true);
if (res == 2) {
if (cuid == 0xAA55C396 ) {
if (cuid == 0xAA55C396) {
isGen = GEN_UNFUSED;
goto OUT;
}

View file

@ -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);
}

View file

@ -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<sectors_cnt; i++) {
for (i2=0; i2<2; i2++) {
for (i = 0; i < sectors_cnt; i++) {
for (i2 = 0; i2 < 2; i2++) {
e_sector[i].Key[i2] = 0;
e_sector[i].foundKey[i2] = 0;
}
@ -1744,8 +1744,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
PrintAndLogEx(WARNING, "Let's see if just the sector or key type are not correct, and then we also give the dictionary a try ;)");
}
// Check if the user supplied key is used by other sectors
for (i=0; i<sectors_cnt; i++) {
for (i2=0; i2<2; i2++) {
for (i = 0; i < sectors_cnt; i++) {
for (i2 = 0; i2 < 2; i2++) {
if (e_sector[i].foundKey[i2] == 0) {
if (mfCheckKeys(FirstBlockOfSector(i), i2, true, 1, key, &key64) == PM3_SUCCESS) {
e_sector[i].Key[i2] = bytes_to_num(key, 6);
@ -1759,7 +1759,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
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,
@ -1803,14 +1804,15 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
PrintAndLogEx(INFO, "Enumerating the card keys with the dictionary!");
if (legacy_mfchk) {
// Check all the sectors
for (i=0; i<sectors_cnt; i++) {
for (i2=0; i2<2; i2++) {
for (i = 0; i < sectors_cnt; i++) {
for (i2 = 0; i2 < 2; i2++) {
// Check if the key is known
if (e_sector[i].foundKey[i2] == 0) {
for (i3=0; i3<key_cnt; i3++) {
printf("."); fflush(stdout);
if (mfCheckKeys(FirstBlockOfSector(i), i2, true, 1, (keyBlock + (6*i3)), &key64) == PM3_SUCCESS) {
e_sector[i].Key[i2] = bytes_to_num((keyBlock + (6*i3)), 6);
for (i3 = 0; i3 < key_cnt; i3++) {
printf(".");
fflush(stdout);
if (mfCheckKeys(FirstBlockOfSector(i), i2, true, 1, (keyBlock + (6 * i3)), &key64) == PM3_SUCCESS) {
e_sector[i].Key[i2] = bytes_to_num((keyBlock + (6 * i3)), 6);
e_sector[i].foundKey[i2] = 1;
break;
}
@ -1818,7 +1820,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
}
}
}
printf("\n"); fflush(stdout);
printf("\n");
fflush(stdout);
} else {
int chunksize = key_cnt > (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,8 +1856,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
}
// Analyse the dictionary attack
for (i=0; i<sectors_cnt; i++) {
for (i2=0; i2<2; i2++) {
for (i = 0; i < sectors_cnt; i++) {
for (i2 = 0; i2 < 2; i2++) {
if (e_sector[i].foundKey[i2] == 1) {
num_to_bytes(e_sector[i].Key[i2], 6, tmp_key);
PrintAndLogEx(SUCCESS, "[ DICT. KEY ] Valid KEY FOUND: sector:%3d key type:%c key: " _YELLOW_("0x%02x%02x%02x%02x%02x%02x"),
@ -1862,7 +1869,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
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,
@ -1914,7 +1922,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
e_sector[blockNo].Key[keyType] = bytes_to_num(key, 6);
e_sector[blockNo].foundKey[keyType] = 2;
} else {
noValidKeyFound:
noValidKeyFound:
PrintAndLogEx(FAILED, "No usable key was found!");
free(keyBlock);
free(e_sector);
@ -1927,8 +1935,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
bool nested_failed = false;
// Iterate over each sector and key(A/B)
for (current_sector_i=0; current_sector_i < sectors_cnt; current_sector_i++) {
for (current_key_type_i=0; current_key_type_i < 2; current_key_type_i++) {
for (current_sector_i = 0; current_sector_i < sectors_cnt; current_sector_i++) {
for (current_key_type_i = 0; current_key_type_i < 2; current_key_type_i++) {
// If the key is already known, just skip it
if (e_sector[current_sector_i].foundKey[current_key_type_i] == 0) {
@ -1937,8 +1945,8 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
if (bytes_to_num(tmp_key, 6) != 0) {
// <!> 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; i<sectors_cnt; i++) {
for (i2=0; i2<2; i2++) {
for (i = 0; i < sectors_cnt; i++) {
for (i2 = 0; i2 < 2; i2++) {
// Check if the sector key is already broken
if (e_sector[i].foundKey[i2] == 0) {
// Check if the key works
@ -2072,7 +2080,7 @@ tryHardnested: // If the nested attack fails then we try the hardnested attack
createMfcKeyDump(sectors_cnt, e_sector, GenerateFilename("hf-mf-", "-key.bin"));
PrintAndLogEx(SUCCESS, "Transferring the found keys to the simulator memory (Cmd Error: 04 can occur, but this shouldn't be a problem)");
for (current_sector_i=0; current_sector_i < sectors_cnt; current_sector_i++) {
for (current_sector_i = 0; current_sector_i < sectors_cnt; current_sector_i++) {
mfEmlGetMem(block, current_sector_i, 1);
if (e_sector[current_sector_i].foundKey[0])
num_to_bytes(e_sector[current_sector_i].Key[0], 6, block);

View file

@ -287,7 +287,7 @@ int saveFileJSON(const char *preferredName, JSONFileType ftype, uint8_t *data, s
memcpy(uid, data, 8);
JsonSaveBufAsHexCompact(root, "$.Card.UID", uid, sizeof(uid));
for (size_t i = 0; i < (datalen / 8 ); i++) {
for (size_t i = 0; i < (datalen / 8); i++) {
char path[PATH_MAX_LENGTH] = {0};
sprintf(path, "$blocks.%zu", i);
JsonSaveBufAsHexCompact(root, path, data + (i * 8), 8);
@ -311,7 +311,7 @@ out:
return retval;
}
int createMfcKeyDump(uint8_t sectorsCnt, sector_t *e_sector, char* fptr) {
int createMfcKeyDump(uint8_t sectorsCnt, sector_t *e_sector, char *fptr) {
uint8_t tmpKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
int i;
@ -694,7 +694,7 @@ static int filelist(const char *path, const char *ext, bool last) {
PrintAndLogEx(NORMAL, "%s── %s", last ? "" : "", path);
for (uint16_t i = 0; i < n; i++) {
if (((ext == NULL) && (namelist[i]->d_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;
}
}

View file

@ -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.

View file

@ -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) {

View file

@ -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,7 +502,7 @@ 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 )
if (errors)
break;
}
free(attack);
@ -510,7 +510,7 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
PrintAndLogEx(SUCCESS, "time: %" PRIu64 " seconds", t1 / 1000);
if ( errors ) {
if (errors) {
PrintAndLogEx(ERR, "loclass exiting. Try run " _YELLOW_("`hf iclass sim 2`") "again and collect new data");
return 1;
}

View file

@ -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);

View file

@ -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;
}
}