diff --git a/CHANGELOG.md b/CHANGELOG.md index 480afab..3717b79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog + +## v1.1.7 +- added null checks before freeing resources +- remove unused commands from menu.c and cleaned up command details +- initialise uart in esp connection check if needed + ## v1.1.6 - sync files more frequently diff --git a/manifest.yml b/manifest.yml index 3a200ea..b58397a 100644 --- a/manifest.yml +++ b/manifest.yml @@ -1,6 +1,6 @@ name: Ghost ESP id: ghost_esp_app -author: Spooks4567 +author: @Spooks4567, @jaylikesbunda icon: "ghost_esp.png" version: 1.1.4 category: GPIO diff --git a/src/main.c b/src/main.c index 5f2bec5..3c58e7f 100644 --- a/src/main.c +++ b/src/main.c @@ -172,6 +172,16 @@ int32_t ghost_esp_app(void* p) { // Initialize UART in background state->uart_context = uart_init(state); + // Check if ESP is connected, if not, try to initialize it + if(!uart_is_esp_connected(state->uart_context)) { + FURI_LOG_W("Ghost_ESP", "ESP not connected, trying to initialize..."); + if(uart_init(state) != NULL) { + FURI_LOG_I("Ghost_ESP", "ESP initialized successfully"); + } else { + FURI_LOG_E("Ghost_ESP", "Failed to initialize ESP"); + } + } + // Set up and run GUI Gui* gui = furi_record_open("gui"); if(gui && state->view_dispatcher) { diff --git a/src/menu.c b/src/menu.c index 4fc7590..0fd0c81 100644 --- a/src/menu.c +++ b/src/menu.c @@ -282,31 +282,14 @@ static const MenuCommand wifi_commands[] = { .confirm_text = NULL, .details_header = "Raw Packet Capture", .details_text = "Captures all WiFi\n" - "traffic in range.\n" - "Saves as PCAP.\n" - "Range: ~50-100m\n", - }, - { - .label = "Sniff PMKID", - .command = "capture -eapol\n", - .capture_prefix = "pmkid_capture", - .file_ext = "pcap", - .folder = GHOST_ESP_APP_FOLDER_PCAPS, - .needs_input = false, - .input_text = NULL, - .needs_confirmation = false, - .confirm_header = NULL, - .confirm_text = NULL, - .details_header = "PMKID Capture", - .details_text = "Captures PMKID and\n" - "EAPOL handshakes.\n" - "Saves as PCAP.\n" + "traffic to a PCAP file\n" + "for later analysis.\n" "Range: ~50-100m\n", }, { .label = "Sniff Probes", - .command = "capture -probe\n", - .capture_prefix = "probes_capture", + .command = "capture -p\n", + .capture_prefix = "probe_capture", .file_ext = "pcap", .folder = GHOST_ESP_APP_FOLDER_PCAPS, .needs_input = false, @@ -315,9 +298,9 @@ static const MenuCommand wifi_commands[] = { .confirm_header = NULL, .confirm_text = NULL, .details_header = "Probe Capture", - .details_text = "Captures probe\n" - "requests from clients.\n" - "Saves to PCAP file.\n" + .details_text = "Captures probe requests\n" + "from client devices to\n" + "a PCAP file.\n" "Range: ~50-100m\n", }, { @@ -332,9 +315,9 @@ static const MenuCommand wifi_commands[] = { .confirm_header = NULL, .confirm_text = NULL, .details_header = "WPS Capture", - .details_text = "Captures WPS data\n" - "exchanges & beacons.\n" - "Saves to PCAP file.\n" + .details_text = "Captures WPS traffic\n" + "to a PCAP file for\n" + "later analysis.\n" "Range: ~50-100m\n", }, { @@ -533,9 +516,9 @@ static const MenuCommand ble_commands[] = { "- Last seen time\n", }, { - .label = "Sniff Bluetooth", - .command = "blescan -r\n", - .capture_prefix = "btscan", + .label = "Sniff BLE", + .command = "blescan -s\n", + .capture_prefix = "ble_capture", .file_ext = "pcap", .folder = GHOST_ESP_APP_FOLDER_PCAPS, .needs_input = false, @@ -544,10 +527,9 @@ static const MenuCommand ble_commands[] = { .confirm_header = NULL, .confirm_text = NULL, .details_header = "BLE Sniffer", - .details_text = "Captures Bluetooth LE\n" - "packets & adv data.\n" - "Saves to PCAP file.\n" - "Range: ~50m\n", + .details_text = "Captures Bluetooth Low\n" + "Energy traffic.\n" + "Range: ~10-30m\n", }, { .label = "Stop BLE Scan", diff --git a/src/settings_ui.c b/src/settings_ui.c index 7b65fce..f62022b 100644 --- a/src/settings_ui.c +++ b/src/settings_ui.c @@ -401,7 +401,7 @@ bool settings_custom_event_callback(void* context, uint32_t event_id) { "Updated by: Jay Candel\n" "Built with <3"; - confirmation_view_set_header(app_state->confirmation_view, "Ghost ESP v1.1.6"); + confirmation_view_set_header(app_state->confirmation_view, "Ghost ESP v1.1.7"); confirmation_view_set_text(app_state->confirmation_view, info_text); // Save current view before switching diff --git a/src/uart_utils.c b/src/uart_utils.c index 0a39aad..7180c74 100644 --- a/src/uart_utils.c +++ b/src/uart_utils.c @@ -430,30 +430,43 @@ UartContext* uart_init(AppState* state) { void uart_free(UartContext *uart) { if(!uart) return; - if(uart->text_manager) { - text_buffer_free(uart->text_manager); - uart->text_manager = NULL; - } - - // Stop thread and wait for it to finish + // Stop the worker thread if(uart->rx_thread) { furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtStop); furi_thread_join(uart->rx_thread); furi_thread_free(uart->rx_thread); + uart->rx_thread = NULL; } - // Clean up serial after thread is stopped + // Clean up serial if(uart->serial_handle) { + furi_hal_serial_async_rx_stop(uart->serial_handle); furi_hal_serial_deinit(uart->serial_handle); furi_hal_serial_control_release(uart->serial_handle); + uart->serial_handle = NULL; } - // Free streams after everything is stopped - if(uart->rx_stream) furi_stream_buffer_free(uart->rx_stream); - if(uart->pcap_stream) furi_stream_buffer_free(uart->pcap_stream); + // Free streams + if(uart->rx_stream) { + furi_stream_buffer_free(uart->rx_stream); + uart->rx_stream = NULL; + } + if(uart->pcap_stream) { + furi_stream_buffer_free(uart->pcap_stream); + uart->pcap_stream = NULL; + } - // Clean up storage context last - if(uart->storageContext) uart_storage_free(uart->storageContext); + // Clean up storage context + if(uart->storageContext) { + uart_storage_free(uart->storageContext); + uart->storageContext = NULL; + } + + // Free text manager + if(uart->text_manager) { + text_buffer_free(uart->text_manager); + uart->text_manager = NULL; + } free(uart); }