mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
Add esp32 (mayhem) board apps
This commit is contained in:
30
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene.c
vendored
Normal file
30
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene.c
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "wifi_marauder_scene.h"
|
||||
|
||||
// Generate scene on_enter handlers array
|
||||
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
|
||||
void (*const wifi_marauder_scene_on_enter_handlers[])(void*) = {
|
||||
#include "wifi_marauder_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_marauder_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
|
||||
#include "wifi_marauder_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_marauder_scene_on_exit_handlers[])(void* context) = {
|
||||
#include "wifi_marauder_scene_config.h"
|
||||
};
|
||||
#undef ADD_SCENE
|
||||
|
||||
// Initialize scene handlers configuration structure
|
||||
const SceneManagerHandlers wifi_marauder_scene_handlers = {
|
||||
.on_enter_handlers = wifi_marauder_scene_on_enter_handlers,
|
||||
.on_event_handlers = wifi_marauder_scene_on_event_handlers,
|
||||
.on_exit_handlers = wifi_marauder_scene_on_exit_handlers,
|
||||
.scene_num = WifiMarauderSceneNum,
|
||||
};
|
||||
29
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene.h
vendored
Normal file
29
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene.h
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/scene_manager.h>
|
||||
|
||||
// Generate scene id and total number
|
||||
#define ADD_SCENE(prefix, name, id) WifiMarauderScene##id,
|
||||
typedef enum {
|
||||
#include "wifi_marauder_scene_config.h"
|
||||
WifiMarauderSceneNum,
|
||||
} WifiMarauderScene;
|
||||
#undef ADD_SCENE
|
||||
|
||||
extern const SceneManagerHandlers wifi_marauder_scene_handlers;
|
||||
|
||||
// Generate scene on_enter handlers declaration
|
||||
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
|
||||
#include "wifi_marauder_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_marauder_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_marauder_scene_config.h"
|
||||
#undef ADD_SCENE
|
||||
5
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_config.h
vendored
Normal file
5
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_config.h
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
ADD_SCENE(wifi_marauder, start, Start)
|
||||
ADD_SCENE(wifi_marauder, console_output, ConsoleOutput)
|
||||
ADD_SCENE(wifi_marauder, text_input, TextInput)
|
||||
ADD_SCENE(wifi_marauder, settings_init, SettingsInit)
|
||||
ADD_SCENE(wifi_marauder, log_viewer, LogViewer)
|
||||
133
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_console_output.c
vendored
Normal file
133
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_console_output.c
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
void wifi_marauder_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* context) {
|
||||
furi_assert(context);
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
if(app->is_writing_log) {
|
||||
app->has_saved_logs_this_session = true;
|
||||
storage_file_write(app->log_file, buf, len);
|
||||
}
|
||||
|
||||
// If text box store gets too big, then truncate it
|
||||
app->text_box_store_strlen += len;
|
||||
if(app->text_box_store_strlen >= WIFI_MARAUDER_TEXT_BOX_STORE_SIZE - 1) {
|
||||
furi_string_right(app->text_box_store, app->text_box_store_strlen / 2);
|
||||
app->text_box_store_strlen = furi_string_size(app->text_box_store) + len;
|
||||
}
|
||||
|
||||
// Null-terminate buf and append to text box store
|
||||
buf[len] = '\0';
|
||||
furi_string_cat_printf(app->text_box_store, "%s", buf);
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventRefreshConsoleOutput);
|
||||
}
|
||||
|
||||
void wifi_marauder_console_output_handle_rx_packets_cb(uint8_t* buf, size_t len, void* context) {
|
||||
furi_assert(context);
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
if(app->is_writing_pcap) {
|
||||
storage_file_write(app->capture_file, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_console_output_on_enter(void* context) {
|
||||
WifiMarauderApp* 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) {
|
||||
furi_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 = "Marauder companion " WIFI_MARAUDER_APP_VERSION "\n";
|
||||
furi_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";
|
||||
furi_string_cat_str(app->text_box_store, help_msg);
|
||||
app->text_box_store_strlen += strlen(help_msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Set starting text - for "View Log from end", this will just be what was already in the text box store
|
||||
text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));
|
||||
|
||||
scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneConsoleOutput, 0);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
|
||||
|
||||
// Register callback to receive data
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->uart,
|
||||
wifi_marauder_console_output_handle_rx_data_cb); // setup callback for general log rx thread
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->lp_uart,
|
||||
wifi_marauder_console_output_handle_rx_packets_cb); // setup callback for packets rx thread
|
||||
|
||||
// Get ready to send command
|
||||
if(app->is_command && app->selected_tx_string) {
|
||||
// Create files *before* sending command
|
||||
// (it takes time to iterate through the directory)
|
||||
if(app->ok_to_save_logs) {
|
||||
app->is_writing_log = true;
|
||||
wifi_marauder_create_log_file(app);
|
||||
}
|
||||
|
||||
// If it is a sniff function, open the pcap file for recording
|
||||
if(app->ok_to_save_pcaps && strncmp("sniff", app->selected_tx_string, strlen("sniff")) == 0) {
|
||||
app->is_writing_pcap = true;
|
||||
wifi_marauder_create_pcap_file(app);
|
||||
}
|
||||
|
||||
// Send command with newline '\n'
|
||||
wifi_marauder_uart_tx(
|
||||
(uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
|
||||
wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool wifi_marauder_scene_console_output_on_event(void* context, SceneManagerEvent event) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
text_box_set_text(app->text_box, furi_string_get_cstr(app->text_box_store));
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_console_output_on_exit(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
// Unregister rx callback
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(app->lp_uart, NULL);
|
||||
|
||||
// Automatically stop the scan when exiting view
|
||||
if(app->is_command) {
|
||||
wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
|
||||
}
|
||||
|
||||
app->is_writing_pcap = false;
|
||||
if(app->capture_file && storage_file_is_open(app->capture_file)) {
|
||||
storage_file_close(app->capture_file);
|
||||
}
|
||||
|
||||
app->is_writing_log = false;
|
||||
if(app->log_file && storage_file_is_open(app->log_file)) {
|
||||
storage_file_close(app->log_file);
|
||||
}
|
||||
}
|
||||
180
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_log_viewer.c
vendored
Normal file
180
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_log_viewer.c
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
void wifi_marauder_scene_log_viewer_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
static void _read_log_page_into_text_store(WifiMarauderApp* app) {
|
||||
char temp[64 + 1];
|
||||
storage_file_seek(
|
||||
app->log_file, WIFI_MARAUDER_TEXT_BOX_STORE_SIZE * (app->open_log_file_page - 1), true);
|
||||
furi_string_reset(app->text_box_store);
|
||||
for(uint16_t i = 0; i < (WIFI_MARAUDER_TEXT_BOX_STORE_SIZE / (sizeof(temp) - 1)); i++) {
|
||||
uint16_t num_bytes = storage_file_read(app->log_file, temp, sizeof(temp) - 1);
|
||||
if(num_bytes == 0) {
|
||||
break;
|
||||
}
|
||||
temp[num_bytes] = '\0';
|
||||
furi_string_cat_str(app->text_box_store, temp);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_log_viewer_setup_widget(WifiMarauderApp* app, bool called_from_browse) {
|
||||
Widget* widget = app->widget;
|
||||
bool is_open = storage_file_is_open(app->log_file);
|
||||
bool should_open_log = (app->has_saved_logs_this_session || called_from_browse);
|
||||
if(is_open) {
|
||||
_read_log_page_into_text_store(app);
|
||||
} else if(
|
||||
should_open_log &&
|
||||
storage_file_open(app->log_file, app->log_file_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
uint64_t filesize = storage_file_size(app->log_file);
|
||||
app->open_log_file_num_pages = filesize / WIFI_MARAUDER_TEXT_BOX_STORE_SIZE;
|
||||
int extra_page = (filesize % WIFI_MARAUDER_TEXT_BOX_STORE_SIZE != 0) ? 1 : 0;
|
||||
app->open_log_file_num_pages = (filesize / WIFI_MARAUDER_TEXT_BOX_STORE_SIZE) + extra_page;
|
||||
app->open_log_file_page = 1;
|
||||
_read_log_page_into_text_store(app);
|
||||
} else {
|
||||
app->open_log_file_page = 0;
|
||||
app->open_log_file_num_pages = 0;
|
||||
}
|
||||
|
||||
widget_reset(widget);
|
||||
|
||||
if(furi_string_empty(app->text_box_store)) {
|
||||
char help_msg[256];
|
||||
snprintf(
|
||||
help_msg,
|
||||
sizeof(help_msg),
|
||||
"The log is empty! :(\nTry sending a command?\n\nSaving pcaps to flipper sdcard: %s\nSaving logs to flipper sdcard: %s",
|
||||
app->ok_to_save_pcaps ? "ON" : "OFF",
|
||||
app->ok_to_save_logs ? "ON" : "OFF");
|
||||
furi_string_set_str(app->text_box_store, help_msg);
|
||||
}
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
widget, 0, 0, 128, 53, furi_string_get_cstr(app->text_box_store));
|
||||
|
||||
if(1 < app->open_log_file_page && app->open_log_file_page < app->open_log_file_num_pages) {
|
||||
// hide "Browse" text for middle pages
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeCenter, "", wifi_marauder_scene_log_viewer_widget_callback, app);
|
||||
} else {
|
||||
// only show "Browse" text on first and last page
|
||||
widget_add_button_element(
|
||||
widget,
|
||||
GuiButtonTypeCenter,
|
||||
"Browse",
|
||||
wifi_marauder_scene_log_viewer_widget_callback,
|
||||
app);
|
||||
}
|
||||
|
||||
char pagecounter[100];
|
||||
snprintf(
|
||||
pagecounter,
|
||||
sizeof(pagecounter),
|
||||
"%d/%d",
|
||||
app->open_log_file_page,
|
||||
app->open_log_file_num_pages);
|
||||
if(app->open_log_file_page > 1) {
|
||||
if(app->open_log_file_page == app->open_log_file_num_pages) {
|
||||
// only show left side page-count on last page
|
||||
widget_add_button_element(
|
||||
widget,
|
||||
GuiButtonTypeLeft,
|
||||
pagecounter,
|
||||
wifi_marauder_scene_log_viewer_widget_callback,
|
||||
app);
|
||||
} else {
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeLeft, "", wifi_marauder_scene_log_viewer_widget_callback, app);
|
||||
}
|
||||
}
|
||||
if(app->open_log_file_page < app->open_log_file_num_pages) {
|
||||
widget_add_button_element(
|
||||
widget,
|
||||
GuiButtonTypeRight,
|
||||
pagecounter,
|
||||
wifi_marauder_scene_log_viewer_widget_callback,
|
||||
app);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_log_viewer_on_enter(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
app->open_log_file_page = 0;
|
||||
app->open_log_file_num_pages = 0;
|
||||
bool saved_logs_exist = false;
|
||||
if (!app->has_saved_logs_this_session && furi_string_empty(app->text_box_store)) {
|
||||
// no commands sent yet this session, find last saved log
|
||||
if (storage_dir_open(app->log_file, MARAUDER_APP_FOLDER_LOGS)) {
|
||||
char name[70];
|
||||
char lastname[70];
|
||||
while (storage_dir_read(app->log_file, NULL, name, sizeof(name))) {
|
||||
// keep reading directory until last file is reached
|
||||
strlcpy(lastname, name, sizeof(lastname));
|
||||
saved_logs_exist = true;
|
||||
}
|
||||
if (saved_logs_exist) {
|
||||
snprintf(app->log_file_path, sizeof(app->log_file_path), "%s/%s", MARAUDER_APP_FOLDER_LOGS, lastname);
|
||||
}
|
||||
}
|
||||
storage_dir_close(app->log_file);
|
||||
}
|
||||
|
||||
wifi_marauder_scene_log_viewer_setup_widget(app, saved_logs_exist);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewWidget);
|
||||
}
|
||||
|
||||
bool wifi_marauder_scene_log_viewer_on_event(void* context, SceneManagerEvent event) {
|
||||
WifiMarauderApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == GuiButtonTypeCenter) {
|
||||
// Browse
|
||||
FuriString* predefined_filepath = furi_string_alloc_set_str(MARAUDER_APP_FOLDER_LOGS);
|
||||
FuriString* selected_filepath = furi_string_alloc();
|
||||
if(dialog_file_browser_show(
|
||||
app->dialogs, selected_filepath, predefined_filepath, NULL)) {
|
||||
strncpy(
|
||||
app->log_file_path,
|
||||
furi_string_get_cstr(selected_filepath),
|
||||
sizeof(app->log_file_path));
|
||||
if(storage_file_is_open(app->log_file)) {
|
||||
storage_file_close(app->log_file);
|
||||
}
|
||||
wifi_marauder_scene_log_viewer_setup_widget(app, true);
|
||||
}
|
||||
furi_string_free(selected_filepath);
|
||||
furi_string_free(predefined_filepath);
|
||||
consumed = true;
|
||||
} else if(event.event == GuiButtonTypeRight) {
|
||||
// Advance page
|
||||
++app->open_log_file_page;
|
||||
wifi_marauder_scene_log_viewer_setup_widget(app, false);
|
||||
} else if(event.event == GuiButtonTypeLeft) {
|
||||
// Previous page
|
||||
--app->open_log_file_page;
|
||||
wifi_marauder_scene_log_viewer_setup_widget(app, false);
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_log_viewer_on_exit(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
if(storage_file_is_open(app->log_file)) {
|
||||
storage_file_close(app->log_file);
|
||||
}
|
||||
}
|
||||
130
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_settings_init.c
vendored
Normal file
130
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_settings_init.c
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
const char* Y = "Y";
|
||||
const char* N = "N";
|
||||
|
||||
#define PROMPT_PCAPS 0
|
||||
#define PROMPT_LOGS 1
|
||||
|
||||
void wifi_marauder_scene_settings_init_widget_callback(
|
||||
GuiButtonType result,
|
||||
InputType type,
|
||||
void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
if(type == InputTypeShort) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, result);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_settings_init_setup_widget(WifiMarauderApp* app) {
|
||||
Widget* widget = app->widget;
|
||||
|
||||
widget_reset(widget);
|
||||
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeLeft, "No", wifi_marauder_scene_settings_init_widget_callback, app);
|
||||
widget_add_button_element(
|
||||
widget, GuiButtonTypeRight, "Yes", wifi_marauder_scene_settings_init_widget_callback, app);
|
||||
|
||||
if(app->which_prompt == PROMPT_PCAPS) {
|
||||
widget_add_string_element(widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Save pcaps?");
|
||||
widget_add_text_scroll_element(
|
||||
widget,
|
||||
0,
|
||||
12,
|
||||
128,
|
||||
38,
|
||||
"With compatible marauder\nfirmware, you can choose to\nsave captures (pcaps) to the\nflipper sd card here:\n" MARAUDER_APP_FOLDER_USER_PCAPS
|
||||
"\n\nYou can change this setting in the app at any time. Would\nyou like to enable this feature now?");
|
||||
} else {
|
||||
widget_add_string_element(widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Save logs?");
|
||||
widget_add_text_scroll_element(
|
||||
widget,
|
||||
0,
|
||||
12,
|
||||
128,
|
||||
38,
|
||||
"This app supports saving text\nlogs of console output to the\nflipper sd card here:\n" MARAUDER_APP_FOLDER_USER_LOGS
|
||||
"\n\nYou can change this setting in the app at any time. Would\nyou like to enable this feature now?");
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_settings_init_on_enter(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
app->which_prompt = PROMPT_PCAPS;
|
||||
wifi_marauder_scene_settings_init_setup_widget(app);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewWidget);
|
||||
}
|
||||
|
||||
bool wifi_marauder_scene_settings_init_on_event(void* context, SceneManagerEvent event) {
|
||||
WifiMarauderApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
// get which button press: "Yes" or "No"
|
||||
if(event.event == GuiButtonTypeRight) {
|
||||
// Yes
|
||||
if(app->which_prompt == PROMPT_PCAPS) {
|
||||
app->ok_to_save_pcaps = true;
|
||||
} else {
|
||||
app->ok_to_save_logs = true;
|
||||
}
|
||||
} else if(event.event == GuiButtonTypeLeft) {
|
||||
// No
|
||||
if(app->which_prompt == PROMPT_PCAPS) {
|
||||
app->ok_to_save_pcaps = false;
|
||||
} else {
|
||||
app->ok_to_save_logs = false;
|
||||
}
|
||||
}
|
||||
|
||||
// save setting to file, load next widget or scene
|
||||
if(app->which_prompt == PROMPT_PCAPS) {
|
||||
if(storage_file_open(
|
||||
app->save_pcap_setting_file,
|
||||
SAVE_PCAP_SETTING_FILEPATH,
|
||||
FSAM_WRITE,
|
||||
FSOM_CREATE_ALWAYS)) {
|
||||
const char* ok = app->ok_to_save_pcaps ? Y : N;
|
||||
storage_file_write(app->save_pcap_setting_file, ok, sizeof(ok));
|
||||
} else {
|
||||
dialog_message_show_storage_error(app->dialogs, "Cannot save settings");
|
||||
}
|
||||
storage_file_close(app->save_pcap_setting_file);
|
||||
// same scene, different-looking widget
|
||||
app->which_prompt = PROMPT_LOGS;
|
||||
wifi_marauder_scene_settings_init_setup_widget(app);
|
||||
} else {
|
||||
if(storage_file_open(
|
||||
app->save_logs_setting_file,
|
||||
SAVE_LOGS_SETTING_FILEPATH,
|
||||
FSAM_WRITE,
|
||||
FSOM_CREATE_ALWAYS)) {
|
||||
const char* ok = app->ok_to_save_logs ? Y : N;
|
||||
storage_file_write(app->save_logs_setting_file, ok, sizeof(ok));
|
||||
} else {
|
||||
dialog_message_show_storage_error(app->dialogs, "Cannot save settings");
|
||||
}
|
||||
storage_file_close(app->save_logs_setting_file);
|
||||
// go back to start scene (main menu)
|
||||
app->need_to_prompt_settings_init = false;
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_settings_init_on_exit(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
widget_reset(app->widget);
|
||||
if(storage_file_is_open(app->save_pcap_setting_file)) {
|
||||
storage_file_close(app->save_pcap_setting_file);
|
||||
}
|
||||
if(storage_file_is_open(app->save_logs_setting_file)) {
|
||||
storage_file_close(app->save_logs_setting_file);
|
||||
}
|
||||
}
|
||||
269
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_start.c
vendored
Normal file
269
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_start.c
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
//** Includes sniffbt and sniffskim for compatible ESP32-WROOM hardware.
|
||||
//wifi_marauder_app_i.h also changed **//
|
||||
#include "../wifi_marauder_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 (9)
|
||||
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;
|
||||
} WifiMarauderItem;
|
||||
|
||||
// NUM_MENU_ITEMS defined in wifi_marauder_app_i.h - if you add an entry here, increment it!
|
||||
const WifiMarauderItem items[NUM_MENU_ITEMS] = {
|
||||
{"View Log from", {"start", "end"}, 2, {"", ""}, NO_ARGS, FOCUS_CONSOLE_TOGGLE, NO_TIP},
|
||||
{"Scan",
|
||||
{"ap", "station"},
|
||||
2,
|
||||
{"scanap", "scansta"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
{"SSID",
|
||||
{"add rand", "add name", "remove"},
|
||||
3,
|
||||
{"ssid -a -g", "ssid -a -n", "ssid -r"},
|
||||
INPUT_ARGS,
|
||||
FOCUS_CONSOLE_START,
|
||||
NO_TIP},
|
||||
{"List",
|
||||
{"ap", "ssid", "station"},
|
||||
3,
|
||||
{"list -a", "list -s", "list -c"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_START,
|
||||
NO_TIP},
|
||||
{"Select",
|
||||
{"ap", "ssid", "station"},
|
||||
3,
|
||||
{"select -a", "select -s", "select -c"},
|
||||
INPUT_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
NO_TIP},
|
||||
{"Clear List",
|
||||
{"ap", "ssid", "station"},
|
||||
3,
|
||||
{"clearlist -a", "clearlist -s", "clearlist -c"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
NO_TIP},
|
||||
{"Attack",
|
||||
{"deauth", "probe", "rickroll"},
|
||||
3,
|
||||
{"attack -t deauth", "attack -t probe", "attack -t rickroll"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
{"Targeted Deauth",
|
||||
{"station", "manual"},
|
||||
2,
|
||||
{"attack -t deauth -c", "attack -t deauth -s"},
|
||||
TOGGLE_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
{"Beacon Spam",
|
||||
{"ap list", "ssid list", "random"},
|
||||
3,
|
||||
{"attack -t beacon -a", "attack -t beacon -l", "attack -t beacon -r"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
{"Sniff",
|
||||
{"beacon", "deauth", "esp", "pmkid", "probe", "pwn", "raw", "bt", "skim"},
|
||||
9,
|
||||
{"sniffbeacon",
|
||||
"sniffdeauth",
|
||||
"sniffesp",
|
||||
"sniffpmkid",
|
||||
"sniffprobe",
|
||||
"sniffpwn",
|
||||
"sniffraw",
|
||||
"sniffbt",
|
||||
"sniffskim"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
{"Sniff PMKID on channel",
|
||||
{""},
|
||||
1,
|
||||
{"sniffpmkid -c"},
|
||||
INPUT_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
SHOW_STOPSCAN_TIP},
|
||||
{"Channel",
|
||||
{"get", "set"},
|
||||
2,
|
||||
{"channel", "channel -s"},
|
||||
TOGGLE_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
NO_TIP},
|
||||
{"Camera",
|
||||
{"photo", "flashlight"},
|
||||
2,
|
||||
{"photo", "flashlight"},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_END,
|
||||
NO_TIP},
|
||||
{"Settings",
|
||||
{"display", "restore", "ForcePMKID", "ForceProbe", "SavePCAP", "EnableLED", "other"},
|
||||
7,
|
||||
{"settings",
|
||||
"settings -r",
|
||||
"settings -s ForcePMKID enable",
|
||||
"settings -s ForceProbe enable",
|
||||
"settings -s SavePCAP enable",
|
||||
"settings -s EnableLED enable",
|
||||
"settings -s"},
|
||||
TOGGLE_ARGS,
|
||||
FOCUS_CONSOLE_START,
|
||||
NO_TIP},
|
||||
{"Update", {"ota", "sd"}, 2, {"update -w", "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},
|
||||
{"Save to flipper sdcard", // keep as last entry or change logic in callback below
|
||||
{""},
|
||||
1,
|
||||
{""},
|
||||
NO_ARGS,
|
||||
FOCUS_CONSOLE_START,
|
||||
NO_TIP},
|
||||
};
|
||||
|
||||
static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uint32_t index) {
|
||||
furi_assert(context);
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
furi_assert(index < NUM_MENU_ITEMS);
|
||||
const WifiMarauderItem* item = &items[index];
|
||||
|
||||
if(index == NUM_MENU_ITEMS - 1) {
|
||||
// "Save to flipper sdcard" special case - start SettingsInit widget
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, WifiMarauderEventStartSettingsInit);
|
||||
return;
|
||||
}
|
||||
|
||||
const int selected_option_index = app->selected_option_index[index];
|
||||
furi_assert(selected_option_index < item->num_options_menu);
|
||||
app->selected_tx_string = item->actual_commands[selected_option_index];
|
||||
app->is_command = (1 <= index);
|
||||
app->is_custom_tx_string = false;
|
||||
app->selected_menu_index = index;
|
||||
app->focus_console_start = (item->focus_console == FOCUS_CONSOLE_TOGGLE) ?
|
||||
(selected_option_index == 0) :
|
||||
item->focus_console;
|
||||
app->show_stopscan_tip = item->show_stopscan_tip;
|
||||
|
||||
if(!app->is_command && selected_option_index == 0) {
|
||||
// View Log from start
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartLogViewer);
|
||||
return;
|
||||
}
|
||||
|
||||
bool needs_keyboard = (item->needs_keyboard == TOGGLE_ARGS) ? (selected_option_index != 0) :
|
||||
item->needs_keyboard;
|
||||
if(needs_keyboard) {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartKeyboard);
|
||||
} else {
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
|
||||
}
|
||||
}
|
||||
|
||||
static void wifi_marauder_scene_start_var_list_change_callback(VariableItem* item) {
|
||||
furi_assert(item);
|
||||
|
||||
WifiMarauderApp* app = variable_item_get_context(item);
|
||||
furi_assert(app);
|
||||
|
||||
const WifiMarauderItem* menu_item = &items[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_marauder_scene_start_on_enter(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
VariableItemList* var_item_list = app->var_item_list;
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, wifi_marauder_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,
|
||||
items[i].item_string,
|
||||
items[i].num_options_menu,
|
||||
wifi_marauder_scene_start_var_list_change_callback,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, app->selected_option_index[i]);
|
||||
variable_item_set_current_value_text(
|
||||
item, items[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, WifiMarauderSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewVarItemList);
|
||||
|
||||
// Wait, if the user hasn't initialized sdcard settings, let's prompt them once (then come back here)
|
||||
if(app->need_to_prompt_settings_init) {
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSettingsInit);
|
||||
}
|
||||
}
|
||||
|
||||
bool wifi_marauder_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
UNUSED(context);
|
||||
WifiMarauderApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == WifiMarauderEventStartKeyboard) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneTextInput);
|
||||
} else if(event.event == WifiMarauderEventStartConsole) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput);
|
||||
} else if(event.event == WifiMarauderEventStartSettingsInit) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSettingsInit);
|
||||
} else if(event.event == WifiMarauderEventStartLogViewer) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneLogViewer);
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
app->selected_menu_index = variable_item_list_get_selected_item_index(app->var_item_list);
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeBack) {
|
||||
scene_manager_stop(app->scene_manager);
|
||||
view_dispatcher_stop(app->view_dispatcher);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_start_on_exit(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
variable_item_list_reset(app->var_item_list);
|
||||
}
|
||||
154
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_text_input.c
vendored
Normal file
154
applications/external/esp32cam_marauder_companion/scenes/wifi_marauder_scene_text_input.c
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
void wifi_marauder_scene_text_input_callback(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
switch(app->special_case_input_step) {
|
||||
case 0: // most commands
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
|
||||
break;
|
||||
case 1: // special case for deauth: save source MAC
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventSaveSourceMac);
|
||||
break;
|
||||
case 2: // special case for deauth: save destination MAC
|
||||
view_dispatcher_send_custom_event(
|
||||
app->view_dispatcher, WifiMarauderEventSaveDestinationMac);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_text_input_on_enter(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
if(0 ==
|
||||
strncmp("attack -t deauth -s", app->selected_tx_string, strlen("attack -t deauth -s"))) {
|
||||
// Special case for manual deauth input
|
||||
app->special_case_input_step = 1;
|
||||
bzero(app->text_input_store, WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE);
|
||||
} else if(false == app->is_custom_tx_string) {
|
||||
// Most commands
|
||||
app->special_case_input_step = 0;
|
||||
|
||||
// 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_MARAUDER_TEXT_INPUT_STORE_SIZE);
|
||||
bzero(app->text_input_store, WIFI_MARAUDER_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(app->special_case_input_step == 1) {
|
||||
text_input_set_header_text(text_input, "Enter source MAC");
|
||||
} else 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_marauder_scene_text_input_callback,
|
||||
app,
|
||||
app->text_input_store,
|
||||
WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE,
|
||||
false);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewTextInput);
|
||||
}
|
||||
|
||||
bool wifi_marauder_scene_text_input_on_event(void* context, SceneManagerEvent event) {
|
||||
WifiMarauderApp* app = context;
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == WifiMarauderEventStartConsole) {
|
||||
// Point to custom string to send
|
||||
app->selected_tx_string = app->text_input_store;
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput);
|
||||
consumed = true;
|
||||
} else if(event.event == WifiMarauderEventSaveSourceMac) {
|
||||
if(12 != strlen(app->text_input_store)) {
|
||||
text_input_set_header_text(app->text_input, "MAC must be 12 hex chars!");
|
||||
} else {
|
||||
snprintf(
|
||||
app->special_case_input_src_addr,
|
||||
sizeof(app->special_case_input_src_addr),
|
||||
"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
|
||||
app->text_input_store[0],
|
||||
app->text_input_store[1],
|
||||
app->text_input_store[2],
|
||||
app->text_input_store[3],
|
||||
app->text_input_store[4],
|
||||
app->text_input_store[5],
|
||||
app->text_input_store[6],
|
||||
app->text_input_store[7],
|
||||
app->text_input_store[8],
|
||||
app->text_input_store[9],
|
||||
app->text_input_store[10],
|
||||
app->text_input_store[11]);
|
||||
|
||||
// Advance scene to input destination MAC, clear text input
|
||||
app->special_case_input_step = 2;
|
||||
bzero(app->text_input_store, WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE);
|
||||
text_input_set_header_text(app->text_input, "Enter destination MAC");
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event.event == WifiMarauderEventSaveDestinationMac) {
|
||||
if(12 != strlen(app->text_input_store)) {
|
||||
text_input_set_header_text(app->text_input, "MAC must be 12 hex chars!");
|
||||
} else {
|
||||
snprintf(
|
||||
app->special_case_input_dst_addr,
|
||||
sizeof(app->special_case_input_dst_addr),
|
||||
"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
|
||||
app->text_input_store[0],
|
||||
app->text_input_store[1],
|
||||
app->text_input_store[2],
|
||||
app->text_input_store[3],
|
||||
app->text_input_store[4],
|
||||
app->text_input_store[5],
|
||||
app->text_input_store[6],
|
||||
app->text_input_store[7],
|
||||
app->text_input_store[8],
|
||||
app->text_input_store[9],
|
||||
app->text_input_store[10],
|
||||
app->text_input_store[11]);
|
||||
|
||||
// Construct command with source and destination MACs
|
||||
snprintf(
|
||||
app->text_input_store,
|
||||
WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE,
|
||||
"attack -t deauth -s %18s -d %18s",
|
||||
app->special_case_input_src_addr,
|
||||
app->special_case_input_dst_addr);
|
||||
app->selected_tx_string = app->text_input_store;
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput);
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_text_input_on_exit(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
text_input_reset(app->text_input);
|
||||
}
|
||||
Reference in New Issue
Block a user