Skip to content

Commit

Permalink
Add View Log menu actions to see output of last command
Browse files Browse the repository at this point in the history
  • Loading branch information
0xchocolate committed Jul 24, 2022
1 parent b105a12 commit 6f72ac7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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"));
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 },
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions applications/wifi_marauder_companion/wifi_marauder_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 6f72ac7

Please sign in to comment.