mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
Fix ibtn fuzzer file loading (temp)
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
-----
|
-----
|
||||||
* Only in release 052 -> **Multiple Extra pack apps was fixed!** -> TAMA P1, Flizzer Tracker, Video Player, Music Tracker
|
* Only in release 052 -> **Multiple Extra pack apps was fixed!** -> TAMA P1, Flizzer Tracker, Video Player, Music Tracker
|
||||||
* NFC V: Remove delay from emulation loop. This improves compatibility when the reader is Android.
|
* NFC V: Remove delay from emulation loop. This improves compatibility when the reader is Android.
|
||||||
|
* Plugins: iButton Fuzzer -> Fix v2 key files load (all new saved files)
|
||||||
### Previous changes
|
### Previous changes
|
||||||
* SubGHz Remote: Fixed BinRAW support, + many other fixes (by @gid9798 | PR #492)
|
* SubGHz Remote: Fixed BinRAW support, + many other fixes (by @gid9798 | PR #492)
|
||||||
* SubGHz: Fix KL: Stilmatic support + add manually support
|
* SubGHz: Fix KL: Stilmatic support + add manually support
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ bool ibtnfuzzer_load(iBtnFuzzerState* context, const char* file_path) {
|
|||||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||||
FuriString* temp_str;
|
FuriString* temp_str;
|
||||||
temp_str = furi_string_alloc();
|
temp_str = furi_string_alloc();
|
||||||
|
bool key_v2 = false;
|
||||||
do {
|
do {
|
||||||
if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
|
if(!flipper_format_file_open_existing(fff_data_file, file_path)) {
|
||||||
FURI_LOG_E(TAG, "Error open file %s", file_path);
|
FURI_LOG_E(TAG, "Error open file %s", file_path);
|
||||||
@@ -30,10 +31,43 @@ bool ibtnfuzzer_load(iBtnFuzzerState* context, const char* file_path) {
|
|||||||
|
|
||||||
// Key type
|
// Key type
|
||||||
if(!flipper_format_read_string(fff_data_file, "Key type", temp_str)) {
|
if(!flipper_format_read_string(fff_data_file, "Key type", temp_str)) {
|
||||||
FURI_LOG_E(TAG, "Missing or incorrect Key type");
|
FURI_LOG_E(TAG, "Missing or incorrect Key type, checking for typ2..");
|
||||||
furi_string_reset(context->notification_msg);
|
|
||||||
furi_string_set(context->notification_msg, "Missing or incorrect Key type");
|
if(!flipper_format_rewind(fff_data_file)) {
|
||||||
break;
|
FURI_LOG_E(TAG, "Failed to rewind file");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) {
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(
|
||||||
|
context->notification_msg, "Missing or incorrect Protocol or Key type");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
FURI_LOG_I(TAG, "Key type V2: %s", furi_string_get_cstr(temp_str));
|
||||||
|
key_v2 = true;
|
||||||
|
|
||||||
|
if(context->proto == DS1990) {
|
||||||
|
if(strcmp(furi_string_get_cstr(temp_str), "DS1990") != 0) {
|
||||||
|
FURI_LOG_E(TAG, "Unsupported Key type");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Unsupported Key type");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if(context->proto == Cyfral) {
|
||||||
|
if(strcmp(furi_string_get_cstr(temp_str), "Cyfral") != 0) {
|
||||||
|
FURI_LOG_E(TAG, "Unsupported Key type");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Unsupported Key type");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(strcmp(furi_string_get_cstr(temp_str), "Metakom") != 0) {
|
||||||
|
FURI_LOG_E(TAG, "Unsupported Key type");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Unsupported Key type");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FURI_LOG_I(TAG, "Key type: %s", furi_string_get_cstr(temp_str));
|
FURI_LOG_I(TAG, "Key type: %s", furi_string_get_cstr(temp_str));
|
||||||
|
|
||||||
@@ -60,46 +94,125 @@ bool ibtnfuzzer_load(iBtnFuzzerState* context, const char* file_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!key_v2) {
|
||||||
// Data
|
// Data
|
||||||
if(!flipper_format_read_string(fff_data_file, "Data", context->data_str)) {
|
if(!flipper_format_read_string(fff_data_file, "Data", context->data_str)) {
|
||||||
FURI_LOG_E(TAG, "Missing or incorrect Data");
|
FURI_LOG_E(TAG, "Missing or incorrect Data");
|
||||||
furi_string_reset(context->notification_msg);
|
furi_string_reset(context->notification_msg);
|
||||||
furi_string_set(context->notification_msg, "Missing or incorrect Key");
|
furi_string_set(context->notification_msg, "Missing or incorrect Key");
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
FURI_LOG_I(TAG, "Key: %s", furi_string_get_cstr(context->data_str));
|
|
||||||
|
|
||||||
if(context->proto == DS1990) {
|
|
||||||
if(furi_string_size(context->data_str) != 23) {
|
|
||||||
FURI_LOG_E(TAG, "Incorrect Key length");
|
|
||||||
furi_string_reset(context->notification_msg);
|
|
||||||
furi_string_set(context->notification_msg, "Incorrect Key length");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if(context->proto == Cyfral) {
|
|
||||||
if(furi_string_size(context->data_str) != 5) {
|
|
||||||
FURI_LOG_E(TAG, "Incorrect Key length");
|
|
||||||
furi_string_reset(context->notification_msg);
|
|
||||||
furi_string_set(context->notification_msg, "Incorrect Key length");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(furi_string_size(context->data_str) != 11) {
|
FURI_LOG_I(TAG, "Key: %s", furi_string_get_cstr(context->data_str));
|
||||||
FURI_LOG_E(TAG, "Incorrect Key length");
|
|
||||||
furi_string_reset(context->notification_msg);
|
if(context->proto == DS1990) {
|
||||||
furi_string_set(context->notification_msg, "Incorrect Key length");
|
if(furi_string_size(context->data_str) != 23) {
|
||||||
break;
|
FURI_LOG_E(TAG, "Incorrect Key length");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Incorrect Key length");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if(context->proto == Cyfral) {
|
||||||
|
if(furi_string_size(context->data_str) != 5) {
|
||||||
|
FURI_LOG_E(TAG, "Incorrect Key length");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Incorrect Key length");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(furi_string_size(context->data_str) != 11) {
|
||||||
|
FURI_LOG_E(TAG, "Incorrect Key length");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Incorrect Key length");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// String to uint8_t
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
char temp_str2[3];
|
||||||
|
temp_str2[0] = furi_string_get_cstr(context->data_str)[i * 3];
|
||||||
|
temp_str2[1] = furi_string_get_cstr(context->data_str)[i * 3 + 1];
|
||||||
|
temp_str2[2] = '\0';
|
||||||
|
context->data[i] = (uint8_t)strtol(temp_str2, NULL, 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Data
|
||||||
|
if(context->proto == DS1990) {
|
||||||
|
if(!flipper_format_read_string(fff_data_file, "Rom Data", context->data_str)) {
|
||||||
|
FURI_LOG_E(TAG, "Missing or incorrect Rom Data");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Missing or incorrect Rom Data");
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
FURI_LOG_I(TAG, "Key: %s", furi_string_get_cstr(context->data_str));
|
||||||
|
|
||||||
// String to uint8_t
|
if(furi_string_size(context->data_str) != 23) {
|
||||||
for(uint8_t i = 0; i < 8; i++) {
|
FURI_LOG_E(TAG, "Incorrect Key length");
|
||||||
char temp_str2[3];
|
furi_string_reset(context->notification_msg);
|
||||||
temp_str2[0] = furi_string_get_cstr(context->data_str)[i * 3];
|
furi_string_set(context->notification_msg, "Incorrect Key length");
|
||||||
temp_str2[1] = furi_string_get_cstr(context->data_str)[i * 3 + 1];
|
break;
|
||||||
temp_str2[2] = '\0';
|
}
|
||||||
context->data[i] = (uint8_t)strtol(temp_str2, NULL, 16);
|
|
||||||
|
// String to uint8_t
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
char temp_str2[3];
|
||||||
|
temp_str2[0] = furi_string_get_cstr(context->data_str)[i * 3];
|
||||||
|
temp_str2[1] = furi_string_get_cstr(context->data_str)[i * 3 + 1];
|
||||||
|
temp_str2[2] = '\0';
|
||||||
|
context->data[i] = (uint8_t)strtol(temp_str2, NULL, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(context->proto == Cyfral) {
|
||||||
|
if(!flipper_format_read_string(fff_data_file, "Data", context->data_str)) {
|
||||||
|
FURI_LOG_E(TAG, "Missing or incorrect Data");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Missing or incorrect Data");
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
FURI_LOG_I(TAG, "Key: %s", furi_string_get_cstr(context->data_str));
|
||||||
|
|
||||||
|
if(furi_string_size(context->data_str) != 5) {
|
||||||
|
FURI_LOG_E(TAG, "Incorrect Key length");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Incorrect Key length");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String to uint8_t
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
char temp_str2[3];
|
||||||
|
temp_str2[0] = furi_string_get_cstr(context->data_str)[i * 3];
|
||||||
|
temp_str2[1] = furi_string_get_cstr(context->data_str)[i * 3 + 1];
|
||||||
|
temp_str2[2] = '\0';
|
||||||
|
context->data[i] = (uint8_t)strtol(temp_str2, NULL, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!flipper_format_read_string(fff_data_file, "Data", context->data_str)) {
|
||||||
|
FURI_LOG_E(TAG, "Missing or incorrect Data");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Missing or incorrect Data");
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
FURI_LOG_I(TAG, "Key: %s", furi_string_get_cstr(context->data_str));
|
||||||
|
|
||||||
|
if(furi_string_size(context->data_str) != 11) {
|
||||||
|
FURI_LOG_E(TAG, "Incorrect Key length");
|
||||||
|
furi_string_reset(context->notification_msg);
|
||||||
|
furi_string_set(context->notification_msg, "Incorrect Key length");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String to uint8_t
|
||||||
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
|
char temp_str2[3];
|
||||||
|
temp_str2[0] = furi_string_get_cstr(context->data_str)[i * 3];
|
||||||
|
temp_str2[1] = furi_string_get_cstr(context->data_str)[i * 3 + 1];
|
||||||
|
temp_str2[2] = '\0';
|
||||||
|
context->data[i] = (uint8_t)strtol(temp_str2, NULL, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user