Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified serial PCAPs #452

Merged
merged 12 commits into from
Jan 18, 2024
Merged

Unified serial PCAPs #452

merged 12 commits into from
Jan 18, 2024

Conversation

Willy-JL
Copy link
Contributor

@Willy-JL Willy-JL commented Jan 1, 2024

Main objectives:

  • Serial PCAPs and logs are sent on main console UART:
    • Text output and buffer data separated by using [BUF/BEGIN] and [BUF/CLOSE] markers
    • This is enabled via a CLI -serial option, no need for separate .bin's anymore
    • Ignoring/filtering the markers handled by application layer (eg. Flipper Zero Marauder Companion app)
    • Without -serial flag everything behaves as before, users won't notice a difference
  • Not needing a second serial means:
    • All boards support serial PCAPs/logs, not just ESP32-S2 / Flipper WiFi Module
    • Second serial can be used for GPS
    • No interference with SD card, can save to both SD card and serial at same time

Technical details:

  • fe08c14 I noticed everywhere else do_save was used to toggle the calls to addLog(), while here it was set but addLog() was always called, fixed it
  • d0f5d89 Instead do_save on SDInterface was a remnant from 4 years ago, set to true and never toggled, removed since it was redundant
  • Fully reworked pcap/log capture system to be centralized and streamlined into buffer_obj, supporting both sd and serial together:
    • f6c27ed For adding capture data, also simplifies log data conversion (type casting instead of redundant copying), later changed to a single append() overloaded function in 9d92c5c
    • c61aaf9 For opening captures, remembers the filesystem and serial boolean passed for saving later on, also adds more return guards for valid GPS state
    • 2004a9e For saving capture data to file and/or serial as chosen when opening
    • e560a88 Makes sure buffer doesnt change while saving, writes will wait
  • bddc7e1 Main point of the PR, serial PCAPs and logs are sent on main UART between [BUF/BEGIN] and [BUF/CLOSE] markers, removes WRITE_PACKETS_SERIAL restrictions in the whole project since second serial is not an issue anymore, and also the related configs.h variables that are left unused
  • 558fe18 Replaces the WRITE_PACKETS_SERIAL config with a -serial commandline option for all scan/attack commands, no need for a second bin anymore

Example:

What happens:

#sniffpmkid -serial
Starting PMKID sniff on channel 1. Stop with stopscan
>[BUF/BEGIN]bla
bla
network traffic[BUF/CLOSE]Received EAPOL:
00:00:00:00:00:00
[BUF/BEGIN]bla
bla
pcap go
very brrrr[BUF/CLOSE]Received EAPOL:
00:00:00:00:00:00

What the user sees with companion app filtering the markers:

#sniffpmkid -serial
Starting PMKID sniff on channel 1. Stop with stopscan
>Received EAPOL:
00:00:00:00:00:00
Received EAPOL:
00:00:00:00:00:00

What the companion app saves into the pcap:

bla
bla
network trafficbla
bla
pcap go
very brrrr

Notes:

I had already implemented this about a month ago but with no CLI toggle, it always dumped into serial. That is currently bundled with the latest (v52) release of Xtreme Flipper Zero firmware, along with a modified companion app that handles the markers and dumps to pcap file (see here).

The big concensus is that this is the easiest and most hassle free way to handle serial PCAPs, since it works for all boards and doesnt require fiddling with bins and UARTs. Safe to say this marker method works well and so I decided to improve it and make it easily togglable, which required a deep rework of the buffer_obj and capture system, although it's probably for the best since the previous setup was a bit spaghetti-sh.

I already verified the serial part to be working as intended, PCAPs land into Flipper storage with no problems. I don't have a board with SD card at hand at the moment to double check this new rework, but I am confident that it should be working as intended, saving to SD card when possible and to serial when set as commandline option.

I will be making a pull request to @0xchocolate 's official companion app to add support for this very shortly.

@Willy-JL
Copy link
Contributor Author

Willy-JL commented Jan 2, 2024

Actually just thought that the pcapAdd and logAdd can be simplified into a single append() function that works with overloads... I'll do that super quick, and also merge develop branch

@Willy-JL Willy-JL marked this pull request as draft January 2, 2024 11:52
@Willy-JL Willy-JL marked this pull request as ready for review January 2, 2024 12:09
@Willy-JL
Copy link
Contributor Author

Willy-JL commented Jan 2, 2024

Made the worklow run on pull request synchronize too (pull_request event does opened, synchronize, reopened by default) so new builds are made when PR is updated (was not building after I pushed my new changes)

@justcallmekoko
Copy link
Owner

@Willy-JL been super busy but I will start testing this with my devices soon. Before I do that, would you mind resolving the MR conflicts? I had added some GPS module stuff to make sure the user has control over the power of the GPS module

@Willy-JL
Copy link
Contributor Author

that should do it

@justcallmekoko
Copy link
Owner

justcallmekoko commented Jan 18, 2024

@Willy-JL Thank you for the very comprehensive write-up. I will start testing this and I look forward to merging this once complete. Really awesome work here!

Edit: Also really good job navigating my source. It's mostly duct-tape and toothpicks at this point. You have a very high level of patience, that's clear.

@justcallmekoko justcallmekoko changed the base branch from develop to unified-serial January 18, 2024 19:21
@justcallmekoko justcallmekoko merged commit 10e9135 into justcallmekoko:unified-serial Jan 18, 2024
1 check passed
@Willy-JL
Copy link
Contributor Author

Willy-JL commented Feb 1, 2024

@justcallmekoko any rumors on when the next release might roughly be? Just to have an idea of when the app and tutorials would need to be updated for this change

@Willy-JL Willy-JL deleted the unified-serial-pcaps branch March 6, 2024 22:46
schrab pushed a commit to schrab/ESP32S3Marauder that referenced this pull request Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants