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