[FL-2828] Dolphin score update take 2 (#1929)

* Move DolphinDeedNfcRead
* Move DolphinDeedNfcReadSuccess
* Move DolphinDeedNfcSave
* Move DolphinDeedNfcDetectReader
* Move DolphinDeedNfcEmulate
* Count DolphinDeedNfcEmulate when launched from file browser
* Implement most of the score accounting for NFC
* Fully update Nfc icounter handling
* Move DolphinDeedSubGhzFrequencyAnalyzer
* Update the rest of icounter in SubGHz
* Adjust SubGHz icounter handling
* Adjust LFRFID icounter handling
* Adjust Infrared icounter handling
* Don't count renaming RFID tags as saving
* Don't count renaming SubGHz signals as saving
* Don't count renaming NFC tags as saving
* Adjust iButton icounter handling
* Minor code refactoring
* Correct formatting
* Account for emulating iButton keys from file manager/rpc

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Georgii Surkov
2022-10-28 10:18:41 +03:00
committed by GitHub
parent 8b7a52b97b
commit f11df49468
59 changed files with 125 additions and 72 deletions

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#define NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX (10U)
@@ -26,7 +25,6 @@ void nfc_scene_detect_reader_callback(void* context) {
void nfc_scene_detect_reader_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcDetectReader);
detect_reader_set_callback(nfc->detect_reader, nfc_scene_detect_reader_callback, nfc);
detect_reader_set_nonces_max(nfc->detect_reader, NFC_SCENE_DETECT_READER_PAIR_NONCES_MAX);

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#define NFC_SCENE_EMULATE_UID_LOG_SIZE_MAX (200)
@@ -59,7 +58,6 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
void nfc_scene_emulate_uid_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcEmulate);
// Setup Widget
nfc_scene_emulate_uid_widget_config(nfc, false);

View File

@@ -1,6 +1,5 @@
#include "../nfc_i.h"
#include "../helpers/nfc_emv_parser.h"
#include <dolphin/dolphin.h>
void nfc_scene_emv_read_success_widget_callback(
GuiButtonType result,
@@ -15,7 +14,6 @@ void nfc_scene_emv_read_success_widget_callback(
void nfc_scene_emv_read_success_on_enter(void* context) {
Nfc* nfc = context;
EmvData* emv_data = &nfc->dev->dev_data.emv_data;
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
// Setup Custom Widget view
widget_add_button_element(

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#define TAG "NfcMfClassicDictAttack"
@@ -110,6 +111,7 @@ bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent
} else {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
}
} else if(event.event == NfcWorkerEventAborted) {
@@ -119,6 +121,8 @@ bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent
} else {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicReadSuccess);
// Counting failed attempts too
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
}
} else if(event.event == NfcWorkerEventCardDetected) {

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#define NFC_MF_CLASSIC_DATA_NOT_CHANGED (0UL)
#define NFC_MF_CLASSIC_DATA_CHANGED (1UL)
@@ -15,7 +14,6 @@ bool nfc_mf_classic_emulate_worker_callback(NfcWorkerEvent event, void* context)
void nfc_scene_mf_classic_emulate_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcEmulate);
// Setup view
Popup* popup = nfc->popup;

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_mf_classic_keys_add_byte_input_callback(void* context) {
Nfc* nfc = context;
@@ -36,6 +37,7 @@ bool nfc_scene_mf_classic_keys_add_on_event(void* context, SceneManagerEvent eve
nfc->scene_manager, NfcSceneMfClassicKeysWarnDuplicate);
} else if(mf_classic_dict_add_key(dict, nfc->byte_input_store)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
DOLPHIN_DEED(DolphinDeedNfcMfcAdd);
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneDictNotFound);
}

View File

@@ -36,8 +36,6 @@ bool nfc_scene_mf_classic_menu_on_event(void* context, SceneManagerEvent event)
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexSave) {
DOLPHIN_DEED(DolphinDeedNfcMfcAdd);
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMfClassicMenu, SubmenuIndexSave);
nfc->dev->format = NfcDeviceSaveFormatMifareClassic;
@@ -49,6 +47,11 @@ bool nfc_scene_mf_classic_menu_on_event(void* context, SceneManagerEvent event)
scene_manager_set_scene_state(
nfc->scene_manager, NfcSceneMfClassicMenu, SubmenuIndexEmulate);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicEmulate);
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
DOLPHIN_DEED(DolphinDeedNfcAddEmulate);
} else {
DOLPHIN_DEED(DolphinDeedNfcEmulate);
}
consumed = true;
} else if(event.event == SubmenuIndexInfo) {
scene_manager_set_scene_state(

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_mf_classic_read_success_widget_callback(
GuiButtonType result,
@@ -18,8 +17,6 @@ void nfc_scene_mf_classic_read_success_on_enter(void* context) {
NfcDeviceData* dev_data = &nfc->dev->dev_data;
MfClassicData* mf_data = &dev_data->mf_classic_data;
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
// Setup view
Widget* widget = nfc->widget;
widget_add_button_element(

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
enum SubmenuIndex {
SubmenuIndexSave,
@@ -48,6 +49,11 @@ bool nfc_scene_mf_desfire_menu_on_event(void* context, SceneManagerEvent event)
consumed = true;
} else if(event.event == SubmenuIndexEmulateUid) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
DOLPHIN_DEED(DolphinDeedNfcAddEmulate);
} else {
DOLPHIN_DEED(DolphinDeedNfcEmulate);
}
consumed = true;
} else if(event.event == SubmenuIndexInfo) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneNfcDataInfo);

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
#define NFC_MF_UL_DATA_NOT_CHANGED (0UL)
#define NFC_MF_UL_DATA_CHANGED (1UL)
@@ -15,7 +14,6 @@ bool nfc_mf_ultralight_emulate_worker_callback(NfcWorkerEvent event, void* conte
void nfc_scene_mf_ultralight_emulate_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcEmulate);
// Setup view
Popup* popup = nfc->popup;

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
enum SubmenuIndex {
SubmenuIndexUnlock,
@@ -56,6 +57,11 @@ bool nfc_scene_mf_ultralight_menu_on_event(void* context, SceneManagerEvent even
consumed = true;
} else if(event.event == SubmenuIndexEmulate) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightEmulate);
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
DOLPHIN_DEED(DolphinDeedNfcAddEmulate);
} else {
DOLPHIN_DEED(DolphinDeedNfcEmulate);
}
consumed = true;
} else if(event.event == SubmenuIndexUnlock) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightUnlockMenu);

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
typedef enum {
NfcSceneMfUlReadStateIdle,
@@ -51,7 +50,6 @@ void nfc_scene_mf_ultralight_read_auth_set_state(Nfc* nfc, NfcSceneMfUlReadState
void nfc_scene_mf_ultralight_read_auth_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcRead);
nfc_device_clear(nfc->dev);
// Setup view

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_mf_ultralight_read_auth_result_widget_callback(
GuiButtonType result,
@@ -37,7 +36,6 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
widget_add_string_element(
widget, 0, 17, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
if(mf_ul_data->auth_success) {
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
furi_string_printf(
temp_str,
"Password: %02X %02X %02X %02X",
@@ -54,8 +52,6 @@ void nfc_scene_mf_ultralight_read_auth_result_on_enter(void* context) {
config_pages->auth_data.pack.raw[1]);
widget_add_string_element(
widget, 0, 39, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(temp_str));
} else {
DOLPHIN_DEED(DolphinDeedNfcMfulError);
}
furi_string_printf(
temp_str, "Pages Read: %d/%d", mf_ul_data->data_read / 4, mf_ul_data->data_size / 4);

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_mf_ultralight_read_success_widget_callback(
GuiButtonType result,
@@ -14,7 +13,6 @@ void nfc_scene_mf_ultralight_read_success_widget_callback(
void nfc_scene_mf_ultralight_read_success_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
// Setup widget view
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_mf_ultralight_unlock_warn_dialog_callback(DialogExResult result, void* context) {
Nfc* nfc = context;
@@ -30,6 +31,7 @@ bool nfc_scene_mf_ultralight_unlock_warn_on_event(void* context, SceneManagerEve
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == DialogExResultCenter) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightReadAuth);
DOLPHIN_DEED(DolphinDeedNfcRead);
consumed = true;
}
}

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
enum SubmenuIndex {
SubmenuIndexSaveUid,
@@ -41,6 +42,11 @@ bool nfc_scene_nfca_menu_on_event(void* context, SceneManagerEvent event) {
consumed = true;
} else if(event.event == SubmenuIndexEmulateUid) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
DOLPHIN_DEED(DolphinDeedNfcAddEmulate);
} else {
DOLPHIN_DEED(DolphinDeedNfcEmulate);
}
consumed = true;
} else if(event.event == SubmenuIndexInfo) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneNfcDataInfo);

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_nfca_read_success_widget_callback(
GuiButtonType result,
@@ -16,8 +15,6 @@ void nfc_scene_nfca_read_success_widget_callback(
void nfc_scene_nfca_read_success_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
// Setup view
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;
Widget* widget = nfc->widget;

View File

@@ -39,7 +39,6 @@ void nfc_scene_read_set_state(Nfc* nfc, NfcSceneReadState state) {
void nfc_scene_read_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcRead);
nfc_device_clear(nfc->dev);
// Setup view
@@ -62,26 +61,32 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) {
(event.event == NfcWorkerEventReadUidNfcV)) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneReadCardSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
} else if(event.event == NfcWorkerEventReadUidNfcA) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneNfcaReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
} else if(event.event == NfcWorkerEventReadMfUltralight) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
} else if(event.event == NfcWorkerEventReadMfClassicDone) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
} else if(event.event == NfcWorkerEventReadMfDesfire) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfDesfireReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
} else if(event.event == NfcWorkerEventReadBankCard) {
notification_message(nfc->notifications, &sequence_success);
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmvReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;
} else if(event.event == NfcWorkerEventReadMfClassicDictAttackRequired) {
if(mf_classic_dict_check_presence(MfClassicDictTypeFlipper)) {

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_read_card_success_widget_callback(
GuiButtonType result,
@@ -18,7 +17,6 @@ void nfc_scene_read_card_success_on_enter(void* context) {
FuriString* temp_str;
temp_str = furi_string_alloc();
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
// Setup view
FuriHalNfcDevData* data = &nfc->dev->dev_data.nfc_data;

View File

@@ -2,6 +2,7 @@
#include <lib/toolbox/random_name.h>
#include <gui/modules/validators.h>
#include <toolbox/path.h>
#include <dolphin/dolphin.h>
void nfc_scene_save_name_text_input_callback(void* context) {
Nfc* nfc = context;
@@ -63,6 +64,13 @@ bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
strlcpy(nfc->dev->dev_name, nfc->text_store, strlen(nfc->text_store) + 1);
if(nfc_device_save(nfc->dev, nfc->text_store)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
if(!scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSavedMenu)) {
// Nothing, do not count editing as saving
} else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
DOLPHIN_DEED(DolphinDeedNfcAddSave);
} else {
DOLPHIN_DEED(DolphinDeedNfcSave);
}
consumed = true;
} else {
consumed = scene_manager_search_and_switch_to_previous_scene(

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_save_success_popup_callback(void* context) {
Nfc* nfc = context;
@@ -8,7 +7,6 @@ void nfc_scene_save_success_popup_callback(void* context) {
void nfc_scene_save_success_on_enter(void* context) {
Nfc* nfc = context;
DOLPHIN_DEED(DolphinDeedNfcSave);
// Setup view
Popup* popup = nfc->popup;

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
enum SubmenuIndex {
SubmenuIndexEmulate,
@@ -76,6 +77,7 @@ bool nfc_scene_saved_menu_on_event(void* context, SceneManagerEvent event) {
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneEmulateUid);
}
DOLPHIN_DEED(DolphinDeedNfcEmulate);
consumed = true;
} else if(event.event == SubmenuIndexRename) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);

View File

@@ -1,5 +1,4 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
void nfc_scene_set_uid_byte_input_callback(void* context) {
Nfc* nfc = context;
@@ -30,7 +29,6 @@ bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventByteInputDone) {
DOLPHIN_DEED(DolphinDeedNfcAddSave);
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSavedMenu)) {
nfc->dev->dev_data.nfc_data = nfc->dev_edit_data;
if(nfc_device_save(nfc->dev, nfc->dev->dev_name)) {

View File

@@ -1,4 +1,5 @@
#include "../nfc_i.h"
#include <dolphin/dolphin.h>
enum SubmenuIndex {
SubmenuIndexRead,
@@ -47,11 +48,13 @@ bool nfc_scene_start_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexRead) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneRead);
DOLPHIN_DEED(DolphinDeedNfcRead);
consumed = true;
} else if(event.event == SubmenuIndexDetectReader) {
bool sd_exist = storage_sd_status(nfc->dev->storage) == FSE_OK;
if(sd_exist) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneDetectReader);
DOLPHIN_DEED(DolphinDeedNfcDetectReader);
} else {
scene_manager_next_scene(nfc->scene_manager, NfcSceneDictNotFound);
}