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
118
client/cmdhfmf.c
118
client/cmdhfmf.c
|
@ -529,6 +529,8 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
||||||
uint8_t keyBlock[NESTED_KEY_COUNT * 6];
|
uint8_t keyBlock[NESTED_KEY_COUNT * 6];
|
||||||
uint64_t key64 = 0;
|
uint64_t key64 = 0;
|
||||||
|
|
||||||
|
bool autosearchKey = false;
|
||||||
|
|
||||||
bool transferToEml = false;
|
bool transferToEml = false;
|
||||||
bool createDumpFile = false;
|
bool createDumpFile = false;
|
||||||
|
@ -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(" 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(" 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(" <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("card memory - 0 - MINI(320 bytes), 1 - 1K, 2 - 2K, 4 - 4K, <other> - 1K");
|
||||||
PrintAndLog("t - transfer keys into emulator memory");
|
PrintAndLog("t - transfer keys into emulator memory");
|
||||||
PrintAndLog("d - write keys to binary file");
|
PrintAndLog("d - write keys to binary file");
|
||||||
|
@ -556,22 +558,6 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdp = param_getchar(Cmd, 0);
|
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) {
|
switch (cmdp) {
|
||||||
case 'o':
|
case 'o':
|
||||||
case 'O':
|
case 'O':
|
||||||
|
@ -593,19 +579,43 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
default: SectorsCnt = 16;
|
default: SectorsCnt = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctmp = param_getchar(Cmd, 4);
|
if (param_getchar(Cmd, 1) == '*') {
|
||||||
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
autosearchKey = true;
|
||||||
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
|
||||||
|
|
||||||
ctmp = param_getchar(Cmd, 6);
|
ctmp = param_getchar(Cmd, 2);
|
||||||
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
||||||
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
||||||
|
} else {
|
||||||
|
blockNo = param_get8(Cmd, 1);
|
||||||
|
|
||||||
// check if we can authenticate to sector
|
ctmp = param_getchar(Cmd, 2);
|
||||||
res = mfCheckKeys(blockNo, keyType, true, 1, key, &key64);
|
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
||||||
if (res) {
|
PrintAndLog("Key type must be A or B");
|
||||||
PrintAndLog("Can't authenticate to block:%3d key type:%c key:%s", blockNo, keyType?'B':'A', sprint_hex(key, 6));
|
return 1;
|
||||||
return 3;
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
|
ctmp = param_getchar(Cmd, 6);
|
||||||
|
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
||||||
|
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
||||||
|
|
||||||
|
// check if we can authenticate to sector
|
||||||
|
res = mfCheckKeys(blockNo, keyType, true, 1, key, &key64);
|
||||||
|
if (res) {
|
||||||
|
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
|
// one-sector nested
|
||||||
|
@ -675,7 +685,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
if (e_sector[i].foundKey[j]) continue;
|
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) {
|
if (!res) {
|
||||||
e_sector[i].Key[j] = key64;
|
e_sector[i].Key[j] = key64;
|
||||||
|
@ -685,35 +695,49 @@ 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 (i = 0; i < SectorsCnt; i++) {
|
||||||
for (j = 0; j < 2; j++) {
|
for (j = 0; j < 2; j++) {
|
||||||
if (e_sector[i].foundKey[j] && e_sector[i].Key[j] == key64) {
|
if (e_sector[i].foundKey[j]) {
|
||||||
// get here
|
// get known key
|
||||||
|
blockNo = i * 4;
|
||||||
|
keyType = j;
|
||||||
|
num_to_bytes(e_sector[i].Key[j], 6, key);
|
||||||
|
|
||||||
|
keyFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (keyFound) break;
|
||||||
// Can't found a key....
|
|
||||||
if (i == SectorsCnt - 1) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Can't found a key....
|
||||||
|
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
|
// nested sectors
|
||||||
iterations = 0;
|
iterations = 0;
|
||||||
PrintAndLog("nested...");
|
PrintAndLog("nested...");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue