From a99da9315c0254cee6eda2977fd8052df8a3aff2 Mon Sep 17 00:00:00 2001 From: lotherk Date: Sat, 21 Nov 2026 06:55:43 +0000 Subject: [PATCH] apex-twin 0.6.0: traffic capture, request and raw response as one proof http_capture is http_request that keeps the exchange: $APEX_HOME/traffic/ tNNNN.http holds the request bytes and the raw response, tNNNN.json holds target, method, path, status and byte counts. TLS goes through curl, so the request side is marked reconstructed in the file - the tool says what it did not see. traffic_list and traffic_read find and replay the pair. http_once now optionally returns the exact request it wrote, so a plain-HTTP capture is byte-for-byte what went out. The store parses unquoted numbers and booleans (simple_long); traffic_read rewinds before reading the pair. The capture found a real pre-existing bug: status_code() took the first number in 'HTTP/1.1 200 OK' - the 1 of the version - so http_paths, sqli_probe and xss_probe had been comparing status 1 for every answer. It now skips the protocol token; the suite asserts 200, and putting the old function back turns two checks red. 40 tools, 185 checks. Two new files per capture are asserted on disk, the raw pair is checked for the request line, the response marker and the status line, and an out-of-scope capture is refused with the scope reason. --- README.md | 40 ++++-- docs/artex-port.md | 8 +- src/apex-twin.c | 2 + src/apex.h | 32 ++++- src/config.c | 2 + src/store.c | 309 ++++++++++++++++++++++++++++++++++++++++++++ src/tools.h | 2 + src/tools_traffic.c | 70 ++++++++++ src/tools_web.c | 189 ++++++++++++++++++++++++++- tests/run.py | 46 ++++++- 10 files changed, 676 insertions(+), 24 deletions(-) create mode 100644 src/tools_traffic.c diff --git a/README.md b/README.md index fdce0cb..7fbba30 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ separate, explicitly armed switch. ## Build ```sh -make # apex-twin, ~200 kB static-ish binary, zero warnings under -Werror -make test # 170 end-to-end checks, no mocks +make # apex-twin, ~210 kB static-ish binary, zero warnings under -Werror +make test # 185 end-to-end checks, no mocks make install # /usr/local/bin/apex-twin ``` @@ -117,7 +117,21 @@ latest reading, so a scan that runs twice does not grow two rows. `report_markdown` with `include_assets: true` appends the inventory table to the same file as the findings. -## Tools (37) +## Captured traffic + +`http_capture` is `http_request` that keeps the exchange: the request bytes (or +a reconstruction when TLS is handed to curl — the file says which) and the raw +response go to `$APEX_HOME/traffic/tNNNN.http`, with a `tNNNN.json` record +beside it holding target, method, path, status and byte counts. `traffic_list` +finds the pair, `traffic_read` shows it again as text, or base64 when the bytes +are not text. + +The capture found an old bug the suite had never exercised: `status_code()` +took the first number in `HTTP/1.1 200 OK`, which is the `1` of the version, so +path discovery and both probes had been comparing status `1` for every answer. +The status is now parsed after the protocol token, and the test asserts `200`. + +## Tools (40) **Scope and bookkeeping** — `scope_show`, `scope_check` (ask the gate without touching anything), `scope_reload`, `capabilities`, `audit_log`, `evidence_save` @@ -128,6 +142,9 @@ then the scope of every target in it) **Inventory** — `asset_add` (gated; merges by target, unions ports), `asset_list`, `asset_read`, `asset_update` +**Traffic** — `http_capture` (request + raw response kept as a pair), +`traffic_list`, `traffic_read` + **Network recon** — `portscan` (in-process TCP connect, no nmap needed), `nmap` (profiles quick/default/full/udp/vuln/http), `dns` (dig), `tls_cert` (openssl), `banner`, `http_head` @@ -204,6 +221,8 @@ $APEX_HOME/ evidence/-