fix 'lf pcf7931 bruteforce' (bug reported in http://www.proxmark.org/forum/viewtopic.php?id=6490)

(and whitespace fixes)
This commit is contained in:
pwpiwi 2019-05-22 18:55:02 +02:00
commit 42c135a3b9
2 changed files with 83 additions and 89 deletions

View file

@ -401,13 +401,7 @@ void BruteForcePCF7931(uint64_t password, uint8_t tries, uint16_t init_delay, in
return;
}
pass_array[0] = password & 0xFF;
pass_array[1] = (password >> 8) & 0xFF;
pass_array[2] = (password >> 16) & 0xFF;
pass_array[3] = (password >> 24) & 0xFF;
pass_array[4] = (password >> 32) & 0xFF;
pass_array[5] = (password >> 40) & 0xFF;
pass_array[6] = (password >> 48) & 0xFF;
num_to_bytes(password, 7, pass_array);
Dbprintf("Trying: %02x %02x %02x %02x %02x %02x %02x ...",
pass_array[0],

View file

@ -180,24 +180,24 @@ int CmdLFPCF7931BruteForce(const char *Cmd){
uint8_t ctmp = param_getchar(Cmd, 0);
if (strlen(Cmd) < 1 || ctmp == 'h' || ctmp == 'H') return usage_pcf7931_bruteforce();
uint64_t start_password = 0;
uint8_t start_password[7] = {0};
uint8_t tries = 3;
if (param_gethex(Cmd, 0, (uint8_t*)(&start_password), 14)) return usage_pcf7931_bruteforce();
if (param_gethex(Cmd, 0, start_password, 14)) return usage_pcf7931_bruteforce();
if (param_getdec(Cmd, 1, &tries)) return usage_pcf7931_bruteforce();
PrintAndLog("Bruteforcing from password: %02x %02x %02x %02x %02x %02x %02x",
start_password & 0xFF,
(start_password >> 8) & 0xFF,
(start_password >> 16) & 0xFF,
(start_password >> 24) & 0xFF,
(start_password >> 32) & 0xFF,
(start_password >> 48) & 0xFF,
(start_password >> 56) & 0xFF);
start_password[0],
start_password[1],
start_password[2],
start_password[3],
start_password[4],
start_password[5],
start_password[6]);
PrintAndLog("Trying each password %d times", tries);
UsbCommand c = {CMD_PCF7931_BRUTEFORCE, {start_password, tries} };
UsbCommand c = {CMD_PCF7931_BRUTEFORCE, {bytes_to_num(start_password, 7), tries} };
c.d.asDwords[7] = (configPcf.OffsetWidth + 128);
c.d.asDwords[8] = (configPcf.OffsetPosition + 128);