mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-24 23:15:28 -07:00
Merge 14e2290be7
into 3e50af4ee4
This commit is contained in:
commit
ee484e33e3
1 changed files with 60 additions and 30 deletions
|
@ -537,8 +537,9 @@ int CmdHF14AMfRestore(const char *Cmd)
|
|||
|
||||
int CmdHF14AMfNested(const char *Cmd)
|
||||
{
|
||||
int i, j, res, iterations;
|
||||
int i, j, res, iterations, NumFound, NumFoundOld;
|
||||
sector *e_sector = NULL;
|
||||
bool *triedOnes = NULL;
|
||||
uint8_t blockNo = 0;
|
||||
uint8_t keyType = 0;
|
||||
uint8_t trgBlockNo = 0;
|
||||
|
@ -658,6 +659,8 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
clock_t time1;
|
||||
time1 = clock();
|
||||
|
||||
NumFound = 0; // did not foud a key, yet
|
||||
triedOnes = calloc(2 * SectorsCnt, sizeof(bool));
|
||||
e_sector = calloc(SectorsCnt, sizeof(sector));
|
||||
if (e_sector == NULL) return 1;
|
||||
|
||||
|
@ -687,12 +690,35 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
if (!res) {
|
||||
e_sector[i].Key[j] = key64;
|
||||
e_sector[i].foundKey[j] = 1;
|
||||
NumFound++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// nested sectors
|
||||
|
||||
iterations = 0;
|
||||
do{
|
||||
NumFoundOld = NumFound;
|
||||
// find a new sector or key for the sector
|
||||
for (i = 0; i < SectorsCnt; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
if (e_sector[i].foundKey[j]){
|
||||
if(!triedOnes[2 * i + j]){
|
||||
triedOnes[2 * i + j] = true; // try this one
|
||||
// reset default values
|
||||
num_to_bytes(e_sector[i].Key[j], 6, key);
|
||||
keyType = j;
|
||||
blockNo = FirstBlockOfSector(i);
|
||||
PrintAndLog("\nTrying block %03d type %01d", blockNo, keyType);
|
||||
goto start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start:
|
||||
PrintAndLog("# Keys found so far: %03d \n", NumFound);
|
||||
PrintAndLog("nested...");
|
||||
bool calibrate = true;
|
||||
for (i = 0; i < NESTED_SECTOR_RETRY; i++) {
|
||||
|
@ -708,6 +734,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
case -3 : PrintAndLog("Tag isn't vulnerable to Nested Attack (random numbers are not predictable).\n"); break;
|
||||
default : PrintAndLog("Unknown Error.\n");
|
||||
}
|
||||
free(triedOnes);
|
||||
free(e_sector);
|
||||
return 2;
|
||||
} else {
|
||||
|
@ -721,10 +748,13 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
PrintAndLog("Found valid key:%012"llx, key64);
|
||||
e_sector[sectorNo].foundKey[trgKeyType] = 1;
|
||||
e_sector[sectorNo].Key[trgKeyType] = key64;
|
||||
NumFound++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}while((NumFound != NumFoundOld) && (NumFound < 2 * SectorsCnt));
|
||||
free(triedOnes);
|
||||
|
||||
printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)clock() - time1)/CLOCKS_PER_SEC, ((float)clock() - time1)/iterations/CLOCKS_PER_SEC);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue