mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-23 06:25:28 -07:00
Added key check to nested command and some refactoring
This commit is contained in:
parent
997f1e4886
commit
76fcccd109
1 changed files with 50 additions and 25 deletions
|
@ -526,10 +526,10 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
uint8_t trgKeyType = 0;
|
uint8_t trgKeyType = 0;
|
||||||
uint8_t SectorsCnt = 0;
|
uint8_t SectorsCnt = 0;
|
||||||
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
||||||
uint8_t keyBlock[14*6];
|
uint8_t keyBlock[14 * 6];
|
||||||
uint64_t key64 = 0;
|
uint64_t key64 = 0;
|
||||||
bool transferToEml = false;
|
|
||||||
|
|
||||||
|
bool transferToEml = false;
|
||||||
bool createDumpFile = false;
|
bool createDumpFile = false;
|
||||||
FILE *fkeys;
|
FILE *fkeys;
|
||||||
uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
uint8_t standart[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
@ -555,8 +555,8 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
|
|
||||||
cmdp = param_getchar(Cmd, 0);
|
cmdp = param_getchar(Cmd, 0);
|
||||||
blockNo = param_get8(Cmd, 1);
|
blockNo = param_get8(Cmd, 1);
|
||||||
ctmp = param_getchar(Cmd, 2);
|
|
||||||
|
|
||||||
|
ctmp = param_getchar(Cmd, 2);
|
||||||
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
||||||
PrintAndLog("Key type must be A or B");
|
PrintAndLog("Key type must be A or B");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -570,35 +570,42 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdp == 'o' || cmdp == 'O') {
|
switch (cmdp) {
|
||||||
cmdp = 'o';
|
case 'o':
|
||||||
trgBlockNo = param_get8(Cmd, 4);
|
case 'O':
|
||||||
ctmp = param_getchar(Cmd, 5);
|
cmdp = 'o';
|
||||||
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
trgBlockNo = param_get8(Cmd, 4);
|
||||||
PrintAndLog("Target key type must be A or B");
|
ctmp = param_getchar(Cmd, 5);
|
||||||
return 1;
|
if (ctmp != 'a' && ctmp != 'A' && ctmp != 'b' && ctmp != 'B') {
|
||||||
}
|
PrintAndLog("Target key type must be A or B");
|
||||||
if (ctmp != 'A' && ctmp != 'a')
|
return 1;
|
||||||
trgKeyType = 1;
|
}
|
||||||
} else {
|
if (ctmp != 'A' && ctmp != 'a')
|
||||||
|
trgKeyType = 1;
|
||||||
switch (cmdp) {
|
break;
|
||||||
case '0': SectorsCnt = 05; break;
|
case '0': SectorsCnt = 05; break;
|
||||||
case '1': SectorsCnt = 16; break;
|
case '1': SectorsCnt = 16; break;
|
||||||
case '2': SectorsCnt = 32; break;
|
case '2': SectorsCnt = 32; break;
|
||||||
case '4': SectorsCnt = 40; break;
|
case '4': SectorsCnt = 40; break;
|
||||||
default: SectorsCnt = 16;
|
default: SectorsCnt = 16;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctmp = param_getchar(Cmd, 4);
|
ctmp = param_getchar(Cmd, 4);
|
||||||
if (ctmp == 't' || ctmp == 'T') transferToEml = true;
|
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
||||||
else if (ctmp == 'd' || ctmp == 'D') createDumpFile = true;
|
createDumpFile |= (ctmp == 'd' || ctmp == 'D');
|
||||||
|
|
||||||
ctmp = param_getchar(Cmd, 6);
|
ctmp = param_getchar(Cmd, 6);
|
||||||
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
transferToEml |= (ctmp == 't' || ctmp == 'T');
|
||||||
transferToEml |= (ctmp == 'd' || ctmp == 'D');
|
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
|
||||||
if (cmdp == 'o') {
|
if (cmdp == 'o') {
|
||||||
PrintAndLog("--target block no:%3d, target key type:%c ", trgBlockNo, trgKeyType?'B':'A');
|
PrintAndLog("--target block no:%3d, target key type:%c ", trgBlockNo, trgKeyType?'B':'A');
|
||||||
int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true);
|
int16_t isOK = mfnested(blockNo, keyType, key, trgBlockNo, trgKeyType, keyBlock, true);
|
||||||
|
@ -672,6 +679,24 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get known key
|
||||||
|
if (false) {
|
||||||
|
key64 = bytes_to_num(keyBlock, 6);
|
||||||
|
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
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't found a key....
|
||||||
|
if (i == SectorsCnt - 1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// nested sectors
|
// nested sectors
|
||||||
iterations = 0;
|
iterations = 0;
|
||||||
PrintAndLog("nested...");
|
PrintAndLog("nested...");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue