Skip to content

Commit

Permalink
update marauder to 0.7.1
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Murdaca <[email protected]>
  • Loading branch information
runcom committed Jun 9, 2024
1 parent 4c93c83 commit f437300
Show file tree
Hide file tree
Showing 52 changed files with 7,334 additions and 6,367 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
App(
appid="mayhem_marauder",
name="[MAYHEM] Marauder",
fap_version=(6, 6),
fap_version=(7, 1),
apptype=FlipperAppType.EXTERNAL,
entry_point="wifi_marauder_app",
requires=["gui"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## WiFi Marauder companion app for Flipper Zero

Requires a connected dev board running Marauder FW. See install instructions from UberGuidoZ here: https://github.com/UberGuidoZ/Flipper/tree/main/Wifi_DevBoard#marauder-install-information

## Support

For app feedback, bugs, and feature requests, please create an issue here: https://github.com/0xchocolate/flipperzero-wifi-marauder/issues

You can find me (0xchocolate) on discord as @cococode.
## WiFi Marauder companion app for Flipper Zero

Requires a connected dev board running Marauder FW. See install instructions from UberGuidoZ here: https://github.com/UberGuidoZ/Flipper/tree/main/Wifi_DevBoard#marauder-install-information

## Support

For app feedback, bugs, and feature requests, please create an issue here: https://github.com/0xchocolate/flipperzero-wifi-marauder/issues

You can find me (0xchocolate) on discord as @cococode.
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
#include "sequential_file.h"

char* sequential_file_resolve_path(
Storage* storage,
const char* dir,
const char* prefix,
const char* extension) {
if(storage == NULL || dir == NULL || prefix == NULL || extension == NULL) {
return NULL;
}

char file_path[256];
int file_index = 0;

do {
if(snprintf(
file_path, sizeof(file_path), "%s/%s_%d.%s", dir, prefix, file_index, extension) <
0) {
return NULL;
}
file_index++;
} while(storage_file_exists(storage, file_path));

return strdup(file_path);
}

bool sequential_file_open(
Storage* storage,
File* file,
const char* dir,
const char* prefix,
const char* extension) {
if(storage == NULL || file == NULL || dir == NULL || prefix == NULL || extension == NULL) {
return false;
}

char* file_path = sequential_file_resolve_path(storage, dir, prefix, extension);
if(file_path == NULL) {
return false;
}

bool success = storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
free(file_path);

return success;
#include "sequential_file.h"

char* sequential_file_resolve_path(
Storage* storage,
const char* dir,
const char* prefix,
const char* extension) {
if(storage == NULL || dir == NULL || prefix == NULL || extension == NULL) {
return NULL;
}

char file_path[256];
int file_index = 0;

do {
if(snprintf(
file_path, sizeof(file_path), "%s/%s_%d.%s", dir, prefix, file_index, extension) <
0) {
return NULL;
}
file_index++;
} while(storage_file_exists(storage, file_path));

return strdup(file_path);
}

bool sequential_file_open(
Storage* storage,
File* file,
const char* dir,
const char* prefix,
const char* extension) {
if(storage == NULL || file == NULL || dir == NULL || prefix == NULL || extension == NULL) {
return false;
}

char* file_path = sequential_file_resolve_path(storage, dir, prefix, extension);
if(file_path == NULL) {
return false;
}

bool success = storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
free(file_path);

return success;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#pragma once

#include <storage/storage.h>

char* sequential_file_resolve_path(
Storage* storage,
const char* dir,
const char* prefix,
const char* extension);
bool sequential_file_open(
Storage* storage,
File* file,
const char* dir,
const char* prefix,
#pragma once

#include <storage/storage.h>

char* sequential_file_resolve_path(
Storage* storage,
const char* dir,
const char* prefix,
const char* extension);
bool sequential_file_open(
Storage* storage,
File* file,
const char* dir,
const char* prefix,
const char* extension);
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ char* _wifi_marauder_get_prefix_from_cmd(const char* command) {
return prefix;
}

bool _wifi_marauder_is_save_pcaps_enabled(WifiMarauderApp* app) {
if(!app->ok_to_save_pcaps) {
return false;
}
bool _wifi_marauder_is_saving_enabled(WifiMarauderApp* app) {
// If it is a script that contains a sniff function
if(app->script != NULL) {
if(app->script->save_pcap == WifiMarauderScriptBooleanFalse) {
return false;
}
if(app->script->save_pcap == WifiMarauderScriptBooleanUndefined) {
if(!app->ok_to_save_pcaps) {
return false;
}
}
return wifi_marauder_script_has_stage(app->script, WifiMarauderScriptStageTypeSniffRaw) ||
wifi_marauder_script_has_stage(
app->script, WifiMarauderScriptStageTypeSniffBeacon) ||
Expand All @@ -24,9 +29,15 @@ bool _wifi_marauder_is_save_pcaps_enabled(WifiMarauderApp* app) {
app->script, WifiMarauderScriptStageTypeSniffPmkid) ||
wifi_marauder_script_has_stage(app->script, WifiMarauderScriptStageTypeSniffPwn);
}
// If it is a sniff function
if(!app->ok_to_save_pcaps) {
return false;
}
// If it is a sniff/wardrive/btwardrive/evilportal function
return app->is_command && app->selected_tx_string &&
strncmp("sniff", app->selected_tx_string, strlen("sniff")) == 0;
(strncmp("sniff", app->selected_tx_string, strlen("sniff")) == 0 ||
strncmp("wardrive", app->selected_tx_string, strlen("wardrive")) == 0 ||
strncmp("btwardrive", app->selected_tx_string, strlen("btwardrive")) == 0 ||
strncmp("evilportal", app->selected_tx_string, strlen("evilportal")) == 0);
}

void wifi_marauder_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* context) {
Expand Down Expand Up @@ -104,39 +115,52 @@ 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
if((app->is_command && app->selected_tx_string) || app->script) {
const char* prefix =
strlen(app->selected_tx_string) > 0 ?
_wifi_marauder_get_prefix_from_cmd(app->selected_tx_string) : // Function name
app->script->name; // Script name
char* prefix_buf = NULL;
if(strlen(app->selected_tx_string) > 0) {
prefix_buf = _wifi_marauder_get_prefix_from_cmd(app->selected_tx_string);
}
const char* prefix = prefix_buf ? prefix_buf : // Function name
app->script->name; // Script name

// Create files *before* sending command
// (it takes time to iterate through the directory)
if(app->ok_to_save_logs) {
strcpy(
app->log_file_path,
sequential_file_resolve_path(
app->storage, MARAUDER_APP_FOLDER_LOGS, prefix, "log"));
if(storage_file_open(
app->log_file, app->log_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
app->is_writing_log = true;
char* resolved_path = sequential_file_resolve_path(app->storage, MARAUDER_APP_FOLDER_LOGS, prefix, "log");
if(resolved_path != NULL) {
strcpy(app->log_file_path, resolved_path);
free(resolved_path);
if(storage_file_open(app->log_file, app->log_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
app->is_writing_log = true;
} else {
dialog_message_show_storage_error(app->dialogs, "Cannot open log file");
}
} else {
dialog_message_show_storage_error(app->dialogs, "Cannot open log file");
dialog_message_show_storage_error(app->dialogs, "Cannot resolve log path");
}
}

// If it is a sniff function or script, open the pcap file for recording
if(_wifi_marauder_is_save_pcaps_enabled(app)) {
if(sequential_file_open(
app->storage, app->capture_file, MARAUDER_APP_FOLDER_PCAPS, prefix, "pcap")) {
// If it is a sniff/wardrive/btwardrive/evilportal function or script, open the capture file for recording
if(_wifi_marauder_is_saving_enabled(app)) {
const char* folder = NULL;
const char* extension = NULL;
if(app->script || // Scripts only support sniff functions, but selected_tx_string is empty
strncmp("sniff", app->selected_tx_string, strlen("sniff")) == 0) {
folder = MARAUDER_APP_FOLDER_PCAPS;
extension = "pcap";
} else {
folder = MARAUDER_APP_FOLDER_DUMPS;
extension = "txt";
}
if(sequential_file_open(app->storage, app->capture_file, folder, prefix, extension)) {
app->is_writing_pcap = true;
} else {
dialog_message_show_storage_error(app->dialogs, "Cannot open pcap file");
dialog_message_show_storage_error(app->dialogs, "Cannot open capture file");
}
}

Expand All @@ -152,9 +176,18 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {

// Send command with newline '\n'
if(app->selected_tx_string) {
wifi_marauder_uart_tx(
app->uart, (uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
wifi_marauder_uart_tx(app->uart, (uint8_t*)("\n"), 1);
if(app->script == NULL) {
wifi_marauder_uart_tx(
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(app->uart, the_html, html_size);
wifi_marauder_uart_tx(app->uart, (uint8_t*)("\n"), 1);
Expand All @@ -168,6 +201,10 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
app->script_worker = wifi_marauder_script_worker_alloc(app->uart);
wifi_marauder_script_worker_start(app->script_worker, app->script);
}

if(prefix_buf) {
free(prefix_buf);
}
}
}

Expand Down Expand Up @@ -197,10 +234,12 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {

// 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
Loading

0 comments on commit f437300

Please sign in to comment.