From fce60381f7c452de60186130ad7c327e376d99fc Mon Sep 17 00:00:00 2001 From: 0xchocolate <109879152+0xchocolate@users.noreply.github.com> Date: Sat, 18 Nov 2023 14:01:04 -0800 Subject: [PATCH] v6.5: Preparing to support EP html over serial when Marauder FW changes merge (#41) * First pass at sending EP index.html * trying to make browseable - not working? * Fixup, run format * fix line endings * Update version --- application.fam | 2 +- scenes/wifi_marauder_scene_console_output.c | 16 +++++++ scenes/wifi_marauder_scene_start.c | 35 +++++++-------- ...fi_marauder_script_stage_menu_sniffpmkid.c | 15 +++---- script/wifi_marauder_script.c | 11 +++-- script/wifi_marauder_script_executor.c | 10 ++--- script/wifi_marauder_script_worker.c | 1 - wifi_marauder_app.h | 2 +- wifi_marauder_app_i.h | 4 +- wifi_marauder_ep.c | 44 +++++++++++++++++++ wifi_marauder_ep.h | 6 +++ 11 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 wifi_marauder_ep.c create mode 100644 wifi_marauder_ep.h diff --git a/application.fam b/application.fam index 2a09c606c00..8fdd93f62bd 100644 --- a/application.fam +++ b/application.fam @@ -1,7 +1,7 @@ App( appid="esp32_wifi_marauder", name="[ESP32] WiFi Marauder", - fap_version=(6,4), + fap_version=(6,5), apptype=FlipperAppType.EXTERNAL, entry_point="wifi_marauder_app", requires=["gui"], diff --git a/scenes/wifi_marauder_scene_console_output.c b/scenes/wifi_marauder_scene_console_output.c index 05d94fe8044..d67c6815d09 100644 --- a/scenes/wifi_marauder_scene_console_output.c +++ b/scenes/wifi_marauder_scene_console_output.c @@ -144,11 +144,27 @@ void wifi_marauder_scene_console_output_on_enter(void* context) { } } + bool send_html = false; + uint8_t* the_html = NULL; + size_t html_size = 0; + if(app->selected_tx_string && strncmp( + "evilportal -c sethtmlstr", + app->selected_tx_string, + strlen("evilportal -c sethtmlstr")) == 0) { + send_html = wifi_marauder_ep_read_html_file(app, &the_html, &html_size); + } + // Send command with newline '\n' if(app->selected_tx_string) { wifi_marauder_uart_tx( (uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string)); wifi_marauder_uart_tx((uint8_t*)("\n"), 1); + if(send_html && the_html) { + wifi_marauder_uart_tx(the_html, html_size); + wifi_marauder_uart_tx((uint8_t*)("\n"), 1); + free(the_html); + send_html = false; + } } // Run the script if the file with the script has been opened diff --git a/scenes/wifi_marauder_scene_start.c b/scenes/wifi_marauder_scene_start.c index b74e2cc7b84..252e1bb9682 100644 --- a/scenes/wifi_marauder_scene_start.c +++ b/scenes/wifi_marauder_scene_start.c @@ -68,12 +68,12 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = { NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP}, - {"Wardrive", - {"ap", "station", "bt", "bt cont"}, - 4, - {"wardrive", "wardrive -s", "btwardrive", "btwardrive -c"}, - NO_ARGS, - FOCUS_CONSOLE_END, + {"Wardrive", + {"ap", "station", "bt", "bt cont"}, + 4, + {"wardrive", "wardrive -s", "btwardrive", "btwardrive -c"}, + NO_ARGS, + FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP}, {"Evil Portal", {"start", "set html"}, @@ -82,6 +82,13 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = { TOGGLE_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP}, + {"Load Evil Portal HTML file", + {""}, + 1, + {"evilportal -c sethtmlstr"}, + NO_ARGS, + FOCUS_CONSOLE_END, + NO_TIP}, {"Targeted Deauth", {"station", "manual"}, 2, @@ -118,13 +125,7 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = { TOGGLE_ARGS, FOCUS_CONSOLE_END, NO_TIP}, - {"LED", - {"hex", "pattern"}, - 2, - {"led -s", "led -p"}, - INPUT_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, + {"LED", {"hex", "pattern"}, 2, {"led -s", "led -p"}, INPUT_ARGS, FOCUS_CONSOLE_END, NO_TIP}, {"GPS Data", {"stream", "fix", "sats", "lat", "lon", "alt", "date"}, 7, @@ -151,13 +152,7 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = { TOGGLE_ARGS, FOCUS_CONSOLE_START, NO_TIP}, - {"List SD", - {""}, - 1, - {"ls /"}, - INPUT_ARGS, - FOCUS_CONSOLE_END, - NO_TIP}, + {"List SD", {""}, 1, {"ls /"}, INPUT_ARGS, FOCUS_CONSOLE_END, NO_TIP}, {"Update", {"sd"}, 1, {"update -s"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP}, {"Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP}, {"Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_START, SHOW_STOPSCAN_TIP}, diff --git a/script/menu/wifi_marauder_script_stage_menu_sniffpmkid.c b/script/menu/wifi_marauder_script_stage_menu_sniffpmkid.c index 212468b8fb8..6a591c4e0ba 100644 --- a/script/menu/wifi_marauder_script_stage_menu_sniffpmkid.c +++ b/script/menu/wifi_marauder_script_stage_menu_sniffpmkid.c @@ -11,7 +11,7 @@ static void wifi_marauder_sniffpmkid_stage_hop_channels_change_callback(Variable uint8_t current_stage_index = variable_item_list_get_selected_item_index(app->var_item_list); const WifiMarauderScriptMenuItem* menu_item = - &app->script_stage_menu->items[current_stage_index]; + &app->script_stage_menu->items[current_stage_index]; uint8_t option_index = variable_item_get_current_value_index(item); variable_item_set_current_value_text(item, menu_item->options[option_index]); @@ -20,7 +20,6 @@ static void wifi_marauder_sniffpmkid_stage_hop_channels_change_callback(Variable stage->hop_channels = option_index; } - static void wifi_marauder_sniffpmkid_stage_force_deauth_setup_callback(VariableItem* item) { WifiMarauderApp* app = variable_item_get_context(item); WifiMarauderScriptStageSniffPmkid* stage = app->script_edit_selected_stage->stage; @@ -110,10 +109,10 @@ void wifi_marauder_script_stage_menu_sniffpmkid_load(WifiMarauderScriptStageMenu .setup_callback = wifi_marauder_sniffpmkid_stage_timeout_setup_callback, .select_callback = wifi_marauder_sniffpmkid_stage_timeout_select_callback}; stage_menu->items[3] = (WifiMarauderScriptMenuItem){ - .name = strdup("Hop Channels"), - .type = WifiMarauderScriptMenuItemTypeOptionsString, - .num_options = 2, - .options = {"no", "yes"}, - .setup_callback = wifi_marauder_sniffpmkid_stage_hop_channels_setup_callback, - .change_callback = wifi_marauder_sniffpmkid_stage_hop_channels_change_callback}; + .name = strdup("Hop Channels"), + .type = WifiMarauderScriptMenuItemTypeOptionsString, + .num_options = 2, + .options = {"no", "yes"}, + .setup_callback = wifi_marauder_sniffpmkid_stage_hop_channels_setup_callback, + .change_callback = wifi_marauder_sniffpmkid_stage_hop_channels_change_callback}; } \ No newline at end of file diff --git a/script/wifi_marauder_script.c b/script/wifi_marauder_script.c index 3b34065e76e..a33e27cc5d5 100644 --- a/script/wifi_marauder_script.c +++ b/script/wifi_marauder_script.c @@ -247,20 +247,20 @@ WifiMarauderScriptStageSniffPmkid* _wifi_marauder_script_get_stage_sniff_pmkid(c cJSON* timeout_json = cJSON_GetObjectItem(sniffpmkid_stage_json, "timeout"); int timeout = timeout_json != NULL ? (int)cJSON_GetNumberValue(timeout_json) : - WIFI_MARAUDER_DEFAULT_TIMEOUT_SNIFF; + WIFI_MARAUDER_DEFAULT_TIMEOUT_SNIFF; cJSON* force_deauth_json = - cJSON_GetObjectItemCaseSensitive(sniffpmkid_stage_json, "forceDeauth"); + cJSON_GetObjectItemCaseSensitive(sniffpmkid_stage_json, "forceDeauth"); bool force_deauth = cJSON_IsBool(force_deauth_json) ? force_deauth_json->valueint : true; cJSON* hop_channels_json = - cJSON_GetObjectItemCaseSensitive(sniffpmkid_stage_json, "hopChannels"); + cJSON_GetObjectItemCaseSensitive(sniffpmkid_stage_json, "hopChannels"); bool hop_channels = cJSON_IsBool(hop_channels_json) ? hop_channels_json->valueint : false; WifiMarauderScriptStageSniffPmkid* sniff_pmkid_stage = - (WifiMarauderScriptStageSniffPmkid*)malloc(sizeof(WifiMarauderScriptStageSniffPmkid)); + (WifiMarauderScriptStageSniffPmkid*)malloc(sizeof(WifiMarauderScriptStageSniffPmkid)); - if (sniff_pmkid_stage == NULL) { + if(sniff_pmkid_stage == NULL) { // Handle memory allocation error return NULL; } @@ -272,7 +272,6 @@ WifiMarauderScriptStageSniffPmkid* _wifi_marauder_script_get_stage_sniff_pmkid(c return sniff_pmkid_stage; } - WifiMarauderScriptStageSniffPwn* _wifi_marauder_script_get_stage_sniff_pwn(cJSON* stages) { cJSON* sniffpwn_stage_json = cJSON_GetObjectItem(stages, "sniffpwn"); if(sniffpwn_stage_json == NULL) { diff --git a/script/wifi_marauder_script_executor.c b/script/wifi_marauder_script_executor.c index df2b2d6c110..41f6285d4bc 100644 --- a/script/wifi_marauder_script_executor.c +++ b/script/wifi_marauder_script_executor.c @@ -14,7 +14,6 @@ void _send_line_break() { wifi_marauder_uart_tx((uint8_t*)("\n"), 1); } - void _send_channel_select(int channel) { char command[30]; _send_line_break(); @@ -138,9 +137,8 @@ void _wifi_marauder_script_execute_sniff_esp( } void _wifi_marauder_script_execute_sniff_pmkid( - WifiMarauderScriptStageSniffPmkid* stage, - WifiMarauderScriptWorker* worker) { - + WifiMarauderScriptStageSniffPmkid* stage, + WifiMarauderScriptWorker* worker) { // If channel hopping is enabled, loop through channels 1-11 if(stage->hop_channels) { for(int i = 1; i <= 11; i++) { @@ -162,8 +160,8 @@ void _wifi_marauder_script_execute_sniff_pmkid( int len = strlen(attack_command); if(stage->channel > 0) { - len += - snprintf(attack_command + len, sizeof(attack_command) - len, " -c %d", stage->channel); + len += snprintf( + attack_command + len, sizeof(attack_command) - len, " -c %d", stage->channel); } if(stage->force_deauth) { diff --git a/script/wifi_marauder_script_worker.c b/script/wifi_marauder_script_worker.c index 0e45305e189..2e11b0e5f1f 100644 --- a/script/wifi_marauder_script_worker.c +++ b/script/wifi_marauder_script_worker.c @@ -1,7 +1,6 @@ #include "../wifi_marauder_app_i.h" #include "wifi_marauder_script_worker.h" - WifiMarauderScriptWorker* wifi_marauder_script_worker_alloc() { WifiMarauderScriptWorker* worker = malloc(sizeof(WifiMarauderScriptWorker)); if(worker == NULL) { diff --git a/wifi_marauder_app.h b/wifi_marauder_app.h index 4bc3a3b22c0..43eb7f15b3f 100644 --- a/wifi_marauder_app.h +++ b/wifi_marauder_app.h @@ -4,7 +4,7 @@ extern "C" { #endif -#define WIFI_MARAUDER_APP_VERSION "v0.6.4" +#define WIFI_MARAUDER_APP_VERSION "v0.6.5" typedef struct WifiMarauderApp WifiMarauderApp; diff --git a/wifi_marauder_app_i.h b/wifi_marauder_app_i.h index af4e7646739..13c5f380a02 100644 --- a/wifi_marauder_app_i.h +++ b/wifi_marauder_app_i.h @@ -6,6 +6,7 @@ #include "scenes/wifi_marauder_scene.h" #include "wifi_marauder_custom_event.h" #include "wifi_marauder_uart.h" +#include "wifi_marauder_ep.h" #include "file/sequential_file.h" #include "script/wifi_marauder_script.h" #include "script/wifi_marauder_script_worker.h" @@ -26,13 +27,14 @@ #include #include -#define NUM_MENU_ITEMS (23) +#define NUM_MENU_ITEMS (24) #define WIFI_MARAUDER_TEXT_BOX_STORE_SIZE (4096) #define WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE (512) #define MARAUDER_APP_FOLDER_USER "apps_data/marauder" #define MARAUDER_APP_FOLDER EXT_PATH(MARAUDER_APP_FOLDER_USER) +#define MARAUDER_APP_FOLDER_HTML MARAUDER_APP_FOLDER "/html" #define MARAUDER_APP_FOLDER_PCAPS MARAUDER_APP_FOLDER "/pcaps" #define MARAUDER_APP_FOLDER_LOGS MARAUDER_APP_FOLDER "/logs" #define MARAUDER_APP_FOLDER_USER_PCAPS MARAUDER_APP_FOLDER_USER "/pcaps" diff --git a/wifi_marauder_ep.c b/wifi_marauder_ep.c new file mode 100644 index 00000000000..07052cf5a82 --- /dev/null +++ b/wifi_marauder_ep.c @@ -0,0 +1,44 @@ +#include "wifi_marauder_ep.h" + +// returns success (if true, then caller needs to free(the_html)) +bool wifi_marauder_ep_read_html_file(WifiMarauderApp* app, uint8_t** the_html, size_t* html_size) { + // browse for files + FuriString* predefined_filepath = furi_string_alloc_set_str(MARAUDER_APP_FOLDER_HTML); + FuriString* selected_filepath = furi_string_alloc(); + DialogsFileBrowserOptions browser_options; + dialog_file_browser_set_basic_options(&browser_options, ".html", &I_Text_10x10); + if(!dialog_file_browser_show( + app->dialogs, selected_filepath, predefined_filepath, &browser_options)) { + return false; + } + + File* index_html = storage_file_alloc(app->storage); + if(!storage_file_open( + index_html, furi_string_get_cstr(selected_filepath), FSAM_READ, FSOM_OPEN_EXISTING)) { + dialog_message_show_storage_error(app->dialogs, "Cannot open file"); + return false; + } + + uint64_t size = storage_file_size(index_html); + + *the_html = malloc(size); // to be freed by caller + uint8_t* buf_ptr = *the_html; + size_t read = 0; + while(read < size) { + size_t to_read = size - read; + if(to_read > UINT16_MAX) to_read = UINT16_MAX; + uint16_t now_read = storage_file_read(index_html, buf_ptr, (uint16_t)to_read); + read += now_read; + buf_ptr += now_read; + } + + *html_size = read; + + storage_file_close(index_html); + storage_file_free(index_html); + + furi_string_free(selected_filepath); + furi_string_free(predefined_filepath); + + return true; +} \ No newline at end of file diff --git a/wifi_marauder_ep.h b/wifi_marauder_ep.h new file mode 100644 index 00000000000..a411fab9fe2 --- /dev/null +++ b/wifi_marauder_ep.h @@ -0,0 +1,6 @@ +// evil portal helper +#pragma once + +#include "wifi_marauder_app_i.h" + +bool wifi_marauder_ep_read_html_file(WifiMarauderApp* app, uint8_t** the_html, size_t* html_size); \ No newline at end of file