mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-01 02:27:21 +08:00
EM4x05 dump: show when lock bits are unknown and show active PR word
This commit is contained in:
parent
9395b9581f
commit
ad6632beee
1 changed files with 18 additions and 8 deletions
|
@ -951,6 +951,8 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||||
int success = PM3_SUCCESS;
|
int success = PM3_SUCCESS;
|
||||||
int status;
|
int status;
|
||||||
uint32_t lock_bits = 0x00; // no blocks locked
|
uint32_t lock_bits = 0x00; // no blocks locked
|
||||||
|
bool gotLockBits = false;
|
||||||
|
bool lockInPW2 = false;
|
||||||
uint32_t word = 0;
|
uint32_t word = 0;
|
||||||
const char *info[] = {"Info/User", "UID", "Password", "User", "Config", "User", "User", "User", "User", "User", "User", "User", "User", "User", "Lock", "Lock"};
|
const char *info[] = {"Info/User", "UID", "Password", "User", "Config", "User", "User", "User", "User", "User", "User", "User", "User", "User", "Lock", "Lock"};
|
||||||
|
|
||||||
|
@ -971,8 +973,10 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||||
if (status == PM3_SUCCESS) {
|
if (status == PM3_SUCCESS) {
|
||||||
if (!usePwd)
|
if (!usePwd)
|
||||||
needReadPwd = false;
|
needReadPwd = false;
|
||||||
if (word != 0x00)
|
if (word != 0x00) {
|
||||||
lock_bits = word;
|
lock_bits = word;
|
||||||
|
gotLockBits = true;
|
||||||
|
}
|
||||||
data[14] = word;
|
data[14] = word;
|
||||||
gotWord14 = true;
|
gotWord14 = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -980,22 +984,26 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||||
}
|
}
|
||||||
status = EM4x05ReadWord_ext(15, pwd, usePwd, &word);
|
status = EM4x05ReadWord_ext(15, pwd, usePwd, &word);
|
||||||
if (status == PM3_SUCCESS) {
|
if (status == PM3_SUCCESS) {
|
||||||
if (word != 0x00) // assume block 15 is the current lock block
|
if (word != 0x00) { // assume block 15 is the current lock block
|
||||||
lock_bits = word;
|
lock_bits = word;
|
||||||
|
gotLockBits = true;
|
||||||
|
lockInPW2 = true;
|
||||||
|
}
|
||||||
data[15] = word;
|
data[15] = word;
|
||||||
gotWord15 = true;
|
gotWord15 = true;
|
||||||
} else {
|
} else {
|
||||||
success = PM3_ESOFT; // If any error ensure fail is set so not to save invalid data
|
success = PM3_ESOFT; // If any error ensure fail is set so not to save invalid data
|
||||||
}
|
}
|
||||||
|
uint32_t lockbit;
|
||||||
// Now read blocks 0 - 13 as we have 14 and 15
|
// Now read blocks 0 - 13 as we have 14 and 15
|
||||||
for (; addr < 14; addr++) {
|
for (; addr < 14; addr++) {
|
||||||
|
lockbit = (lock_bits >> addr) & 1;
|
||||||
if (addr == 2) {
|
if (addr == 2) {
|
||||||
if (usePwd) {
|
if (usePwd) {
|
||||||
if ((needReadPwd) && (success != PM3_ESOFT)) {
|
if ((needReadPwd) && (success != PM3_ESOFT)) {
|
||||||
data[addr] = BSWAP_32(pwd);
|
data[addr] = BSWAP_32(pwd);
|
||||||
num_to_bytes(pwd, 4, bytes);
|
num_to_bytes(pwd, 4, bytes);
|
||||||
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %s | %s", addr, pwd, sprint_ascii(bytes, 4), ((lock_bits >> addr) & 1) ? _RED_("x") : " ", info[addr]);
|
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %s | %s", addr, pwd, sprint_ascii(bytes, 4), gotLockBits ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?"), info[addr]);
|
||||||
} else {
|
} else {
|
||||||
// The pwd is not needed for Login so we're not sure what's the actual content of that block
|
// The pwd is not needed for Login so we're not sure what's the actual content of that block
|
||||||
PrintAndLogEx(NORMAL, " %02u | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
PrintAndLogEx(NORMAL, " %02u | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
||||||
|
@ -1012,7 +1020,7 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||||
data[addr] = BSWAP_32(word);
|
data[addr] = BSWAP_32(word);
|
||||||
if (status == PM3_SUCCESS) {
|
if (status == PM3_SUCCESS) {
|
||||||
num_to_bytes(word, 4, bytes);
|
num_to_bytes(word, 4, bytes);
|
||||||
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %s | %s", addr, word, sprint_ascii(bytes, 4), ((lock_bits >> addr) & 1) ? _RED_("x") : " ", info[addr]);
|
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %s | %s", addr, word, sprint_ascii(bytes, 4), gotLockBits ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?"), info[addr]);
|
||||||
} else
|
} else
|
||||||
PrintAndLogEx(NORMAL, " %02u | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
PrintAndLogEx(NORMAL, " %02u | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
||||||
}
|
}
|
||||||
|
@ -1021,13 +1029,15 @@ static int CmdEM4x05Dump(const char *Cmd) {
|
||||||
// Both lock bits are protected with bit idx 14 (special case)
|
// Both lock bits are protected with bit idx 14 (special case)
|
||||||
if (gotWord14) {
|
if (gotWord14) {
|
||||||
addr = 14;
|
addr = 14;
|
||||||
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %s | %s", addr, data[addr], sprint_ascii(bytes, 4), ((lock_bits >> 14) & 1) ? _RED_("x") : " ", info[addr]);
|
lockbit = (lock_bits >> addr) & 1;
|
||||||
|
PrintAndLogEx(NORMAL, " %02u | %08X | %s | %s | %-10s %s", addr, data[addr], sprint_ascii(bytes, 4), gotLockBits ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?"), info[addr], lockInPW2 ? "" : _GREEN_("active"));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, " %02u | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
PrintAndLogEx(NORMAL, " %02u | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
||||||
}
|
}
|
||||||
if (gotWord15) {
|
if (gotWord15) {
|
||||||
addr = 15; // beware lock bit of word15 is pr14
|
addr = 15;
|
||||||
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %s | %s", addr, data[addr], sprint_ascii(bytes, 4), ((lock_bits >> 14) & 1) ? _RED_("x") : " ", info[addr]);
|
lockbit = (lock_bits >> 14) & 1; // beware lock bit of word15 is pr14
|
||||||
|
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %s | %-10s %s", addr, data[addr], sprint_ascii(bytes, 4), gotLockBits ? (lockbit ? _RED_("x") : " ") : _YELLOW_("?"), info[addr], lockInPW2 ? _GREEN_("active") : "");
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(NORMAL, " %02d | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
PrintAndLogEx(NORMAL, " %02d | | | | %-10s " _RED_("cannot read"), addr, info[addr]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue