diff --git a/ReadMe.md b/ReadMe.md index 081dacb32..bb3523431 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -5,7 +5,6 @@ To Be Added/To Verify Present: - [Game of Life (Updated to work by tgxn) (By itsyourbedtime)](https://github.com/tgxn/flipperzero-firmware/blob/dev/applications/game_of_life/game_of_life.c) - [Mandelbrot Set (By Possibly-Matt)](https://github.com/Possibly-Matt/flipperzero-firmware-wPlugins) - [Monty Hall (By DevMilanIan)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/pull/203) -- [RayCast (Bt Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/raycast-game-engine) - [TAMA P1 (By GMMan)](https://github.com/GMMan/flipperzero-firmware/tree/tama-p1) requires [this rom](https://tinyurl.com/tamap1) IN `tama_p1` on SD as `rom.bin` to make it work. - [Tanks (By Alexgr13)](https://github.com/alexgr13/flipperzero-firmware/tree/fork/dev/applications/tanks-game) - [Video Poker (By PixlEmly)](https://github.com/PixlEmly/flipperzero-firmware-testing/blob/420/applications/VideoPoker/poker.c) @@ -33,6 +32,7 @@ To Be Added/To Verify Present: - [RFID: fix read info screen #1723 (By nminaylov)](https://github.com/flipperdevices/flipperzero-firmware/pull/1723) - [SubGhz: fix display information in the file if the frequenc… #1724 (By Skorpionm)](https://github.com/flipperdevices/flipperzero-firmware/pull/1724) - [Show error popup when NFC chip is not init/disconnected #1722 (By Astrrra)](https://github.com/flipperdevices/flipperzero-firmware/pull/1722) +- Fix Passport Pic Lvls Documentation Implemented: diff --git a/applications/plugins/game2048/2048.png b/applications/plugins/game2048/2048.png index 79862b99c..517a30564 100644 Binary files a/applications/plugins/game2048/2048.png and b/applications/plugins/game2048/2048.png differ diff --git a/applications/plugins/wifi_deauther/application.fam b/applications/plugins/wifi_deauther/application.fam new file mode 100644 index 000000000..15d172982 --- /dev/null +++ b/applications/plugins/wifi_deauther/application.fam @@ -0,0 +1,12 @@ +App( + appid="APPS_wifi_deauther", + name="[ESP8266] WiFi (Deauther)", + apptype=FlipperAppType.EXTERNAL, + entry_point="wifi_deauther_app", + cdefines=["APP_WIFI_deauther"], + requires=["gui"], + stack_size=1 * 1024, + order=101, + fap_icon="wifi_10px.png", + fap_category="GPIO", +) diff --git a/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene.c b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene.c new file mode 100644 index 000000000..a974beea9 --- /dev/null +++ b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene.c @@ -0,0 +1,30 @@ +#include "wifi_deauther_scene.h" + +// Generate scene on_enter handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, +void (*const wifi_deauther_scene_on_enter_handlers[])(void*) = { +#include "wifi_deauther_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_event handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, +bool (*const wifi_deauther_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = { +#include "wifi_deauther_scene_config.h" +}; +#undef ADD_SCENE + +// Generate scene on_exit handlers array +#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, +void (*const wifi_deauther_scene_on_exit_handlers[])(void* context) = { +#include "wifi_deauther_scene_config.h" +}; +#undef ADD_SCENE + +// Initialize scene handlers configuration structure +const SceneManagerHandlers wifi_deauther_scene_handlers = { + .on_enter_handlers = wifi_deauther_scene_on_enter_handlers, + .on_event_handlers = wifi_deauther_scene_on_event_handlers, + .on_exit_handlers = wifi_deauther_scene_on_exit_handlers, + .scene_num = WifideautherSceneNum, +}; diff --git a/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene.h b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene.h new file mode 100644 index 000000000..a6ef08553 --- /dev/null +++ b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +// Generate scene id and total number +#define ADD_SCENE(prefix, name, id) WifideautherScene##id, +typedef enum { +#include "wifi_deauther_scene_config.h" + WifideautherSceneNum, +} WifideautherScene; +#undef ADD_SCENE + +extern const SceneManagerHandlers wifi_deauther_scene_handlers; + +// Generate scene on_enter handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); +#include "wifi_deauther_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_event handlers declaration +#define ADD_SCENE(prefix, name, id) \ + bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); +#include "wifi_deauther_scene_config.h" +#undef ADD_SCENE + +// Generate scene on_exit handlers declaration +#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); +#include "wifi_deauther_scene_config.h" +#undef ADD_SCENE diff --git a/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_config.h b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_config.h new file mode 100644 index 000000000..5f21cdc50 --- /dev/null +++ b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_config.h @@ -0,0 +1,3 @@ +ADD_SCENE(wifi_deauther, start, Start) +ADD_SCENE(wifi_deauther, console_output, ConsoleOutput) +ADD_SCENE(wifi_deauther, text_input, TextInput) diff --git a/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_console_output.c b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_console_output.c new file mode 100644 index 000000000..b66e79a1f --- /dev/null +++ b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_console_output.c @@ -0,0 +1,88 @@ +#include "../wifi_deauther_app_i.h" + +void wifi_deauther_console_output_handle_rx_data_cb(uint8_t *buf, size_t len, void* context) { + furi_assert(context); + WifideautherApp* app = context; + + // If text box store gets too big, then truncate it + app->text_box_store_strlen += len; + if (app->text_box_store_strlen >= WIFI_deauther_TEXT_BOX_STORE_SIZE - 1) { + string_right(app->text_box_store, app->text_box_store_strlen / 2); + app->text_box_store_strlen = string_size(app->text_box_store); + } + + // Null-terminate buf and append to text box store + buf[len] = '\0'; + string_cat_printf(app->text_box_store, "%s", buf); + + view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventRefreshConsoleOutput); +} + +void wifi_deauther_scene_console_output_on_enter(void* context) { + WifideautherApp* app = context; + + TextBox* text_box = app->text_box; + text_box_reset(app->text_box); + text_box_set_font(text_box, TextBoxFontText); + if (app->focus_console_start) { + text_box_set_focus(text_box, TextBoxFocusStart); + } else { + text_box_set_focus(text_box, TextBoxFocusEnd); + } + if (app->is_command) { + string_reset(app->text_box_store); + app->text_box_store_strlen = 0; + if (0 == strncmp("help", app->selected_tx_string, strlen("help"))) { + const char* help_msg = "For app support/feedback,\nreach out to me:\n@cococode#6011 (discord)\n0xchocolate (github)\n"; + string_cat_str(app->text_box_store, help_msg); + app->text_box_store_strlen += strlen(help_msg); + } + + if (app->show_stopscan_tip) { + const char* help_msg = "Press BACK to send stopscan\n"; + string_cat_str(app->text_box_store, help_msg); + app->text_box_store_strlen += strlen(help_msg); + } + } else { // "View Log" menu action + text_box_set_text(app->text_box, string_get_cstr(app->text_box_store)); + } + + scene_manager_set_scene_state(app->scene_manager, WifideautherSceneConsoleOutput, 0); + view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewConsoleOutput); + + // Register callback to receive data + wifi_deauther_uart_set_handle_rx_data_cb(app->uart, wifi_deauther_console_output_handle_rx_data_cb); // setup callback for rx thread + + // Send command with newline '\n' + if (app->is_command && app->selected_tx_string) { + wifi_deauther_uart_tx((uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string)); + wifi_deauther_uart_tx((uint8_t*)("\n"), 1); + } +} + +bool wifi_deauther_scene_console_output_on_event(void* context, SceneManagerEvent event) { + WifideautherApp* app = context; + + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + text_box_set_text(app->text_box, string_get_cstr(app->text_box_store)); + consumed = true; + } else if(event.type == SceneManagerEventTypeTick) { + consumed = true; + } + + return consumed; +} + +void wifi_deauther_scene_console_output_on_exit(void* context) { + WifideautherApp* app = context; + + // Unregister rx callback + wifi_deauther_uart_set_handle_rx_data_cb(app->uart, NULL); + + // Automatically stop the scan when exiting view + if (app->is_command) { + wifi_deauther_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n")); + } +} \ No newline at end of file diff --git a/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_start.c b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_start.c new file mode 100644 index 000000000..eccfe1c14 --- /dev/null +++ b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_start.c @@ -0,0 +1,128 @@ +#include "../wifi_deauther_app_i.h" + +// For each command, define whether additional arguments are needed +// (enabling text input to fill them out), and whether the console +// text box should focus at the start of the output or the end +typedef enum { + NO_ARGS = 0, + INPUT_ARGS, + TOGGLE_ARGS +} InputArgs; + +typedef enum { + FOCUS_CONSOLE_END = 0, + FOCUS_CONSOLE_START, + FOCUS_CONSOLE_TOGGLE +} FocusConsole; + +#define SHOW_STOPSCAN_TIP (true) +#define NO_TIP (false) + +#define MAX_OPTIONS (6) +typedef struct { + const char* item_string; + const char* options_menu[MAX_OPTIONS]; + int num_options_menu; + const char* actual_commands[MAX_OPTIONS]; + InputArgs needs_keyboard; + FocusConsole focus_console; + bool show_stopscan_tip; +} WifideautherItem; + +// NUM_MENU_ITEMS defined in wifi_deauther_app_i.h - if you add an entry here, increment it! +const WifideautherItem MenuItems[NUM_MENU_ITEMS] = { + { "View Log from", {"start", "end"}, 2, {}, NO_ARGS, FOCUS_CONSOLE_TOGGLE, NO_TIP }, + { "Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Stop", {""}, 1, {"stop all"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Scan", {"All", "SSIDs", "Stations"}, 3, {"scan", "scan aps", "scan stations"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Select", {"All", "SSIDs", "Stations"}, 3, {"select all", "select aps", "select stations"}, INPUT_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Deselect", {"All", "SSIDs", "Stations"}, 3, {"deselect all", "deselect aps", "deselect stations"}, INPUT_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Show", {"All", "Selected"}, 2, {"show all", "show selected"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Attack", {"deauth", "deauthall", "beacon", "probe"}, 4, {"attack deauth", "attack deauthall", "attack beacon", "attack probe"}, NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP }, + { "Settings", {"Get", "Remove AP", "Set SSID", "Set Pass", "Save"}, 5, {"get settings", "set webinterface false", "set ssid: pwned", "set password: deauther", "save settings"}, INPUT_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Sysinfo", {""}, 1, {"sysinfo"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP }, + { "Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP }, +}; + + +static void wifi_deauther_scene_start_var_list_enter_callback(void* context, uint32_t index) { + furi_assert(context); + WifideautherApp* app = context; + if (app->selected_option_index[index] < MenuItems[index].num_options_menu) { + app->selected_tx_string = MenuItems[index].actual_commands[app->selected_option_index[index]]; + } + app->is_command = (1 <= index); + app->is_custom_tx_string = false; + app->selected_menu_index = index; + app->focus_console_start = (MenuItems[index].focus_console == FOCUS_CONSOLE_TOGGLE) ? (app->selected_option_index[index] == 0) : MenuItems[index].focus_console; + app->show_stopscan_tip = MenuItems[index].show_stopscan_tip; + + bool needs_keyboard = (MenuItems[index].needs_keyboard == TOGGLE_ARGS) ? (app->selected_option_index[index] != 0) : MenuItems[index].needs_keyboard; + if (needs_keyboard) { + view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartKeyboard); + } else { + view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartConsole); + } +} + +static void wifi_deauther_scene_start_var_list_change_callback(VariableItem* item) { + furi_assert(item); + + WifideautherApp* app = variable_item_get_context(item); + furi_assert(app); + + const WifideautherItem* menu_item = &MenuItems[app->selected_menu_index]; + uint8_t item_index = variable_item_get_current_value_index(item); + furi_assert(item_index < menu_item->num_options_menu); + variable_item_set_current_value_text(item, menu_item->options_menu[item_index]); + app->selected_option_index[app->selected_menu_index] = item_index; +} + +void wifi_deauther_scene_start_on_enter(void* context) { + WifideautherApp* app = context; + VariableItemList* var_item_list = app->var_item_list; + + variable_item_list_set_enter_callback( + var_item_list, wifi_deauther_scene_start_var_list_enter_callback, app); + + VariableItem* item; + for (int i = 0; i < NUM_MENU_ITEMS; ++i) { + item = variable_item_list_add(var_item_list, MenuItems[i].item_string, MenuItems[i].num_options_menu, wifi_deauther_scene_start_var_list_change_callback, app); + if (MenuItems[i].num_options_menu) { + variable_item_set_current_value_index(item, app->selected_option_index[i]); + variable_item_set_current_value_text(item, MenuItems[i].options_menu[app->selected_option_index[i]]); + } + } + + variable_item_list_set_selected_item( + var_item_list, scene_manager_get_scene_state(app->scene_manager, WifideautherSceneStart)); + + view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewVarItemList); +} + +bool wifi_deauther_scene_start_on_event(void* context, SceneManagerEvent event) { + UNUSED(context); + WifideautherApp* app = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if (event.event == WifideautherEventStartKeyboard) { + scene_manager_set_scene_state(app->scene_manager, WifideautherSceneStart, app->selected_menu_index); + scene_manager_next_scene(app->scene_manager, WifideautherAppViewTextInput); + } else if (event.event == WifideautherEventStartConsole) { + scene_manager_set_scene_state(app->scene_manager, WifideautherSceneStart, app->selected_menu_index); + scene_manager_next_scene(app->scene_manager, WifideautherAppViewConsoleOutput); + } + consumed = true; + } else if (event.type == SceneManagerEventTypeTick) { + app->selected_menu_index = variable_item_list_get_selected_item_index(app->var_item_list); + consumed = true; + } + + return consumed; +} + +void wifi_deauther_scene_start_on_exit(void* context) { + WifideautherApp* app = context; + variable_item_list_reset(app->var_item_list); +} diff --git a/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_text_input.c b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_text_input.c new file mode 100644 index 000000000..a05feaf25 --- /dev/null +++ b/applications/plugins/wifi_deauther/scenes/wifi_deauther_scene_text_input.c @@ -0,0 +1,67 @@ +#include "../wifi_deauther_app_i.h" + + +void wifi_deauther_scene_text_input_callback(void* context) { + WifideautherApp* app = context; + + view_dispatcher_send_custom_event(app->view_dispatcher, WifideautherEventStartConsole); +} + +void wifi_deauther_scene_text_input_on_enter(void* context) { + WifideautherApp* app = context; + + if (false == app->is_custom_tx_string) { + // Fill text input with selected string so that user can add to it + size_t length = strlen(app->selected_tx_string); + furi_assert(length < WIFI_deauther_TEXT_INPUT_STORE_SIZE); + bzero(app->text_input_store, WIFI_deauther_TEXT_INPUT_STORE_SIZE); + strncpy(app->text_input_store, app->selected_tx_string, length); + + // Add space - because flipper keyboard currently doesn't have a space + app->text_input_store[length] = ' '; + app->text_input_store[length+1] = '\0'; + app->is_custom_tx_string = true; + } + + // Setup view + TextInput* text_input = app->text_input; + // Add help message to header + if (0 == strncmp("ssid -a -g", app->selected_tx_string, strlen("ssid -a -g"))) { + text_input_set_header_text(text_input, "Enter # SSIDs to generate"); + } else if (0 == strncmp("ssid -a -n", app->selected_tx_string, strlen("ssid -a -n"))) { + text_input_set_header_text(text_input, "Enter SSID name to add"); + } else if (0 == strncmp("ssid -r", app->selected_tx_string, strlen("ssid -r"))) { + text_input_set_header_text(text_input, "Remove target from SSID list"); + } else if (0 == strncmp("select -a", app->selected_tx_string, strlen("select -a"))) { + text_input_set_header_text(text_input, "Add target from AP list"); + } else if (0 == strncmp("select -s", app->selected_tx_string, strlen("select -s"))) { + text_input_set_header_text(text_input, "Add target from SSID list"); + } else { + text_input_set_header_text(text_input, "Add command arguments"); + } + text_input_set_result_callback(text_input, wifi_deauther_scene_text_input_callback, app, app->text_input_store, WIFI_deauther_TEXT_INPUT_STORE_SIZE, false); + + view_dispatcher_switch_to_view(app->view_dispatcher, WifideautherAppViewTextInput); +} + +bool wifi_deauther_scene_text_input_on_event(void* context, SceneManagerEvent event) { + WifideautherApp* app = context; + bool consumed = false; + + if (event.type == SceneManagerEventTypeCustom) { + if (event.event == WifideautherEventStartConsole) { + // Point to custom string to send + app->selected_tx_string = app->text_input_store; + scene_manager_next_scene(app->scene_manager, WifideautherAppViewConsoleOutput); + consumed = true; + } + } + + return consumed; +} + +void wifi_deauther_scene_text_input_on_exit(void* context) { + WifideautherApp* app = context; + + text_input_reset(app->text_input); +} diff --git a/applications/plugins/wifi_deauther/wifi_10px.png b/applications/plugins/wifi_deauther/wifi_10px.png new file mode 100644 index 000000000..c13534660 Binary files /dev/null and b/applications/plugins/wifi_deauther/wifi_10px.png differ diff --git a/applications/plugins/wifi_deauther/wifi_deauther_app.c b/applications/plugins/wifi_deauther/wifi_deauther_app.c new file mode 100644 index 000000000..c98f2c6dc --- /dev/null +++ b/applications/plugins/wifi_deauther/wifi_deauther_app.c @@ -0,0 +1,102 @@ +#include "wifi_deauther_app_i.h" + +#include +#include + +static bool wifi_deauther_app_custom_event_callback(void* context, uint32_t event) { + furi_assert(context); + WifideautherApp* app = context; + return scene_manager_handle_custom_event(app->scene_manager, event); +} + +static bool wifi_deauther_app_back_event_callback(void* context) { + furi_assert(context); + WifideautherApp* app = context; + return scene_manager_handle_back_event(app->scene_manager); +} + +static void wifi_deauther_app_tick_event_callback(void* context) { + furi_assert(context); + WifideautherApp* app = context; + scene_manager_handle_tick_event(app->scene_manager); +} + +WifideautherApp* wifi_deauther_app_alloc() { + WifideautherApp* app = malloc(sizeof(WifideautherApp)); + + app->gui = furi_record_open(RECORD_GUI); + + app->view_dispatcher = view_dispatcher_alloc(); + app->scene_manager = scene_manager_alloc(&wifi_deauther_scene_handlers, app); + view_dispatcher_enable_queue(app->view_dispatcher); + view_dispatcher_set_event_callback_context(app->view_dispatcher, app); + + view_dispatcher_set_custom_event_callback( + app->view_dispatcher, wifi_deauther_app_custom_event_callback); + view_dispatcher_set_navigation_event_callback( + app->view_dispatcher, wifi_deauther_app_back_event_callback); + view_dispatcher_set_tick_event_callback( + app->view_dispatcher, wifi_deauther_app_tick_event_callback, 100); + + view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen); + + app->var_item_list = variable_item_list_alloc(); + view_dispatcher_add_view( + app->view_dispatcher, + WifideautherAppViewVarItemList, + variable_item_list_get_view(app->var_item_list)); + + for (int i = 0; i < NUM_MENU_ITEMS; ++i) { + app->selected_option_index[i] = 0; + } + + app->text_box = text_box_alloc(); + view_dispatcher_add_view(app->view_dispatcher, WifideautherAppViewConsoleOutput, text_box_get_view(app->text_box)); + string_init(app->text_box_store); + string_reserve(app->text_box_store, WIFI_deauther_TEXT_BOX_STORE_SIZE); + + app->text_input = text_input_alloc(); + view_dispatcher_add_view(app->view_dispatcher, WifideautherAppViewTextInput, text_input_get_view(app->text_input)); + + scene_manager_next_scene(app->scene_manager, WifideautherSceneStart); + + return app; +} + +void wifi_deauther_app_free(WifideautherApp* app) { + furi_assert(app); + + // Views + view_dispatcher_remove_view(app->view_dispatcher, WifideautherAppViewVarItemList); + view_dispatcher_remove_view(app->view_dispatcher, WifideautherAppViewConsoleOutput); + view_dispatcher_remove_view(app->view_dispatcher, WifideautherAppViewTextInput); + text_box_free(app->text_box); + string_clear(app->text_box_store); + text_input_free(app->text_input); + + // View dispatcher + view_dispatcher_free(app->view_dispatcher); + scene_manager_free(app->scene_manager); + + wifi_deauther_uart_free(app->uart); + + // Close records + furi_record_close(RECORD_GUI); + + free(app); +} + +int32_t wifi_deauther_app(void* p) { + furi_hal_power_enable_otg(); + UNUSED(p); + WifideautherApp* wifi_deauther_app = wifi_deauther_app_alloc(); + + wifi_deauther_app->uart = wifi_deauther_uart_init(wifi_deauther_app); + + view_dispatcher_run(wifi_deauther_app->view_dispatcher); + + wifi_deauther_app_free(wifi_deauther_app); + furi_hal_power_disable_otg(); + + return 0; +} diff --git a/applications/plugins/wifi_deauther/wifi_deauther_app.h b/applications/plugins/wifi_deauther/wifi_deauther_app.h new file mode 100644 index 000000000..bb2f6fbfb --- /dev/null +++ b/applications/plugins/wifi_deauther/wifi_deauther_app.h @@ -0,0 +1,11 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct WifideautherApp WifideautherApp; + +#ifdef __cplusplus +} +#endif diff --git a/applications/plugins/wifi_deauther/wifi_deauther_app_i.h b/applications/plugins/wifi_deauther/wifi_deauther_app_i.h new file mode 100644 index 000000000..20b0d4de6 --- /dev/null +++ b/applications/plugins/wifi_deauther/wifi_deauther_app_i.h @@ -0,0 +1,69 @@ +#pragma once + +#include "wifi_deauther_app.h" +#include "scenes/wifi_deauther_scene.h" +#include "wifi_deauther_custom_event.h" +#include "wifi_deauther_uart.h" + +#include +#include +#include +#include +#include +#include + +#define NUM_MENU_ITEMS (11) + +#define WIFI_deauther_TEXT_BOX_STORE_SIZE (4096) +#define WIFI_deauther_TEXT_INPUT_STORE_SIZE (512) + +struct WifideautherApp { + Gui* gui; + ViewDispatcher* view_dispatcher; + SceneManager* scene_manager; + + char text_input_store[WIFI_deauther_TEXT_INPUT_STORE_SIZE + 1]; + string_t text_box_store; + size_t text_box_store_strlen; + TextBox* text_box; + TextInput* text_input; + //Widget* widget; + + VariableItemList* var_item_list; + + WifideautherUart* uart; + int selected_menu_index; + int selected_option_index[NUM_MENU_ITEMS]; + const char* selected_tx_string; + bool is_command; + bool is_custom_tx_string; + bool focus_console_start; + bool show_stopscan_tip; +}; + +// Supported commands: +// https://github.com/justcallmekoko/ESP32deauther/wiki/cli +// Scan +// -> If list is empty, then start a new scanap. (Tap any button to stop.) +// -> If there's a list, provide option to rescan and dump list of targets to select. +// -> Press BACK to go back to top-level. +// Attack +// -> Beacon +// -> Deauth +// -> Probe +// -> Rickroll +// Sniff +// -> Beacon +// -> Deauth +// -> ESP +// -> PMKID +// -> Pwnagotchi +// Channel +// Update +// Reboot + +typedef enum { + WifideautherAppViewVarItemList, + WifideautherAppViewConsoleOutput, + WifideautherAppViewTextInput, +} WifideautherAppView; diff --git a/applications/plugins/wifi_deauther/wifi_deauther_custom_event.h b/applications/plugins/wifi_deauther/wifi_deauther_custom_event.h new file mode 100644 index 000000000..142961b1d --- /dev/null +++ b/applications/plugins/wifi_deauther/wifi_deauther_custom_event.h @@ -0,0 +1,7 @@ +#pragma once + +typedef enum { + WifideautherEventRefreshConsoleOutput = 0, + WifideautherEventStartConsole, + WifideautherEventStartKeyboard, +} WifideautherCustomEvent; diff --git a/applications/plugins/wifi_deauther/wifi_deauther_uart.c b/applications/plugins/wifi_deauther/wifi_deauther_uart.c new file mode 100644 index 000000000..ba756d8e5 --- /dev/null +++ b/applications/plugins/wifi_deauther/wifi_deauther_uart.c @@ -0,0 +1,97 @@ +#include "wifi_deauther_app_i.h" +#include "wifi_deauther_uart.h" + +#include + +#define UART_CH (FuriHalUartIdUSART1) +#define BAUDRATE (115200) + +struct WifideautherUart { + WifideautherApp* app; + FuriThread* rx_thread; + StreamBufferHandle_t rx_stream; + uint8_t rx_buf[RX_BUF_SIZE+1]; + void (*handle_rx_data_cb)(uint8_t *buf, size_t len, void* context); +}; + +typedef enum { + WorkerEvtStop = (1 << 0), + WorkerEvtRxDone = (1 << 1), +} WorkerEvtFlags; + +void wifi_deauther_uart_set_handle_rx_data_cb(WifideautherUart* uart, void (*handle_rx_data_cb)(uint8_t *buf, size_t len, void* context)) { + furi_assert(uart); + uart->handle_rx_data_cb = handle_rx_data_cb; +} + +#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone) + +void wifi_deauther_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) { + WifideautherUart* uart = (WifideautherUart*)context; + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + + if(ev == UartIrqEventRXNE) { + xStreamBufferSendFromISR(uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken); + furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone); + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); + } +} + +static int32_t uart_worker(void* context) { + WifideautherUart* uart = (void*)context; + + uart->rx_stream = xStreamBufferCreate(RX_BUF_SIZE, 1); + + while(1) { + uint32_t events = + furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever); + furi_check((events & FuriFlagError) == 0); + if(events & WorkerEvtStop) break; + if(events & WorkerEvtRxDone) { + size_t len = + xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0); + if(len > 0) { + if (uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app); + } + } + } + + vStreamBufferDelete(uart->rx_stream); + + return 0; +} + +void wifi_deauther_uart_tx(uint8_t *data, size_t len) { + furi_hal_uart_tx(UART_CH, data, len); +} + +WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) { + WifideautherUart *uart = malloc(sizeof(WifideautherUart)); + + furi_hal_console_disable(); + furi_hal_uart_set_br(UART_CH, BAUDRATE); + furi_hal_uart_set_irq_cb(UART_CH, wifi_deauther_uart_on_irq_cb, uart); + + uart->app = app; + uart->rx_thread = furi_thread_alloc(); + furi_thread_set_name(uart->rx_thread, "WifideautherUartRxThread"); + furi_thread_set_stack_size(uart->rx_thread, 1024); + furi_thread_set_context(uart->rx_thread, uart); + furi_thread_set_callback(uart->rx_thread, uart_worker); + + furi_thread_start(uart->rx_thread); + return uart; +} + +void wifi_deauther_uart_free(WifideautherUart* uart) { + furi_assert(uart); + + furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtStop); + furi_thread_join(uart->rx_thread); + furi_thread_free(uart->rx_thread); + + furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL); + furi_hal_console_enable(); + + free(uart); +} \ No newline at end of file diff --git a/applications/plugins/wifi_deauther/wifi_deauther_uart.h b/applications/plugins/wifi_deauther/wifi_deauther_uart.h new file mode 100644 index 000000000..0017519bb --- /dev/null +++ b/applications/plugins/wifi_deauther/wifi_deauther_uart.h @@ -0,0 +1,12 @@ +#pragma once + +#include "furi_hal.h" + +#define RX_BUF_SIZE (320) + +typedef struct WifideautherUart WifideautherUart; + +void wifi_deauther_uart_set_handle_rx_data_cb(WifideautherUart* uart, void (*handle_rx_data_cb)(uint8_t *buf, size_t len, void* context)); +void wifi_deauther_uart_tx(uint8_t *data, size_t len); +WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app); +void wifi_deauther_uart_free(WifideautherUart* uart);