mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
mifare simulation: do not respond for authentication attempts for sectors out of range for selected mifare type
Resolves #2635
This commit is contained in:
parent
133fe505f6
commit
18db45b00e
1 changed files with 22 additions and 0 deletions
|
@ -184,6 +184,20 @@ static bool IsAccessAllowed(uint8_t blockNo, uint8_t keytype, uint8_t action) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t MifareMaxSector(uint16_t flags) {
|
||||||
|
if (IS_FLAG_MF_SIZE(flags, MIFARE_MINI_MAX_BYTES)) {
|
||||||
|
return MIFARE_MINI_MAXSECTOR;
|
||||||
|
} else if (IS_FLAG_MF_SIZE(flags, MIFARE_1K_MAX_BYTES)) {
|
||||||
|
return MIFARE_1K_MAXSECTOR;
|
||||||
|
} else if (IS_FLAG_MF_SIZE(flags, MIFARE_2K_MAX_BYTES)) {
|
||||||
|
return MIFARE_2K_MAXSECTOR;
|
||||||
|
} else if (IS_FLAG_MF_SIZE(flags, MIFARE_4K_MAX_BYTES)) {
|
||||||
|
return MIFARE_4K_MAXSECTOR;
|
||||||
|
} else {
|
||||||
|
return MIFARE_4K_MAXSECTOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool MifareSimInit(uint16_t flags, uint8_t *uid, uint16_t atqa, uint8_t sak, tag_response_info_t **responses, uint32_t *cuid, uint8_t *uid_len, uint8_t **rats, uint8_t *rats_len) {
|
static bool MifareSimInit(uint16_t flags, uint8_t *uid, uint16_t atqa, uint8_t sak, tag_response_info_t **responses, uint32_t *cuid, uint8_t *uid_len, uint8_t **rats, uint8_t *rats_len) {
|
||||||
|
|
||||||
uint8_t uid_tmp[10] = {0};
|
uint8_t uid_tmp[10] = {0};
|
||||||
|
@ -769,6 +783,14 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
|
||||||
|
|
||||||
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] KEY %c: %012" PRIx64, (cardAUTHKEY == 0) ? 'A' : 'B', emlGetKey(cardAUTHSC, cardAUTHKEY));
|
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] KEY %c: %012" PRIx64, (cardAUTHKEY == 0) ? 'A' : 'B', emlGetKey(cardAUTHSC, cardAUTHKEY));
|
||||||
|
|
||||||
|
// sector out of range - do not respond
|
||||||
|
if (cardAUTHSC >= MifareMaxSector(flags)) {
|
||||||
|
cardAUTHKEY = AUTHKEYNONE; // not authenticated
|
||||||
|
cardSTATE_TO_IDLE();
|
||||||
|
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] Out of range sector %d(0x%02x)", cardAUTHSC, cardAUTHSC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// first authentication
|
// first authentication
|
||||||
crypto1_deinit(pcs);
|
crypto1_deinit(pcs);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue