Update Marauder w Xtreme UART

This commit is contained in:
Sil333033
2023-08-02 20:23:04 +02:00
parent cef4a004f7
commit 02db8d4e7d
7 changed files with 221 additions and 58 deletions

View File

@@ -105,6 +105,12 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
app->uart,
wifi_marauder_console_output_handle_rx_data_cb); // setup callback for general log rx thread
if(app->ok_to_save_pcaps) {
wifi_marauder_uart_set_handle_rx_data_cb(
app->pcap_uart,
wifi_marauder_console_output_handle_rx_packets_cb); // setup callback for packets rx thread
}
// Get ready to send command
if((app->is_command && app->selected_tx_string) || app->script) {
const char* prefix =
@@ -143,14 +149,21 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
// Send command with newline '\n'
if(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);
if(app->ok_to_save_pcaps) {
wifi_marauder_usart_tx(
(uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
wifi_marauder_usart_tx((uint8_t*)("\n"), 1);
} else {
wifi_marauder_xtreme_uart_tx(
(uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
wifi_marauder_xtreme_uart_tx((uint8_t*)("\n"), 1);
}
}
// Run the script if the file with the script has been opened
if(app->script != NULL) {
app->script_worker = wifi_marauder_script_worker_alloc();
app->script_worker->save_pcaps = app->ok_to_save_pcaps;
wifi_marauder_script_worker_start(app->script_worker, app->script);
}
}
@@ -176,12 +189,20 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {
// Automatically stop the scan when exiting view
if(app->is_command) {
wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
if(app->ok_to_save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
}
furi_delay_ms(50);
}
// Unregister rx callback
wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
if(app->ok_to_save_pcaps) {
wifi_marauder_uart_set_handle_rx_data_cb(app->pcap_uart, NULL);
}
wifi_marauder_script_worker_free(app->script_worker);
app->script_worker = NULL;

View File

@@ -5,20 +5,33 @@ void _wifi_marauder_script_delay(WifiMarauderScriptWorker* worker, uint32_t dela
for(uint32_t i = 0; i < delay_secs && worker->is_running; i++) furi_delay_ms(1000);
}
void _send_stop() {
void _send_stop(bool save_pcaps) {
const char stop_command[] = "stopscan\n";
wifi_marauder_uart_tx((uint8_t*)(stop_command), strlen(stop_command));
if(save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(stop_command), strlen(stop_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(stop_command), strlen(stop_command));
}
}
void _send_line_break() {
wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
void _send_line_break(bool save_pcaps) {
if(save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)("\n"), 1);
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)("\n"), 1);
}
}
void _send_channel_select(int channel) {
void _send_channel_select(int channel, bool save_pcaps) {
char command[30];
wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
snprintf(command, sizeof(command), "channel -s %d\n", channel);
wifi_marauder_uart_tx((uint8_t*)(command), strlen(command));
if(save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)("\n"), 1);
wifi_marauder_usart_tx((uint8_t*)(command), strlen(command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)("\n"), 1);
wifi_marauder_xtreme_uart_tx((uint8_t*)(command), strlen(command));
}
}
void _wifi_marauder_script_execute_scan(
@@ -27,7 +40,7 @@ void _wifi_marauder_script_execute_scan(
char command[15];
// Set channel
if(stage->channel > 0) {
_send_channel_select(stage->channel);
_send_channel_select(stage->channel, worker->save_pcaps);
}
// Start scan
if(stage->type == WifiMarauderScriptScanTypeAp) {
@@ -35,12 +48,18 @@ void _wifi_marauder_script_execute_scan(
} else {
snprintf(command, sizeof(command), "scansta\n");
}
wifi_marauder_uart_tx((uint8_t*)(command), strlen(command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(command), strlen(command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(command), strlen(command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_select(WifiMarauderScriptStageSelect* stage) {
void _wifi_marauder_script_execute_select(WifiMarauderScriptStageSelect* stage, bool save_pcaps) {
const char* select_type = NULL;
switch(stage->type) {
case WifiMarauderScriptSelectTypeAp:
@@ -79,61 +98,101 @@ void _wifi_marauder_script_execute_select(WifiMarauderScriptStageSelect* stage)
command, sizeof(command), "select %s -f \"%s\"\n", select_type, stage->filter);
}
wifi_marauder_uart_tx((uint8_t*)command, command_length);
if(save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)command, command_length);
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)command, command_length);
}
}
void _wifi_marauder_script_execute_deauth(
WifiMarauderScriptStageDeauth* stage,
WifiMarauderScriptWorker* worker) {
const char attack_command[] = "attack -t deauth\n";
wifi_marauder_uart_tx((uint8_t*)(attack_command), strlen(attack_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(attack_command), strlen(attack_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(attack_command), strlen(attack_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_probe(
WifiMarauderScriptStageProbe* stage,
WifiMarauderScriptWorker* worker) {
const char attack_command[] = "attack -t probe\n";
wifi_marauder_uart_tx((uint8_t*)(attack_command), strlen(attack_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(attack_command), strlen(attack_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(attack_command), strlen(attack_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_sniff_raw(
WifiMarauderScriptStageSniffRaw* stage,
WifiMarauderScriptWorker* worker) {
const char sniff_command[] = "sniffraw\n";
wifi_marauder_uart_tx((uint8_t*)sniff_command, strlen(sniff_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_sniff_beacon(
WifiMarauderScriptStageSniffBeacon* stage,
WifiMarauderScriptWorker* worker) {
const char sniff_command[] = "sniffbeacon\n";
wifi_marauder_uart_tx((uint8_t*)sniff_command, strlen(sniff_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_sniff_deauth(
WifiMarauderScriptStageSniffDeauth* stage,
WifiMarauderScriptWorker* worker) {
const char sniff_command[] = "sniffdeauth\n";
wifi_marauder_uart_tx((uint8_t*)sniff_command, strlen(sniff_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_sniff_esp(
WifiMarauderScriptStageSniffEsp* stage,
WifiMarauderScriptWorker* worker) {
const char sniff_command[] = "sniffesp\n";
wifi_marauder_uart_tx((uint8_t*)sniff_command, strlen(sniff_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_sniff_pmkid(
@@ -153,25 +212,41 @@ void _wifi_marauder_script_execute_sniff_pmkid(
len += snprintf(attack_command + len, sizeof(attack_command) - len, "\n");
wifi_marauder_uart_tx((uint8_t*)attack_command, len);
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)attack_command, len);
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)attack_command, len);
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_sniff_pwn(
WifiMarauderScriptStageSniffPwn* stage,
WifiMarauderScriptWorker* worker) {
const char sniff_command[] = "sniffpwn\n";
wifi_marauder_uart_tx((uint8_t*)sniff_command, strlen(sniff_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(sniff_command), strlen(sniff_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_beacon_list(
WifiMarauderScriptStageBeaconList* stage,
WifiMarauderScriptWorker* worker) {
const char clearlist_command[] = "clearlist -s\n";
wifi_marauder_uart_tx((uint8_t*)(clearlist_command), strlen(clearlist_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(clearlist_command), strlen(clearlist_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(clearlist_command), strlen(clearlist_command));
}
char command[100];
char* ssid;
@@ -179,8 +254,14 @@ void _wifi_marauder_script_execute_beacon_list(
for(int i = 0; i < stage->ssid_count; i++) {
ssid = stage->ssids[i];
snprintf(command, sizeof(command), "ssid -a -n \"%s\"", ssid);
wifi_marauder_uart_tx((uint8_t*)(command), strlen(command));
_send_line_break();
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(command), strlen(command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(command), strlen(command));
}
_send_line_break(worker->save_pcaps);
}
if(stage->random_ssids > 0) {
char add_random_command[50];
@@ -189,26 +270,45 @@ void _wifi_marauder_script_execute_beacon_list(
sizeof(add_random_command),
"ssid -a -r -g %d\n",
stage->random_ssids);
wifi_marauder_uart_tx((uint8_t*)add_random_command, strlen(add_random_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)add_random_command, strlen(add_random_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)add_random_command, strlen(add_random_command));
}
}
const char attack_command[] = "attack -t beacon -l\n";
wifi_marauder_uart_tx((uint8_t*)(attack_command), strlen(attack_command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(attack_command), strlen(attack_command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(attack_command), strlen(attack_command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_beacon_ap(
WifiMarauderScriptStageBeaconAp* stage,
WifiMarauderScriptWorker* worker) {
const char command[] = "attack -t beacon -a\n";
wifi_marauder_uart_tx((uint8_t*)command, strlen(command));
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)(command), strlen(command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)(command), strlen(command));
}
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker->save_pcaps);
}
void _wifi_marauder_script_execute_exec(WifiMarauderScriptStageExec* stage) {
void _wifi_marauder_script_execute_exec(WifiMarauderScriptStageExec* stage, bool save_pcaps) {
if(stage->command != NULL) {
wifi_marauder_uart_tx((uint8_t*)stage->command, strlen(stage->command));
if(save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)stage->command, strlen(stage->command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)stage->command, strlen(stage->command));
}
}
}
@@ -231,8 +331,14 @@ void wifi_marauder_script_execute_start(void* context) {
sizeof(command),
"settings -s EnableLED %s",
script->enable_led ? "enable" : "disable");
wifi_marauder_uart_tx((uint8_t*)command, strlen(command));
_send_line_break();
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)command, strlen(command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)command, strlen(command));
}
_send_line_break(worker->save_pcaps);
}
// Enables or disables PCAP saving according to script settings
@@ -242,8 +348,14 @@ void wifi_marauder_script_execute_start(void* context) {
sizeof(command),
"settings -s SavePCAP %s",
script->save_pcap ? "enable" : "disable");
wifi_marauder_uart_tx((uint8_t*)command, strlen(command));
_send_line_break();
if(worker->save_pcaps) {
wifi_marauder_usart_tx((uint8_t*)command, strlen(command));
} else {
wifi_marauder_xtreme_uart_tx((uint8_t*)command, strlen(command));
}
_send_line_break(worker->save_pcaps);
}
}
@@ -257,7 +369,8 @@ void wifi_marauder_script_execute_stage(WifiMarauderScriptStage* stage, void* co
_wifi_marauder_script_execute_scan((WifiMarauderScriptStageScan*)stage_data, worker);
break;
case WifiMarauderScriptStageTypeSelect:
_wifi_marauder_script_execute_select((WifiMarauderScriptStageSelect*)stage_data);
_wifi_marauder_script_execute_select(
(WifiMarauderScriptStageSelect*)stage_data, worker->save_pcaps);
break;
case WifiMarauderScriptStageTypeDeauth:
_wifi_marauder_script_execute_deauth((WifiMarauderScriptStageDeauth*)stage_data, worker);
@@ -298,7 +411,8 @@ void wifi_marauder_script_execute_stage(WifiMarauderScriptStage* stage, void* co
(WifiMarauderScriptStageBeaconAp*)stage_data, worker);
break;
case WifiMarauderScriptStageTypeExec:
_wifi_marauder_script_execute_exec((WifiMarauderScriptStageExec*)stage_data);
_wifi_marauder_script_execute_exec(
(WifiMarauderScriptStageExec*)stage_data, worker->save_pcaps);
break;
case WifiMarauderScriptStageTypeDelay:
_wifi_marauder_script_execute_delay((WifiMarauderScriptStageDelay*)stage_data, worker);

View File

@@ -15,6 +15,7 @@ typedef struct WifiMarauderScriptWorker {
void (*callback_stage)(WifiMarauderScriptStage*, void*);
void* context;
bool is_running;
bool save_pcaps;
} WifiMarauderScriptWorker;
/**

View File

@@ -161,7 +161,9 @@ void wifi_marauder_app_free(WifiMarauderApp* app) {
scene_manager_free(app->scene_manager);
wifi_marauder_uart_free(app->uart);
// wifi_marauder_uart_free(app->lp_uart);
if(app->ok_to_save_pcaps) {
wifi_marauder_uart_free(app->pcap_uart);
}
// Close records
furi_record_close(RECORD_GUI);
@@ -186,8 +188,13 @@ int32_t wifi_marauder_app(void* p) {
wifi_marauder_make_app_folder(wifi_marauder_app);
wifi_marauder_load_settings(wifi_marauder_app);
wifi_marauder_app->uart =
wifi_marauder_uart_init(wifi_marauder_app, UART_CH, "WifiMarauderUartRxThread");
if(wifi_marauder_app->ok_to_save_pcaps) {
wifi_marauder_app->uart = wifi_marauder_usart_init(wifi_marauder_app);
wifi_marauder_app->pcap_uart = wifi_marauder_lp_uart_init(wifi_marauder_app);
} else {
wifi_marauder_app->uart =
wifi_marauder_uart_init(wifi_marauder_app, XTREME_UART_CH, "WifiMarauderUartRxThread");
}
view_dispatcher_run(wifi_marauder_app->view_dispatcher);

View File

@@ -28,10 +28,14 @@
#include <dialogs/dialogs.h>
#include <xtreme.h>
#define UART_CH \
#define XTREME_UART_CH \
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
FuriHalUartIdLPUART1)
#define US_ART_CH (FuriHalUartIdUSART1)
#define LP_UART_CH (FuriHalUartIdLPUART1)
#define BAUDRATE (115200)
#define NUM_MENU_ITEMS (20)
#define WIFI_MARAUDER_TEXT_BOX_STORE_SIZE (4096)
@@ -84,6 +88,7 @@ struct WifiMarauderApp {
int open_log_file_num_pages;
WifiMarauderUart* uart;
WifiMarauderUart* pcap_uart;
int selected_menu_index;
int selected_option_index[NUM_MENU_ITEMS];
const char* selected_tx_string;

View File

@@ -1,8 +1,6 @@
#include "wifi_marauder_app_i.h"
#include "wifi_marauder_uart.h"
#define BAUDRATE (115200)
struct WifiMarauderUart {
WifiMarauderApp* app;
FuriHalUartId channel;
@@ -51,14 +49,21 @@ static int32_t uart_worker(void* context) {
}
}
furi_hal_uart_set_irq_cb(uart->channel, NULL, NULL);
furi_stream_buffer_free(uart->rx_stream);
return 0;
}
void wifi_marauder_uart_tx(uint8_t* data, size_t len) {
furi_hal_uart_tx(UART_CH, data, len);
void wifi_marauder_xtreme_uart_tx(uint8_t* data, size_t len) {
furi_hal_uart_tx(XTREME_UART_CH, data, len);
}
void wifi_marauder_usart_tx(uint8_t* data, size_t len) {
furi_hal_uart_tx(US_ART_CH, data, len);
}
void wifi_marauder_lp_uart_tx(uint8_t* data, size_t len) {
furi_hal_uart_tx(LP_UART_CH, data, len);
}
WifiMarauderUart*
@@ -85,6 +90,14 @@ WifiMarauderUart*
return uart;
}
WifiMarauderUart* wifi_marauder_usart_init(WifiMarauderApp* app) {
return wifi_marauder_uart_init(app, US_ART_CH, "WifiMarauderUartRxThread");
}
WifiMarauderUart* wifi_marauder_lp_uart_init(WifiMarauderApp* app) {
return wifi_marauder_uart_init(app, LP_UART_CH, "WifiMarauderLPUartRxThread");
}
void wifi_marauder_uart_free(WifiMarauderUart* uart) {
furi_assert(uart);
@@ -92,6 +105,7 @@ void wifi_marauder_uart_free(WifiMarauderUart* uart) {
furi_thread_join(uart->rx_thread);
furi_thread_free(uart->rx_thread);
furi_hal_uart_set_irq_cb(uart->channel, NULL, NULL);
if(uart->channel == FuriHalUartIdLPUART1) {
furi_hal_uart_deinit(uart->channel);
} else {

View File

@@ -9,7 +9,8 @@ typedef struct WifiMarauderUart WifiMarauderUart;
void wifi_marauder_uart_set_handle_rx_data_cb(
WifiMarauderUart* uart,
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context));
void wifi_marauder_uart_tx(uint8_t* data, size_t len);
void wifi_marauder_xtreme_uart_tx(uint8_t* data, size_t len);
void wifi_marauder_usart_tx(uint8_t* data, size_t len);
void wifi_marauder_lp_uart_tx(uint8_t* data, size_t len);
WifiMarauderUart* wifi_marauder_usart_init(WifiMarauderApp* app);
WifiMarauderUart* wifi_marauder_lp_uart_init(WifiMarauderApp* app);