mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-24 07:05:40 -07:00
extra ev2 challenges
This commit is contained in:
parent
c51a366d0d
commit
1e35567e15
1 changed files with 104 additions and 69 deletions
|
@ -97,6 +97,27 @@ static uint8_t extract_epurse[8] = {0};
|
|||
|
||||
#define SKIP_TO_NEXT(a) (TRACELOG_HDR_LEN + (a)->data_len + TRACELOG_PARITY_LEN((a)))
|
||||
|
||||
static uint16_t extractChall_ev2(uint16_t tracepos, uint8_t *trace, uint8_t cmdpos, uint8_t long_jmp) {
|
||||
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
if (next_hdr->data_len != 21) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
|
||||
PrintAndLogEx(INFO, "1499999999 %s " NOLF, sprint_hex_inrow(next_hdr->frame + 1, 16));
|
||||
|
||||
next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
|
||||
if (next_hdr->frame[cmdpos] == MFDES_ADDITIONAL_FRAME) {
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex_inrow(next_hdr->frame + cmdpos + long_jmp, 32));
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
return tracepos;
|
||||
}
|
||||
|
||||
static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t *trace) {
|
||||
|
||||
// sanity check
|
||||
|
@ -270,6 +291,10 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
return tracepos;
|
||||
}
|
||||
|
||||
if (hdr->isResponse) {
|
||||
return tracepos;
|
||||
}
|
||||
|
||||
// PCB [CID] [NAD] [INF] CRC CRC
|
||||
uint8_t pos = calc_pos(frame);
|
||||
uint8_t long_jmp = (data_len > 6) ? 4 : 1;
|
||||
|
@ -279,16 +304,18 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
switch (frame[pos]) {
|
||||
|
||||
case MFDES_AUTHENTICATE: {
|
||||
|
||||
// Assume wrapped or unwrapped
|
||||
PrintAndLogEx(INFO, "AUTH NATIVE (keyNo %d)", frame[pos + long_jmp]);
|
||||
|
||||
if (hdr->isResponse == false && next_record_is_response(tracepos, trace)) {
|
||||
if (next_record_is_response(tracepos, trace) == false) {
|
||||
break;
|
||||
}
|
||||
|
||||
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
if (next_hdr->data_len < 7) {
|
||||
break;
|
||||
}
|
||||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
|
||||
PrintAndLogEx(INFO, "DES 1499999999 %s " NOLF, sprint_hex_inrow(next_hdr->frame + 1, 8));
|
||||
|
||||
|
@ -297,16 +324,17 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
|
||||
if (next_hdr->frame[pos] == MFDES_ADDITIONAL_FRAME) {
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex_inrow(next_hdr->frame + pos + long_jmp, 16));
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
return tracepos;
|
||||
}
|
||||
break; // AUTHENTICATE_NATIVE
|
||||
return tracepos; // AUTHENTICATE_NATIVE
|
||||
}
|
||||
case MFDES_AUTHENTICATE_ISO: {
|
||||
|
||||
// Assume wrapped or unwrapped
|
||||
PrintAndLogEx(INFO, "AUTH ISO (keyNo %d)", frame[pos + long_jmp]);
|
||||
if (hdr->isResponse == false && next_record_is_response(tracepos, trace)) {
|
||||
if (next_record_is_response(tracepos, trace) == false) {
|
||||
break;
|
||||
}
|
||||
|
||||
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
|
@ -327,22 +355,24 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
|
||||
if (next_hdr->frame[pos] == MFDES_ADDITIONAL_FRAME) {
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex_inrow(next_hdr->frame + pos + long_jmp, (tdea << 1)));
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
return tracepos;
|
||||
}
|
||||
|
||||
break; // AUTHENTICATE_STANDARD
|
||||
return tracepos; // AUTHENTICATE_STANDARD
|
||||
}
|
||||
case MFDES_AUTHENTICATE_AES: {
|
||||
// Assume wrapped or unwrapped
|
||||
PrintAndLogEx(INFO, "AUTH AES (keyNo %d)", frame[pos + long_jmp]);
|
||||
if (hdr->isResponse == false && next_record_is_response(tracepos, trace)) {
|
||||
if (next_record_is_response(tracepos, trace)) {
|
||||
break;
|
||||
}
|
||||
|
||||
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
tracepos += TRACELOG_HDR_LEN + next_hdr->data_len + TRACELOG_PARITY_LEN(next_hdr);
|
||||
if (next_hdr->data_len < 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "AES 1499999999 %s " NOLF, sprint_hex_inrow(next_hdr->frame + 1, 8));
|
||||
|
||||
next_hdr = (tracelog_hdr_t *)(trace + tracepos);
|
||||
|
@ -350,22 +380,27 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
|
|||
|
||||
if (next_hdr->frame[pos] == MFDES_ADDITIONAL_FRAME) {
|
||||
PrintAndLogEx(NORMAL, "%s", sprint_hex_inrow(next_hdr->frame + pos + long_jmp, 16));
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
return tracepos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MFDES_AUTHENTICATE_EV2F: {
|
||||
if (hdr->isResponse == false) {
|
||||
PrintAndLogEx(INFO, "AUTH EV2 First");
|
||||
}
|
||||
uint16_t tmp = extractChall_ev2(tracepos, trace, pos, long_jmp);
|
||||
if (tmp == 0)
|
||||
break;
|
||||
else
|
||||
return tmp;
|
||||
|
||||
}
|
||||
case MFDES_AUTHENTICATE_EV2NF: {
|
||||
if (hdr->isResponse == false) {
|
||||
PrintAndLogEx(INFO, "AUTH EV2 Non First");
|
||||
}
|
||||
uint16_t tmp = extractChall_ev2(tracepos, trace, pos, long_jmp);
|
||||
if (tmp == 0)
|
||||
break;
|
||||
else
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue