MX 2 лет назад
Сommit
e7100c7216
8 измененных файлов с 221 добавлено и 0 удалено
  1. BIN
      .flipcorg/gallery/Screenshot-20230223-203332.png
  2. 21 0
      LICENSE
  3. 5 0
      README.md
  4. 11 0
      application.fam
  5. BIN
      icon.png
  6. BIN
      images/icon_10x10.png
  7. BIN
      images/ok_64x64.png
  8. 184 0
      key_generator.c

BIN
.flipcorg/gallery/Screenshot-20230223-203332.png


+ 21 - 0
LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2023 Milk-Cool
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 5 - 0
README.md

@@ -0,0 +1,5 @@
+# fz-em4100-generator [![FlipC.org](https://flipc.org/Milk-Cool/fz-em4100-generator/badge)](https://flipc.org/Milk-Cool/fz-em4100-generator)
+A program that generates universal keys from a EM4100 key
+
+## Installing
+Click the FAP badge, connect your flipper and click "Install".

+ 11 - 0
application.fam

@@ -0,0 +1,11 @@
+App(
+    appid="key_generator",
+    name="EM4100 Key generator",
+    apptype=FlipperAppType.EXTERNAL,
+    entry_point="key_generator_main",
+    requires=["gui"],
+    stack_size=1 * 1024,
+    fap_category="Tools_Extra",
+    fap_icon_assets="images",
+    fap_icon="icon.png",
+)


BIN
images/icon_10x10.png


BIN
images/ok_64x64.png


+ 184 - 0
key_generator.c

@@ -0,0 +1,184 @@
+#include <furi.h>
+#include <furi_hal.h>
+
+#include <gui/gui.h>
+#include <input/input.h>
+#include <dialogs/dialogs.h>
+#include <storage/storage.h>
+#include <flipper_format/flipper_format.h>
+
+#include <notification/notification.h>
+#include <notification/notification_messages.h>
+
+#include "key_generator_icons.h"
+
+FuriString* file_path;
+FuriString* key;
+
+// Screen is 128x64 px
+static void app_draw_callback(Canvas* canvas, void* ctx) {
+    UNUSED(ctx);
+
+    canvas_clear(canvas);
+    canvas_draw_icon(canvas, 0, 0, &I_ok_64x64);
+    canvas_draw_str(canvas, 80, 24, "Saved as");
+    canvas_draw_str(canvas, 75, 36, "rfidfuzzer/");
+    canvas_draw_str(canvas, 70, 48, "generated.txt");
+}
+
+static void app_input_callback(InputEvent* input_event, void* ctx) {
+    furi_assert(ctx);
+
+    FuriMessageQueue* event_queue = ctx;
+    furi_message_queue_put(event_queue, input_event, FuriWaitForever);
+}
+
+static void beep() {
+    NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
+    notification_message(notification, &sequence_success);
+    furi_record_close(RECORD_NOTIFICATION);
+}
+
+int32_t key_generator_main(void* p) {
+    UNUSED(p);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
+
+    // Configure view port
+    ViewPort* view_port = view_port_alloc();
+    view_port_draw_callback_set(view_port, app_draw_callback, view_port);
+    view_port_input_callback_set(view_port, app_input_callback, event_queue);
+
+    // Register view port in GUI
+    Gui* gui = furi_record_open(RECORD_GUI);
+    gui_add_view_port(gui, view_port, GuiLayerFullscreen);
+
+    // Selecting file
+    file_path = furi_string_alloc_set_str("/ext/lfrfid");
+    key = furi_string_alloc_set_str("");
+    DialogsFileBrowserOptions browser_options;
+    dialog_file_browser_set_basic_options(&browser_options, ".rfid", &I_icon_10x10);
+    browser_options.base_path = "/ext/lfrfid";
+    DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
+    bool running = dialog_file_browser_show(dialogs, file_path, file_path, &browser_options);
+    furi_record_close(RECORD_DIALOGS);
+
+    if(running) {
+        Storage* storage = furi_record_open(RECORD_STORAGE);
+        FlipperFormat* format = flipper_format_file_alloc(storage);
+
+        // Parsing file
+        flipper_format_file_open_existing(format, furi_string_get_cstr(file_path));
+        flipper_format_read_string(format, "Data", key);
+        furi_string_replace_str(key, " ", "", 0);
+
+        flipper_format_file_close(format);
+        flipper_format_free(format);
+
+        File* file = storage_file_alloc(storage);
+        bool ok =
+            storage_file_open(file, "/ext/rfidfuzzer/generated.txt", FSAM_WRITE, FSOM_OPEN_ALWAYS);
+        if(ok) {
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"11111111\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"22222222\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"33333333\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"44444444\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"55555555\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"66666666\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"77777777\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"88888888\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"99999999\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"AAAAAAAA\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"BBBBBBBB\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"CCCCCCCC\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"DDDDDDDD\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"EEEEEEEE\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"FFFFFFFF\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"12345678\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"01234567\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"98765432\r\n", 10);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 2);
+            storage_file_write(file, (uint8_t*)"FEDCBA98\r\n", 10);
+
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"111111\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"222222\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"333333\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"444444\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"555555\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"666666\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"777777\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"888888\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"999999\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"AAAAAA\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"BBBBBB\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"CCCCCC\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"DDDDDD\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"EEEEEE\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"FFFFFF\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"123456\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"012345\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"987654\r\n", 8);
+            storage_file_write(file, (uint8_t*)furi_string_get_cstr(key), 4);
+            storage_file_write(file, (uint8_t*)"FEDCBA\r\n", 8);
+        }
+        storage_file_close(file);
+        storage_file_free(file);
+
+        furi_record_close(RECORD_STORAGE);
+
+        beep();
+    }
+
+    InputEvent event;
+
+    while(running) {
+        if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
+            if(event.type == InputTypePress && event.key == InputKeyBack) running = false;
+        }
+        view_port_update(view_port);
+    }
+
+    view_port_enabled_set(view_port, false);
+    gui_remove_view_port(gui, view_port);
+    view_port_free(view_port);
+    furi_message_queue_free(event_queue);
+
+    furi_record_close(RECORD_GUI);
+
+    return 0;
+}