# 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. **427 tools · 1637 end-to-end checks · 240 fuzz cases · 84.7% line coverage · ~1402 KiB** ``` $ ./apex-twin --check {"version":"1.100.0","tools":427,...,"scope":{"loaded":true,...}} ``` APEX TWIN was inspired by [ARTEX](https://github.com/Autumn-27/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. **Exploit framework** (`exploit_modules`, `exploit_info`, `exploit_check`, `exploit_run`, `payload_list`, `payload_build`): eleven modules — shellshock, log4shell, Struts2 S2-045, Tomcat PUT, Redis CONFIG SET write, OS command injection, Apache CVE-2021-41773/42013 traversal, Jenkins script console, WebLogic console CVE-2020-14882, CouchDB admin party, Spring Boot Actuator `/env` — each with a `check` that proves itself with its own marker and a `run` that carries the operator's command, script, content, file name, console handle or config value. A write is only reported as confirmed when it can be read back; a status code alone is not proof. `payload_build` renders and encodes the operator's payload. A confirmed hit writes evidence, a finding and an audit line before it acts. The gate decides the target; the operator decides everything else. 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`: ```c 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 ```sh 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: ```json {"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 (427) ### 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 / ` 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 | | `http_redirect_audit` | Follows redirects per hop inside the scope; flags HTTPS-to-HTTP downgrades | | `hsts_audit` | HSTS max-age, includeSubDomains and preload, or a missing header | | `tls_hostname_check` | SAN/CN wildcard match for the requested SNI name | | `ftp_tls_probe` | `AUTH TLS` -> 234 means explicit FTPS; otherwise cleartext | | `zookeeper_4lw_probe` | `stat`/`mntr` answered without auth leaks version and state | | `etcd_api_probe` | `/version`, `/health`, `/v2/keys` without a token; 2xx is open access | | `docker_registry_probe` | `/v2/` and `/v2/_catalog` without auth; catalog saved as evidence | | `consul_api_probe` | `/v1/agent/self` and `/v1/catalog/services` without a token | | `couchdb_probe` | `/` welcome and `/_all_dbs` without auth; database list as evidence | | `prometheus_api_probe` | `/-/ready` and `/api/v1/query` without auth; query answer as evidence | | `rabbitmq_management_probe` | `/api/overview` and `/api/queues` without auth; overview as evidence | | `grafana_api_probe` | `/api/datasources` and `/api/admin/users` without auth; datasources as evidence | | `minio_admin_probe` | `/minio/admin/v3/info` without a signature; admin answer as evidence | | `nats_monitoring_probe` | `/varz` and `/connz` without auth; varz answer as evidence | | `influxdb_probe` | `/ping` and `/query?q=SHOW DATABASES` without auth; answer as evidence | | `clickhouse_probe` | `/ping` and `SELECT version()` without auth; version as evidence | | `kibana_api_probe` | `/api/saved_objects/_find` without auth; answer as evidence | | `logstash_api_probe` | `/_node/info` and `/_node/stats` without auth; stats as evidence | | `amqp_probe` | AMQP 0-9-1 Connection.Start: product, version, mechanisms, no login | | `tls_chain_probe` | Counts presented certs; a lone non-self-signed leaf means a missing intermediate | | `smtp_auth_probe` | EHLO AUTH mechanisms; PLAIN/LOGIN without STARTTLS is a clear-text risk | | `jenkins_api_probe` | `/api/json` and `/whoAmI` without auth; job list as evidence | | `nexus_probe` | `/service/rest/v1/repositories` without auth; list as evidence | | `gitea_api_probe` | `/api/v1/admin/users` without auth; admin list as evidence | | `harbor_probe` | `/api/v2.0/projects` without auth; project list as evidence | | `portainer_probe` | `/api/status` and `/api/users/admin/check`; setup-open or unauth admin check | | `argocd_probe` | `/api/v1/applications` without a token; deployed apps as evidence | | `kafka_connect_probe` | `/connectors` on 8083 without auth; connector list as evidence | | `sonarqube_probe` | `/api/projects/search` on 9000 without auth; project list as evidence | | `keycloak_probe` | `/realms/master` on 8080: open self-registration; realm JSON as evidence | | `rundeck_probe` | `/api/14/projects` without a token; project list as evidence | | `zabbix_probe` | `user.login` with the default Admin/zabbix pair; response as evidence | | `datasette_probe` | `/-/databases.json` without a token; database list as evidence | | `vault_probe` | `/v1/sys/mounts` on 8200 without a token; mount list as evidence | | `nomad_probe` | `/v1/jobs` on 4646 without a token; job inventory as evidence | | `coredns_probe` | plugin API `/config/` on 2019 without a token; server blocks as evidence | | `openbmc_probe` | xyz.openbmc_project control tree on 443 without a session; power policy as evidence | | `schema_registry_probe` | `/subjects` on 8081 without auth; subject list as evidence | | `airflow_probe` | `/api/v1/dags` without auth; DAG inventory as evidence | | `loki_probe` | `/loki/api/v1/labels` on 3100 without auth; label names as evidence | | `tempo_probe` | `/api/search/tags` on 3200 without auth; tag names as evidence | | `jaeger_probe` | `/api/services` on 16686 without auth; service list as evidence | | `solr_probe` | `/solr/admin/cores` on 8983 without auth; core list as evidence | | `confluence_probe` | `/rest/api/space` on 8090 without a token; space list as evidence | | `bitbucket_probe` | `/rest/api/1.0/projects` on 7990 without a token; project list as evidence | | `jupyter_probe` | `/api/kernels` on 8888 without a token; sessions as evidence | | `jira_probe` | `/rest/api/2/project` on 8080 without auth; project list as evidence | | `ollama_probe` | `/api/tags` on 11434 without auth; pulled model list as evidence | | `cadvisor_probe` | `/api/v1/containers` on 8080 without auth; container list as evidence | | `teamcity_probe` | `/app/rest/projects` and `/app/rest/users` without auth; project and user list as evidence | | `superset_probe` | `/api/v1/dashboard/` on 8088 without a session; dashboard list as evidence | | `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 | | `auth_test` | Real login attempts against one in-scope service: http, ftp, smtp, imap, pop3, mysql. Your wordlists, your delay, your attempt ceiling, your stop conditions; a hit is the protocol's own accept code, saved as evidence and recorded as a finding | | `auth_plan` | Count a credential run (pairs, delay total) without connecting | | `auth_protocols` | The protocols `auth_test` speaks and their default ports | | `auth_hits` | The credential findings so far, with the evidence file that holds the pair | | `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 | | `docker_api_probe` | Unauthenticated `/version` and `/containers/json`: engine version, container/running counts, names, images | | `elasticsearch_probe` | Unauthenticated `/`, cluster health and index list: cluster, version, status, node and index counts | | `http_methods` | OPTIONS Allow list and TRACE echo detection; names PUT/DELETE but never sends them | | `websocket_probe` | Upgrade handshake: 101, Upgrade/Connection and Sec-WebSocket-Accept | | `websocket_origin_check` | Two unrelated Origins; both 101 means Origin is not enforced (CSWSH) | | `dns_fcrdns_check` | PTR then A/AAAA; a forward answer without the address fails FCrDNS | | `dns_soa_mname_check` | SOA MNAME must be one of the zone's NS records | | `ike_probe` | IKEv2 SA_INIT (AES-CBC-128/HMAC-SHA2-256/DH14); version, exchange, notify, responder SPI | | `snmp_walk` | GETNEXT over the system group: OID, name and decoded value (string, integer, timeticks, OID) | | `ldap_search` | Anonymous subtree search (size limit 20) from namingContexts; DNs plus cn/uid/mail | | `openapi_discovery` | Six usual spec paths: OpenAPI/Swagger version, title and path count, evidence | | `csrf_audit` | Forms on one page: action, method, input count and missing CSRF token fields | | `rpc_probe` | ONC RPC portmapper DUMP: program/version/protocol/port mappings with service names | | `ntp_probe` | NTPv4 client packet: version, mode, leap, stratum, refid, root delay/dispersion, time | | `api_auth_audit` | Unauthenticated GETs over an endpoint list: status, JSON, open vs 401/403, evidence | | `cache_audit` | Clean vs parameterized URL: Cache-Control/Age/Vary/X-Cache, parameterized-cacheable finding | | `tls_cipher_matrix` | Weak cipher list per TLS version; reports which suites negotiate | | `smb_null_session` | SMB 2.1 negotiate, anonymous session, IPC$ tree connect | | `smb_shares` | Share-name dictionary over the anonymous session; reports reachable shares and NT status | | `email_security_audit` | SPF, DMARC, DKIM and MX via gated dig; policy and gaps | | `smtp_open_relay` | EHLO/MAIL/RCPT for an external recipient; open relay detection, no DATA | | `dns_open_resolver` | One recursive query against an in-scope resolver; answer means open | | `crlf_probe` | Encoded CRLF in one parameter; detects an injected response header | | `dns_version_bind` | CHAOS TXT version.bind/hostname.bind; reports version disclosure | | `ntp_monlist_probe` | Mode-7 MON_GETLIST; monlist enabled, entry estimate, amplification | | `oidc_discovery` | OpenID/OAuth metadata: issuer, auth/token/JWKS/userinfo endpoints, evidence | | `security_txt` | security.txt Contact/Expires/Policy; expired documents flagged | | `http2_probe` | ALPN h2 over TLS or h2c preface/SETTINGS; reports HTTP/2 support | | `ssh_hostkey_fingerprint` | ssh-keyscan or saved output: key type, bits, SHA-256 fingerprint | | `kerberos_discovery` | DNS SRV for _kerberos._tcp/_udp and _kpasswd._tcp: KDC priority/weight/port/target | | `winrm_probe` | GET /wsman: 401/405 with Negotiate/NTLM/Kerberos identifies WinRM; evidence on hit | | `dnssec_check` | DNSKEY/DS with +dnssec: signed, algorithm, key bits; flags unsigned/RSASHA1/short keys | | `smtp_starttls_probe` | EHLO/STARTTLS and a real TLS upgrade via openssl s_client -starttls smtp | | `tls_ocsp_probe` | `s_client -status`: stapled or not, OCSP response and certificate status | | `alpn_probe` | Per-protocol `s_client -alpn`: which of h2/http1.1/spdy3.1 the server selects | | `webdav_probe` | OPTIONS + Depth:0 PROPFIND: 207 Multistatus means WebDAV is enabled | | `dns_wildcard_check` | Random label under a domain; an answer means wildcard DNS | | `dns_caa_check` | CAA records: flags, issue/issuewild/iodef tags and values | | `sni_vhost_check` | Per-name `s_client -servername`: distinct certificate subjects/fingerprints | | `tls_client_auth_probe` | `s_client -msg`: CertificateRequest means mutual TLS required | | `kubernetes_api_probe` | Unauthenticated `/version`, `/api`, `/apis`, `/healthz`; 2xx is open access | | `dns_ns_consistency` | Parent vs authoritative NS sets; reports names missing on either side | | `dns_dangling_cname` | Follows a CNAME chain; NXDOMAIN at the end means a takeover target | | `imap_probe` | Banner, CAPABILITY list, STARTTLS and LOGINDISABLED; no LOGIN | | `pop3_probe` | Banner, CAPA list, STLS flag; no USER/PASS | | `sip_probe` | One UDP OPTIONS: status line, Server header, Allow methods | | `telnet_probe` | Banner plus IAC WILL/WONT/DO/DONT decoding; sends nothing | | `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 | | `cassandra_probe` | CQL native protocol on 9042: OPTIONS/SUPPORTED, then STARTUP; READY means no authentication | ### Exploit framework | Tool | What it does | |---|---| | `exploit_modules` | The module registry: id, CVE, platform, kind, severity, CWE, default port, the run parameters and the count | | `exploit_info` | One module in full: summary, what `run` takes, remediation | | `exploit_check` | Proves the vulnerability with a marker this process generates; a confirmed hit saves evidence, writes a finding and records an audit line | | `exploit_run` | Carries what the operator supplies: a command, a script, a file, a file name, a console handle, a config value. A write is confirmed only when it reads back. Same evidence and finding path | | `payload_list` | Every payload template and every encoder with its exact text | | `payload_build` | Renders a template with `lhost`/`lport`/`command` and encodes it (raw, url, url2, b64, b64url, hex, octal, html, unicode, charcodes, json) | Modules: `shellshock` (CVE-2014-6271), `log4shell` (CVE-2021-44228), `struts2_s2045` (CVE-2017-5638), `tomcat_put` (CVE-2017-12617), `redis_write` (CVE-2022-0543), `cmd_inject`, `traversal` (CVE-2021-41773/42013), `jenkins_script`. The gate decides the target; the operator decides everything else. ### Authentication testing `auth_test` tries credentials against one in-scope service. Protocols: `http` (Basic), `ftp`, `smtp` (AUTH LOGIN), `imap`, `pop3` and `mysql` (`mysql_native_password`, scrambled the way the server expects). You supply the users and passwords — inline as a comma list or as a file with one entry per line — and every knob of the run: | Parameter | Meaning | |---|---| | `users` / `userlist` | comma list, or a file with one user per line | | `passwords` / `passlist` | the same for passwords | | `delay_ms` | pause between attempts, default 0 | | `max_attempts` | hard ceiling, default all pairs | | `stop_on_hit` | stop at the first accepted pair | | `lockout_limit` | consecutive rate-limit answers that end the run; 0 disables | | `timeout_ms` | per connection, default 10000 | A hit is the protocol saying so: 235, `+OK`, 230, `a1 OK`, a MySQL OK packet, or an HTTP 2xx/3xx. Anything else is a miss — including a 404 or a 500, which say nothing about credentials — and a connection that dies is counted as an error rather than as a refused password. An accepted pair becomes a `critical` finding whose evidence file holds the pair and the answer it got; the audit log records the account and the service but never the password, so the log can be shared and the evidence cannot. `auth_plan` counts a run before it happens (pairs, delay total, first users) without connecting. `auth_protocols` lists the protocols and default ports. `auth_hits` shows the credential findings so far with their evidence paths. ### External scanners (gated wrappers) | Tool | What it does | |---|---| | `nuclei_scan` | Template scan of one in-scope URL; `-jsonl` output saved as evidence | | `nikto_scan` | Web server scan of one in-scope host; the report is evidence | | `ffuf_scan` | Content discovery with a wordlist the operator already has | | `gobuster_scan` | Directory, DNS or vhost brute force with an existing wordlist | | `sqlmap_scan` | SQL injection verification in `--batch`; no shell, no file read | | `hydra_scan` | Login testing against one in-scope service; a hit is a finding with the tool's own output as evidence | | `medusa_scan` | Same for medusa; `[SUCCESS]` or exit 1/2 is the hit, the raw output is the evidence | | `msfvenom_build` | Renders the operator's payload locally (no target); the bytes are saved as evidence | Every wrapper follows the same three rules: the target goes through `gated_run()` so the scope gate and the audit line happen **before** anything executes; each argument is checked against a per-tool allowlist and a flag that is not on it is refused rather than passed through; and there is no shell — argv is built in C and handed to `exec`, so no string is ever parsed by `/bin/sh`. A missing binary is a plain sentence from `apex_have()`, not exit 127 in the middle of a scan. Three flags are refused on purpose, and not for taste: hydra `-M`, medusa `-H`/`-C` and hydra/medusa host files read their targets out of a file the gate never sees, so the gate would be checking one host while the tool walks another. Those stay out until the file is parsed and each entry checked. The msfvenom mode switches (`-l`, `--list`, `--help`, `--refresh-cache`) are out for a different reason: they print and exit without building anything, and the tool would then report a payload it never rendered. ### 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|sh`, `curl|sh`, `nc -e`, `socat EXEC:`, setuid chmod, systemd units under `/tmp` | | `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 | | `module_audit` | Loaded modules and taint letters, kernel taint bits decoded (proprietary, out-of-tree, unsigned, ...) | | `package_integrity` | `dpkg -V` / `rpm -V` changed files, optionally one package or a saved verify output | | `mount_audit` | Mount table hardening: temp/shm mounts missing nosuid/nodev/noexec, home/media/mnt missing nosuid/nodev | | `firewall_audit` | `nft list ruleset` / `iptables-save` (or saved dump): chain/rule counts and ACCEPT default policies | | `systemd_audit` | Units: ExecStart in /tmp, missing User= (root), world-writable files, .wants links | | `kernel_hardening` | Sysctl hardening set (ASLR, kptr, dmesg, perf, BPF, ptrace, symlinks, core_pattern) with score | | `sudoers_audit` | NOPASSWD, !authenticate, broad ALL, direct user rules, world-writable sudoers | | `auditd_audit` | auditd type counts, AVC denials, failed auth, top exe paths and keys | | `ssh_config_audit` | sshd_config scoring: root login, passwords, tunnels, forwardings, legacy ciphers/MACs/kex | | `pam_audit` | pam.d: pam_permit, pam_unix nullok, pam_exec and missing faillock/tally lockout | | `log_timeline` | Merge auth and access logs into one sorted chronology with source tags | | `docker_audit` | docker.sock mode, docker group members, daemon.json TCP/TLS/insecure registries | | `www_audit` | Web roots: world-writable content, .env/config/keys, backups, .git, missing index | | `apparmor_audit` | Profile list: enforce/complain counts, complain profiles named | | `selinux_audit` | enforce, SELINUX=/SELINUXTYPE=, boolean count; disabled/permissive findings | | `audit_rules` | audit.rules/rules.d: rule count, -e 2, execve, watches on passwd/shadow/sudoers/group | | `usb_audit` | sysfs USB devices: IDs, strings, serial, mass-storage interface flagged | | `ssh_known_hosts_audit` | known_hosts: hashed vs plain, ssh-rsa/ssh-dss, duplicates | | `logrotate_audit` | logrotate configs: world-writable, low rotate, no compress, unsafe postrotate | | `nfs_exports_audit` | exports/`: *`, writable (no ro), no_root_squash | | `samba_audit` | smb.conf shares: root path, guest access, writable, no valid users | | `snmpd_audit` | snmpd.conf communities: ro/rw/com2sec, public/private, default source | | `rsyslog_audit` | rsyslog remote targets, world-writable configs, missing auth logging | | `postfix_audit` | main.cf: mynetworks all-addresses, relay without reject_unauth_destination, optional TLS, writable config | | `nginx_audit` | nginx.conf/conf.d/sites-enabled: server_tokens, autoindex, TLSv1/1.1, legacy ciphers, writable files | | `redis_config_audit` | redis.conf: no requirepass, protected-mode no, bind-all, debug command, /tmp data dir | | `mysql_config_audit` | my.cnf: bind-all, skip-grant-tables, local-infile, empty secure-file-priv, writable files | | `apache_audit` | Apache: ServerTokens Full/OS, Options Indexes, AllowOverride All, SSLv3/TLSv1, signature | | `haproxy_audit` | haproxy.cfg: stats socket mode, stats auth, bind 443 without ssl, writable config | | `php_config_audit` | php.ini: expose_php, display_errors, URL include/fopen, disable_functions, cookie_secure | | `dovecot_audit` | dovecot.conf: ssl = no, plaintext auth, PLAIN mechanism, writable drop-ins | | `openvpn_audit` | server.conf: no tls-auth/tls-crypt, BF-CBC/DES, SHA1/MD5 HMAC, duplicate-cn | | `postgresql_config_audit` | postgresql.conf/pg_hba.conf: listen-all, ssl off, trust, md5/password | | `exim_audit` | exim.conf: relay_from_hosts all, accept-any, no TLS advertisement, writable config | | `elasticsearch_config_audit` | elasticsearch.yml: network.host all, security disabled, single-node | | `squid_audit` | squid.conf: http_access allow all, open http_port, cache in /tmp, writable config | | `unbound_audit` | unbound.conf: interface all, access-control allow all, missing DNSSEC anchor | | `cups_audit` | cupsd.conf: Listen all, Browsing On, Location Allow All, writable config | | `rsync_audit` | rsyncd.conf: wildcard hosts allow, uid/gid 0, no chroot, readable secrets | | `dhcpd_audit` | dhcpd.conf: authoritative, weak ddns, missing DNS option, range outside subnet | | `krb5_conf_audit` | krb5.conf: DNS lookup off, rdns on, legacy enctypes, writable config | | `mongodb_config_audit` | mongod.conf: bindIp all, authorization off, TLS disabled | | `memcached_config_audit` | memcached.conf: listen all, UDP enabled (no -U 0), 8 GiB+ memory | | `ntpd_config_audit` | ntp.conf: weak/missing restrict, no disable monitor, drift in /tmp | | `bind9_config_audit` | named.conf: allow-query any, open recursion, transfer any, visible version | | `tomcat_audit` | server.xml/tomcat-users.xml: shutdown port, 0.0.0.0 connector, manager roles | | `proftpd_audit` | proftpd.conf: AllowAll, anonymous without AnonReadOnly, RootLogin, TLS off | | `kubelet_config_audit` | kubelet config.yaml: anonymous auth, AlwaysAllow, readOnlyPort | | `etcd_config_audit` | etcd config: 0.0.0.0/http URLs, client/peer cert auth off, auto-tls | | `rabbitmq_audit` | rabbitmq.conf: loopback removed, guest/guest, management without TLS | | `consul_config_audit` | consul.hcl: ACL allow, bind 0.0.0.0, verify flags off, no gossip encryption | | `vault_config_audit` | vault.hcl: tls_disable, UI on, mlock off, Shamir without auto-unseal | | `zookeeper_audit` | zoo.cfg: open 4lw whitelist, clientPortAddress all, missing authProvider | | `grafana_audit` | grafana.ini: anonymous access, default admin password, plain HTTP, default secret | | `prometheus_audit` | prometheus.yml/web.yml: no basic auth, no external labels, HTTP targets | | `wireguard_config_audit` | wg conf: readable private key, 0.0.0.0/0 route, no ListenPort, curl pipe hooks | | `ipsec_config_audit` | ipsec.conf/secrets: 0.0.0.0/0 subnet, PSK auth, no leftid, readable secrets | | `openldap_config_audit` | slapd.conf: cleartext rootpw, anonymous bind, default read access | | `cron_audit` | crontabs and cron.d: writable files/dirs, `curl \| sh` jobs | | `fail2ban_audit` | jail.local/conf: disabled sshd jail, ignore-all, maxretry 0, no banaction | | `chrony_config_audit` | chrony.conf: allow all, open command port, world-writable | | `apt_config_audit` | apt.conf.d/sources: unsigned, insecure, trusted=yes, plain HTTP | | `login_defs_audit` | login.defs: aging, PASS_MIN_DAYS 0, loose UMASK, DES/MD5 | | `pg_hba_audit` | pg_hba.conf: `trust`, `0.0.0.0/0`, world-writable | | `polkit_audit` | rules.d/pkla: `polkit.Result.YES`, `ResultAny=yes` | | `ldap_client_audit` | ldap.conf: plaintext `ldap://` URI, `TLS_REQCERT never` | | `ssl_cert_audit` | /etc/ssl/certs: expired, SHA-1, weak key, non-critical CA | | `timesyncd_audit` | timesyncd.conf: no servers, public fallback, lax polling | | `resolv_conf_audit` | resolv.conf: no/single/public nameserver, no search domain | | `journald_audit` | journald.conf: volatile storage, forwarding, size, sealing | | `coredump_audit` | coredump.conf: disk storage keeps cores, no compression | | `nftables_audit` | nftables: accept policy, no conntrack, exposed admin ports | | `dnsmasq_audit` | dnsmasq.conf: wildcard listener, missing bogus-priv/domain-needed | | `nsswitch_audit` | nsswitch.conf: NIS compat, direct LDAP, hosts without files | | `jenkins_audit` | config.xml: security off, AnyoneCanDoAnything, no CSRF, fixed agent port | | `pgbouncer_audit` | pgbouncer.ini: trust auth, wildcard listen, readable auth file | | `xinetd_audit` | xinetd: telnet/ftp/rsh enabled, no only_from, service as root | | `sssd_audit` | sssd.conf: enumerate, cache_credentials, StartTLS off, reqcert never | | `avahi_audit` | avahi-daemon.conf: workstation/address publication, no interface limit | | `logind_audit` | logind.conf: idle ignore, lid ignore, IdleActionSec=0 | | `tftpd_hpa_audit` | tftpd-hpa: `--create`, missing `--secure`, root directory | | `iscsi_audit` | iscsid.conf: auto startup, no session/discovery CHAP | | `rpcbind_audit` | rpcbind: `-w`, `-i`, no `-l` bind address | | `kdump_audit` | kdump: remote target, no `-c`, shell/dump_to_rootfs action | | `kafka_audit` | server.properties: PLAINTEXT listener, no authorizer, auto topics | | `powerdns_audit` | pdns/recursor: open recursor, webserver, API key in the file | | `varnish_audit` | VCL: open `acl purge`, management on 0.0.0.0 | | `freeradius_audit` | clients.conf/users: default secret, no message authenticator | | `containerd_audit` | config.toml: TCP gRPC without TLS, unpinned sandbox image | | `nats_audit` | nats-server.conf: no authorization/TLS, open monitoring port | | `caddy_audit` | Caddyfile: `:80`, auto_https off, tls internal, exposed admin | | `traefik_audit` | traefik.yml: api insecure, no redirect, no TLS | | `autofs_audit` | auto.master: wildcard maps, writable maps, timeout=0 | | `gitea_audit` | app.ini: HTTP, open installer, empty SECRET_KEY | | `minio_audit` | minio defaults: default root credentials, browser, HTTP | | `nextcloud_audit` | config.php: debug, wildcard domain, HTTP, writable data | | `zabbix_audit` | agent: any Server, remote commands, no TLS, unsafe UserParameter | | `nrpe_audit` | nrpe.cfg: any allowed host, dont_blame_nrpe, shell commands | | `unattended_upgrades_audit` | security-only origins, no auto reboot, no mail | | `gitlab_audit` | gitlab.rb: HTTP URL, no redirect, open signup | | `vaultwarden_audit` | env: open signups, default admin token, HTTP domain | | `keepalived_audit` | VRRP: `auth_type PASS`, default password, shell notify | | `webmin_audit` | miniserv.conf: ssl=0, wildcard allow, weak password | | `cockpit_audit` | cockpit.conf: AllowUnencrypted, missing Origins | | `phpmyadmin_audit` | config.inc.php: empty blowfish secret, config auth | | `kibana_audit` | kibana.yml: 0.0.0.0, xpack off, credentials in file | | `nagios_audit` | nagios.cfg/cgi.cfg: external commands, no SSL, CGI wildcard | | `synapse_audit` | homeserver.yaml: open registration, no TLS | | `logstash_audit` | logstash.yml: API on 0.0.0.0, monitoring off, no path.data | | `filebeat_audit` | filebeat.yml: HTTP output, verification none, credentials | | `fluentd_audit` | forward without shared key, HTTP output without TLS | | `telegraf_audit` | HTTP output, insecure_skip_verify, credentials in file | | `graylog_audit` | REST on 0.0.0.0, short password_secret, empty root hash | | `netdata_audit` | bind 0.0.0.0, allow list `*`, missing allow list | | `sshd_config_audit` | sshd_config(.d): root login, password auth, empty passwords | | `hosts_access_audit` | hosts.allow/deny: `ALL: ALL`, missing deny rules | | `profile_audit` | profile scripts: world-writable, loose umask, `.` in PATH | | `atd_audit` | at.allow/deny: empty deny list, world-writable lists | | `securetty_audit` | securetty: serial/console entries allow root login | | `tmpfiles_audit` | tmpfiles.d: 0777/0666 modes, z/Z rules on /tmp | | `compose_audit` | compose: privileged, host namespaces, docker socket, secrets | | `k8s_manifest_audit` | manifest: privileged, host namespaces, root, hostPath / | | `dockerfile_audit` | Dockerfile: root USER, :latest base, remote ADD, curl pipe | | `openssl_cnf_audit` | openssl.cnf: MinProtocol TLSv1, SECLEVEL 0/1 | | `curlrc_audit` | /etc/curlrc: `insecure`, plain-HTTP proxy | | `wgetrc_audit` | /etc/wgetrc: `check_certificate=off`, plain proxy | | `resolved_audit` | resolved.conf: public DNS, DNSSEC/DoT off, LLMNR/mDNS on | | `udev_audit` | udev rules: MODE 0666, `RUN+=` downloads piped to a shell | | `issue_audit` | /etc/issue: `\r`/`\v` version disclosure | | `usbguard_audit` | allow without with-interface, implicit allow policy | | `certbot_audit` | renewal: manual authenticator, curl-pipe hook | | `wpa_supplicant_audit` | key_mgmt=NONE, WEP, readable PSK | | `bluetooth_audit` | main.conf: auto enable, privacy off, JustWorks always | | `networkmanager_audit` | connections: WEP, readable PSK, 802.1X without CA | | `dbus_audit` | policy: `own="*"` and `send_destination="*"` | | `passwd_audit` | duplicate UID 0, empty shadow hash, system login shells | | `authorized_keys_audit` | writable keys/dirs, `command=` download pipes | | `ld_preload_audit` | non-empty preload list, writable library | | `gitconfig_audit` | gitconfig: sslVerify off, HTTP rewrite, store helper | | `npmrc_audit` | npmrc: strict-ssl off, HTTP registry, cleartext token | | `pip_conf_audit` | pip.conf: HTTP index, trusted-host override | | `pam_env_audit` | environment/pam_env.conf: global LD_PRELOAD, writable PATH | | `hosts_audit` | hosts: private pin, conflicting addresses, writable file | | `dnf_repo_audit` | dnf/yum repos: gpgcheck off, sslverify off, plain http | | `anacrontab_audit` | anacrontab and cron.d: root job out of /tmp, download piped to a shell | | `motd_audit` | update-motd.d: writable script, missing shebang, URL fetch at login | | `syslog_ng_audit` | syslog-ng: network source on all addresses, plaintext | | `ntpd_audit` | ntp.conf: no default restrict, open restricts, monitor on | | `inetd_audit` | inetd.conf: shell services, legacy cleartext daemons, writable file | | `ld_so_conf_audit` | ld.so.conf: user-writable library path, world-writable dir | | `rc_local_audit` | rc.local: remote pipe, /tmp reference, missing exit | | `opendkim_audit` | opendkim.conf: inet socket, RequireSafeKeys off, Mode without `s` | | `rspamd_audit` | rspamd UCL: wildcard bind_socket, clear-text password, secure_ip 0.0.0.0/0 | | `spamassassin_audit` | local.cf: `required_score 0`, `report_safe 0`, RBL skipped, dead rule | | `opendmarc_audit` | opendmarc.conf: `RejectFailures` off, reports off, auth clients skipped | | `amavis_audit` | amavisd.conf: virus/spam `D_PASS`, bypass flags, no virus admin | | `crypttab_audit` | crypttab: readable key file, `none` key, discard | | `useradd_audit` | useradd defaults: empty INACTIVE, bad SHELL, writable skel | | `aide_audit` | AIDE: `!` on /etc or /bin, md5-only rules, db in /tmp | | `ufw_audit` | ufw: disabled, default ACCEPT, an open ACCEPT on a service port, writable rules | | `monit_audit` | monitrc: public httpd, plain `allow user:pw`, writable config | | `clamav_audit` | clamd/freshclam: public TCPSocket, exec hooks, LogRotate off | | `modules_load_audit` | module lists: CIS-disabled modules, invalid names, duplicates | | `depmod_audit` | depmod.d: absolute path first in `search`, `override` lines | | `adduser_conf_audit` | adduser.conf: loose `DIR_MODE`, `USERGROUPS=no`, unlisted shell | | `nfs_conf_audit` | nfs.conf: `vers2`/`vers3`, mountd `insecure`, `Sec=sys` only | | `idmapd_audit` | idmapd.conf: no `Domain`, Nobody-User is a real account | | `netplan_audit` | netplan: DNS without `dnssec`, interface without address source | | `apt_auth_audit` | apt auth.conf: credentials over plain HTTP, world-readable/writable file | | `aliases_audit` | aliases: mail piped into a command, root mail forwarded to another account | | `netgroup_audit` | netgroup: member with an empty host field (matches any host) | | `php_fpm_audit` | PHP-FPM pools: user root, `listen.mode` 0666/777, display_errors, allow_url_include | | `uwsgi_audit` | uWSGI ini: uid/gid 0, `chmod-socket` 666/777, `chdir = /`, master off | | `lighttpd_audit` | lighttpd.conf: document-root `/`, ssl.engine off, dir-listing, runs as root | | `jetty_audit` | jetty.xml + start.d: connector on 0.0.0.0 without TLS, literal password, MD5 | | `dhclient_audit` | dhclient.conf + hooks: DHCP resolver, supersede override, writable hook | | `journal_upload_audit` | journal-upload.conf: plain http URL, missing client key | | `fwupd_audit` | fwupd daemon.conf: OnlyTrusted off, empty DisabledPlugins | | `smartd_audit` | smartd.conf: device without `-m`, writable `-M exec` hook, untyped DEVICESCAN | | `tlog_audit` | tlog: scope without `session`, notice without `wall`, missing log target | | `abrt_audit` | abrt.conf: autoreporting, public collector URL, no TLS verify | | `freshclam_audit` | freshclam.conf: UpdateChecks off, http mirror, Checks below 2 | | `fapolicyd_audit` | fapolicyd: permissive = 1, integrity = none, allow-all before deny | | `systemd_timer_audit` | timers: every-minute interval, Persistent, service without User= | | `yara_audit` | YARA: scanning disabled, writable or empty rule file | | `suricata_audit` | suricata.yaml: empty rule-files, disabled engine, world-writable rules | | `icinga2_audit` | API bound beyond localhost, accept_config, run_as_root commands, writable config | | `falco_audit` | no rules_file, debug threshold, http webhook, writable rules | | `promtail_audit` | positions in /tmp or missing, no tenant_id, http client URL, writable config | | `otel_collector_audit` | exporters without tls, debug exporter, zpages/pprof, writable config | | `fluentbit_audit` | remote output without `tls On`, HTTP on any interface, debug level, writable config | | `vector_audit` | source on `0.0.0.0`, sink without tls, GraphQL API beyond loopback, writable config | | `seccomp_audit` | empty or only-negating `SystemCallFilter`, root service without `NoNewPrivileges`, `SCMP_ACT_ALLOW` profile | | `systemd_socket_audit` | `ListenStream` on every interface, world `SocketMode`, `Accept=yes` without `MaxConnections` | | `tripwire_audit` | twcfg.txt: no site key, loose site key, no MAILTO | | `networkd_audit` | systemd-networkd: [Match] without Name/MAC/Type, DHCP DNS without UseDNS=no, public resolver | | `namespace_audit` | namespace.conf: no /tmp entry, empty/unknown method, `~` user list | | `ssh_client_audit` | ssh_config: StrictHostKeyChecking no, known_hosts /dev/null, ssh-rsa | | `podman_audit` | registries.conf: insecure or http registry, unsigned policy | | `buildkitd_audit` | buildkitd.toml: insecure registry, tcp without CA, no rootless | | `supervisor_audit` | supervisord.conf: exposed web UI, no username, root programs | | `fstab_audit` | fstab: /tmp and friends without nosuid/nodev/noexec, user mounts | | `modprobe_audit` | modprobe.d: `install` hooks that run a command as root | | `grub_audit` | /etc/default/grub: mitigations=off, nokaslr, no init_on_alloc | | `limits_audit` | limits.conf: unlimited nofile/nproc/memlock, core dumps | | `access_conf_audit` | access.conf: `+ : ALL : ALL`, default-allow tail | | `pwquality_audit` | pwquality.conf: minlen < 8, minclass 0, enforcing=0 | | `pam_restrict_audit` | group.conf/time.conf: dead rule, unknown group, wildcard, bad time list | | `pwhistory_audit` | pwhistory.conf: remember missing/0, root not enforced, bare sepermit separator | | `firewalld_audit` | firewalld: PanicMode, CleanupOnExit=no, trusted default, ACCEPT target, unbound zone | ### 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 | | `esp_partition_table` | Parse a flash dump's partition table at 0x8000 (0xAA50 entries, MD5 entry) | | `esp_nvs_parse` | Parse an NVS partition dump: namespaces, keys, types, spans | | `firmware_scan` | Signatures (ESP app, partition table, NVS, filesystems, PEM), 4 KiB entropy, strings | | `esp_app_info` | App header and esp_app_desc_t: version, project, build date, IDF version, ELF hash | | `esp_image_verify` | Segment table, XOR checksum and appended SHA-256; valid flag, OTA offset | ### 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 ```sh 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: ```json {"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 ` 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 ```sh 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/-