-
Notifications
You must be signed in to change notification settings - Fork 20
/
mifare_nested_i.h
181 lines (149 loc) · 4.59 KB
/
mifare_nested_i.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#pragma once
#include "mifare_nested.h"
#include "mifare_nested_worker.h"
#include "lib/nested/nested.h"
#include <furi.h>
#include <gui/gui.h>
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <notification/notification_messages.h>
#include <gui/modules/submenu.h>
#include <gui/modules/popup.h>
#include <gui/modules/loading.h>
#include <gui/modules/text_input.h>
#include <gui/modules/widget.h>
#include <input/input.h>
#include "scenes/mifare_nested_scene.h"
#include <storage/storage.h>
#include <lib/toolbox/path.h>
#include <lib/nfc/nfc_device.h>
#include <lib/toolbox/value_index.h>
#include <gui/modules/variable_item_list.h>
#include "mifare_nested_icons.h"
#define NESTED_VERSION_APP "1.5.2"
#define NESTED_GITHUB_LINK "https://github.com/AloneLiberty/FlipperNested"
#define NESTED_RECOVER_KEYS_GITHUB_LINK "https://github.com/AloneLiberty/FlipperNestedRecovery"
#define NESTED_NONCE_FORMAT_VERSION "3"
#define NESTED_AUTHOR "@AloneLiberty (t.me/libertydev)"
enum MifareNestedCustomEvent {
// Reserve first 100 events for button types and indexes, starting from 0
MifareNestedCustomEventReserved = 100,
MifareNestedCustomEventViewExit,
MifareNestedCustomEventWorkerExit,
MifareNestedCustomEventByteInputDone,
MifareNestedCustomEventTextInputDone,
MifareNestedCustomEventSceneSettingLock
};
typedef void (*NestedCallback)(void* context);
typedef struct {
FuriMutex* mutex;
FuriMessageQueue* event_queue;
ViewPort* view_port;
View* view;
NestedCallback callback;
void* context;
} NestedState;
typedef void (*CheckKeysCallback)(void* context);
typedef struct {
FuriMutex* mutex;
FuriMessageQueue* event_queue;
ViewPort* view_port;
View* view;
CheckKeysCallback callback;
void* context;
} CheckKeysState;
typedef enum {
EventTypeTick,
EventTypeKey,
} EventType;
typedef struct {
EventType type;
InputEvent input;
} PluginEvent;
typedef struct {
bool only_hardnested;
} MifareNestedSettings;
typedef enum { NestedRunIdle, NestedRunCheckKeys, NestedRunAttack } NestedRunNext;
struct MifareNested {
MifareNestedWorker* worker;
ViewDispatcher* view_dispatcher;
Gui* gui;
NotificationApp* notifications;
SceneManager* scene_manager;
NfcDevice* nfc_dev;
VariableItemList* variable_item_list;
MifareNestedSettings* settings;
FuriString* text_box_store;
// Common Views
Submenu* submenu;
Popup* popup;
Loading* loading;
TextInput* text_input;
Widget* widget;
NonceList_t* nonces;
KeyInfo_t* keys;
NestedState* nested_state;
CheckKeysState* keys_state;
SaveNoncesResult_t* save_state;
MifareNestedWorkerState collecting_type;
NestedRunNext run;
};
typedef enum {
MifareNestedViewMenu,
MifareNestedViewPopup,
MifareNestedViewLoading,
MifareNestedViewTextInput,
MifareNestedViewWidget,
MifareNestedViewVariableList,
MifareNestedViewCollecting,
MifareNestedViewCheckKeys,
} MifareNestedView;
typedef struct {
FuriString* header;
uint32_t keys_count;
uint32_t nonces_collected;
uint32_t hardnested_states;
bool lost_tag;
bool calibrating;
bool need_prediction;
bool hardnested;
} NestedAttackViewModel;
typedef struct {
FuriString* header;
uint32_t keys_count;
uint32_t keys_checked;
uint32_t keys_found;
uint32_t keys_total;
bool lost_tag;
bool processing_keys;
} CheckKeysViewModel;
static const NotificationSequence mifare_nested_sequence_blink_start_blue = {
&message_blink_start_10,
&message_blink_set_color_blue,
&message_do_not_reset,
NULL,
};
static const NotificationSequence mifare_nested_sequence_blink_start_magenta = {
&message_blink_start_10,
&message_blink_set_color_magenta,
&message_do_not_reset,
NULL,
};
static const NotificationSequence mifare_nested_sequence_blink_start_yellow = {
&message_blink_start_10,
&message_blink_set_color_yellow,
&message_do_not_reset,
NULL,
};
static const NotificationSequence mifare_nested_sequence_blink_stop = {
&message_blink_stop,
NULL,
};
MifareNested* mifare_nested_alloc();
void mifare_nested_text_store_set(MifareNested* mifare_nested, const char* text, ...);
void mifare_nested_text_store_clear(MifareNested* mifare_nested);
void mifare_nested_blink_start(MifareNested* mifare_nested);
void mifare_nested_blink_calibration_start(MifareNested* mifare_nested);
void mifare_nested_blink_nonce_collection_start(MifareNested* mifare_nested);
void mifare_nested_blink_stop(MifareNested* mifare_nested);
void mifare_nested_show_loading_popup(void* context, bool show);