diff options
| author | srdusr <[email protected]> | 2024-05-14 01:42:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2024-05-14 01:42:00 +0200 |
| commit | 08332a4195956611db80a2cfe3710d760cbd6acf (patch) | |
| tree | 0cb5cdf9fdcfdd8dc8c129a33575ad9b182d5c01 /CMakeLists.txt | |
| download | packeteer-08332a4195956611db80a2cfe3710d760cbd6acf.tar.gz packeteer-08332a4195956611db80a2cfe3710d760cbd6acf.zip | |
Initial commit: wireframe packet capture/analysis tool
Terminal packet capture and analysis tool built to learn the C++
memory model (byte layout, alignment, endianness, std::span over
unowned buffers) via a real capture pipeline.
- Hand-rolled L2-L4 decoders (Ethernet, IPv4, IPv6 with extension
header walking, TCP, UDP) over std::span, no struct-casting
- L7 dissector interface with DNS, HTTP, and TLS SNI implementations
- pcapng read/write for Wireshark-compatible capture files
- Bounded capture queue: drop-on-backpressure for live capture,
blocking push for faithful file replay
- Kernel-level BPF filtering (-f) and a separate display-only search
(-g / interactive) that doesn't touch what's captured
- Replay mode (-r) reads a saved pcapng file back through the same
pipeline as live capture, no root or live device needed
- pcap_stats() surfaces kernel/interface drops invisible to the
capture queue's own counter
- Three frontends sharing one CaptureSession setup path: CLI, TUI
(FTXUI, primary), GUI (Dear ImGui + SDL3, secondary)
- 89 unit tests (doctest) plus 9 libFuzzer harnesses covering every
hand-rolled parser; fuzzing found and fixed a real OOM in the
pcapng reader (unbounded allocation from an untrusted length field)
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..211738a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,136 @@ +cmake_minimum_required(VERSION 3.20) +project(wireframe CXX) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug) +endif() + +add_compile_options(-Wall -Wextra) + +find_package(Threads REQUIRED) + +include(FetchContent) +FetchContent_Declare( + ftxui + GIT_REPOSITORY https://github.com/ArthurSonzogni/FTXUI.git + GIT_TAG v7.0.3 + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(ftxui) + +add_executable(wireframe src/main.cpp) +target_include_directories(wireframe PRIVATE include) +target_link_libraries(wireframe PRIVATE + pcap + Threads::Threads + ftxui::component + ftxui::dom + ftxui::screen +) + +# GUI (secondary to the TUI - see PLAN.md Decisions). Dear ImGui + +# SDL3, same FetchContent approach as FTXUI/doctest: no dependency on +# a system package, so it builds the same way on every platform this +# project targets. SDL3 over SDL2 because sdl2-compat (an SDL3-backed +# shim) is what's actually packaged in this ecosystem now - SDL3 is +# the live line. SDL_Renderer (not raw OpenGL3) avoids needing a +# separate GL function loader as another dependency. +set(SDL_SHARED OFF CACHE BOOL "" FORCE) +set(SDL_STATIC ON CACHE BOOL "" FORCE) +set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE) +FetchContent_Declare( + sdl3 + GIT_REPOSITORY https://github.com/libsdl-org/SDL.git + GIT_TAG release-3.4.14 + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(sdl3) + +FetchContent_Declare( + imgui + GIT_REPOSITORY https://github.com/ocornut/imgui.git + GIT_TAG v1.92.9b + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(imgui) + +add_library(imgui STATIC + ${imgui_SOURCE_DIR}/imgui.cpp + ${imgui_SOURCE_DIR}/imgui_draw.cpp + ${imgui_SOURCE_DIR}/imgui_tables.cpp + ${imgui_SOURCE_DIR}/imgui_widgets.cpp + ${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp + ${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp +) +target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR} ${imgui_SOURCE_DIR}/backends) +target_link_libraries(imgui PUBLIC SDL3::SDL3) + +add_executable(wireframe_gui src/gui_main.cpp) +target_include_directories(wireframe_gui PRIVATE include) +target_link_libraries(wireframe_gui PRIVATE pcap Threads::Threads imgui SDL3::SDL3) + +enable_testing() + +FetchContent_Declare( + doctest + GIT_REPOSITORY https://github.com/doctest/doctest.git + GIT_TAG v2.5.3 + GIT_SHALLOW TRUE +) +FetchContent_MakeAvailable(doctest) + +add_executable(wireframe_tests + tests/main.cpp + tests/test_byteio.cpp + tests/test_net.cpp + tests/test_ipv6.cpp + tests/test_dns.cpp + tests/test_http.cpp + tests/test_tls.cpp + tests/test_pcapng.cpp + tests/test_capture_queue.cpp + tests/test_filter.cpp + tests/test_summarize.cpp + tests/test_capture_session.cpp + tests/test_search.cpp +) +target_include_directories(wireframe_tests PRIVATE include) +target_link_libraries(wireframe_tests PRIVATE doctest::doctest Threads::Threads pcap) + +add_test(NAME wireframe_tests COMMAND wireframe_tests) + +# libFuzzer harnesses for the hand-rolled decoders - the actual point +# of this project (byte layout/alignment/UB) makes these the highest- +# value tests in the repo, not an afterthought. Opt-in and clang-only +# (libFuzzer is a clang/compiler-rt feature) so a normal `cmake --build` +# with the default compiler is unaffected. +option(WIREFRAME_ENABLE_FUZZING "Build libFuzzer harnesses (requires clang)" OFF) +if(WIREFRAME_ENABLE_FUZZING) + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + message(FATAL_ERROR "WIREFRAME_ENABLE_FUZZING requires clang (libFuzzer); " + "reconfigure with -DCMAKE_CXX_COMPILER=clang++") + endif() + + function(add_wireframe_fuzz_target name) + add_executable(${name} fuzz/${name}.cpp) + target_include_directories(${name} PRIVATE include) + target_link_libraries(${name} PRIVATE pcap) + target_compile_options(${name} PRIVATE -fsanitize=fuzzer,address,undefined -g -O1) + target_link_options(${name} PRIVATE -fsanitize=fuzzer,address,undefined) + endfunction() + + add_wireframe_fuzz_target(fuzz_ethernet) + add_wireframe_fuzz_target(fuzz_ipv4) + add_wireframe_fuzz_target(fuzz_ipv6) + add_wireframe_fuzz_target(fuzz_tcp) + add_wireframe_fuzz_target(fuzz_udp) + add_wireframe_fuzz_target(fuzz_dns) + add_wireframe_fuzz_target(fuzz_http) + add_wireframe_fuzz_target(fuzz_tls) + add_wireframe_fuzz_target(fuzz_pcapng_reader) + add_wireframe_fuzz_target(fuzz_summarize) +endif() |