From 6f72ac71a6bf85d36a5c5d7e6b44790e966aa2c0 Mon Sep 17 00:00:00 2001 From: 0xchocolate <0xchocolate@users.noreply.github.com> Date: Sun, 24 Jul 2022 11:34:31 -0700 Subject: [PATCH] Add View Log menu actions to see output of last command --- .../wifi_marauder_scene_console_output.c | 19 +++++++++++-------- .../scenes/wifi_marauder_scene_start.c | 5 ++++- .../wifi_marauder_app_i.h | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c b/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c index e131aa0d3..7f1c14892 100644 --- a/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c +++ b/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_console_output.c @@ -22,14 +22,19 @@ 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); } - string_reset(app->text_box_store); - app->text_box_store_strlen = 0; + if (app->is_command) { + string_reset(app->text_box_store); + app->text_box_store_strlen = 0; + } else { // "View Log" menu action + text_box_set_text(app->text_box, 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); @@ -38,7 +43,7 @@ void wifi_marauder_scene_console_output_on_enter(void* context) { wifi_marauder_uart_set_handle_rx_data_cb(app->uart, wifi_marauder_console_output_handle_rx_data_cb); // setup callback for rx thread // Send command with newline '\n' - if (app->selected_tx_string) { + if (app->is_command && 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); } @@ -66,9 +71,7 @@ void wifi_marauder_scene_console_output_on_exit(void* context) { wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL); // Automatically stop the scan when exiting view - wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n")); - - text_box_reset(app->text_box); - string_reset(app->text_box_store); - app->text_box_store_strlen = 0; + if (app->is_command) { + wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n")); + } } \ No newline at end of file diff --git a/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c b/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c index b285f638d..bc5e5641c 100644 --- a/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c +++ b/applications/wifi_marauder_companion/scenes/wifi_marauder_scene_start.c @@ -1,6 +1,6 @@ #include "../wifi_marauder_app_i.h" -#define NUM_MENU_ITEMS (27) +#define NUM_MENU_ITEMS (29) // For each command, define whether additional arguments are needed // (enabling text input to fill them out), and whether the console @@ -16,6 +16,8 @@ struct WifiMarauderItem { }; const struct WifiMarauderItem items[NUM_MENU_ITEMS] = { + { "View Log (start)", NO_ARGS, FOCUS_CONSOLE_START }, + { "View Log (end)", NO_ARGS, FOCUS_CONSOLE_END }, { "attack -t beacon -l", NO_ARGS, FOCUS_CONSOLE_END }, { "attack -t beacon -r", NO_ARGS, FOCUS_CONSOLE_END }, { "attack -t beacon -a", NO_ARGS, FOCUS_CONSOLE_END }, @@ -49,6 +51,7 @@ static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uin furi_assert(context); WifiMarauderApp* app = context; app->selected_tx_string = items[index].item_string; + app->is_command = (2 <= index); app->is_custom_tx_string = false; app->selected_menu_index = index; app->focus_console_start = items[index].focus_console_start; diff --git a/applications/wifi_marauder_companion/wifi_marauder_app_i.h b/applications/wifi_marauder_companion/wifi_marauder_app_i.h index 6bd3ef3e6..b5832c914 100644 --- a/applications/wifi_marauder_companion/wifi_marauder_app_i.h +++ b/applications/wifi_marauder_companion/wifi_marauder_app_i.h @@ -32,6 +32,7 @@ struct WifiMarauderApp { WifiMarauderUart* uart; int selected_menu_index; const char* selected_tx_string; + bool is_command; bool is_custom_tx_string; bool focus_console_start; };