Skip to content

Commit

Permalink
Support Unified serial PCAPs + Fix for OFW 0.98 (#47)
Browse files Browse the repository at this point in the history
* Support Unified serial PCAPs (packets over main UART)

* Port to new FuriHalSerial API

* Format

* Remember if 5v was enabled

* Bump version 7.0

* Fix interference with expansion modules
  • Loading branch information
Willy-JL authored Feb 4, 2024
1 parent 178da0b commit 272eb25
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 111 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
App(
appid="esp32_wifi_marauder",
name="[ESP32] WiFi Marauder",
fap_version=(6,6),
fap_version=(7, 0),
apptype=FlipperAppType.EXTERNAL,
entry_point="wifi_marauder_app",
requires=["gui"],
Expand Down
28 changes: 17 additions & 11 deletions scenes/wifi_marauder_scene_console_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ 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 general log rx thread
wifi_marauder_uart_set_handle_rx_data_cb(
app->lp_uart,
wifi_marauder_uart_set_handle_rx_pcap_cb(
app->uart,
wifi_marauder_console_output_handle_rx_packets_cb); // setup callback for packets rx thread

// Get ready to send command
Expand Down Expand Up @@ -157,19 +157,23 @@ 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);
app->uart, (uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
if(app->is_writing_pcap) {
wifi_marauder_uart_tx(app->uart, (uint8_t*)(" -serial\n"), strlen(" -serial\n"));
} else {
wifi_marauder_uart_tx(app->uart, (uint8_t*)("\n"), 1);
}
if(send_html && the_html) {
wifi_marauder_uart_tx(the_html, html_size);
wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
wifi_marauder_uart_tx(app->uart, the_html, html_size);
wifi_marauder_uart_tx(app->uart, (uint8_t*)("\n"), 1);
free(the_html);
send_html = false;
}
}

// 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 = wifi_marauder_script_worker_alloc(app->uart);
wifi_marauder_script_worker_start(app->script_worker, app->script);
}
}
Expand All @@ -195,16 +199,18 @@ 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"));
wifi_marauder_uart_tx(app->uart, (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);
wifi_marauder_uart_set_handle_rx_data_cb(app->lp_uart, NULL);
wifi_marauder_uart_set_handle_rx_pcap_cb(app->uart, NULL);

wifi_marauder_script_worker_free(app->script_worker);
app->script_worker = NULL;
if(app->script_worker) {
wifi_marauder_script_worker_free(app->script_worker);
app->script_worker = NULL;
}

app->is_writing_pcap = false;
if(app->capture_file && storage_file_is_open(app->capture_file)) {
Expand Down
18 changes: 16 additions & 2 deletions scenes/wifi_marauder_scene_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,23 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
FOCUS_CONSOLE_END,
NO_TIP},
{"Attack",
{"deauth", "probe", "rickroll", "sour apple", "swiftpair spam", "samsung spam", "google spam", "bt spam all"},
{"deauth",
"probe",
"rickroll",
"sour apple",
"swiftpair spam",
"samsung spam",
"google spam",
"bt spam all"},
8,
{"attack -t deauth", "attack -t probe", "attack -t rickroll", "blespam -t apple", "blespam -t windows", "blespam -t samsung", "blespam -t google", "blespam -t all"},
{"attack -t deauth",
"attack -t probe",
"attack -t rickroll",
"blespam -t apple",
"blespam -t windows",
"blespam -t samsung",
"blespam -t google",
"blespam -t all"},
NO_ARGS,
FOCUS_CONSOLE_END,
SHOW_STOPSCAN_TIP},
Expand Down
1 change: 0 additions & 1 deletion scenes/wifi_marauder_scene_user_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ bool wifi_marauder_scene_user_input_on_event(void* context, SceneManagerEvent ev
}

return consumed;

}

void wifi_marauder_scene_user_input_on_exit(void* context) {
Expand Down
113 changes: 59 additions & 54 deletions script/wifi_marauder_script_executor.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ 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(WifiMarauderScriptWorker* worker) {
const char stop_command[] = "stopscan\n";
wifi_marauder_uart_tx((uint8_t*)(stop_command), strlen(stop_command));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(stop_command), strlen(stop_command));
}

void _send_line_break() {
wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
void _send_line_break(WifiMarauderScriptWorker* worker) {
wifi_marauder_uart_tx(worker->uart, (uint8_t*)("\n"), 1);
}

void _send_channel_select(int channel) {
void _send_channel_select(WifiMarauderScriptWorker* worker, int channel) {
char command[30];
_send_line_break();
_send_line_break(worker);
snprintf(command, sizeof(command), "channel -s %d\n", channel);
wifi_marauder_uart_tx((uint8_t*)(command), strlen(command));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(command), strlen(command));
}

void _wifi_marauder_script_execute_scan(
Expand All @@ -27,20 +27,22 @@ void _wifi_marauder_script_execute_scan(
char command[15];
// Set channel
if(stage->channel > 0) {
_send_channel_select(stage->channel);
_send_channel_select(worker, stage->channel);
}
// Start scan
if(stage->type == WifiMarauderScriptScanTypeAp) {
snprintf(command, sizeof(command), "scanap\n");
} else {
snprintf(command, sizeof(command), "scansta\n");
}
wifi_marauder_uart_tx((uint8_t*)(command), strlen(command));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(command), strlen(command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

void _wifi_marauder_script_execute_select(WifiMarauderScriptStageSelect* stage) {
void _wifi_marauder_script_execute_select(
WifiMarauderScriptStageSelect* stage,
WifiMarauderScriptWorker* worker) {
const char* select_type = NULL;
switch(stage->type) {
case WifiMarauderScriptSelectTypeAp:
Expand Down Expand Up @@ -79,61 +81,61 @@ 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);
wifi_marauder_uart_tx(worker->uart, (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));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(attack_command), strlen(attack_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(attack_command), strlen(attack_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
const char sniff_command[] = "sniffraw -serial\n";
wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
const char sniff_command[] = "sniffbeacon -serial\n";
wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
const char sniff_command[] = "sniffdeauth -serial\n";
wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
const char sniff_command[] = "sniffesp -serial\n";
wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

void _wifi_marauder_script_execute_sniff_pmkid(
Expand All @@ -150,10 +152,10 @@ void _wifi_marauder_script_execute_sniff_pmkid(
len += snprintf(attack_command + len, sizeof(attack_command) - len, " -d");
}

len += snprintf(attack_command + len, sizeof(attack_command) - len, "\n");
wifi_marauder_uart_tx((uint8_t*)attack_command, len);
len += snprintf(attack_command + len, sizeof(attack_command) - len, " -serial\n");
wifi_marauder_uart_tx(worker->uart, (uint8_t*)attack_command, len);
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}
} else {
char attack_command[50] = "sniffpmkid";
Expand All @@ -167,36 +169,36 @@ void _wifi_marauder_script_execute_sniff_pmkid(
if(stage->force_deauth) {
len += snprintf(attack_command + len, sizeof(attack_command) - len, " -d");
}
len += snprintf(attack_command + len, sizeof(attack_command) - len, "\n");
wifi_marauder_uart_tx((uint8_t*)attack_command, len);
len += snprintf(attack_command + len, sizeof(attack_command) - len, " -serial\n");
wifi_marauder_uart_tx(worker->uart, (uint8_t*)attack_command, len);
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}
}

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));
const char sniff_command[] = "sniffpwn -serial\n";
wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(clearlist_command), strlen(clearlist_command));

char command[100];
char* ssid;

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();
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(command), strlen(command));
_send_line_break(worker);
}
if(stage->random_ssids > 0) {
char add_random_command[50];
Expand All @@ -205,27 +207,30 @@ 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));
wifi_marauder_uart_tx(
worker->uart, (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));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)(attack_command), strlen(attack_command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

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));
wifi_marauder_uart_tx(worker->uart, (uint8_t*)command, strlen(command));
_wifi_marauder_script_delay(worker, stage->timeout);
_send_stop();
_send_stop(worker);
}

void _wifi_marauder_script_execute_exec(WifiMarauderScriptStageExec* stage) {
void _wifi_marauder_script_execute_exec(
WifiMarauderScriptStageExec* stage,
WifiMarauderScriptWorker* worker) {
if(stage->command != NULL) {
wifi_marauder_uart_tx((uint8_t*)stage->command, strlen(stage->command));
_send_line_break();
wifi_marauder_uart_tx(worker->uart, (uint8_t*)stage->command, strlen(stage->command));
_send_line_break(worker);
}
}

Expand All @@ -248,8 +253,8 @@ 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();
wifi_marauder_uart_tx(worker->uart, (uint8_t*)command, strlen(command));
_send_line_break(worker);
}

// Enables or disables PCAP saving according to script settings
Expand All @@ -259,8 +264,8 @@ 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();
wifi_marauder_uart_tx(worker->uart, (uint8_t*)command, strlen(command));
_send_line_break(worker);
}
}

Expand All @@ -274,7 +279,7 @@ 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);
break;
case WifiMarauderScriptStageTypeDeauth:
_wifi_marauder_script_execute_deauth((WifiMarauderScriptStageDeauth*)stage_data, worker);
Expand Down Expand Up @@ -315,7 +320,7 @@ 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);
break;
case WifiMarauderScriptStageTypeDelay:
_wifi_marauder_script_execute_delay((WifiMarauderScriptStageDelay*)stage_data, worker);
Expand Down
3 changes: 2 additions & 1 deletion script/wifi_marauder_script_worker.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include "../wifi_marauder_app_i.h"
#include "wifi_marauder_script_worker.h"

WifiMarauderScriptWorker* wifi_marauder_script_worker_alloc() {
WifiMarauderScriptWorker* wifi_marauder_script_worker_alloc(WifiMarauderUart* uart) {
WifiMarauderScriptWorker* worker = malloc(sizeof(WifiMarauderScriptWorker));
if(worker == NULL) {
return NULL;
}
worker->callback_start = NULL;
worker->callback_stage = NULL;
worker->worker_thread = NULL;
worker->uart = uart;
worker->is_running = false;
return worker;
}
Expand Down
Loading

0 comments on commit 272eb25

Please sign in to comment.