Przeglądaj źródła

Add toggled args, remember selected options

0xchocolate 3 lat temu
rodzic
commit
225524d9b8

+ 24 - 21
applications/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c

@@ -3,33 +3,39 @@
 // For each command, define whether additional arguments are needed
 // For each command, define whether additional arguments are needed
 // (enabling text input to fill them out), and whether the console
 // (enabling text input to fill them out), and whether the console
 // text box should focus at the start of the output or the end
 // text box should focus at the start of the output or the end
-#define INPUT_ARGS          (true)
-#define NO_ARGS             (false)
-#define FOCUS_CONSOLE_START (true)
-#define FOCUS_CONSOLE_END   (false)
-struct WifiMarauderItem {
+typedef enum {
+    NO_ARGS = 0,
+    INPUT_ARGS,
+    TOGGLE_ARGS
+} InputArgs;
+
+typedef enum {
+    FOCUS_CONSOLE_END = 0,
+    FOCUS_CONSOLE_START,
+    FOCUS_CONSOLE_TOGGLE
+} FocusConsole;
+
+typedef struct {
     const char* item_string;
     const char* item_string;
     const char* options_menu[5];
     const char* options_menu[5];
     int num_options_menu;
     int num_options_menu;
     const char* actual_commands[5];
     const char* actual_commands[5];
-    bool needs_keyboard;
-    bool focus_console_start;
-};
-
-typedef struct WifiMarauderItem WifiMarauderItem;
+    InputArgs needs_keyboard;
+    FocusConsole focus_console;
+} WifiMarauderItem;
 
 
 const WifiMarauderItem items[NUM_MENU_ITEMS] = {
 const WifiMarauderItem items[NUM_MENU_ITEMS] = {
-    { "View Log from", {"start", "end"}, 2, {}, NO_ARGS, FOCUS_CONSOLE_START },
+    { "View Log from", {"start", "end"}, 2, {}, NO_ARGS, FOCUS_CONSOLE_TOGGLE },
     { "Scan", {""}, 1, {"scanap"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Scan", {""}, 1, {"scanap"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "List", {"ap", "ssid"}, 2, {"list -a", "list -s"}, NO_ARGS, FOCUS_CONSOLE_START },
     { "List", {"ap", "ssid"}, 2, {"list -a", "list -s"}, NO_ARGS, FOCUS_CONSOLE_START },
     { "Select", {"ap", "ssid"}, 2, {"select -a", "select -s"}, INPUT_ARGS, FOCUS_CONSOLE_END },
     { "Select", {"ap", "ssid"}, 2, {"select -a", "select -s"}, INPUT_ARGS, FOCUS_CONSOLE_END },
     { "Clear List", {"ap", "ssid"}, 2, {"clearlist -a", "clearlist -s"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Clear List", {"ap", "ssid"}, 2, {"clearlist -a", "clearlist -s"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "SSID", {"add random", "add name", "remove"}, 3, {"ssid -a -g", "ssid -a -n", "ssid -r"}, INPUT_ARGS, FOCUS_CONSOLE_END },
     { "SSID", {"add random", "add name", "remove"}, 3, {"ssid -a -g", "ssid -a -n", "ssid -r"}, INPUT_ARGS, FOCUS_CONSOLE_END },
     { "Attack", {"deauth", "probe", "rickroll"}, 3, {"attack -t deauth", "attack -t probe", "attack -t rickroll"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Attack", {"deauth", "probe", "rickroll"}, 3, {"attack -t deauth", "attack -t probe", "attack -t rickroll"}, NO_ARGS, FOCUS_CONSOLE_END },
-    { "Beacon Spam", {"list", "random", "ap"}, 3, {"attack -t beacon -l", "attack -t beacon -r", "attack -t beacon -a"}, NO_ARGS, FOCUS_CONSOLE_END },
+    { "Beacon Spam", {"ap", "ssid", "random"}, 3, {"attack -t beacon -a", "attack -t beacon -l", "attack -t beacon -r"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Sniff", {"beacon", "deauth", "esp", "pmkid", "pwn"}, 5, {"sniffbeacon", "sniffdeauth", "sniffesp", "sniffpmkid", "sniffpwn"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Sniff", {"beacon", "deauth", "esp", "pmkid", "pwn"}, 5, {"sniffbeacon", "sniffdeauth", "sniffesp", "sniffpmkid", "sniffpwn"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Sniff PMKID on channel", {""}, 1, {"sniffpmkid -c"}, INPUT_ARGS, FOCUS_CONSOLE_END },
     { "Sniff PMKID on channel", {""}, 1, {"sniffpmkid -c"}, INPUT_ARGS, FOCUS_CONSOLE_END },
-    { "Channel", {""}, 1, {"channel -s"}, INPUT_ARGS, FOCUS_CONSOLE_END },
+    { "Channel", {"get", "set"}, 2, {"channel", "channel -s"}, TOGGLE_ARGS, FOCUS_CONSOLE_END },
     { "Update", {""}, 1, {"update -w"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Update", {""}, 1, {"update -w"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END },
     { "Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_START },
     { "Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_START },
@@ -45,12 +51,10 @@ static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uin
     app->is_command = (1 <= index);
     app->is_command = (1 <= index);
     app->is_custom_tx_string = false;
     app->is_custom_tx_string = false;
     app->selected_menu_index = index;
     app->selected_menu_index = index;
-    app->focus_console_start = items[index].focus_console_start;
-    if (!(app->is_command) && (app->selected_option_index[index] == 1)) { // special case: View Log from end
-        app->focus_console_start = FOCUS_CONSOLE_END;
-    }
+    app->focus_console_start = (items[index].focus_console == FOCUS_CONSOLE_TOGGLE) ? (app->selected_option_index[index] == 0) : items[index].focus_console;
 
 
-    if (items[index].needs_keyboard) {
+    bool needs_keyboard = (items[index].needs_keyboard == TOGGLE_ARGS) ? (app->selected_option_index[index] == 1) : items[index].needs_keyboard;
+    if (needs_keyboard) {
         view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartKeyboard);
         view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartKeyboard);
     } else {
     } else {
         view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
         view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
@@ -79,11 +83,10 @@ void wifi_marauder_scene_start_on_enter(void* context) {
 
 
     VariableItem* item;
     VariableItem* item;
     for (int i = 0; i < NUM_MENU_ITEMS; ++i) {
     for (int i = 0; i < NUM_MENU_ITEMS; ++i) {
-        app->selected_option_index[i] = 0;
         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);
         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);
         if (items[i].num_options_menu) {
         if (items[i].num_options_menu) {
-            variable_item_set_current_value_index(item, 0);
-            variable_item_set_current_value_text(item, items[i].options_menu[0]);
+            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]]);
         }
         }
     }
     }
 
 

+ 4 - 0
applications/wifi_marauder_companion/wifi_marauder_app.c

@@ -46,6 +46,10 @@ WifiMarauderApp* wifi_marauder_app_alloc() {
         WifiMarauderAppViewVarItemList,
         WifiMarauderAppViewVarItemList,
         variable_item_list_get_view(app->var_item_list));
         variable_item_list_get_view(app->var_item_list));
 
 
+    for (int i = 0; i < NUM_MENU_ITEMS; ++i) {
+        app->selected_option_index[i] = 0;
+    }
+
     app->text_box = text_box_alloc();
     app->text_box = text_box_alloc();
     view_dispatcher_add_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput, text_box_get_view(app->text_box));
     view_dispatcher_add_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput, text_box_get_view(app->text_box));
     string_init(app->text_box_store);
     string_init(app->text_box_store);