lotherk 48ca583c5c apex-twin 1.11.0: VNC, MQTT and GraphQL probes, capability baseline
Red:
- vnc_probe: reads the RFB version, echoes it, then reads the security types
  (3.7/3.8 list or 3.3 single type), names them and flags None authentication
  (audited). A zero-length list reports the server's reason. No authentication.
- mqtt_probe: one MQTT 3.1.1 CONNECT with a clean session and no username or
  password; reads the CONNACK code, disconnects, reports an anonymous broker
  (code 0) or the refusal reason.
- graphql_probe: POSTs a compact introspection query and reports whether the
  schema is exposed, the type count, query/mutation type names and a reason
  when introspection is disabled or the endpoint is missing; evidence on hit.

Blue:
- cap_baseline: create/verify a baseline of Linux file capabilities
  (security.capability xattr) under the same paths as suid_baseline, reporting
  new, gone and changed capability sets; optional root prefix.

Tests: RFB 3.8 with None+VNC auth, RFB 3.3, a zero-security-type server, MQTT
brokers answering 0 and 5, GraphQL endpoints with a schema, disabled
introspection and a 404, and a capability tree (real caps need CAP_SETFCAP, so
the diff is exercised with a fabricated baseline entry). 593 checks, ASan suite
green, analyze clean, release-check green including distcheck 1.11.0.
2026-11-21 13:48:28 +00:00

APEX TWIN

An offensive-security MCP server in C99 + POSIX. One static binary, libc only, no Python in the serving path. It gives an agent real reconnaissance and real web testing behind a scope gate that refuses everything until a rules-of-engagement file says otherwise.

92 tools · 593 end-to-end checks · 340 fuzz cases · 79.3% line coverage · ~437 KiB

$ ./apex-twin --check
{"version":"1.11.0","tools":92,...,"scope":{"loaded":true,...}}

APEX TWIN was inspired by ARTEX (scope gates, findings with evidence, budgets). The C implementation is written from nothing; it takes the ideas, not the code.


What it is, and what it is not

It is a tool server for one operator, covering both sides of an engagement:

  • red: a real TCP connect scan, nmap/dig/openssl through gated child processes, HTTP requests and header audits, CORS and cookie checks, path discovery, SQLi/XSS lead probes, exposed-artifact verification, subdomain enumeration, default-credential checks;
  • blue: a read-only host posture audit, auth-log brute-force summary and an indicator scan for persistence and remote-execution strings;
  • hardware: the ESP32 Marauder CLI and ESP32 board tools (chip identity, serial monitor, flash dump).

All of it behind one gate, with an inventory, traffic capture, findings with evidence and a report writer.

It is not an exploit framework. There is no shell, no exploit payload, no post-exploitation, no C2, no persistence, no TLS interception, no agent loop. Every tool observes, proves, or (for the credential check) makes a small, rate-limited authentication attempt. Radio transmission is a separate, explicitly armed switch.

The MCP client is the agent. This process is the gate, the tools and the records.


The gate is the product

A tool never decides for itself whether a target is fair game. Every tool that can touch a network calls one of two helpers from src/tools.h:

gated(c, "nmap", target, port);                        /* scope check, no action */
gated_cmd(c, "nmap", target, port, argv, timeout, NULL);  /* scope check + spawn */

Both consult apex_scope_check(), write the audit line before the action, and refuse with mcp_reply_error naming the reason. scope_check is the same decision without an action, for planning.

tests/gate_audit.py enforces the invariant statically: it parses every TOOLS_*[] table and handler body and fails if a tool whose schema names a target does not call the gate (four record filters excepted), or if a handler opens a socket or spawns a process without it. make test runs that audit before the suite.

Rules, in the order they are applied

# Rule Result
1 no scope file loaded deny everything
2 scope expired deny everything
3 target in deny_ip deny (deny beats allow)
4 port > 0 and not in allow_port deny
5 target in neither allow_ip nor allow_domain deny
6 private/loopback/link-local and allow_private is false deny
7 a name outside allow_domain that does not resolve entirely inside allow_ip deny

Notes that matter:

  • port <= 0 means the caller enumerates ports itself (used by portscan, which filters every probe with apex_port_in_scope()). It is not a wildcard for a single-port action.
  • A name in allow_domain is trusted for its addresses, but while allow_private is false it may not resolve into a private network.
  • A name outside allow_domain must resolve, and every address it returns must be inside allow_ip; an unresolvable name is refused, never waved through.
  • *.example.com matches subdomains only; example.com matches the apex and its subdomains. A trailing FQDN dot and an embedded host:port are normalised before the check.

No scope file means no engagement. That is deliberate: a default that scans something is a liability, not a convenience.


Quick start

make                              # build (zero warnings under -Werror)
mkdir -p ~/.local/state/apex-twin
cat > ~/.local/state/apex-twin/scope.json <<'EOF'
{
  "label": "lab",
  "expires": "2099-12-31T23:59:59Z",
  "allow_private": false,
  "serial_tx": false,
  "allow_ip": ["192.0.2.0/24"],
  "deny_ip": ["192.0.2.66"],
  "allow_domain": ["example.com"],
  "allow_port": ["80", "443", "8000-8100"]
}
EOF

apex-twin --check                # is the scope loaded, what is the tool count?
apex-twin                        # MCP over stdin/stdout

An MCP client then calls scope_show, portscan, http_headers, finding_add, report_markdown, and so on. A minimal stdio exchange:

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"scope_check","arguments":{"target":"192.0.2.5","port":80}}}
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"http_headers","arguments":{"target":"example.com","port":80,"path":"/"}}}

Transports and modes

Mode Command Listener
MCP over stdio apex-twin none
MCP over HTTP apex-twin --http 8797 127.0.0.1:8797, POST /mcp
Forward proxy apex-twin --proxy 8798 127.0.0.1:8798
Diagnostics apex-twin --check none; prints JSON and exits
Version apex-twin --version none

Both listeners bind loopback only and do not authenticate. Reach them through an SSH tunnel or a VPN; never put them on a LAN interface. The HTTP face serves at most APEX_HTTP_MAX_CHILDREN connections at once (503 beyond) and closes a request whose head or body does not arrive within APEX_HTTP_HEAD_TIMEOUT_MS.

--check reports the operational state without starting a server: rewrite_rules, webhook_configured (a boolean; the URL is never printed), proxy_max_children, audit_max_bytes, http_max_children, http_head_timeout_ms, evidence_max_bytes and the loaded scope.


Tools (92)

Scope and bookkeeping

Tool What it does
scope_show The loaded rules of engagement as JSON
scope_check Ask the gate about one target/port without touching it
scope_reload Reload the scope file, optionally from another path
capabilities State dir, programs present, limits, dry-run flag
audit_log The newest audit lines (one JSON object per decision)
evidence_save Store a raw proof blob (APEX_EVIDENCE_MAX_BYTES cap)
notify_test Fire the configured webhook once and report the result

Command guard

Tool What it does
guard_check May this shell line run? Deny rules first, then the scope of every URL/IP/host in it

guard_check exists for the half of the work that happens in the operator's own shell. It tokenises the command, applies the deny rules, and only then checks targets. Order is the contract: rm -rf / <out-of-scope-url> is refused for the delete, not for the URL.

Deny rules: recursive rm/chmod on a system path, rm -rf * after cd into one, find -delete, dd/mkfs/wipefs/mkswap/shred on a device, shutdown/reboot/halt/init 0|6/kill 1, systemctl stop|disable|mask, firewall flushes (iptables -F/-X, nft flush, ufw disable, pfctl -F), a pipe into an interpreter that reads stdin, nc -e/socat EXEC:, and writes or mv into /etc. It also notes (but allows) sudo, world-writable chmod 777, uploads and secret-file reads. It does not execute anything.

Network reconnaissance

Tool What it does
portscan TCP connect scan in-process; no nmap needed; per-probe scope filter
nmap Profiles: quick, default (top-100 + -sV), full (-p-), udp, vuln, http
dns dig for A/AAAA/MX/TXT/NS/SOA/CNAME/SRV/CAA/PTR
whois Registration and netblock record; speaks to port 43, so allow it
tls_cert openssl s_client chain and verification for host:port
banner Read the first bytes a service sends
http_head Request the head of a URL and return it verbatim

Web

Tool What it does
http_request Any method, headers and body; response verbatim
http_headers Audit HSTS/CSP/frame/nosniff/referrer/permissions with reasons
http_paths Built-in wordlist: .git, .env, admin, actuator, swagger, backups
cors_check Marker Origin; grades reflection with credentials as high risk
cookie_audit Secure/HttpOnly/SameSite per cookie, incl. SameSite=None without Secure
http_options Allow/Public; flags TRACE, PUT, DELETE
sqli_probe Quote and boolean payloads; differing answers are a lead, not proof
xss_probe Marked payload; returns the reflection context
curl curl for a gated path when the operator wants its behaviour

Traffic and evidence

Tool What it does
http_capture One request and the raw response stored as a pair
traffic_list Captures, newest last, filterable by target
traffic_read One pair back as text, or base64 when the bytes are not text
evidence_list Saved proof blobs, newest first
evidence_read One blob back, text or base64

Inventory and findings

Tool What it does
asset_add Gated inventory entry; merges by target and unions ports
asset_list / asset_read / asset_update Inventory access, atomic updates
finding_add Record a finding; duplicate target+title returns the existing id
finding_list / finding_read Query findings
finding_update Lifecycle open/confirmed/false-positive/fixed, severity, note
report_markdown Markdown, CSV or JSON report written under $APEX_HOME/reports

Radio (ESP32 Marauder)

Tool What it does
marauder_info Ask info and help; refuses a device that looks like a console
marauder_commands The allowlist and which commands transmit
marauder_cmd One allowlisted command, output returned
marauder_scan A receive-only scan for N seconds, always ending in stopscan

The serial guard sends a bare CRLF and refuses on console markers (login:, password:, console (, …). Transmission requires serial_tx: true and a command in the allowlist: a receiver is a scanner, a transmitter is an attack.

Red team

Tool What it does
vuln_check Non-destructive verification of /.git/HEAD, /.env (keys only, values redacted), directory listing and phpinfo; raw response saved as evidence
subdomain_enum Built-in wordlist (or your names) under one in-scope domain; every name is gate-checked before it is resolved
cred_test HTTP Basic default credentials, max 20 attempts, 200 ms apart, stops on 429, refuses an endpoint that answers without auth
vhost_discovery Host-header fuzzing against one in-scope IP; reports names whose status, byte count or title differs from the baseline, with evidence
http_brute Built-in, comma or file wordlist for hidden paths; 200/201/204/3xx/401/403 are hits, 100 ms apart, evidence for the first five 200s
ssrf_probe Injects a URL parameter pointing at its own loopback listener (or your callback_base) and confirms a real fetch; never targets metadata endpoints
jwt_audit Offline JWT audit: alg/typ/kid, iss/aud/sub/exp/iat/nbf, alg=none, expired, missing exp, path-like kid; HS256 signature verified with secret=
hash_id Identify a hash shape: MD5/NTLM, SHA-1/256/512, bcrypt, Argon2, crypt(3) formats, JWT
param_fuzz Marker, quote and {{1337*7}} per parameter; reports reflection, SQL/stack/template errors and template evaluation
open_redirect Sends an external marker URL and a protocol-relative variant; reports Location/meta-refresh redirects with evidence
host_header_injection Canary as Host and X-Forwarded-Host; reports reflection in body or Location, with baseline size
ssti_probe Five template payloads with expected results; reports evaluation, reflection or template errors and the likely engine
xxe_probe XML with an external entity pointing at its own loopback listener; callback proves the parser resolved it
ldap_probe LDAPv3 anonymous bind plus rootDSE read (namingContexts, vendorName, supportedLDAPVersion)
rdp_probe X.224 connection request; reports the selected protocol (RDP/TLS/CredSSP/RDSTLS) and NLA, or the failure code
smb_probe SMB2 NEGOTIATE with five dialects; reports dialect, signing, capabilities, max sizes and server GUID
vnc_probe RFB version and offered security types; flags None authentication
mqtt_probe MQTT 3.1.1 CONNECT without credentials; CONNACK code, anonymous broker detection
graphql_probe Introspection query: schema exposed, type count, query/mutation names, evidence
ftp_probe One FTP connection: banner, FEAT list, and whether the literal anonymous pair is accepted (audited)
smtp_probe One SMTP connection: banner, EHLO extensions, VRFY of up to 8 users classified exists/unknown/cannot-verify
ssh_audit Banner plus KEXINIT lists (kex, host key, ciphers, MACs) and deprecated algorithms flagged
tls_audit TLS 1.0–1.3 probes, negotiated ciphers, weak-version/cipher flags, certificate subject/issuer/dates/SANs
redis_probe PING/INFO/DBSIZE on one connection; reports open access, version, role, clients, dbsize
snmp_probe Hand-built SNMPv1/v2c GET sysDescr.0 over UDP for up to four communities; raw answer as evidence
dns_zone_transfer dig AXFR against one in-scope server and zone; record counts per type, raw records, evidence
mysql_probe Initial handshake: server version, thread id, auth plugin, capability flags (TLS, plugin auth)
postgres_probe SSL offer plus one StartupMessage; reports trust/cleartext/md5/SCRAM/rejected and the server message
mongo_probe Hand-built OP_QUERY isMaster on admin.$cmd: ok, maxWireVersion, writable primary
memcached_probe One stats: open access, version, connections, items, memory limit, uptime

Blue team

Tool What it does
hardening_audit Read-only local posture: sshd_config, sysctl, /etc/shadow mode, world-writable /etc dirs, listening sockets, firewall files, SUID count; scored findings
log_audit Auth-log summary: failures per IP (flagged at 5+), invalid users, accepted logins; paths limited to /var/log/ and the state dir
ioc_scan Walk a directory for /dev/tcp shells, bash -i, `base64
web_log_audit nginx/apache access log: status split, top IPs, scanner UAs, SQLi/traversal/XSS patterns (URL-decoded), 4xx/5xx bursts
detect_rules Sigma, Suricata and YARA skeletons per finding under $APEX_HOME/detections/; templates that need tuning
integrity_baseline SHA-256 manifest of a tree (create) and a changed/missing/added report (verify), no external tools
mitre_map Map findings to ATT&CK techniques by title/tool/tags/CWE, with finding ids per technique
process_snapshot Read /proc: exe/fd count per process, flags /tmp or deleted executables, reverse-shell command lines, >256 fds
persistence_audit Cron, systemd units/timers and at jobs: flags /tmp paths, curl/wget piped to a shell, base64-to-shell, nc -e/socat, bash -i, setuid chmod
net_baseline Listening TCP ports with owning process names (create/verify); reports new, gone and process-changed ports
ssh_key_audit authorized_keys and private keys: unrestricted entries, ssh-rsa/ssh-dss, duplicates, loose permissions
suid_baseline SUID/SGID SHA-256 manifest (create/verify); reports planted, removed and changed setuid binaries
cap_baseline File capability xattr manifest (create/verify); reports new, gone and changed capability sets

ESP32

Tool What it does
esp_info esptool chip_id on the serial port, plus USB VID/PID when sysfs exposes it
esp_monitor Read the console for N seconds; sends nothing
esp_read_flash Dump up to 4 MiB of flash into evidence/ with esptool read_flash
esp_flash esptool write_flash with mandatory confirm=true, absolute image, audited

Method

Tool What it does
method_techniques 11 techniques across recon/enum/web/creds/AD/wifi/report, filterable
method_playbook The ordered plan for a phase
method_tool When to use a tool and the mistake that wastes the engagement

The proxy

apex-twin --proxy 8798
curl -x http://127.0.0.1:8798 http://target.example/

Every request passes the scope gate before the origin socket is opened, and the decision is appended to audit.log. Plain HTTP is forwarded with the request line rewritten to origin form, and the exchange is stored through the same traffic store as http_capture. CONNECT is tunnelled blind and recorded as metadata only: this binary links no TLS stack, so it does not pretend to see inside TLS.

Each accepted connection gets its own child process: a tunnel does not block the next request, and parallel captures cannot overwrite each other (traffic ids are reserved with O_EXCL). At most APEX_PROXY_MAX_CHILDREN (default 64) children run at once; beyond that the parent answers 503 with proxy busy and audits the refusal.

Bodies: Content-Length and Transfer-Encoding: chunked are forwarded. A chunked body is validated against a 1 MiB payload cap and relayed unchanged; over the cap answers 413, malformed framing 400, both decided before the origin is opened. Captured responses are capped at 1 MiB and marked truncated.

Rewrite rules

$APEX_HOME/rewrite.json (APEX_REWRITE overrides) holds ordered rules:

{"rules": [
  {"match_host": "app.example.com", "match_path_prefix": "/api",
   "set": [{"name": "X-Test", "value": "1"}],
   "remove": ["User-Agent"], "note": "mark the request"},
  {"match_host": "*", "match_path_prefix": "/admin",
   "block": true, "note": "not part of this engagement"}
]}

The first matching rule is applied: block answers 403 with the note and a deny line in the audit; set replaces a client header and adds missing ones; remove drops one. The applied rule is named in the traffic record and audited. kill -HUP <pid> reloads the file; an invalid file is rejected whole and the previous rules stay active. The scope gate still runs first: a rule can narrow what the proxy does, never widen the engagement.


Findings, assets, traffic, reports

A finding starts open. finding_update moves it to confirmed, false-positive or fixed, changes severity, confidence, remediation or tags, and records why. Updates are written beside the old file and renamed, so a reader sees one version or the other and never half of either. finding_add is idempotent for the same target and title (case-insensitive, whitespace collapsed) and returns duplicate: true with the existing id.

An asset is one record per target: a second observation merges into it, unions the port list and replaces the service text with the latest reading.

A capture is a proof, not a memory: tNNNN.http holds the request bytes and the raw response, tNNNN.json the metadata.

report_markdown renders everything into one file:

  • Markdown — severity and lifecycle tables, one section per finding;
  • CSV — stable columns, quoted fields;
  • JSON — filters, counts by severity and status, the records themselves, and the inventory when include_assets is set.

Filters: exact target, min_severity, status. Reports are opened O_EXCL: a report is never overwritten. save: false renders without writing.


Notifications

APEX_WEBHOOK=https://hooks.example/apex \
APEX_WEBHOOK_MIN_SEVERITY=high \
apex-twin

A finding at or above the floor is POSTed as JSON after it is on disk, and so is the transition of a finding into confirmed. notify_test sends one event so the path can be proven before anyone relies on it. The webhook is operator infrastructure, not a target: it is not put through the scope gate, it is called with argv (no shell), and a failing webhook never fails the finding.


State directory

Everything lives under $APEX_HOME (default ~/.local/state/apex-twin), created 0700; files are 0600:

scope.json                 the rules of engagement
audit.log                  one JSON line per decision, append-only
audit.log.1                previous audit file after size rotation
findings/f0001.json        one finding per file
evidence/<ts>-<label>.bin  raw proof
reports/report-<ts>.md     Markdown / .csv / .json, never overwritten
assets/a0001.json          one record per target, merged on the next look
traffic/t0001.json         one capture: target, method, status, byte counts
traffic/t0001.http         the request and the raw response
rewrite.json               proxy rules (optional, reloaded on SIGHUP)

The audit line is written before the action, so a process that dies mid-scan still left its intent on disk. When audit.log reaches APEX_AUDIT_MAX_BYTES it is rotated to audit.log.1 under flock, one previous file kept. Audit lines are one write() each, so parallel proxy children cannot interleave them.

Back up audit.log, audit.log.1 and evidence/ before deleting a state directory; they may contain credentials, tokens or personal data from an engagement.


Security model

  • Loopback only. The HTTP face and the proxy bind 127.0.0.1 and have no authentication. Any local user who can reach the port can use the server within the loaded scope. Run it as a dedicated user on a host you control.
  • The scope file is trusted input. Writing it is equivalent to being the operator.
  • Audit before action. A missing audit line for a tool that touched the network is a bug worth reporting.
  • Target content is data. Responses are stored as bytes; the program does not execute target content.
  • No TLS interception. CONNECT is a blind tunnel, by design.
  • Memory safety is tested. Scope, rewrite, HTTP and proxy parsers run under ASan/UBSan in the suite and in three fuzzers; a sanitizer report is a test failure.

The full threat model, trust boundaries and a hardening checklist are in SECURITY.md.


Limits

Limit Value
HTTP MCP request body 8 MiB (413 over)
Proxy chunked request payload 1 MiB (413 over, malformed 400)
Proxy response per capture 1 MiB (marked truncated)
Concurrent proxy children APEX_PROXY_MAX_CHILDREN, default 64, 503 beyond
Concurrent HTTP MCP connections APEX_HTTP_MAX_CHILDREN, default 64
HTTP request deadline (head + body) APEX_HTTP_HEAD_TIMEOUT_MS, default 20000
Evidence blob APEX_EVIDENCE_MAX_BYTES, default 16 MiB
Audit file APEX_AUDIT_MAX_BYTES, default 10 MiB, rotates to .1
Findings per report 1024
Tool timeout default 60 s, hard cap 900 s
Radio scan 3–300 s, always ends with stopscan
Credential attempts 20 per call, 200 ms apart, stop on 429
IOC scan 20 000 files maximum, 100 findings, 1 MiB per file
Path brute force 200 paths per call, 100 ms apart
vhost discovery 100 names per call, 100 ms apart
Integrity baseline 1000 files per call (max 5000), 1 MiB per file
SSRF probe 3 loopback variants, 1.2 s callback wait
Service probes One connection each; SMTP VRFY at most 8 users
Persistence audit 2000 files per call, 1 MiB per file, 100 findings
TLS audit 4 protocol probes + 2 certificate runs per call
SNMP 4 communities, 2 attempts each, 1.8 s wait
Zone transfer one server, one in-scope zone, 30 s
Database probes one or two connections each; no password attempts
Param fuzz 10 parameters × 3 probes per call, 100 ms apart
Net baseline 500 ports; process lookup capped by /proc walk
SSTI 5 payloads per call, 100 ms apart
SSRF/XXE callbacks one loopback listener, 1.2 s wait per probe
RDP/SMB one connection and one negotiation each
SUID baseline 2000 entries; 1 MiB per file hashed
VNC/MQTT one connection and one handshake each
Capability baseline 2000 entries; security.capability xattr only

Build, test, release

Flags are fixed: -std=c99 -Wall -Wextra -Wpedantic -Werror plus -D_POSIX_C_SOURCE=200809L -D_DEFAULT_SOURCE.

make                # apex-twin
make test           # version check + gate audit + 593 end-to-end checks
make version-check  # the five places that carry a version must agree
make gate-audit     # static: every target-taking tool calls the gate
make asan           # apex-twin-asan with ASan + UBSan
make test-asan      # the whole suite against the sanitizer binary
make analyze        # gcc -fanalyzer over every translation unit
make coverage       # -O0 --coverage build, suite, per-file gcov report
make fuzz           # 240 mutated scope/rewrite/MCP inputs against the ASan binary
make fuzz-proxy     # 60 mutated raw requests against the ASan proxy
make fuzz-http      # 40 mutated raw requests against the ASan MCP HTTP face
make dist           # apex-twin-<version>.tar.gz: source, tests, docs, units
make distcheck      # build the tarball, unpack it, build and test it there
make release-check  # the whole gate, fail-fast (several minutes)
make install        # binary, docs, man page and both systemd units

The fuzzers have red proofs: make fuzz-red, make fuzz-proxy-red and make fuzz-http-red build deliberately broken binaries and fail if the harness reports them green. make fuzz-selftest compiles a real out-of-bounds program and requires the detector to flag it.

make release-check runs: version check → gate audit → suite → ASan/UBSan suite → -fanalyzer → all three fuzzers → distcheck. It takes several minutes and needs the network for the example.com checks; make test is the fast loop.

Every guarantee in this repository was seen failing before it was trusted: a report without its closing brace, a disabled status filter, a disabled asset merge, the old status_code() (which read the 1 of HTTP/1.1), a bypassed proxy gate, forced CORS/cookie flags, a disabled notification floor, a disabled rewrite matcher, a serial proxy, a missing connection cap, a missing HTTP deadline, a disabled evidence cap, a disabled audit rotation and a stale man page. README claims without a red test are treated as unfinished work.


Install

make install                            # /usr/local
make install DESTDIR=/tmp/pkg PREFIX=/usr

Installs:

$PREFIX/bin/apex-twin
$PREFIX/share/doc/apex-twin/{README,CHANGELOG,SECURITY,LICENSE,operations,artex-port}.md
$PREFIX/share/man/man1/apex-twin.1
$PREFIX/lib/systemd/system/apex-twin.service
$PREFIX/lib/systemd/system/apex-twin-proxy.service

The units hardcode User=lotherk and a state path under /home/lotherk/stack/data/apex-twin; edit them for another account. Secrets belong in ~/.config/apex-twin/env (the units read it when present), not in the unit file. The proxy unit is separate: an engagement box may want the MCP server without an open listener. Neither unit gets CAP_NET_RAW; connect scans need no privilege.


Environment

Variable Default Meaning
APEX_HOME ~/.local/state/apex-twin state directory
APEX_SCOPE $APEX_HOME/scope.json rules of engagement
APEX_REWRITE $APEX_HOME/rewrite.json proxy rewrite rules
APEX_SERIAL /dev/ttyACM0 Marauder tty
APEX_BAUD 115200 serial baud
APEX_DRY_RUN unset 1 prints commands instead of running them
APEX_DEFAULT_TIMEOUT_MS 60000 per-tool timeout
APEX_MAX_TIMEOUT_MS 900000 hard timeout cap
APEX_WEBHOOK unset URL POSTed on a finding at or above the floor
APEX_WEBHOOK_MIN_SEVERITY critical webhook floor
APEX_PROXY_MAX_CHILDREN 64 concurrent proxy connections before 503
APEX_HTTP_MAX_CHILDREN 64 concurrent MCP HTTP connections before 503
APEX_HTTP_HEAD_TIMEOUT_MS 20000 HTTP head/body deadline; 0 disables
APEX_AUDIT_MAX_BYTES 10485760 rotate audit.log to .1; 0 disables
APEX_EVIDENCE_MAX_BYTES 16777216 evidence_save cap; 0 unlimited

Source layout

src/apex.h          types, version, prototypes
src/config.c        $APEX_HOME, paths, environment defaults
src/scope.c         the gate: parse, match, expiry, DNS rule, JSON view
src/proc.c          fork/exec, timeout via process-group kill, output cap
src/store.c         audit log, findings, assets, evidence, traffic, rotation
src/guard.c         command guard: tokeniser, deny rules, target extraction
src/proxy.c         loopback forward proxy, CONNECT tunnel, chunked bodies
src/rewrite.c       rewrite rule file and matching
src/notify.c        webhook via curl (argv, no shell)
src/tools_recon.c   gated(), gated_cmd(), TCP helpers, recon + findings tools
src/tools_web.c     HTTP in-process, header audit, probes, capture
src/tools_radio.c   Marauder serial: guard, allowlist, scan-then-stop
src/tools_kb.c      technique and tool notes (data, not code)
src/tools_asset.c   inventory tools
src/tools_report.c  report renderers (Markdown, CSV, JSON)
src/tools_traffic.c traffic_list / traffic_read
src/tools_red.c     vuln_check, subdomain_enum, cred_test, vhost_discovery,
                    http_brute, ssrf_probe, jwt_audit, hash_id, param_fuzz,
                    open_redirect, host_header_injection, ssti_probe,
                    xxe_probe, ldap_probe, rdp_probe, smb_probe, vnc_probe,
                    mqtt_probe, graphql_probe
src/tools_blue.c    hardening_audit, log_audit, ioc_scan, web_log_audit,
                    detect_rules, integrity_baseline, mitre_map,
                    process_snapshot, persistence_audit, net_baseline,
                    ssh_key_audit, suid_baseline, cap_baseline
src/tools_esp.c     esp_info, esp_monitor, esp_read_flash, esp_flash
src/tools_proto.c   ftp_probe, smtp_probe, ssh_audit, tls_audit,
                    redis_probe, snmp_probe, dns_zone_transfer
src/tools_db.c      mysql_probe, postgres_probe, mongo_probe,
                    memcached_probe
src/sha256.c        SHA-256/HMAC for integrity_baseline and jwt_audit
src/tools_guard.c   guard_check
src/apex-twin.c     MCP stdio + HTTP face, --check, --version
vendor/libmcp/      header-only MCP transport (JSON-RPC, tools, HTTP body)
tests/              run.py, gate_audit.py, version_check.py, fuzzers, coverage
docs/               operations.md, artex-port.md, apex-twin.1 (man page)
systemd/            apex-twin.service, apex-twin-proxy.service
examples/           scope.json

Documentation

  • docs/operations.md — run book: install, state and backup, scope lifecycle, systemd, proxy and rewrite rules, webhook, upgrade, troubleshooting, limits.
  • docs/artex-port.md — what was ported from ARTEX and what was deliberately left out.
  • SECURITY.md — threat model, trust boundaries, hardening checklist.
  • CHANGELOG.md — every release with the commit that introduced it.
  • man apex-twin (source: docs/apex-twin.1) — modes, environment, scope rules, files and limits in one page.

Status

1.11.0. Built and run: 92 tools, 593 checks, 340 fuzz cases and 79.3% line coverage. The loop closes: a probe captures the exchange as a pair, a finding points at it, finding_update gives it a state, an asset records the host it came from, cors_check/cookie_audit/http_options turn a web answer into a graded lead, report_markdown turns findings and inventory into one Markdown, CSV or JSON file, and evidence_read/traffic_read get the proof back. --proxy puts the same gate in front of curl and a browser, serves connections in parallel, forwards chunked and Content-Length bodies, and takes rewrite rules that can set or remove a header or block a path; APEX_WEBHOOK wakes someone when the severity floor is crossed. The radio is tested against a PTY Marauder (firmware info, scans that end in stopscan, a login prompt that is refused, serial_tx gating). make install ships the binary, this README, the docs, the man page and both units; --check reports the operational state without starting a server. The whole suite also runs under ASan/UBSan, make analyze is clean, all three fuzzers reject a deliberately broken build, and make coverage keeps the gaps visible.

1.x is the first stable line: the gate invariant and the on-disk JSON formats (fields may be added, old files stay readable) are the compatibility promise. 1.1 added the red, blue and ESP32 tool groups; 1.2 added vhost discovery, wordlist path brute-forcing and access-log analysis; 1.3 added SSRF verification, detection-rule export, integrity baselines and firmware writing (confirm-gated); 1.4 added offline JWT/hash analysis, ATT&CK mapping and a /proc snapshot; 1.5 added FTP/SMTP/SSH service probes and a persistence audit; 1.6 added TLS, Redis, SNMP and DNS zone-transfer checks; 1.7 added MySQL, PostgreSQL, MongoDB and Memcached probes; 1.8 added parameter fuzzing, open redirect and Host-header checks plus a network baseline; 1.9 added SSTI, XXE and LDAP probes plus an SSH key audit; 1.10 added RDP and SMB negotiation checks and a SUID baseline; 1.11 added VNC, MQTT and GraphQL checks plus a file capability baseline, again without changing an existing tool or file format.

Not yet wired into a fleet router, and there is no TLS interception.


License

CNCL 1.1 — Could Not Care Less License.

No rights reserved. No obligations imposed. Use it, copy it, modify it, break it, fix it, sell it, give it away, keep your changes private, publish them, feed it to an AI, relicense it. No attribution, no royalties, no source disclosure, no conditions. The software is provided as is, without warranty.

The full text is in LICENSE. If you change that text, it is no longer CNCL.

ARTEX inspired the design; this C implementation is original work and is offered under CNCL. The vendored libmcp transport is part of this tree.

S
Description
Scope-gated offensive-security MCP server in C99/POSIX
Readme
33 MiB
0 Stars 3 Watchers 0 Forks
Languages
C 68.5%
Python 31.3%
Makefile 0.2%