Skip to content

Commit

Permalink
Merge pull request #26 from jaylikesbunda/main
Browse files Browse the repository at this point in the history
v1.1.7 🎄
  • Loading branch information
jaylikesbunda authored Nov 28, 2024
2 parents cabac46 + c1629c7 commit 9a7336f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 48 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion manifest.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
50 changes: 16 additions & 34 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
},
{
Expand All @@ -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",
},
{
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/settings_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 25 additions & 12 deletions src/uart_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9a7336f

Please sign in to comment.