Просмотр исходного кода

Copy Momentum-Apps and RM changes

0xchocolate 1 год назад
Родитель
Сommit
9596f2581f

+ 56 - 29
scenes/wifi_marauder_scene_console_output.c

@@ -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) ||
@@ -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) {
@@ -110,10 +121,12 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
 
     // 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)
@@ -122,25 +135,30 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
                 app->log_file_path,
                 sequential_file_resolve_path(
                     app->storage, MARAUDER_APP_FOLDER_LOGS, prefix, "log"));
-            if(app->log_file_path != NULL) {
-                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");
-                }
+            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 resolve log path");
+                dialog_message_show_storage_error(app->dialogs, "Cannot open log file");
             }
         }
 
-        // 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");
             }
         }
 
@@ -156,12 +174,17 @@ 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));
-            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(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);
@@ -176,6 +199,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);
+        }
     }
 }
 

+ 1 - 1
script/cJSON.c

@@ -331,7 +331,7 @@ double string_to_double(const char* str, char** endptr) {
 /* Parse the input text to generate a number, and populate the result into item. */
 static cJSON_bool parse_number(cJSON* const item, parse_buffer* const input_buffer) {
     double number = 0;
-    unsigned char* after_end = NULL;
+    unsigned char* volatile after_end = NULL;
     unsigned char number_c_string[64];
     unsigned char decimal_point = get_decimal_point();
     size_t i = 0;

+ 41 - 7
script/wifi_marauder_script_executor.c

@@ -105,8 +105,13 @@ void _wifi_marauder_script_execute_probe(
 void _wifi_marauder_script_execute_sniff_raw(
     WifiMarauderScriptStageSniffRaw* stage,
     WifiMarauderScriptWorker* worker) {
-    const char sniff_command[] = "sniffraw -serial\n";
+    const char sniff_command[] = "sniffraw";
     wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
+    if(((WifiMarauderScript*)worker->context)->save_pcap != WifiMarauderScriptBooleanFalse) {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)(" -serial\n"), strlen(" -serial\n"));
+    } else {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)("\n"), 1);
+    }
     _wifi_marauder_script_delay(worker, stage->timeout);
     _send_stop(worker);
 }
@@ -114,8 +119,13 @@ void _wifi_marauder_script_execute_sniff_raw(
 void _wifi_marauder_script_execute_sniff_beacon(
     WifiMarauderScriptStageSniffBeacon* stage,
     WifiMarauderScriptWorker* worker) {
-    const char sniff_command[] = "sniffbeacon -serial\n";
+    const char sniff_command[] = "sniffbeacon";
     wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
+    if(((WifiMarauderScript*)worker->context)->save_pcap != WifiMarauderScriptBooleanFalse) {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)(" -serial\n"), strlen(" -serial\n"));
+    } else {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)("\n"), 1);
+    }
     _wifi_marauder_script_delay(worker, stage->timeout);
     _send_stop(worker);
 }
@@ -123,8 +133,13 @@ void _wifi_marauder_script_execute_sniff_beacon(
 void _wifi_marauder_script_execute_sniff_deauth(
     WifiMarauderScriptStageSniffDeauth* stage,
     WifiMarauderScriptWorker* worker) {
-    const char sniff_command[] = "sniffdeauth -serial\n";
+    const char sniff_command[] = "sniffdeauth";
     wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
+    if(((WifiMarauderScript*)worker->context)->save_pcap != WifiMarauderScriptBooleanFalse) {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)(" -serial\n"), strlen(" -serial\n"));
+    } else {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)("\n"), 1);
+    }
     _wifi_marauder_script_delay(worker, stage->timeout);
     _send_stop(worker);
 }
@@ -132,8 +147,13 @@ void _wifi_marauder_script_execute_sniff_deauth(
 void _wifi_marauder_script_execute_sniff_esp(
     WifiMarauderScriptStageSniffEsp* stage,
     WifiMarauderScriptWorker* worker) {
-    const char sniff_command[] = "sniffesp -serial\n";
+    const char sniff_command[] = "sniffesp";
     wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
+    if(((WifiMarauderScript*)worker->context)->save_pcap != WifiMarauderScriptBooleanFalse) {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)(" -serial\n"), strlen(" -serial\n"));
+    } else {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)("\n"), 1);
+    }
     _wifi_marauder_script_delay(worker, stage->timeout);
     _send_stop(worker);
 }
@@ -152,7 +172,12 @@ 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, " -serial\n");
+            if(((WifiMarauderScript*)worker->context)->save_pcap !=
+               WifiMarauderScriptBooleanFalse) {
+                len += snprintf(attack_command + len, sizeof(attack_command) - len, " -serial\n");
+            } else {
+                len += snprintf(attack_command + len, sizeof(attack_command) - len, "\n");
+            }
             wifi_marauder_uart_tx(worker->uart, (uint8_t*)attack_command, len);
             _wifi_marauder_script_delay(worker, stage->timeout);
             _send_stop(worker);
@@ -169,7 +194,11 @@ 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, " -serial\n");
+        if(((WifiMarauderScript*)worker->context)->save_pcap != WifiMarauderScriptBooleanFalse) {
+            len += snprintf(attack_command + len, sizeof(attack_command) - len, " -serial\n");
+        } else {
+            len += snprintf(attack_command + len, sizeof(attack_command) - len, "\n");
+        }
         wifi_marauder_uart_tx(worker->uart, (uint8_t*)attack_command, len);
         _wifi_marauder_script_delay(worker, stage->timeout);
         _send_stop(worker);
@@ -179,8 +208,13 @@ void _wifi_marauder_script_execute_sniff_pmkid(
 void _wifi_marauder_script_execute_sniff_pwn(
     WifiMarauderScriptStageSniffPwn* stage,
     WifiMarauderScriptWorker* worker) {
-    const char sniff_command[] = "sniffpwn -serial\n";
+    const char sniff_command[] = "sniffpwn";
     wifi_marauder_uart_tx(worker->uart, (uint8_t*)sniff_command, strlen(sniff_command));
+    if(((WifiMarauderScript*)worker->context)->save_pcap != WifiMarauderScriptBooleanFalse) {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)(" -serial\n"), strlen(" -serial\n"));
+    } else {
+        wifi_marauder_uart_tx(worker->uart, (uint8_t*)("\n"), 1);
+    }
     _wifi_marauder_script_delay(worker, stage->timeout);
     _send_stop(worker);
 }

+ 9 - 1
wifi_marauder_app.c

@@ -103,13 +103,21 @@ void wifi_marauder_make_app_folder(WifiMarauderApp* app) {
         dialog_message_show_storage_error(app->dialogs, "Cannot create\npcaps folder");
     }
 
+    if(!storage_simply_mkdir(app->storage, MARAUDER_APP_FOLDER_DUMPS)) {
+        dialog_message_show_storage_error(app->dialogs, "Cannot create\ndumps folder");
+    }
+
     if(!storage_simply_mkdir(app->storage, MARAUDER_APP_FOLDER_LOGS)) {
-        dialog_message_show_storage_error(app->dialogs, "Cannot create\npcaps folder");
+        dialog_message_show_storage_error(app->dialogs, "Cannot create\nlogs folder");
     }
 
     if(!storage_simply_mkdir(app->storage, MARAUDER_APP_FOLDER_SCRIPTS)) {
         dialog_message_show_storage_error(app->dialogs, "Cannot create\nscripts folder");
     }
+
+    if(!storage_simply_mkdir(app->storage, MARAUDER_APP_FOLDER_HTML)) {
+        dialog_message_show_storage_error(app->dialogs, "Cannot create\nhtml folder");
+    }
 }
 
 void wifi_marauder_load_settings(WifiMarauderApp* app) {

+ 1 - 0
wifi_marauder_app_i.h

@@ -36,6 +36,7 @@
 #define MARAUDER_APP_FOLDER EXT_PATH(MARAUDER_APP_FOLDER_USER)
 #define MARAUDER_APP_FOLDER_HTML MARAUDER_APP_FOLDER "/html"
 #define MARAUDER_APP_FOLDER_PCAPS MARAUDER_APP_FOLDER "/pcaps"
+#define MARAUDER_APP_FOLDER_DUMPS MARAUDER_APP_FOLDER "/dumps"
 #define MARAUDER_APP_FOLDER_LOGS MARAUDER_APP_FOLDER "/logs"
 #define MARAUDER_APP_FOLDER_USER_PCAPS MARAUDER_APP_FOLDER_USER "/pcaps"
 #define MARAUDER_APP_FOLDER_USER_LOGS MARAUDER_APP_FOLDER_USER "/logs"