Skip to content

Commit

Permalink
v6.5: Preparing to support EP html over serial when Marauder FW chang…
Browse files Browse the repository at this point in the history
…es merge (#41)

* First pass at sending EP index.html

* trying to make browseable - not working?

* Fixup, run format

* fix line endings

* Update version
  • Loading branch information
0xchocolate authored Nov 18, 2023
1 parent b13649b commit fce6038
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 44 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
16 changes: 16 additions & 0 deletions scenes/wifi_marauder_scene_console_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 15 additions & 20 deletions scenes/wifi_marauder_scene_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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},
Expand Down
15 changes: 7 additions & 8 deletions script/menu/wifi_marauder_script_stage_menu_sniffpmkid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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;
Expand Down Expand Up @@ -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};
}
11 changes: 5 additions & 6 deletions script/wifi_marauder_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down
10 changes: 4 additions & 6 deletions script/wifi_marauder_script_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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++) {
Expand All @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion script/wifi_marauder_script_worker.c
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion wifi_marauder_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion wifi_marauder_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -26,13 +27,14 @@
#include <lib/toolbox/path.h>
#include <dialogs/dialogs.h>

#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"
Expand Down
44 changes: 44 additions & 0 deletions wifi_marauder_ep.c
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 6 additions & 0 deletions wifi_marauder_ep.h
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit fce6038

Please sign in to comment.