Skip to content

Commit 0685939

Browse files
committed
Move apps from flipperzero firmware into separate repository
0 parents  commit 0685939

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5150
-0
lines changed

125_10px.png

308 Bytes
Loading

application.fam

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
App(
2+
appid="picopass",
3+
name="PicoPass",
4+
apptype=FlipperAppType.EXTERNAL,
5+
targets=["f7"],
6+
entry_point="picopass_app",
7+
requires=[
8+
"storage",
9+
"gui",
10+
],
11+
stack_size=4 * 1024,
12+
order=30,
13+
fap_icon="125_10px.png",
14+
fap_category="NFC",
15+
fap_libs=["mbedtls"],
16+
fap_private_libs=[
17+
Lib(
18+
name="loclass",
19+
),
20+
],
21+
fap_icon_assets="icons",
22+
)

helpers/iclass_elite_dict.c

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
#include "iclass_elite_dict.h"
2+
3+
#include <lib/toolbox/args.h>
4+
#include <lib/flipper_format/flipper_format.h>
5+
6+
#define ICLASS_ELITE_DICT_FLIPPER_NAME APP_DATA_PATH("assets/iclass_elite_dict.txt")
7+
#define ICLASS_ELITE_DICT_USER_NAME APP_DATA_PATH("assets/iclass_elite_dict_user.txt")
8+
#define ICLASS_STANDARD_DICT_FLIPPER_NAME APP_DATA_PATH("assets/iclass_standard_dict.txt")
9+
10+
#define TAG "IclassEliteDict"
11+
12+
#define ICLASS_ELITE_KEY_LINE_LEN (17)
13+
#define ICLASS_ELITE_KEY_LEN (8)
14+
15+
struct IclassEliteDict {
16+
Stream* stream;
17+
uint32_t total_keys;
18+
};
19+
20+
bool iclass_elite_dict_check_presence(IclassEliteDictType dict_type) {
21+
Storage* storage = furi_record_open(RECORD_STORAGE);
22+
23+
bool dict_present = false;
24+
if(dict_type == IclassEliteDictTypeFlipper) {
25+
dict_present =
26+
(storage_common_stat(storage, ICLASS_ELITE_DICT_FLIPPER_NAME, NULL) == FSE_OK);
27+
} else if(dict_type == IclassEliteDictTypeUser) {
28+
dict_present = (storage_common_stat(storage, ICLASS_ELITE_DICT_USER_NAME, NULL) == FSE_OK);
29+
} else if(dict_type == IclassStandardDictTypeFlipper) {
30+
dict_present =
31+
(storage_common_stat(storage, ICLASS_STANDARD_DICT_FLIPPER_NAME, NULL) == FSE_OK);
32+
}
33+
34+
furi_record_close(RECORD_STORAGE);
35+
36+
return dict_present;
37+
}
38+
39+
IclassEliteDict* iclass_elite_dict_alloc(IclassEliteDictType dict_type) {
40+
IclassEliteDict* dict = malloc(sizeof(IclassEliteDict));
41+
Storage* storage = furi_record_open(RECORD_STORAGE);
42+
dict->stream = buffered_file_stream_alloc(storage);
43+
FuriString* next_line = furi_string_alloc();
44+
45+
bool dict_loaded = false;
46+
do {
47+
if(dict_type == IclassEliteDictTypeFlipper) {
48+
if(!buffered_file_stream_open(
49+
dict->stream, ICLASS_ELITE_DICT_FLIPPER_NAME, FSAM_READ, FSOM_OPEN_EXISTING)) {
50+
buffered_file_stream_close(dict->stream);
51+
break;
52+
}
53+
} else if(dict_type == IclassEliteDictTypeUser) {
54+
if(!buffered_file_stream_open(
55+
dict->stream, ICLASS_ELITE_DICT_USER_NAME, FSAM_READ_WRITE, FSOM_OPEN_ALWAYS)) {
56+
buffered_file_stream_close(dict->stream);
57+
break;
58+
}
59+
} else if(dict_type == IclassStandardDictTypeFlipper) {
60+
if(!buffered_file_stream_open(
61+
dict->stream,
62+
ICLASS_STANDARD_DICT_FLIPPER_NAME,
63+
FSAM_READ,
64+
FSOM_OPEN_EXISTING)) {
65+
buffered_file_stream_close(dict->stream);
66+
break;
67+
}
68+
}
69+
70+
// Read total amount of keys
71+
while(true) { //-V547
72+
if(!stream_read_line(dict->stream, next_line)) break;
73+
if(furi_string_get_char(next_line, 0) == '#') continue;
74+
if(furi_string_size(next_line) != ICLASS_ELITE_KEY_LINE_LEN) continue;
75+
dict->total_keys++;
76+
}
77+
furi_string_reset(next_line);
78+
stream_rewind(dict->stream);
79+
80+
dict_loaded = true;
81+
FURI_LOG_I(TAG, "Loaded dictionary with %lu keys", dict->total_keys);
82+
} while(false);
83+
84+
if(!dict_loaded) { //-V547
85+
buffered_file_stream_close(dict->stream);
86+
free(dict);
87+
dict = NULL;
88+
}
89+
90+
furi_record_close(RECORD_STORAGE);
91+
furi_string_free(next_line);
92+
93+
return dict;
94+
}
95+
96+
void iclass_elite_dict_free(IclassEliteDict* dict) {
97+
furi_assert(dict);
98+
furi_assert(dict->stream);
99+
100+
buffered_file_stream_close(dict->stream);
101+
stream_free(dict->stream);
102+
free(dict);
103+
}
104+
105+
uint32_t iclass_elite_dict_get_total_keys(IclassEliteDict* dict) {
106+
furi_assert(dict);
107+
108+
return dict->total_keys;
109+
}
110+
111+
bool iclass_elite_dict_get_next_key(IclassEliteDict* dict, uint8_t* key) {
112+
furi_assert(dict);
113+
furi_assert(dict->stream);
114+
115+
uint8_t key_byte_tmp = 0;
116+
FuriString* next_line = furi_string_alloc();
117+
118+
bool key_read = false;
119+
*key = 0ULL;
120+
while(!key_read) {
121+
if(!stream_read_line(dict->stream, next_line)) break;
122+
if(furi_string_get_char(next_line, 0) == '#') continue;
123+
if(furi_string_size(next_line) != ICLASS_ELITE_KEY_LINE_LEN) continue;
124+
for(uint8_t i = 0; i < ICLASS_ELITE_KEY_LEN * 2; i += 2) {
125+
args_char_to_hex(
126+
furi_string_get_char(next_line, i),
127+
furi_string_get_char(next_line, i + 1),
128+
&key_byte_tmp);
129+
key[i / 2] = key_byte_tmp;
130+
}
131+
key_read = true;
132+
}
133+
134+
furi_string_free(next_line);
135+
return key_read;
136+
}
137+
138+
bool iclass_elite_dict_rewind(IclassEliteDict* dict) {
139+
furi_assert(dict);
140+
furi_assert(dict->stream);
141+
142+
return stream_rewind(dict->stream);
143+
}
144+
145+
bool iclass_elite_dict_add_key(IclassEliteDict* dict, uint8_t* key) {
146+
furi_assert(dict);
147+
furi_assert(dict->stream);
148+
149+
FuriString* key_str = furi_string_alloc();
150+
for(size_t i = 0; i < 6; i++) {
151+
furi_string_cat_printf(key_str, "%02X", key[i]);
152+
}
153+
furi_string_cat_printf(key_str, "\n");
154+
155+
bool key_added = false;
156+
do {
157+
if(!stream_seek(dict->stream, 0, StreamOffsetFromEnd)) break;
158+
if(!stream_insert_string(dict->stream, key_str)) break;
159+
key_added = true;
160+
} while(false);
161+
162+
furi_string_free(key_str);
163+
return key_added;
164+
}

helpers/iclass_elite_dict.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include <stdbool.h>
4+
#include <storage/storage.h>
5+
#include <lib/flipper_format/flipper_format.h>
6+
#include <lib/toolbox/stream/file_stream.h>
7+
#include <lib/toolbox/stream/buffered_file_stream.h>
8+
9+
typedef enum {
10+
IclassEliteDictTypeUser,
11+
IclassEliteDictTypeFlipper,
12+
IclassStandardDictTypeFlipper,
13+
} IclassEliteDictType;
14+
15+
typedef struct IclassEliteDict IclassEliteDict;
16+
17+
bool iclass_elite_dict_check_presence(IclassEliteDictType dict_type);
18+
19+
IclassEliteDict* iclass_elite_dict_alloc(IclassEliteDictType dict_type);
20+
21+
void iclass_elite_dict_free(IclassEliteDict* dict);
22+
23+
uint32_t iclass_elite_dict_get_total_keys(IclassEliteDict* dict);
24+
25+
bool iclass_elite_dict_get_next_key(IclassEliteDict* dict, uint8_t* key);
26+
27+
bool iclass_elite_dict_rewind(IclassEliteDict* dict);
28+
29+
bool iclass_elite_dict_add_key(IclassEliteDict* dict, uint8_t* key);

icons/DolphinMafia_115x62.png

2.45 KB
Loading

icons/DolphinNice_96x59.png

2.4 KB
Loading

icons/Nfc_10px.png

304 Bytes
Loading

icons/RFIDDolphinReceive_97x61.png

1.39 KB
Loading

icons/RFIDDolphinSend_97x61.png

1.38 KB
Loading

0 commit comments

Comments
 (0)