|
@@ -1,4 +1,6 @@
|
|
|
#include "../mifare_fuzzer_i.h"
|
|
#include "../mifare_fuzzer_i.h"
|
|
|
|
|
+#include <notification/notification.h>
|
|
|
|
|
+#include <notification/notification_messages.h>
|
|
|
|
|
|
|
|
uint8_t tick_counter = 0;
|
|
uint8_t tick_counter = 0;
|
|
|
uint8_t attack_step = 0;
|
|
uint8_t attack_step = 0;
|
|
@@ -69,16 +71,38 @@ void mifare_fuzzer_scene_emulator_on_enter(void* context) {
|
|
|
/// @return
|
|
/// @return
|
|
|
bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent event) {
|
|
bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent event) {
|
|
|
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event()");
|
|
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event()");
|
|
|
- Iso14443_3aData nfc_data;
|
|
|
|
|
-
|
|
|
|
|
MifareFuzzerApp* app = context;
|
|
MifareFuzzerApp* app = context;
|
|
|
MifareFuzzerEmulator* emulator = app->emulator_view;
|
|
MifareFuzzerEmulator* emulator = app->emulator_view;
|
|
|
-
|
|
|
|
|
bool consumed = false;
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
if(event.event == MifareFuzzerEventStartAttack) {
|
|
if(event.event == MifareFuzzerEventStartAttack) {
|
|
|
- //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStartAttack");
|
|
|
|
|
|
|
+ NfcDevice* nfc_device = NULL;
|
|
|
|
|
+ const MfClassicData* mf_classic_data = NULL;
|
|
|
|
|
+ bool nfc_device_parsed = false;
|
|
|
|
|
+ if(app->card_file_path) {
|
|
|
|
|
+ nfc_device = app->worker->nfc_device;
|
|
|
|
|
+ const char* path = furi_string_get_cstr(app->card_file_path);
|
|
|
|
|
+ if(nfc_device_load(nfc_device, path)) {
|
|
|
|
|
+ nfc_device_parsed = true;
|
|
|
|
|
+ mf_classic_data = nfc_device_get_data(nfc_device, NfcProtocolMfClassic);
|
|
|
|
|
+ if(mf_classic_data->type == MfClassicType1k) {
|
|
|
|
|
+ app->card = MifareCardClassic1k;
|
|
|
|
|
+ } else if(mf_classic_data->type == MfClassicType4k) {
|
|
|
|
|
+ app->card = MifareCardClassic4k;
|
|
|
|
|
+ } else if(nfc_device_get_protocol(nfc_device) == NfcProtocolMfUltralight) {
|
|
|
|
|
+ app->card = MifareCardUltralight;
|
|
|
|
|
+ }
|
|
|
|
|
+ mifare_fuzzer_emulator_set_card(emulator, app->card, app->card_file_path);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Iso14443_3aData* nfc_data;
|
|
|
|
|
+ if(mf_classic_data) {
|
|
|
|
|
+ nfc_data = mf_classic_data->iso14443_3a_data;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ nfc_data = iso14443_3a_alloc();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Stop worker
|
|
// Stop worker
|
|
|
mifare_fuzzer_worker_stop(app->worker);
|
|
mifare_fuzzer_worker_stop(app->worker);
|
|
@@ -86,27 +110,27 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
|
|
|
// Set card type
|
|
// Set card type
|
|
|
// TODO: Move somewhere else, I do not like this to be there
|
|
// TODO: Move somewhere else, I do not like this to be there
|
|
|
if(app->card == MifareCardClassic1k) {
|
|
if(app->card == MifareCardClassic1k) {
|
|
|
- nfc_data.atqa[0] = 0x04;
|
|
|
|
|
- nfc_data.atqa[1] = 0x00;
|
|
|
|
|
- nfc_data.sak = 0x08;
|
|
|
|
|
- nfc_data.uid_len = 0x04;
|
|
|
|
|
|
|
+ nfc_data->atqa[0] = 0x04;
|
|
|
|
|
+ nfc_data->atqa[1] = 0x00;
|
|
|
|
|
+ nfc_data->sak = 0x08;
|
|
|
|
|
+ nfc_data->uid_len = 0x04;
|
|
|
} else if(app->card == MifareCardClassic4k) {
|
|
} else if(app->card == MifareCardClassic4k) {
|
|
|
- nfc_data.atqa[0] = 0x02;
|
|
|
|
|
- nfc_data.atqa[1] = 0x00;
|
|
|
|
|
- nfc_data.sak = 0x18;
|
|
|
|
|
- nfc_data.uid_len = 0x04;
|
|
|
|
|
|
|
+ nfc_data->atqa[0] = 0x02;
|
|
|
|
|
+ nfc_data->atqa[1] = 0x00;
|
|
|
|
|
+ nfc_data->sak = 0x18;
|
|
|
|
|
+ nfc_data->uid_len = 0x04;
|
|
|
} else if(app->card == MifareCardUltralight) {
|
|
} else if(app->card == MifareCardUltralight) {
|
|
|
- nfc_data.atqa[0] = 0x44;
|
|
|
|
|
- nfc_data.atqa[1] = 0x00;
|
|
|
|
|
- nfc_data.sak = 0x00;
|
|
|
|
|
- nfc_data.uid_len = 0x07;
|
|
|
|
|
|
|
+ nfc_data->atqa[0] = 0x44;
|
|
|
|
|
+ nfc_data->atqa[1] = 0x00;
|
|
|
|
|
+ nfc_data->sak = 0x00;
|
|
|
|
|
+ nfc_data->uid_len = 0x07;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Set UIDs
|
|
// Set UIDs
|
|
|
if(app->attack == MifareFuzzerAttackTestValues) {
|
|
if(app->attack == MifareFuzzerAttackTestValues) {
|
|
|
// Load test UIDs
|
|
// Load test UIDs
|
|
|
- for(uint8_t i = 0; i < nfc_data.uid_len; i++) {
|
|
|
|
|
- nfc_data.uid[i] = id_uid_test[attack_step][i];
|
|
|
|
|
|
|
+ for(uint8_t i = 0; i < nfc_data->uid_len; i++) {
|
|
|
|
|
+ nfc_data->uid[i] = id_uid_test[attack_step][i];
|
|
|
}
|
|
}
|
|
|
// Next UIDs on next loop
|
|
// Next UIDs on next loop
|
|
|
if(attack_step >= 8) {
|
|
if(attack_step >= 8) {
|
|
@@ -123,13 +147,13 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
|
|
|
|
|
|
|
|
// TODO: Manufacture-code must be selectable from a list
|
|
// TODO: Manufacture-code must be selectable from a list
|
|
|
// use a fixed manufacture-code for now: 0x04 = NXP Semiconductors Germany
|
|
// use a fixed manufacture-code for now: 0x04 = NXP Semiconductors Germany
|
|
|
- nfc_data.uid[0] = 0x04;
|
|
|
|
|
- for(uint8_t i = 1; i < nfc_data.uid_len; i++) {
|
|
|
|
|
- nfc_data.uid[i] = (furi_hal_random_get() & 0xFF);
|
|
|
|
|
|
|
+ nfc_data->uid[0] = 0x04;
|
|
|
|
|
+ for(uint8_t i = 1; i < nfc_data->uid_len; i++) {
|
|
|
|
|
+ nfc_data->uid[i] = (furi_hal_random_get() & 0xFF);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- for(uint8_t i = 0; i < nfc_data.uid_len; i++) {
|
|
|
|
|
- nfc_data.uid[i] = (furi_hal_random_get() & 0xFF);
|
|
|
|
|
|
|
+ for(uint8_t i = 0; i < nfc_data->uid_len; i++) {
|
|
|
|
|
+ nfc_data->uid[i] = (furi_hal_random_get() & 0xFF);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {
|
|
} else if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {
|
|
@@ -157,21 +181,25 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
|
|
|
|
|
|
|
|
// parse string to UID
|
|
// parse string to UID
|
|
|
// TODO: a better validation on input?
|
|
// TODO: a better validation on input?
|
|
|
- for(uint8_t i = 0; i < nfc_data.uid_len; i++) {
|
|
|
|
|
|
|
+ for(uint8_t i = 0; i < nfc_data->uid_len; i++) {
|
|
|
if(i <= ((furi_string_size(app->uid_str) - 1) / 2)) {
|
|
if(i <= ((furi_string_size(app->uid_str) - 1) / 2)) {
|
|
|
char temp_str[3];
|
|
char temp_str[3];
|
|
|
temp_str[0] = furi_string_get_cstr(app->uid_str)[i * 2];
|
|
temp_str[0] = furi_string_get_cstr(app->uid_str)[i * 2];
|
|
|
temp_str[1] = furi_string_get_cstr(app->uid_str)[i * 2 + 1];
|
|
temp_str[1] = furi_string_get_cstr(app->uid_str)[i * 2 + 1];
|
|
|
temp_str[2] = '\0';
|
|
temp_str[2] = '\0';
|
|
|
- nfc_data.uid[i] = (uint8_t)strtol(temp_str, NULL, 16);
|
|
|
|
|
|
|
+ nfc_data->uid[i] = (uint8_t)strtol(temp_str, NULL, 16);
|
|
|
} else {
|
|
} else {
|
|
|
- nfc_data.uid[i] = 0x00;
|
|
|
|
|
|
|
+ nfc_data->uid[i] = 0x00;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- mifare_fuzzer_worker_set_nfc_data(app->worker, nfc_data);
|
|
|
|
|
- mifare_fuzzer_emulator_set_nfc_data(app->emulator_view, nfc_data);
|
|
|
|
|
|
|
+ mifare_fuzzer_emulator_set_nfc_data(app->emulator_view, *nfc_data);
|
|
|
|
|
+ if(nfc_device_parsed) {
|
|
|
|
|
+ mifare_fuzzer_worker_set_nfc_device(app->worker, nfc_device);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mifare_fuzzer_worker_set_nfc_data(app->worker, *nfc_data);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Reset tick_counter
|
|
// Reset tick_counter
|
|
|
tick_counter = 0;
|
|
tick_counter = 0;
|
|
@@ -180,10 +208,14 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
|
|
|
// Start worker
|
|
// Start worker
|
|
|
mifare_fuzzer_worker_start(app->worker);
|
|
mifare_fuzzer_worker_start(app->worker);
|
|
|
|
|
|
|
|
|
|
+ if(nfc_device_parsed) {
|
|
|
|
|
+ notification_message(app->notifications, &sequence_blink_start_magenta);
|
|
|
|
|
+ }
|
|
|
} else if(event.event == MifareFuzzerEventStopAttack) {
|
|
} else if(event.event == MifareFuzzerEventStopAttack) {
|
|
|
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStopAttack");
|
|
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStopAttack");
|
|
|
// Stop worker
|
|
// Stop worker
|
|
|
mifare_fuzzer_worker_stop(app->worker);
|
|
mifare_fuzzer_worker_stop(app->worker);
|
|
|
|
|
+ notification_message(app->notifications, &sequence_blink_stop);
|
|
|
} else if(event.event == MifareFuzzerEventIncrementTicks) {
|
|
} else if(event.event == MifareFuzzerEventIncrementTicks) {
|
|
|
if(!emulator->is_attacking) {
|
|
if(!emulator->is_attacking) {
|
|
|
if(emulator->ticks_between_cards < MIFARE_FUZZER_MAX_TICKS_BETWEEN_CARDS) {
|
|
if(emulator->ticks_between_cards < MIFARE_FUZZER_MAX_TICKS_BETWEEN_CARDS) {
|
|
@@ -234,6 +266,7 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
|
|
|
void mifare_fuzzer_scene_emulator_on_exit(void* context) {
|
|
void mifare_fuzzer_scene_emulator_on_exit(void* context) {
|
|
|
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_exit()");
|
|
//FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_exit()");
|
|
|
MifareFuzzerApp* app = context;
|
|
MifareFuzzerApp* app = context;
|
|
|
|
|
+ notification_message(app->notifications, &sequence_blink_stop);
|
|
|
mifare_fuzzer_worker_stop(app->worker);
|
|
mifare_fuzzer_worker_stop(app->worker);
|
|
|
|
|
|
|
|
if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {
|
|
if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {
|