@@ -10,6 +10,7 @@ bool ibtnfuzzer_load(iBtnFuzzerState* context, const char* file_path) {
10
10
FlipperFormat * fff_data_file = flipper_format_file_alloc (storage );
11
11
FuriString * temp_str ;
12
12
temp_str = furi_string_alloc ();
13
+ bool key_v2 = false;
13
14
do {
14
15
if (!flipper_format_file_open_existing (fff_data_file , file_path )) {
15
16
FURI_LOG_E (TAG , "Error open file %s" , file_path );
@@ -30,10 +31,43 @@ bool ibtnfuzzer_load(iBtnFuzzerState* context, const char* file_path) {
30
31
31
32
// Key type
32
33
if (!flipper_format_read_string (fff_data_file , "Key type" , temp_str )) {
33
- FURI_LOG_E (TAG , "Missing or incorrect Key type" );
34
- furi_string_reset (context -> notification_msg );
35
- furi_string_set (context -> notification_msg , "Missing or incorrect Key type" );
36
- break ;
34
+ FURI_LOG_E (TAG , "Missing or incorrect Key type, checking for typ2.." );
35
+
36
+ if (!flipper_format_rewind (fff_data_file )) {
37
+ FURI_LOG_E (TAG , "Failed to rewind file" );
38
+ break ;
39
+ }
40
+ if (!flipper_format_read_string (fff_data_file , "Protocol" , temp_str )) {
41
+ furi_string_reset (context -> notification_msg );
42
+ furi_string_set (
43
+ context -> notification_msg , "Missing or incorrect Protocol or Key type" );
44
+ break ;
45
+ }
46
+ FURI_LOG_I (TAG , "Key type V2: %s" , furi_string_get_cstr (temp_str ));
47
+ key_v2 = true;
48
+
49
+ if (context -> proto == DS1990 ) {
50
+ if (strcmp (furi_string_get_cstr (temp_str ), "DS1990" ) != 0 ) {
51
+ FURI_LOG_E (TAG , "Unsupported Key type" );
52
+ furi_string_reset (context -> notification_msg );
53
+ furi_string_set (context -> notification_msg , "Unsupported Key type" );
54
+ break ;
55
+ }
56
+ } else if (context -> proto == Cyfral ) {
57
+ if (strcmp (furi_string_get_cstr (temp_str ), "Cyfral" ) != 0 ) {
58
+ FURI_LOG_E (TAG , "Unsupported Key type" );
59
+ furi_string_reset (context -> notification_msg );
60
+ furi_string_set (context -> notification_msg , "Unsupported Key type" );
61
+ break ;
62
+ }
63
+ } else {
64
+ if (strcmp (furi_string_get_cstr (temp_str ), "Metakom" ) != 0 ) {
65
+ FURI_LOG_E (TAG , "Unsupported Key type" );
66
+ furi_string_reset (context -> notification_msg );
67
+ furi_string_set (context -> notification_msg , "Unsupported Key type" );
68
+ break ;
69
+ }
70
+ }
37
71
} else {
38
72
FURI_LOG_I (TAG , "Key type: %s" , furi_string_get_cstr (temp_str ));
39
73
@@ -60,46 +94,125 @@ bool ibtnfuzzer_load(iBtnFuzzerState* context, const char* file_path) {
60
94
}
61
95
}
62
96
}
97
+ if (!key_v2 ) {
98
+ // Data
99
+ if (!flipper_format_read_string (fff_data_file , "Data" , context -> data_str )) {
100
+ FURI_LOG_E (TAG , "Missing or incorrect Data" );
101
+ furi_string_reset (context -> notification_msg );
102
+ furi_string_set (context -> notification_msg , "Missing or incorrect Key" );
103
+ break ;
104
+ } else {
105
+ FURI_LOG_I (TAG , "Key: %s" , furi_string_get_cstr (context -> data_str ));
63
106
64
- // Data
65
- if (!flipper_format_read_string (fff_data_file , "Data" , context -> data_str )) {
66
- FURI_LOG_E (TAG , "Missing or incorrect Data" );
67
- furi_string_reset (context -> notification_msg );
68
- furi_string_set (context -> notification_msg , "Missing or incorrect Key" );
69
- break ;
70
- } else {
71
- FURI_LOG_I (TAG , "Key: %s" , furi_string_get_cstr (context -> data_str ));
107
+ if (context -> proto == DS1990 ) {
108
+ if (furi_string_size (context -> data_str ) != 23 ) {
109
+ FURI_LOG_E (TAG , "Incorrect Key length" );
110
+ furi_string_reset (context -> notification_msg );
111
+ furi_string_set (context -> notification_msg , "Incorrect Key length" );
112
+ break ;
113
+ }
114
+ } else if (context -> proto == Cyfral ) {
115
+ if (furi_string_size (context -> data_str ) != 5 ) {
116
+ FURI_LOG_E (TAG , "Incorrect Key length" );
117
+ furi_string_reset (context -> notification_msg );
118
+ furi_string_set (context -> notification_msg , "Incorrect Key length" );
119
+ break ;
120
+ }
121
+ } else {
122
+ if (furi_string_size (context -> data_str ) != 11 ) {
123
+ FURI_LOG_E (TAG , "Incorrect Key length" );
124
+ furi_string_reset (context -> notification_msg );
125
+ furi_string_set (context -> notification_msg , "Incorrect Key length" );
126
+ break ;
127
+ }
128
+ }
72
129
130
+ // String to uint8_t
131
+ for (uint8_t i = 0 ; i < 8 ; i ++ ) {
132
+ char temp_str2 [3 ];
133
+ temp_str2 [0 ] = furi_string_get_cstr (context -> data_str )[i * 3 ];
134
+ temp_str2 [1 ] = furi_string_get_cstr (context -> data_str )[i * 3 + 1 ];
135
+ temp_str2 [2 ] = '\0' ;
136
+ context -> data [i ] = (uint8_t )strtol (temp_str2 , NULL , 16 );
137
+ }
138
+ }
139
+ } else {
140
+ // Data
73
141
if (context -> proto == DS1990 ) {
74
- if (furi_string_size ( context -> data_str ) != 23 ) {
75
- FURI_LOG_E (TAG , "Incorrect Key length " );
142
+ if (! flipper_format_read_string ( fff_data_file , "Rom Data" , context -> data_str )) {
143
+ FURI_LOG_E (TAG , "Missing or incorrect Rom Data " );
76
144
furi_string_reset (context -> notification_msg );
77
- furi_string_set (context -> notification_msg , "Incorrect Key length " );
145
+ furi_string_set (context -> notification_msg , "Missing or incorrect Rom Data " );
78
146
break ;
147
+ } else {
148
+ FURI_LOG_I (TAG , "Key: %s" , furi_string_get_cstr (context -> data_str ));
149
+
150
+ if (furi_string_size (context -> data_str ) != 23 ) {
151
+ FURI_LOG_E (TAG , "Incorrect Key length" );
152
+ furi_string_reset (context -> notification_msg );
153
+ furi_string_set (context -> notification_msg , "Incorrect Key length" );
154
+ break ;
155
+ }
156
+
157
+ // String to uint8_t
158
+ for (uint8_t i = 0 ; i < 8 ; i ++ ) {
159
+ char temp_str2 [3 ];
160
+ temp_str2 [0 ] = furi_string_get_cstr (context -> data_str )[i * 3 ];
161
+ temp_str2 [1 ] = furi_string_get_cstr (context -> data_str )[i * 3 + 1 ];
162
+ temp_str2 [2 ] = '\0' ;
163
+ context -> data [i ] = (uint8_t )strtol (temp_str2 , NULL , 16 );
164
+ }
79
165
}
80
166
} else if (context -> proto == Cyfral ) {
81
- if (furi_string_size ( context -> data_str ) != 5 ) {
82
- FURI_LOG_E (TAG , "Incorrect Key length " );
167
+ if (! flipper_format_read_string ( fff_data_file , "Data" , context -> data_str )) {
168
+ FURI_LOG_E (TAG , "Missing or incorrect Data " );
83
169
furi_string_reset (context -> notification_msg );
84
- furi_string_set (context -> notification_msg , "Incorrect Key length " );
170
+ furi_string_set (context -> notification_msg , "Missing or incorrect Data " );
85
171
break ;
172
+ } else {
173
+ FURI_LOG_I (TAG , "Key: %s" , furi_string_get_cstr (context -> data_str ));
174
+
175
+ if (furi_string_size (context -> data_str ) != 5 ) {
176
+ FURI_LOG_E (TAG , "Incorrect Key length" );
177
+ furi_string_reset (context -> notification_msg );
178
+ furi_string_set (context -> notification_msg , "Incorrect Key length" );
179
+ break ;
180
+ }
181
+
182
+ // String to uint8_t
183
+ for (uint8_t i = 0 ; i < 8 ; i ++ ) {
184
+ char temp_str2 [3 ];
185
+ temp_str2 [0 ] = furi_string_get_cstr (context -> data_str )[i * 3 ];
186
+ temp_str2 [1 ] = furi_string_get_cstr (context -> data_str )[i * 3 + 1 ];
187
+ temp_str2 [2 ] = '\0' ;
188
+ context -> data [i ] = (uint8_t )strtol (temp_str2 , NULL , 16 );
189
+ }
86
190
}
87
191
} else {
88
- if (furi_string_size ( context -> data_str ) != 11 ) {
89
- FURI_LOG_E (TAG , "Incorrect Key length " );
192
+ if (! flipper_format_read_string ( fff_data_file , "Data" , context -> data_str )) {
193
+ FURI_LOG_E (TAG , "Missing or incorrect Data " );
90
194
furi_string_reset (context -> notification_msg );
91
- furi_string_set (context -> notification_msg , "Incorrect Key length " );
195
+ furi_string_set (context -> notification_msg , "Missing or incorrect Data " );
92
196
break ;
93
- }
94
- }
197
+ } else {
198
+ FURI_LOG_I ( TAG , "Key: %s" , furi_string_get_cstr ( context -> data_str ));
95
199
96
- // String to uint8_t
97
- for (uint8_t i = 0 ; i < 8 ; i ++ ) {
98
- char temp_str2 [3 ];
99
- temp_str2 [0 ] = furi_string_get_cstr (context -> data_str )[i * 3 ];
100
- temp_str2 [1 ] = furi_string_get_cstr (context -> data_str )[i * 3 + 1 ];
101
- temp_str2 [2 ] = '\0' ;
102
- context -> data [i ] = (uint8_t )strtol (temp_str2 , NULL , 16 );
200
+ if (furi_string_size (context -> data_str ) != 11 ) {
201
+ FURI_LOG_E (TAG , "Incorrect Key length" );
202
+ furi_string_reset (context -> notification_msg );
203
+ furi_string_set (context -> notification_msg , "Incorrect Key length" );
204
+ break ;
205
+ }
206
+
207
+ // String to uint8_t
208
+ for (uint8_t i = 0 ; i < 8 ; i ++ ) {
209
+ char temp_str2 [3 ];
210
+ temp_str2 [0 ] = furi_string_get_cstr (context -> data_str )[i * 3 ];
211
+ temp_str2 [1 ] = furi_string_get_cstr (context -> data_str )[i * 3 + 1 ];
212
+ temp_str2 [2 ] = '\0' ;
213
+ context -> data [i ] = (uint8_t )strtol (temp_str2 , NULL , 16 );
214
+ }
215
+ }
103
216
}
104
217
}
105
218
0 commit comments