mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
make style
This commit is contained in:
parent
99159b3cda
commit
2022df1068
12 changed files with 199 additions and 198 deletions
|
@ -1875,15 +1875,15 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
|
|||
}
|
||||
|
||||
// keep tx buffer in a defined state anyway.
|
||||
/*
|
||||
/*
|
||||
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0x00;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
// Wait for byte be become available in rx holding register
|
||||
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||
|
||||
if ( GetCountSspClk() - foo > timeout) return false;
|
||||
if (GetCountSspClk() - foo > timeout) return false;
|
||||
// if (c >= timeout) return false;
|
||||
|
||||
c++;
|
||||
|
@ -1959,7 +1959,7 @@ bool sendCmdGetResponseWithRetries(uint8_t *command, size_t cmdsize, uint8_t *re
|
|||
// since its called with fixed sized arrays
|
||||
|
||||
// update/write commadn takes 4ms to 15ms before responding
|
||||
if ( command[0] == ICLASS_CMD_UPDATE )
|
||||
if (command[0] == ICLASS_CMD_UPDATE)
|
||||
g_wait = 15000;
|
||||
|
||||
uint8_t got_n = ReaderReceiveIClass(resp);
|
||||
|
|
|
@ -733,9 +733,9 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
|||
size_t bytes_read = 2048;
|
||||
int res = 0;
|
||||
|
||||
switch ( dftype ) {
|
||||
switch (dftype) {
|
||||
case BIN: {
|
||||
res = loadFile(filename, ".bin", (void*)&dump, 2048, &bytes_read);
|
||||
res = loadFile(filename, ".bin", (void *)&dump, 2048, &bytes_read);
|
||||
break;
|
||||
}
|
||||
case EML: {
|
||||
|
@ -751,7 +751,7 @@ static int CmdHFiClassELoad(const char *Cmd) {
|
|||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
if ( res != PM3_SUCCESS ) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
free(dump);
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
@ -811,13 +811,13 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
|||
case 'h':
|
||||
return usage_hf_iclass_decrypt();
|
||||
case 'f':
|
||||
if ( param_getstr(Cmd, cmdp + 1, filename, sizeof(filename) ) == 0) {
|
||||
if (param_getstr(Cmd, cmdp + 1, filename, sizeof(filename)) == 0) {
|
||||
PrintAndLogEx(WARNING, "no filename found after f");
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( loadFile_safe(filename, "", (void**)&decrypted, &decryptedlen) != PM3_SUCCESS ) {
|
||||
if (loadFile_safe(filename, "", (void **)&decrypted, &decryptedlen) != PM3_SUCCESS) {
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
|
@ -840,8 +840,8 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
|||
|
||||
if (errors || cmdp < 1) return usage_hf_iclass_decrypt();
|
||||
|
||||
if ( have_key == false ) {
|
||||
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void**)&keyptr, &keylen);
|
||||
if (have_key == false) {
|
||||
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void **)&keyptr, &keylen);
|
||||
if (res != PM3_SUCCESS)
|
||||
return PM3_EINVARG;
|
||||
|
||||
|
@ -878,7 +878,7 @@ static int CmdHFiClassDecrypt(const char *Cmd) {
|
|||
//Use the first block (CSN) for filename
|
||||
char *fptr = calloc(42, sizeof(uint8_t));
|
||||
strcat(fptr, "hf-iclass-");
|
||||
FillFileNameByUID(fptr, hdr->csn, "-data-decrypted", sizeof(hdr->csn) );
|
||||
FillFileNameByUID(fptr, hdr->csn, "-data-decrypted", sizeof(hdr->csn));
|
||||
|
||||
saveFile(fptr, ".bin", decrypted, decryptedlen);
|
||||
saveFileEML(fptr, decrypted, decryptedlen, 8);
|
||||
|
@ -935,9 +935,9 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
|
|||
|
||||
if (errors || cmdp < 1) return usage_hf_iclass_encrypt();
|
||||
|
||||
if ( have_key == false ) {
|
||||
if (have_key == false) {
|
||||
size_t keylen = 0;
|
||||
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void**)&keyptr, &keylen);
|
||||
int res = loadFile_safe(ICLASS_DECRYPTION_BIN, "", (void **)&keyptr, &keylen);
|
||||
if (res != PM3_SUCCESS)
|
||||
return PM3_EINVARG;
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ static int CmdHFiClassReader_Dump(const char *Cmd) {
|
|||
|
||||
//Use the first block (CSN) for filename
|
||||
strcat(filename, "hf-iclass-");
|
||||
FillFileNameByUID(filename, tag_data, "-data", 8 );
|
||||
FillFileNameByUID(filename, tag_data, "-data", 8);
|
||||
}
|
||||
|
||||
// save the dump to .bin file
|
||||
|
@ -1936,7 +1936,7 @@ static int saveKeys(char *filename) {
|
|||
static int printKeys(void) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++) {
|
||||
if ( memcmp(iClass_Key_Table[i], "\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0)
|
||||
if (memcmp(iClass_Key_Table[i], "\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0)
|
||||
PrintAndLogEx(NORMAL, "%u: %s", i, sprint_hex(iClass_Key_Table[i], 8));
|
||||
else
|
||||
PrintAndLogEx(NORMAL, "%u: "_YELLOW_("%s"), i, sprint_hex(iClass_Key_Table[i], 8));
|
||||
|
@ -2096,7 +2096,7 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
uint16_t keycount = 0;
|
||||
|
||||
// load keys
|
||||
int res = loadFileDICTIONARY_safe(filename, (void**)&keyBlock, 8, &keycount);
|
||||
int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
|
||||
if (res != PM3_SUCCESS || keycount == 0) {
|
||||
free(keyBlock);
|
||||
return res;
|
||||
|
@ -2106,11 +2106,11 @@ static int CmdHFiClassCheckKeys(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Reading tag CSN");
|
||||
for (uint8_t i = 0; i < 10 && !got_csn; i++) {
|
||||
got_csn = select_only(CSN, CCNR, false, false);
|
||||
if ( got_csn == false )
|
||||
if (got_csn == false)
|
||||
PrintAndLogEx(WARNING, "one more try\n");
|
||||
}
|
||||
|
||||
if ( got_csn == false ) {
|
||||
if (got_csn == false) {
|
||||
PrintAndLogEx(WARNING, "Tried 10 times. Can't select card, aborting...");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
@ -2233,12 +2233,12 @@ out:
|
|||
DropField();
|
||||
|
||||
// add to managekeys
|
||||
if ( found_debit ) {
|
||||
for (uint8_t i=0; i< ICLASS_KEYS_MAX; i++) {
|
||||
if (found_debit) {
|
||||
for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++) {
|
||||
// simple check for preexistences
|
||||
if ( memcmp(iClass_Key_Table[i], keyBlock + (key_offset + found_offset) * 8, 8) == 0 ) break;
|
||||
if (memcmp(iClass_Key_Table[i], keyBlock + (key_offset + found_offset) * 8, 8) == 0) break;
|
||||
|
||||
if ( memcmp(iClass_Key_Table[i], "\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0 ) {
|
||||
if (memcmp(iClass_Key_Table[i], "\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0) {
|
||||
memcpy(iClass_Key_Table[i], keyBlock + (key_offset + found_offset) * 8, 8);
|
||||
PrintAndLogEx(SUCCESS, "Added key to keyslot [%d] - "_YELLOW_("`hf iclass managekeys p`")" to view", i);
|
||||
break;
|
||||
|
@ -2295,7 +2295,7 @@ static int CmdHFiClassLookUp(const char *Cmd) {
|
|||
case 'h':
|
||||
return usage_hf_iclass_lookup();
|
||||
case 'f':
|
||||
if ( param_getstr(Cmd, cmdp + 1, filename, sizeof(filename)) < 1 ) {
|
||||
if (param_getstr(Cmd, cmdp + 1, filename, sizeof(filename)) < 1) {
|
||||
PrintAndLogEx(WARNING, "No filename found after f");
|
||||
errors = true;
|
||||
}
|
||||
|
@ -2358,7 +2358,7 @@ static int CmdHFiClassLookUp(const char *Cmd) {
|
|||
uint16_t keycount = 0;
|
||||
|
||||
// load keys
|
||||
int res = loadFileDICTIONARY_safe(filename, (void**)&keyBlock, 8, &keycount);
|
||||
int res = loadFileDICTIONARY_safe(filename, (void **)&keyBlock, 8, &keycount);
|
||||
if (res != PM3_SUCCESS || keycount == 0) {
|
||||
free(keyBlock);
|
||||
return res;
|
||||
|
@ -2395,11 +2395,11 @@ static int CmdHFiClassLookUp(const char *Cmd) {
|
|||
// foudn
|
||||
if (item != NULL) {
|
||||
PrintAndLogEx(SUCCESS, "[debit] found key " _YELLOW_("%s"), sprint_hex(item->key, 8));
|
||||
for (uint8_t i=0; i< ICLASS_KEYS_MAX; i++) {
|
||||
for (uint8_t i = 0; i < ICLASS_KEYS_MAX; i++) {
|
||||
// simple check for preexistences
|
||||
if ( memcmp(item->key, iClass_Key_Table[i], 8) == 0 ) break;
|
||||
if (memcmp(item->key, iClass_Key_Table[i], 8) == 0) break;
|
||||
|
||||
if ( memcmp(iClass_Key_Table[i] , "\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0 ) {
|
||||
if (memcmp(iClass_Key_Table[i], "\x00\x00\x00\x00\x00\x00\x00\x00", 8) == 0) {
|
||||
memcpy(iClass_Key_Table[i], item->key, 8);
|
||||
PrintAndLogEx(SUCCESS, "Added key to keyslot [%d] - "_YELLOW_("`hf iclass managekeys p`")"to view", i);
|
||||
break;
|
||||
|
|
|
@ -774,7 +774,7 @@ static char GetFormatFromSector(uint8_t sectorNo) {
|
|||
}
|
||||
}
|
||||
|
||||
static int FastDumpWithEcFill(uint8_t numsectors){
|
||||
static int FastDumpWithEcFill(uint8_t numsectors) {
|
||||
PacketResponseNG resp;
|
||||
|
||||
mfc_eload_t payload;
|
||||
|
@ -786,7 +786,7 @@ static int FastDumpWithEcFill(uint8_t numsectors){
|
|||
SendCommandNG(CMD_HF_MIFARE_EML_LOAD, (uint8_t *)&payload, sizeof(payload));
|
||||
|
||||
int res = WaitForResponseTimeout(CMD_HF_MIFARE_EML_LOAD, &resp, 2000);
|
||||
if ( res != PM3_SUCCESS) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
}
|
||||
|
||||
// ecfill key B
|
||||
|
@ -795,7 +795,7 @@ static int FastDumpWithEcFill(uint8_t numsectors){
|
|||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_MIFARE_EML_LOAD, (uint8_t *)&payload, sizeof(payload));
|
||||
res = WaitForResponseTimeout(CMD_HF_MIFARE_EML_LOAD, &resp, 2000);
|
||||
if ( res != PM3_SUCCESS) {
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
||||
}
|
||||
return PM3_SUCCESS;
|
||||
|
@ -1287,7 +1287,7 @@ static int CmdHF14AMfNested(const char *Cmd) {
|
|||
|
||||
PrintAndLogEx(SUCCESS, "Testing known keys. Sector count=%d", SectorsCnt);
|
||||
int res = mfCheckKeys_fast(SectorsCnt, true, true, 1, ARRAYLEN(g_mifare_default_keys) + 1, keyBlock, e_sector, false);
|
||||
if ( res == PM3_SUCCESS ) {
|
||||
if (res == PM3_SUCCESS) {
|
||||
// all keys found
|
||||
PrintAndLogEx(SUCCESS, "Fast check found all keys");
|
||||
goto jumptoend;
|
||||
|
@ -1666,7 +1666,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
|||
bool errors = false;
|
||||
|
||||
// Parse the options given by the user
|
||||
while ( (ctmp = param_getchar(Cmd, cmdp)) && !errors ) {
|
||||
while ((ctmp = param_getchar(Cmd, cmdp)) && !errors) {
|
||||
switch (tolower(ctmp)) {
|
||||
case 'h':
|
||||
return usage_hf14_autopwn();
|
||||
|
@ -1760,7 +1760,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( errors ) {
|
||||
if (errors) {
|
||||
return usage_hf14_autopwn();
|
||||
}
|
||||
|
||||
|
@ -1858,7 +1858,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
|||
bool load_success = true;
|
||||
// Load the dictionary
|
||||
if (has_filename) {
|
||||
int res = loadFileDICTIONARY_safe(filename, (void**) &keyBlock, 6, &key_cnt);
|
||||
int res = loadFileDICTIONARY_safe(filename, (void **) &keyBlock, 6, &key_cnt);
|
||||
if (res != PM3_SUCCESS || key_cnt == 0 || keyBlock == NULL) {
|
||||
PrintAndLogEx(FAILED, "An error occurred while loading the dictionary! (we will use the default keys now)");
|
||||
if (keyBlock != NULL)
|
||||
|
@ -1869,7 +1869,7 @@ static int CmdHF14AMfAutoPWN(const char *Cmd) {
|
|||
|
||||
}
|
||||
|
||||
if ( has_filename == false || load_success == false ) {
|
||||
if (has_filename == false || load_success == false) {
|
||||
keyBlock = calloc(ARRAYLEN(g_mifare_default_keys), 6);
|
||||
if (keyBlock == NULL) {
|
||||
free(e_sector);
|
||||
|
@ -2526,7 +2526,7 @@ out:
|
|||
|
||||
printKeyTable(sectorsCnt, e_sector);
|
||||
|
||||
if ( use_flashmemory && found_keys == (sectorsCnt << 1) ) {
|
||||
if (use_flashmemory && found_keys == (sectorsCnt << 1)) {
|
||||
PrintAndLogEx(SUCCESS, "Card dumped aswell. run " _YELLOW_("`%s %c`"),
|
||||
"hf mf esave",
|
||||
GetFormatFromSector(sectorsCnt)
|
||||
|
@ -2552,7 +2552,7 @@ out:
|
|||
}
|
||||
PrintAndLogEx(SUCCESS, "Found keys have been transferred to the emulator memory");
|
||||
|
||||
if ( found_keys == (sectorsCnt << 1) ) {
|
||||
if (found_keys == (sectorsCnt << 1)) {
|
||||
FastDumpWithEcFill(sectorsCnt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2128,7 +2128,7 @@ static int CmdT55xxChkPwds(const char *Cmd) {
|
|||
if (use_pwd_file) {
|
||||
uint16_t keycount = 0;
|
||||
|
||||
int res = loadFileDICTIONARY_safe(filename, (void**) &keyBlock, 4, &keycount);
|
||||
int res = loadFileDICTIONARY_safe(filename, (void **) &keyBlock, 4, &keycount);
|
||||
if (res != PM3_SUCCESS || keycount == 0 || keyBlock == NULL) {
|
||||
PrintAndLogEx(WARNING, "No keys found in file");
|
||||
if (keyBlock != NULL)
|
||||
|
|
|
@ -721,7 +721,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
char line[255];
|
||||
|
||||
// allocate some space for the dictionary
|
||||
*pdata = calloc( block_size , sizeof(uint8_t));
|
||||
*pdata = calloc(block_size, sizeof(uint8_t));
|
||||
if (*pdata == NULL)
|
||||
return PM3_EFILE;
|
||||
|
||||
|
@ -731,13 +731,14 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
if (!f) {
|
||||
PrintAndLogEx(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", path);
|
||||
retval = PM3_EFILE;
|
||||
goto out; }
|
||||
goto out;
|
||||
}
|
||||
|
||||
// read file
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
|
||||
// check if we have enough space (if not allocate more)
|
||||
if ( (*keycnt * (keylen >> 1) ) >= mem_size ) {
|
||||
if ((*keycnt * (keylen >> 1)) >= mem_size) {
|
||||
|
||||
mem_size += block_size;
|
||||
*pdata = realloc(*pdata, mem_size);
|
||||
|
@ -767,7 +768,7 @@ int loadFileDICTIONARY_safe(const char *preferredName, void **pdata, uint8_t key
|
|||
|
||||
uint64_t key = strtoull(line, NULL, 16);
|
||||
|
||||
num_to_bytes(key, keylen >> 1, *pdata + (*keycnt * (keylen >> 1)) );
|
||||
num_to_bytes(key, keylen >> 1, *pdata + (*keycnt * (keylen >> 1)));
|
||||
|
||||
(*keycnt)++;
|
||||
|
||||
|
|
|
@ -543,7 +543,7 @@ int bruteforceFile(const char *filename, uint16_t keytable[]) {
|
|||
|
||||
size_t dumplen = 0;
|
||||
uint8_t *dump = NULL;
|
||||
if ( loadFile_safe(filename, "", (void**)&dump, &dumplen) != PM3_SUCCESS ) {
|
||||
if (loadFile_safe(filename, "", (void **)&dump, &dumplen) != PM3_SUCCESS) {
|
||||
return PM3_EFILE;
|
||||
}
|
||||
|
||||
|
|
|
@ -655,19 +655,19 @@ static int doTestsWithKnownInputs() {
|
|||
}
|
||||
|
||||
|
||||
static bool readKeyFile(uint8_t* key, size_t keylen) {
|
||||
static bool readKeyFile(uint8_t *key, size_t keylen) {
|
||||
|
||||
size_t len = 0;
|
||||
uint8_t *keyptr = NULL;
|
||||
if ( loadFile_safe("iclass_key.bin", "", (void**)&keyptr, &len) != PM3_SUCCESS ) {
|
||||
if (loadFile_safe("iclass_key.bin", "", (void **)&keyptr, &len) != PM3_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( keylen != len ) {
|
||||
if (keylen != len) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(key, keyptr, keylen );
|
||||
memcpy(key, keyptr, keylen);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,10 +64,10 @@ int searchHomeFilePath(char **foundpath, const char *filename, bool create_home)
|
|||
#ifdef _WIN32
|
||||
struct _stat st;
|
||||
// Mingw _stat fails if path ends with /, so let's use a stripped path
|
||||
if (path[strlen(path)-1]=='/') {
|
||||
path[strlen(path)-1]='\0';
|
||||
if (path[strlen(path) - 1] == '/') {
|
||||
path[strlen(path) - 1] = '\0';
|
||||
result = _stat(path, &st);
|
||||
path[strlen(path)]='/';
|
||||
path[strlen(path)] = '/';
|
||||
} else {
|
||||
result = _stat(path, &st);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue