Skip to content

Commit

Permalink
Merge branch 'CMD_CONTROL' into pre_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Otrebor671 committed Oct 31, 2024
2 parents 3f41609 + 5051b76 commit 3d9f119
Show file tree
Hide file tree
Showing 14 changed files with 285 additions and 108 deletions.
157 changes: 157 additions & 0 deletions firmware/main/apps/wifi_analyzer/scenes/analyzer_scenes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#include "analyzer_scenes.h"

#include "general_radio_selection.h"
#include "general_screens.h"
#include "general_submenu.h"
#include "menus_module.h"
#include "wifi_analyzer.h"
#include "wifi_sniffer.h"

static analyzer_scenes_e current_scene;

void analyzer_scenes_main_menu();
void analyzer_scenes_settings();
void analyzer_scenes_channel();
void analyzer_scenes_destination();

analyzer_scenes_e analyzer_get_current_scene() {
return current_scene;
}

////////////////////////// MAIN MENU ///////////////////////////////
static enum {
ANALYZER_START_OPTION,
ANALYZER_SETTINGS_OPTION,
ANALYZER_HELP_OPTION
} analyzer_main_options_e;

char* analizer_main_options[] = {"Start", "Settings", "Help"};

static void main_menu_selection_handler(uint8_t selection) {
switch (selection) {
case ANALYZER_START_OPTION:
wifi_analyzer_run();
break;
case ANALYZER_SETTINGS_OPTION:
analyzer_scenes_settings();
break;
case ANALYZER_HELP_OPTION:
wifi_analyzer_help();
break;
default:
break;
}
}

static void main_menu_exit_handler() {
menus_module_exit_app();
}

void analyzer_scenes_main_menu() {
current_scene = ANALYZER_MAIN_SCENE;
general_submenu_menu_t main_menu;
main_menu.options = analizer_main_options;
main_menu.options_count = sizeof(analizer_main_options) / sizeof(char*);
main_menu.select_cb = main_menu_selection_handler;
main_menu.exit_cb = main_menu_exit_handler;
general_submenu(main_menu);
wifi_analyzer_begin();
}

////////////////////////// SETTINGS MENU ///////////////////////////////
static enum {
ANALYZER_SETTINGS_CHANNEL_OPTION,
ANALYZER_SETTINGS_DESTINATION_OPTION,
} analyzer_settings_options_e;

char* analizer_settings_options[] = {"Channel", "Destination"};

static void settings_selection_handler(uint8_t selection) {
switch (selection) {
case ANALYZER_SETTINGS_CHANNEL_OPTION:
analyzer_scenes_channel();
break;
case ANALYZER_SETTINGS_DESTINATION_OPTION:
analyzer_scenes_destination();
break;
default:
break;
}
}

static void settings_exit_handler() {
analyzer_scenes_main_menu();
}

void analyzer_scenes_settings() {
current_scene = ANALYZER_SETTINGS_OPTION;
general_submenu_menu_t settings_menu;
settings_menu.options = analizer_settings_options;
settings_menu.options_count =
sizeof(analizer_settings_options) / sizeof(char*);
settings_menu.select_cb = settings_selection_handler;
settings_menu.exit_cb = settings_exit_handler;
general_submenu(settings_menu);
// wifi_analyzer_begin();
}
////////////////////////// CHANNEL MENU ///////////////////////////////
static const char* channel_options[] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
};
static void set_channel(uint8_t selected_item) {
wifi_sniffer_set_channel(selected_item + 1);
}
void analyzer_scenes_channel() {
general_radio_selection_menu_t channel = {0};
channel.banner = "Choose Channel",
channel.current_option = wifi_sniffer_get_channel() - 1;
channel.options = channel_options;
channel.options_count = sizeof(channel_options) / sizeof(char*);
channel.select_cb = set_channel;
channel.exit_cb = analyzer_scenes_settings;
channel.style = RADIO_SELECTION_OLD_STYLE;
general_radio_selection(channel);
}

////////////////////////// DESTINATION MENU ///////////////////////////////
static const char* destination_options[] = {"SD", "Internal"};
static void set_destination(uint8_t selected_item) {
if (selected_item == WIFI_SNIFFER_DESTINATION_SD) {
wifi_sniffer_set_destination_sd();
} else {
wifi_sniffer_set_destination_internal();
}
}

static void destination_scene_exit() {
wifi_module_analyzer_destination_exit();
analyzer_scenes_settings();
}
void analyzer_scenes_destination() {
general_radio_selection_menu_t destination = {0};
destination.banner = "Choose Destination",
destination.current_option = wifi_sniffer_is_destination_internal();
destination.options = destination_options;
destination.options_count = sizeof(destination_options) / sizeof(char*);
destination.select_cb = set_destination;
destination.exit_cb = destination_scene_exit;
destination.style = RADIO_SELECTION_OLD_STYLE;
general_radio_selection(destination);
}
////////////////////////// HELP MENU ///////////////////////////////
static const char* wifi_analizer_help[] = {
"This tool", "allows you to", "analyze the",
"WiFi networks", "around you.", "",
"You can select", "the channel and", "the destination",
"to save the", "results.",
};

static const general_menu_t analyzer_help_menu = {
.menu_items = wifi_analizer_help,
.menu_count = 11,
.menu_level = GENERAL_TREE_APP_MENU};

void wifi_analyzer_help() {
general_register_scrolling_menu(&analyzer_help_menu);
general_screen_display_scrolling_text_handler(analyzer_scenes_main_menu);
}
15 changes: 15 additions & 0 deletions firmware/main/apps/wifi_analyzer/scenes/analyzer_scenes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "stdio.h"

typedef enum {
ANALYZER_MAIN_SCENE,
ANALYZER_RUN_SCENE,
ANALYZER_SETTINGS_SCENE,
ANALYZER_DESTINATION_SCENE,
ANALYZER_CHANNEL_SCENE,
ANALYZER_HELP_SCENE,
} analyzer_scenes_e;

void analyzer_scenes_main_menu();
void analyzer_scenes_settings();
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "animations_task.h"
#include "esp_log.h"
#include "esp_wifi.h"
#include "modules/wifi/wifi_bitmaps.h"
#include "oled_screen.h"
#include "wifi_bitmaps.h"

TaskHandle_t wifi_sniffer_animation_task_handle = NULL;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "wifi_module.h"
#include "wifi_analyzer.h"

#include "captive_portal.h"
#include "catdos_module.h"
Expand All @@ -9,47 +9,28 @@
#include "keyboard_module.h"
#include "string.h"

#include "analyzer_scenes.h"
#include "deauth_module.h"
#include "general_radio_selection.h"
#include "general_screens.h"
#include "led_events.h"
#include "menus_module.h"
#include "oled_screen.h"
#include "sd_card.h"
#include "wifi_analyzer.h"
#include "wifi_attacks.h"
#include "wifi_controller.h"
#include "wifi_module.h"
#include "wifi_scanner.h"
#include "wifi_screens_module.h"

static const char* TAG = "wifi_module";
bool analizer_initialized = false;
static bool analizer_initialized = false;

static general_menu_t analyzer_summary_menu;
static char* wifi_analizer_summary_2[120] = {
"Summary",
};
static const char* wifi_analizer_help_2[] = {
"This tool", "allows you to", "analyze the",
"WiFi networks", "around you.", "",
"You can select", "the channel and", "the destination",
"to save the", "results.",
};

static const general_menu_t analyzer_help_menu = {
.menu_items = wifi_analizer_help_2,
.menu_count = 11,
.menu_level = GENERAL_TREE_APP_MENU};

static const char* destination_options[] = {"SD", "Internal"};
static const char* channel_options[] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
};

void wifi_module_show_analyzer_help() {
general_register_scrolling_menu(&analyzer_help_menu);
general_screen_display_scrolling_text_handler(menus_module_exit_app);
}
static void wifi_module_input_cb(uint8_t button_name, uint8_t button_event);

uint16_t get_summary_rows_count() {
Expand Down Expand Up @@ -95,7 +76,7 @@ void wifi_module_init_sniffer() {
}
static void wifi_module_summary_exit_cb() {
wifi_sniffer_close_file();
menus_module_exit_app();
analyzer_scenes_main_menu();
}

void wifi_module_analyzer_run_exit() {
Expand All @@ -113,7 +94,7 @@ void wifi_module_analyzer_summary_exit() {
wifi_sniffer_close_file();
}

void wifi_module_analyzer_exit() {
void wifi_analyzer_exit() {
menus_module_restart();
}

Expand All @@ -130,51 +111,20 @@ void wifi_module_analyzer_destination_exit() {
}
}

void wifi_module_analyzer_run() {
void wifi_analyzer_run() {
wifi_module_init_sniffer();
menus_module_set_app_state(true, wifi_module_input_cb);
}

static void wifi_module_set_destination(uint8_t selected_item) {
if (selected_item == WIFI_SNIFFER_DESTINATION_SD) {
wifi_sniffer_set_destination_sd();
} else {
wifi_sniffer_set_destination_internal();
}
}
static void wifi_module_set_channel(uint8_t selected_item) {
wifi_sniffer_set_channel(selected_item + 1);
}

void wifi_module_analyzer_channel() {
general_radio_selection_menu_t channel = {0};
channel.banner = "Choose Channel",
channel.current_option = wifi_sniffer_get_channel() - 1;
channel.options = channel_options;
channel.options_count = 14;
channel.select_cb = wifi_module_set_channel;
channel.exit_cb = menus_module_exit_app;
channel.style = RADIO_SELECTION_OLD_STYLE;
general_radio_selection(channel);
}

void wifi_module_analyzer_destination() {
general_radio_selection_menu_t destination = {0};
destination.banner = "Choose Destination",
destination.current_option = wifi_sniffer_is_destination_internal();
destination.options = destination_options;
destination.options_count = 2;
destination.select_cb = wifi_module_set_destination;
destination.exit_cb = menus_module_exit_app;
destination.style = RADIO_SELECTION_OLD_STYLE;
general_radio_selection(destination);
}
void wifi_module_analizer_begin() {
void wifi_analyzer_begin() {
ESP_LOGI(TAG, "Initializing WiFi analizer module");
wifi_sniffer_register_cb(wifi_screens_module_display_sniffer_cb);
wifi_sniffer_register_animation_cbs(wifi_screens_sniffer_animation_start,
wifi_screens_sniffer_animation_stop);
wifi_sniffer_register_summary_cb(wifi_module_analizer_summary_cb);
if (analizer_initialized) {
return;
}
wifi_sniffer_begin();
analizer_initialized = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ void wifi_module_begin();
*
* @return void
*/
void wifi_module_analizer_begin();
void wifi_analyzer_begin();

void wifi_module_init_sniffer();

void wifi_module_analyzer_run();
void wifi_analyzer_run();

/**
* @brief Stop the wifi module
*
*/
void wifi_module_exit(void);
void wifi_module_analyzer_run_exit();
void wifi_module_analyzer_exit();
void wifi_analyzer_exit();
void wifi_module_analyzer_summary_exit();
void wifi_module_analyzer_destination_exit();

Expand All @@ -40,7 +40,7 @@ void wifi_module_analyzer_destination_exit();
*/
void wifi_module_analizer_summary_cb(FILE* pcap_file);

void wifi_module_show_analyzer_help();
void wifi_analyzer_help();

void wifi_module_analyzer_destination();
void wifi_module_analyzer_channel();
void analyzer_scenes_destination();
void analyzer_scenes_channel();
File renamed without changes.
3 changes: 2 additions & 1 deletion firmware/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "buzzer.h"
#include "cat_console.h"
#include "cmd_control.h"
#include "esp_log.h"
#include "esp_timer.h"
#include "flash_fs.h"
Expand Down Expand Up @@ -40,5 +41,5 @@ void app_main() {
menus_module_begin();
leds_off();
preferences_put_bool("wifi_connected", false);
// cat_console_begin();
cat_console_begin();
}
3 changes: 3 additions & 0 deletions firmware/main/modules/cat_dos/cat_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <unistd.h>
#include "argtable3/argtable3.h"
#include "cmd_catdos.h"
#include "cmd_control.h"
#include "cmd_wifi.h"
// #include "driver/uart.h"
// #include "driver/uart_vfs.h"
Expand Down Expand Up @@ -83,6 +84,8 @@ void cat_console_begin() {
/* Register commands */
esp_console_register_help_command();
register_wifi();
launch_cmd_register();

// if(show_dos){
// register_catdos_commands();
// }
Expand Down
Loading

0 comments on commit 3d9f119

Please sign in to comment.