Skip to content

Commit

Permalink
feat: add deauth detector scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
Otrebor671 committed Dec 19, 2024
1 parent 91d4976 commit 03d30ca
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 1 deletion.
106 changes: 106 additions & 0 deletions firmware/main/apps/wifi/deauth_detector/scenes/detector_scenes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#include "detector_scenes.h"

#include "general_radio_selection.h"
#include "general_submenu.h"
#include "menus_module.h"

void detector_scenes_main_menu();
void detector_scenes_settings();
void detector_scenes_channel();
void detector_scenes_help();

////////////////////////// Main Menu //////////////////////////
static enum { RUN_OPTION, SETTINGS_OPTION, HELP_OPTION } main_menu_options_e;
static const char* main_menu_options[] = {"Run", "Settings", "Help"};
static void main_menu_handler(uint8_t selection) {
switch (selection) {
case RUN_OPTION:
// DEAUTH DETECTOR BEGIN
break;
case SETTINGS_OPTION:
detector_scenes_settings();
break;
case HELP_OPTION:
detector_scenes_help();
break;
default:
break;
}
}

static void main_menu_exit() {
menus_module_exit_app();
}

void detector_scenes_main_menu() {
general_submenu_menu_t main_menu;
main_menu.options = main_menu_options;
main_menu.options_count = sizeof(main_menu_options) / sizeof(char*);
main_menu.select_cb = main_menu_handler;
main_menu.exit_cb = main_menu_exit;
general_submenu(main_menu);
}

////////////////////////// Settings Menu //////////////////////////
static enum { CHANNEL_HOP_OPTION, CHANNEL_OPTION } settings_options_e;
static const char* settings_options[] = {"Channel hop", "Channel"};
static void settings_handler(uint8_t scan_mode) {
// TODO: SAVE "scan_mode" TO FLASH
// TODO: SET SCAN MODE TO "scan_mode"
switch (scan_mode) {
case CHANNEL_HOP_OPTION:
break;
case CHANNEL_OPTION:
detector_scenes_channel();
break;
default:
break;
}
}

static void settings_exit() {
detector_scenes_main_menu();
}

void detector_scenes_settings() {
general_radio_selection_menu_t settings;
settings.banner = "Scan Mode";
settings.options = settings_options;
settings.options_count = sizeof(settings_options) / sizeof(char*);
settings.select_cb = settings_handler;
settings.style = RADIO_SELECTION_OLD_STYLE;
settings.exit_cb = settings_exit;
settings.current_option = 0; // TODO: GET "scan_mode" FROM FLASH
general_radio_selection(settings);
}

////////////////////////// Channel Hop Menu //////////////////////////
static const char* channel_options[] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
};
static void channel_handler(uint8_t channel) {
// TODO: Set Deauth Detector Channel to "channel"
// TODO: SAVE "channel" TO FLASH
}

static void channel_exit() {
detector_scenes_settings();
}

void detector_scenes_channel() {
general_radio_selection_menu_t settings;
settings.banner = "Select Channel";
settings.options = channel_options;
settings.options_count = sizeof(channel_options) / sizeof(char*);
settings.select_cb = channel_handler;
settings.style = RADIO_SELECTION_OLD_STYLE;
settings.exit_cb = channel_exit;
settings.current_option = 0; // TODO: GET "channel" FROM FLASH
general_radio_selection(settings);
}

////////////////////////// Help Menu //////////////////////////

static void help_exit() {}

void detector_scenes_help() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <stdio.h>

void detector_scenes_main_menu();
void detector_scenes_settings();
void detector_scenes_channel();
void detector_scenes_help();
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ static void input_cb(uint8_t button_name, uint8_t button_event) {
switch (button_name) {
case BUTTON_LEFT:
void (*exit_cb)() = general_radio_selection_ctx->exit_cb;
free(general_radio_selection_ctx);
general_radio_selection_ctx = NULL;
if (exit_cb) {
exit_cb();
}
free(general_radio_selection_ctx);
break;
case BUTTON_RIGHT:
general_radio_selection_ctx->current_option =
Expand Down Expand Up @@ -110,6 +111,10 @@ static void input_cb(uint8_t button_name, uint8_t button_event) {

void general_radio_selection(
general_radio_selection_menu_t radio_selection_menu) {
if (general_radio_selection_ctx) {
free(general_radio_selection_ctx);
general_radio_selection_ctx = NULL;
}
general_radio_selection_ctx = calloc(1, sizeof(general_radio_selection_t));
general_radio_selection_ctx->options = radio_selection_menu.options;
general_radio_selection_ctx->options_count =
Expand Down
12 changes: 12 additions & 0 deletions firmware/main/modules/menus_module/menus_include/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "analyzer_scenes.h"
#include "catdos_module.h"
#include "deauth_module.h"
#include "detector_scenes.h"
#include "display_settings.h"
#include "file_manager_module.h"
#include "gps_module.h"
Expand Down Expand Up @@ -45,6 +46,7 @@ typedef enum {
/* WiFi applications */
MENU_WIFI_ANALIZER,
MENU_WIFI_DEAUTH,
MENU_WIFI_DEAUTH_SCAN,
MENU_WIFI_DOS,
MENU_WIFI_SSID_SPAM,
/* WiFi analizer items */
Expand Down Expand Up @@ -215,6 +217,16 @@ menu_t menus[] = { //////////////////////////////////
.on_exit_cb = NULL,
.is_visible = true},
#endif
// #ifdef CONFIG_WIFI_APP_DEAUTH TODO: ADD TO MENUCONFIG
{.display_name = "Deauth Scan",
.menu_idx = MENU_WIFI_DEAUTH_SCAN,
.parent_idx = MENU_WIFI_APPS,
.entry_cmd = "deauth_scan",
.last_selected_submenu = 0,
.on_enter_cb = detector_scenes_main_menu,
.on_exit_cb = NULL,
.is_visible = true},
// #endif
#ifdef CONFIG_WIFI_APP_DOS
{.display_name = "DoS",
.menu_idx = MENU_WIFI_DOS,
Expand Down

0 comments on commit 03d30ca

Please sign in to comment.