mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 09:32:41 +08:00
text
This commit is contained in:
parent
94192d0976
commit
c6473afcc1
1 changed files with 14 additions and 8 deletions
|
@ -557,7 +557,7 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
int res = EmGetCmd(receivedCmd, &receivedCmd_len, receivedCmd_par);
|
||||
|
||||
if (res == 2) { //Field is off!
|
||||
FpgaDisableTracing();
|
||||
//FpgaDisableTracing();
|
||||
LEDsoff();
|
||||
cardSTATE = MFEMUL_NOFIELD;
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
|
@ -595,14 +595,16 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
}
|
||||
|
||||
switch (cardSTATE) {
|
||||
case MFEMUL_NOFIELD:
|
||||
case MFEMUL_NOFIELD: {
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
Dbprintf("MFEMUL_NOFIELD");
|
||||
break;
|
||||
case MFEMUL_HALTED:
|
||||
}
|
||||
case MFEMUL_HALTED: {
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
Dbprintf("MFEMUL_HALTED");
|
||||
break;
|
||||
}
|
||||
case MFEMUL_IDLE: {
|
||||
LogTrace(uart->output, uart->len, uart->startTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->endTime * 16 - DELAY_AIR2ARM_AS_TAG, uart->parity, true);
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
|
@ -706,8 +708,9 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
// WORK
|
||||
case MFEMUL_WORK: {
|
||||
|
||||
if (DBGLEVEL >= DBG_EXTENDED)
|
||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||
Dbprintf("[MFEMUL_WORK] Enter in case");
|
||||
}
|
||||
|
||||
if (receivedCmd_len == 0) {
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] NO CMD received");
|
||||
|
@ -718,13 +721,14 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
if (encrypted_data) {
|
||||
// decrypt seqence
|
||||
mf_crypto1_decryptEx(pcs, receivedCmd, receivedCmd_len, receivedCmd_dec);
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] Decrypt seqence");
|
||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] Decrypt sequence");
|
||||
} else {
|
||||
// Data in clear
|
||||
memcpy(receivedCmd_dec, receivedCmd, receivedCmd_len);
|
||||
}
|
||||
|
||||
if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) { // all commands must have a valid CRC
|
||||
// all commands must have a valid CRC
|
||||
if (!CheckCrc14A(receivedCmd_dec, receivedCmd_len)) {
|
||||
EmSend4bit(encrypted_data ? mf_crypto1_encrypt4bit(pcs, CARD_NACK_NA) : CARD_NACK_NA);
|
||||
FpgaDisableTracing();
|
||||
|
||||
|
@ -1251,8 +1255,10 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
|
||||
} // End While Loop
|
||||
|
||||
FpgaDisableTracing();
|
||||
|
||||
// NR AR ATTACK
|
||||
// mfkey32
|
||||
if (((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) && (DBGLEVEL >= DBG_INFO)) {
|
||||
for (uint8_t i = 0; i < ATTACK_KEY_COUNT; i++) {
|
||||
if (ar_nr_collected[i] == 2) {
|
||||
|
@ -1268,7 +1274,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// mfkey32 v2
|
||||
for (uint8_t i = ATTACK_KEY_COUNT; i < ATTACK_KEY_COUNT * 2; i++) {
|
||||
if (ar_nr_collected[i] == 2) {
|
||||
Dbprintf("Collected two pairs of AR/NR which can be used to extract %s from reader for sector %d:", (i < ATTACK_KEY_COUNT / 2) ? "keyA" : "keyB", ar_nr_resp[i].sector);
|
||||
|
@ -1288,7 +1295,6 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain, uint1
|
|||
Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", get_tracing(), BigBuf_get_traceLen());
|
||||
}
|
||||
|
||||
|
||||
if ((flags & FLAG_INTERACTIVE) == FLAG_INTERACTIVE) { // Interactive mode flag, means we need to send ACK
|
||||
//Send the collected ar_nr in the response
|
||||
reply_mix(CMD_ACK, CMD_HF_MIFARE_SIMULATE, button_pushed, 0, &ar_nr_resp, sizeof(ar_nr_resp));
|
||||
|
|
Loading…
Reference in a new issue