mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-19 22:00:34 +08:00
Log Level
This commit is contained in:
parent
619ef2ba37
commit
86955c1de2
1 changed files with 39 additions and 30 deletions
|
@ -36,7 +36,7 @@ static bool IsTrailerAccessAllowed(uint8_t blockNo, uint8_t keytype, uint8_t act
|
||||||
| ((sector_trailer[8] >> 7) & 0x01);
|
| ((sector_trailer[8] >> 7) & 0x01);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case AC_KEYA_READ: {
|
case AC_KEYA_READ: {
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("IsTrailerAccessAllowed: AC_KEYA_READ");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsTrailerAccessAllowed: AC_KEYA_READ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case AC_KEYA_WRITE: {
|
case AC_KEYA_WRITE: {
|
||||||
|
@ -45,7 +45,7 @@ static bool IsTrailerAccessAllowed(uint8_t blockNo, uint8_t keytype, uint8_t act
|
||||||
|| (keytype == AUTHKEYB && (AC == 0x04 || AC == 0x03)));
|
|| (keytype == AUTHKEYB && (AC == 0x04 || AC == 0x03)));
|
||||||
}
|
}
|
||||||
case AC_KEYB_READ: {
|
case AC_KEYB_READ: {
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("IsTrailerAccessAllowed: AC_KEYB_READ");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsTrailerAccessAllowed: AC_KEYB_READ");
|
||||||
return (keytype == AUTHKEYA && (AC == 0x00 || AC == 0x02 || AC == 0x01));
|
return (keytype == AUTHKEYA && (AC == 0x00 || AC == 0x02 || AC == 0x01));
|
||||||
}
|
}
|
||||||
case AC_KEYB_WRITE: {
|
case AC_KEYB_WRITE: {
|
||||||
|
@ -75,7 +75,7 @@ static bool IsDataAccessAllowed(uint8_t blockNo, uint8_t keytype, uint8_t action
|
||||||
emlGetMem(sector_trailer, SectorTrailer(blockNo), 1);
|
emlGetMem(sector_trailer, SectorTrailer(blockNo), 1);
|
||||||
|
|
||||||
uint8_t sector_block;
|
uint8_t sector_block;
|
||||||
if (blockNo < MIFARE_2K_MAXBLOCK) {
|
if (blockNo <= MIFARE_2K_MAXBLOCK) {
|
||||||
sector_block = blockNo & 0x03;
|
sector_block = blockNo & 0x03;
|
||||||
} else {
|
} else {
|
||||||
sector_block = (blockNo & 0x0f) / 5;
|
sector_block = (blockNo & 0x0f) / 5;
|
||||||
|
@ -87,41 +87,41 @@ static bool IsDataAccessAllowed(uint8_t blockNo, uint8_t keytype, uint8_t action
|
||||||
AC = ((sector_trailer[7] >> 2) & 0x04)
|
AC = ((sector_trailer[7] >> 2) & 0x04)
|
||||||
| ((sector_trailer[8] << 1) & 0x02)
|
| ((sector_trailer[8] << 1) & 0x02)
|
||||||
| ((sector_trailer[8] >> 4) & 0x01);
|
| ((sector_trailer[8] >> 4) & 0x01);
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("IsDataAccessAllowed: case 0x00");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed: case 0x00 - %02x", AC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x01: {
|
case 0x01: {
|
||||||
AC = ((sector_trailer[7] >> 3) & 0x04)
|
AC = ((sector_trailer[7] >> 3) & 0x04)
|
||||||
| ((sector_trailer[8] >> 0) & 0x02)
|
| ((sector_trailer[8] >> 0) & 0x02)
|
||||||
| ((sector_trailer[8] >> 5) & 0x01);
|
| ((sector_trailer[8] >> 5) & 0x01);
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("IsDataAccessAllowed: case 0x01");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed: case 0x01 - %02x", AC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x02: {
|
case 0x02: {
|
||||||
AC = ((sector_trailer[7] >> 4) & 0x04)
|
AC = ((sector_trailer[7] >> 4) & 0x04)
|
||||||
| ((sector_trailer[8] >> 1) & 0x02)
|
| ((sector_trailer[8] >> 1) & 0x02)
|
||||||
| ((sector_trailer[8] >> 6) & 0x01);
|
| ((sector_trailer[8] >> 6) & 0x01);
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("IsDataAccessAllowed: case 0x02");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed: case 0x02 - %02x", AC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("IsDataAccessAllowed: Error");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed: Error");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case AC_DATA_READ: {
|
case AC_DATA_READ: {
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("AC_DATA_READ: OK");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed - AC_DATA_READ: OK");
|
||||||
return ((keytype == AUTHKEYA && !(AC == 0x03 || AC == 0x05 || AC == 0x07))
|
return ((keytype == AUTHKEYA && !(AC == 0x03 || AC == 0x05 || AC == 0x07))
|
||||||
|| (keytype == AUTHKEYB && !(AC == 0x07)));
|
|| (keytype == AUTHKEYB && !(AC == 0x07)));
|
||||||
}
|
}
|
||||||
case AC_DATA_WRITE: {
|
case AC_DATA_WRITE: {
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("AC_DATA_WRITE: OK");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed - AC_DATA_WRITE: OK");
|
||||||
return ((keytype == AUTHKEYA && (AC == 0x00))
|
return ((keytype == AUTHKEYA && (AC == 0x00))
|
||||||
|| (keytype == AUTHKEYB && (AC == 0x00 || AC == 0x04 || AC == 0x06 || AC == 0x03)));
|
|| (keytype == AUTHKEYB && (AC == 0x00 || AC == 0x04 || AC == 0x06 || AC == 0x03)));
|
||||||
}
|
}
|
||||||
case AC_DATA_INC: {
|
case AC_DATA_INC: {
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("AC_DATA_WRITE: OK");
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("IsDataAccessAllowed - AC_DATA_INC: OK");
|
||||||
return ((keytype == AUTHKEYA && (AC == 0x00))
|
return ((keytype == AUTHKEYA && (AC == 0x00))
|
||||||
|| (keytype == AUTHKEYB && (AC == 0x00 || AC == 0x06)));
|
|| (keytype == AUTHKEYB && (AC == 0x00 || AC == 0x06)));
|
||||||
}
|
}
|
||||||
|
@ -785,36 +785,45 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t
|
||||||
blockNo = receivedCmd_dec[1];
|
blockNo = receivedCmd_dec[1];
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Reader reading block %d (0x%02x)", blockNo, blockNo);
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Reader reading block %d (0x%02x)", blockNo, blockNo);
|
||||||
emlGetMem(response, blockNo, 1);
|
emlGetMem(response, blockNo, 1);
|
||||||
if (MF_DBGLEVEL >= 2) {
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
|
||||||
Dbprintf("Data Block[%d]: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", blockNo,
|
Dbprintf("[ISO14443A_CMD_READBLOCK] Data Block[%d]: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", blockNo,
|
||||||
response[0], response[1], response[2], response[3], response[4], response[5], response[6],
|
response[0], response[1], response[2], response[3], response[4], response[5], response[6],
|
||||||
response[7], response[8], response[9], response[10], response[11], response[12], response[13],
|
response[7], response[8], response[9], response[10], response[11], response[12], response[13],
|
||||||
response[14],response[15]);
|
response[14],response[15]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (IsSectorTrailer(blockNo)) {
|
if (IsSectorTrailer(blockNo)) {
|
||||||
memset(response, 0x00, 6); // keyA can never be read
|
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("[IsSectorTrailer] keyA can never be read - block %d (0x%02x)", blockNo, blockNo);
|
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_KEYA_READ)) {
|
||||||
|
memset(response, 0x00, 6); // keyA can never be read, Why ??? Need source ?
|
||||||
|
// a0a1a2a3a4a561e789c1b0b1b2b3b4b5 => 00000000000061e789c1b0b1b2b3b4b5
|
||||||
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[IsSectorTrailer] keyA can never be read - block %d (0x%02x)", blockNo, blockNo);
|
||||||
|
}
|
||||||
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_KEYB_READ)) {
|
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_KEYB_READ)) {
|
||||||
memset(response + 10, 0x00, 6); // keyB cannot be read
|
memset(response + 10, 0x00, 6); // keyB cannot be read
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("[IsSectorTrailer] keyB cannot be read - block %d (0x%02x)", blockNo, blockNo);
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[IsSectorTrailer] keyB cannot be read - block %d (0x%02x)", blockNo, blockNo);
|
||||||
}
|
}
|
||||||
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_AC_READ)) {
|
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_AC_READ)) {
|
||||||
memset(response + 6, 0x00, 4); // AC bits cannot be read
|
memset(response + 6, 0x00, 4); // AC bits cannot be read
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("[IsAccessAllowed] AC bits cannot be read - block %d (0x%02x)", blockNo, blockNo);
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[IsAccessAllowed] AC bits cannot be read - block %d (0x%02x)", blockNo, blockNo);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_DATA_READ)) {
|
if (!IsAccessAllowed(blockNo, cardAUTHKEY, AC_DATA_READ)) {
|
||||||
memset(response, 0x00, 16); // datablock cannot be read
|
memset(response, 0x00, 16); // datablock cannot be read
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("[IsAccessAllowed] Data block %d (0x%02x) cannot be read", blockNo, blockNo);
|
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("[IsAccessAllowed] Data block %d (0x%02x) cannot be read", blockNo, blockNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppendCrc14443a(response, 16);
|
AppendCrc14443a(response, 16);
|
||||||
mf_crypto1_encrypt(pcs, response, MAX_MIFARE_FRAME_SIZE, response_par);
|
mf_crypto1_encrypt(pcs, response, MAX_MIFARE_FRAME_SIZE, response_par);
|
||||||
EmSendCmdPar(response, MAX_MIFARE_FRAME_SIZE, response_par);
|
EmSendCmdPar(response, MAX_MIFARE_FRAME_SIZE, response_par);
|
||||||
|
if (MF_DBGLEVEL >= 2) {
|
||||||
|
Dbprintf("[EmSendCmdPar] Data Block[%d]: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", blockNo,
|
||||||
|
response[0], response[1], response[2], response[3], response[4], response[5], response[6],
|
||||||
|
response[7], response[8], response[9], response[10], response[11], response[12], response[13],
|
||||||
|
response[14],response[15]);
|
||||||
|
}
|
||||||
numReads++;
|
numReads++;
|
||||||
if (MF_DBGLEVEL >= 2) Dbprintf("Num Read: %d",numReads);
|
|
||||||
if (exitAfterNReads > 0 && numReads == exitAfterNReads) {
|
if (exitAfterNReads > 0 && numReads == exitAfterNReads) {
|
||||||
Dbprintf("%d reads done, exiting", numReads);
|
Dbprintf("%d reads done, exiting", numReads);
|
||||||
finished = true;
|
finished = true;
|
||||||
|
|
Loading…
Reference in a new issue