Skip to content

Commit

Permalink
Intercept Desfire EV2 request with file not found
Browse files Browse the repository at this point in the history
  • Loading branch information
bettse committed Jan 2, 2024
1 parent 6257bb3 commit 907b363
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions sam_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ uint8_t read4Block13[] = {RFAL_PICOPASS_CMD_READ4, 0x0D, 0x96, 0xE8};

uint8_t updateBlock2[] = {RFAL_PICOPASS_CMD_UPDATE, 0x02};

uint8_t ev2_request[] =
{0x00, 0xa4, 0x04, 0x00, 0x0a, 0xa0, 0x00, 0x00, 0x04, 0x40, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00};
uint8_t FILE_NOT_FOUND[] = {0x6a, 0x82};

void* calloc(size_t count, size_t size) {
return malloc(count * size);
}
Expand Down Expand Up @@ -569,14 +573,19 @@ void seader_iso14443a_transmit(
BitBuffer* rx_buffer = bit_buffer_alloc(SEADER_POLLER_MAX_BUFFER_SIZE);

do {
bit_buffer_append_bytes(tx_buffer, buffer, len);
if(memcmp(buffer, ev2_request, len) == 0) {
bit_buffer_append_bytes(rx_buffer, FILE_NOT_FOUND, sizeof(FILE_NOT_FOUND));

Iso14443_4aError error =
iso14443_4a_poller_send_block(iso14443_4a_poller, tx_buffer, rx_buffer);
if(error != Iso14443_4aErrorNone) {
FURI_LOG_W(TAG, "iso14443_4a_poller_send_block error %d", error);
seader_worker->stage = SeaderPollerEventTypeFail;
break;
} else {
bit_buffer_append_bytes(tx_buffer, buffer, len);

Iso14443_4aError error =
iso14443_4a_poller_send_block(iso14443_4a_poller, tx_buffer, rx_buffer);
if(error != Iso14443_4aErrorNone) {
FURI_LOG_W(TAG, "iso14443_4a_poller_send_block error %d", error);
seader_worker->stage = SeaderPollerEventTypeFail;
break;
}
}

seader_capture_sio(tx_buffer, rx_buffer, seader->credential);
Expand Down

0 comments on commit 907b363

Please sign in to comment.