Skip to content

Commit 5bcc8b9

Browse files
authored
Merge pull request #17 from ahnilica/uids-file-fix-up-arrow-issue14
Fixed prev navigation for AttackTypeLoadFileCustomUids
2 parents 3d772e7 + b37465b commit 5bcc8b9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lib/worker/fake_worker.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,11 @@ static bool fuzzer_worker_load_key(FuzzerWorker* instance, bool next) {
141141
break;
142142

143143
case FuzzerWorkerAttackTypeLoadFileCustomUids: {
144-
if(next) {
145-
instance->index++;
146-
}
147144
uint8_t str_len = protocol->data_size * 2 + 1;
148145
FuriString* data_str = furi_string_alloc();
149146
while(true) {
150147
furi_string_reset(data_str);
151148
if(!stream_read_line(instance->uids_stream, data_str)) {
152-
stream_rewind(instance->uids_stream);
153149
// TODO Check empty file & close stream and storage
154150
break;
155151
} else if(furi_string_get_char(data_str, 0) == '#') {
@@ -172,6 +168,9 @@ static bool fuzzer_worker_load_key(FuzzerWorker* instance, bool next) {
172168
}
173169
}
174170
res = parse_ok;
171+
if(res && next) {
172+
instance->index++;
173+
}
175174
}
176175
break;
177176
}
@@ -219,6 +218,22 @@ static bool fuzzer_worker_load_previous_key(FuzzerWorker* instance) {
219218
}
220219
break;
221220

221+
case FuzzerWorkerAttackTypeLoadFileCustomUids:
222+
if(instance->index == 0 || instance->uids_stream == NULL) {
223+
break;
224+
}
225+
instance->index--;
226+
stream_rewind(instance->uids_stream);
227+
228+
bool ok = false;
229+
uint16_t steps = (uint16_t)(instance->index + 1);
230+
for(uint16_t i = 0; i < steps; i++) {
231+
ok = fuzzer_worker_load_key(instance, false);
232+
if(!ok) break;
233+
}
234+
res = ok;
235+
break;
236+
222237
case FuzzerWorkerAttackTypeLoadFile:
223238
if(instance->payload[instance->index] != 0x00) {
224239
instance->payload[instance->index]--;

0 commit comments

Comments
 (0)