Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgornekich <n.gorbadey@gmail.com>2022-05-24 17:00:15 +0300
committerGitHub <noreply@github.com>2022-05-24 17:00:15 +0300
commitd31578508a95144cf5964878349a21aac642850d (patch)
tree6b206a5d43de87ef661933c6ce977dac7d800ccf /applications/nfc/nfc_worker.c
parent2017baac48939fc58344a2d60294a9d9e6513b64 (diff)
[FL-2245] Introduce Mifare Classic Emulation (#1242)
* digital signal: introduce digital signal * nfca: add nfca signal encoder * nfc: add mifare classic emulation scene * nfca: add classic emulation support to lib and hal * mifare classic: support basic read commands * nfc: add mifare classic menu scene * mifare classic: start parsing commands in emulation * mifare classic: add nested auth * nfc: fix errors * mifare classic: add encrypt function * nfc: fix mifare classic save * lib hex: add hex uint64_t ASCII parser * flipper format: add uint64 hex format support * nfc: add mifare classic key map * nfc: hide mifare classic keys on emulation * mifare classic: add NACK responce * nfc: add partial bytes support in transparent mode * nfc: mifare classic add shadow file support * digital signal: move arr buffer from BSS to heap * mifare classic: process access bits more careful * nfca: fix memory leack * nfc: format sources * mifare classic: cleun up Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'applications/nfc/nfc_worker.c')
-rw-r--r--applications/nfc/nfc_worker.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/applications/nfc/nfc_worker.c b/applications/nfc/nfc_worker.c
index 6b3c8f09..5ae99d6d 100644
--- a/applications/nfc/nfc_worker.c
+++ b/applications/nfc/nfc_worker.c
@@ -7,6 +7,7 @@
#include <lib/nfc_protocols/mifare_ultralight.h>
#include <lib/nfc_protocols/mifare_classic.h>
#include <lib/nfc_protocols/mifare_desfire.h>
+#include <lib/nfc_protocols/nfca.h>
#include "helpers/nfc_mf_classic_dict.h"
@@ -104,6 +105,8 @@ int32_t nfc_worker_task(void* context) {
nfc_worker_emulate_mifare_ul(nfc_worker);
} else if(nfc_worker->state == NfcWorkerStateReadMifareClassic) {
nfc_worker_mifare_classic_dict_attack(nfc_worker);
+ } else if(nfc_worker->state == NfcWorkerStateEmulateMifareClassic) {
+ nfc_worker_emulate_mifare_classic(nfc_worker);
} else if(nfc_worker->state == NfcWorkerStateReadMifareDesfire) {
nfc_worker_read_mifare_desfire(nfc_worker);
}
@@ -474,6 +477,34 @@ void nfc_worker_mifare_classic_dict_attack(NfcWorker* nfc_worker) {
stream_free(nfc_worker->dict_stream);
}
+void nfc_worker_emulate_mifare_classic(NfcWorker* nfc_worker) {
+ FuriHalNfcTxRxContext tx_rx;
+ FuriHalNfcDevData* nfc_data = &nfc_worker->dev_data->nfc_data;
+ MfClassicEmulator emulator = {
+ .cuid = nfc_util_bytes2num(&nfc_data->uid[nfc_data->uid_len - 4], 4),
+ .data = nfc_worker->dev_data->mf_classic_data,
+ .data_changed = false,
+ };
+ NfcaSignal* nfca_signal = nfca_signal_alloc();
+ tx_rx.nfca_signal = nfca_signal;
+
+ while(nfc_worker->state == NfcWorkerStateEmulateMifareClassic) {
+ if(furi_hal_nfc_listen(
+ nfc_data->uid, nfc_data->uid_len, nfc_data->atqa, nfc_data->sak, true, 300)) {
+ mf_classic_emulator(&emulator, &tx_rx);
+ }
+ }
+ if(emulator.data_changed) {
+ nfc_worker->dev_data->mf_classic_data = emulator.data;
+ if(nfc_worker->callback) {
+ nfc_worker->callback(NfcWorkerEventSuccess, nfc_worker->context);
+ }
+ emulator.data_changed = false;
+ }
+
+ nfca_signal_free(nfca_signal);
+}
+
void nfc_worker_read_mifare_desfire(NfcWorker* nfc_worker) {
ReturnCode err;
uint8_t tx_buff[64] = {};