mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 22:23:38 -07:00
Added nested auto mode. it checks known keys and thel launches nested
This commit is contained in:
parent
136dde0bb9
commit
2709391d3b
1 changed files with 71 additions and 47 deletions
|
@ -530,6 +530,8 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
uint8_t keyBlock[NESTED_KEY_COUNT * 6];
|
||||
uint64_t key64 = 0;
|
||||
|
||||
bool autosearchKey = false;
|
||||
|
||||
bool transferToEml = false;
|
||||
bool createDumpFile = false;
|
||||
FILE *fkeys;
|
||||
|
@ -543,7 +545,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
PrintAndLog(" all sectors: hf mf nested <card memory> <block number> <key A/B> <key (12 hex symbols)> [t,d]");
|
||||
PrintAndLog(" one sector: hf mf nested o <block number> <key A/B> <key (12 hex symbols)>");
|
||||
PrintAndLog(" <target block number> <target key A/B> [t]");
|
||||
// PrintAndLog(" all sectors autosearch key: hf mf nested s <card memory> [t,d]");
|
||||
PrintAndLog(" all sectors autosearch key: hf mf nested <card memory> * [t,d]");
|
||||
PrintAndLog("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, <other> - 1K");
|
||||
PrintAndLog("t - transfer keys into emulator memory");
|
||||
PrintAndLog("d - write keys to binary file");
|
||||
|
@ -556,22 +558,6 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
}
|
||||
|
||||
cmdp = param_getchar(Cmd, 0);
|
||||
blockNo = param_get8(Cmd, 1);
|
||||
|
||||
ctmp = param_getchar(Cmd, 2);
|
||||
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
||||
PrintAndLog("Key type must be A or B");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ctmp != 'A' && ctmp != 'a')
|
||||
keyType = 1;
|
||||
|
||||
if (param_gethex(Cmd, 3, key, 12)) {
|
||||
PrintAndLog("Key must include 12 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (cmdp) {
|
||||
case 'o':
|
||||
case 'O':
|
||||
|
@ -593,6 +579,29 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
default: SectorsCnt = 16;
|
||||
}
|
||||
|
||||
if (param_getchar(Cmd, 1) == '*') {
|
||||
autosearchKey = true;
|
||||
|
||||
ctmp = param_getchar(Cmd, 2);
|
||||
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
||||
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
||||
} else {
|
||||
blockNo = param_get8(Cmd, 1);
|
||||
|
||||
ctmp = param_getchar(Cmd, 2);
|
||||
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
||||
PrintAndLog("Key type must be A or B");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ctmp != 'A' && ctmp != 'a')
|
||||
keyType = 1;
|
||||
|
||||
if (param_gethex(Cmd, 3, key, 12)) {
|
||||
PrintAndLog("Key must include 12 HEX symbols");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ctmp = param_getchar(Cmd, 4);
|
||||
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
||||
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
||||
|
@ -607,6 +616,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
PrintAndLog("Can't authenticate to block:%3d key type:%c key:%s", blockNo, keyType?'B':'A', sprint_hex(key, 6));
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
// one-sector nested
|
||||
if (cmdp == 'o') {
|
||||
|
@ -675,7 +685,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
for (j = 0; j < 2; j++) {
|
||||
if (e_sector[i].foundKey[j]) continue;
|
||||
|
||||
res = mfCheckKeys(FirstBlockOfSector(i), j, true, NESTED_KEY_COUNT, keyBlock, &key64); // bbbuuuuggg!!!!!!!!
|
||||
res = mfCheckKeys(FirstBlockOfSector(i), j, true, NESTED_KEY_COUNT, keyBlock, &key64);
|
||||
|
||||
if (!res) {
|
||||
e_sector[i].Key[j] = key64;
|
||||
|
@ -685,34 +695,48 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
}
|
||||
|
||||
|
||||
// PrintAndLog("---- known key:");
|
||||
// PrintAndLog("|sec|key A |res|key B |res|");
|
||||
// for (i = 0; i < SectorsCnt; i++) {
|
||||
// PrintAndLog("|%03d| %012" PRIx64 " | %d | %012" PRIx64 " | %d |", i,
|
||||
// e_sector[i].Key[0], e_sector[i].foundKey[0], e_sector[i].Key[1], e_sector[i].foundKey[1]);
|
||||
// }
|
||||
// PrintAndLog("|---|----------------|---|----------------|---|");
|
||||
|
||||
|
||||
// return 0;
|
||||
|
||||
// get known key
|
||||
if (false) {
|
||||
key64 = bytes_to_num(keyBlock, 6);
|
||||
|
||||
|
||||
|
||||
PrintAndLog("---- known key:");
|
||||
PrintAndLog("|sec|key A |res|key B |res|");
|
||||
for (i = 0; i < SectorsCnt; i++) {
|
||||
PrintAndLog("|%03d| %012" PRIx64 " | %d | %012" PRIx64 " | %d |", i,
|
||||
e_sector[i].Key[0], e_sector[i].foundKey[0], e_sector[i].Key[1], e_sector[i].foundKey[1]);
|
||||
}
|
||||
PrintAndLog("|---|----------------|---|----------------|---|");
|
||||
|
||||
|
||||
// get known key from array
|
||||
bool keyFound = false;
|
||||
if (autosearchKey) {
|
||||
for (i = 0; i < SectorsCnt; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
if (e_sector[i].foundKey[j] && e_sector[i].Key[j] == key64) {
|
||||
// get here
|
||||
if (e_sector[i].foundKey[j]) {
|
||||
// get known key
|
||||
blockNo = i * 4;
|
||||
keyType = j;
|
||||
num_to_bytes(e_sector[i].Key[j], 6, key);
|
||||
|
||||
keyFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (keyFound) break;
|
||||
}
|
||||
|
||||
// Can't found a key....
|
||||
if (i == SectorsCnt - 1) {
|
||||
if (!keyFound) {
|
||||
PrintAndLog("Can't found any of the known keys.");
|
||||
return 4;
|
||||
}
|
||||
PrintAndLog("--auto key. block no:%3d, key type:%c key:%s", blockNo, keyType?'B':'A', sprint_hex(key, 6));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// return 0;
|
||||
|
||||
// nested sectors
|
||||
iterations = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue