Files
lotherk 59b71ab3a1 apex-twin 1.100.0: auth_test over six protocols, SIGPIPE fix
Authentication testing in src/tools_auth.c (new file, 16th table): auth_test
speaks http Basic, ftp, smtp AUTH LOGIN, imap, pop3 and mysql
(mysql_native_password) against one in-scope service. The operator supplies
the wordlists (inline or file) and every limit - delay_ms, max_attempts,
stop_on_hit, lockout_limit, timeout_ms; the program adds none of its own.
auth_plan counts a run without connecting, auth_protocols lists the
protocols, auth_hits returns the credential findings with evidence paths.
A hit is the protocol's own accept answer; each accepted pair becomes a
critical finding with the pair and the answer in evidence, while the audit
log keeps the account and service and never the password.

Two real bugs found by the tests they came with:

- An HTTP answer below 400 counted as a hit, so a 404 or a 500 would have
  been reported as valid credentials. Only 2xx/3xx prove authentication
  now; two checks pin it and fail against the old logic.
- SIGPIPE killed the whole server when a target hung up mid-write: one
  dead target, one dead MCP server. Ignored once at startup, so the write
  returns EPIPE and the tool reports a failed connection. Five checks, one
  per protocol.

SHA1 for the MySQL scramble is written out in the file and checked against
the published vectors for "", "abc", "password" and a 1000-byte multi-block
input. The MySQL seed is read by counting handshake fields; a fixed offset
picked up the capability flags and made every login fail against a healthy
server, which the suite proves by neutralising the offset.

427 tools, 1637 end-to-end checks, 84.7% line coverage.
release-check exit 0, distcheck 1.100.0 passes 1637/1637 from the tarball.
2026-11-24 06:45:02 +00:00

295 lines
11 KiB
Groff

.\" apex-twin.1 - manual page for APEX TWIN
.TH APEX-TWIN 1 "2026-11-24" "apex-twin 1.100.0" "User Commands"
.SH NAME
apex-twin \- scope\-gated offensive\-security MCP server
.SH SYNOPSIS
.B apex-twin
.RI [ options ]
.br
.B apex-twin
.B \-\-http
.I PORT
.br
.B apex-twin
.B \-\-proxy
.I PORT
.br
.B apex-twin
.B \-\-check
.br
.B apex-twin
.B \-\-version
.SH DESCRIPTION
.B apex-twin
is a C99/POSIX MCP server that gives an agent reconnaissance and web testing
behind a rules\-of\-engagement gate.
Every tool that can touch a network calls one gate function; a target that is
not named by the scope is refused, and the decision is appended to
.I audit.log
before the action.
No scope file means no engagement: the gate refuses everything until one is
written.
.PP
The binary links libc only; plain HTTP is spoken in\-process, HTTPS is handed to
.BR curl ,
and the radio is the ESP32 Marauder serial CLI.
.PP
The exploit framework is built in: exploit_modules, exploit_info,
exploit_check, exploit_run, payload_list and payload_build. Each module has a
check that proves itself with its own marker and a run that carries whatever
the operator supplies: a command, a script, a file, a file name, a console
handle or a config value. Eleven modules ship: shellshock, log4shell, Struts2
S2-045, Tomcat PUT, Redis CONFIG SET, command injection, Apache traversal,
the Jenkins script console, the WebLogic console bypass, CouchDB admin party
and Spring Boot Actuator. A write counts as confirmed only when it is read
back. A confirmed hit writes evidence, a finding and an audit line.
.PP
.B auth_test
tries credentials against one in-scope service over http (Basic), ftp,
smtp, imap, pop3 or mysql. The wordlists, the delay between attempts, the
attempt ceiling, the stop-on-first-hit and the lockout threshold are the
operator's settings; the program adds no limit of its own. A hit is the
protocol's own accept answer, never a guess: an HTTP 2xx or 3xx, a 235, a
\&+OK, a 230, an "a1 OK" or a MySQL OK packet. A 404 or a 500 is a miss. The
password goes into the evidence file and never into the audit log.
verification (vuln_check, subdomain_enum,
cred_test, auth_test, auth_plan, auth_protocols, auth_hits,
vhost_discovery, http_brute, ssrf_probe, jwt_audit, hash_id,
ftp_probe, smtp_probe, ssh_audit, tls_audit, redis_probe, snmp_probe,
dns_zone_transfer, mysql_probe, postgres_probe, mongo_probe,
memcached_probe, param_fuzz, open_redirect, host_header_injection, ssti_probe,
xxe_probe, ldap_probe, rdp_probe, smb_probe, vnc_probe, mqtt_probe,
graphql_probe, docker_api_probe, elasticsearch_probe, imap_probe, pop3_probe,
sip_probe, telnet_probe, http_methods, websocket_probe, ike_probe, snmp_walk,
ldap_search, openapi_discovery, csrf_audit, rpc_probe, ntp_probe, dnssec_check, smtp_starttls_probe, tls_ocsp_probe, alpn_probe, webdav_probe, dns_wildcard_check, dns_caa_check, sni_vhost_check, tls_client_auth_probe, kubernetes_api_probe,
dns_ns_consistency, dns_dangling_cname, http_redirect_audit,
websocket_origin_check, dns_fcrdns_check, dns_soa_mname_check, hsts_audit, tls_hostname_check, ftp_tls_probe, zookeeper_4lw_probe, etcd_api_probe, docker_registry_probe, consul_api_probe, couchdb_probe, prometheus_api_probe, rabbitmq_management_probe, grafana_api_probe, minio_admin_probe, nats_monitoring_probe, influxdb_probe, clickhouse_probe, kibana_api_probe, logstash_api_probe, amqp_probe, tls_chain_probe, smtp_auth_probe, jenkins_api_probe, nexus_probe, gitea_api_probe, harbor_probe, portainer_probe, argocd_probe, kafka_connect_probe, sonarqube_probe, keycloak_probe, rundeck_probe, zabbix_probe, datasette_probe, airflow_probe, gitlab_probe, jupyter_probe, jira_probe, ollama_probe, cadvisor_probe, teamcity_probe, superset_probe, vault_probe, nomad_probe, coredns_probe, openbmc_probe, schema_registry_probe, loki_probe, tempo_probe, jaeger_probe, solr_probe, confluence_probe, bitbucket_probe, cassandra_probe,
nuclei_scan, nikto_scan, ffuf_scan, gobuster_scan, sqlmap_scan,
hydra_scan, medusa_scan, msfvenom_build),
defensive
audits (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, module_audit,
package_integrity, mount_audit, firewall_audit, systemd_audit,
kernel_hardening, sudoers_audit, auditd_audit, ssh_config_audit,
pam_audit, ssh_known_hosts_audit, logrotate_audit, nfs_exports_audit,
samba_audit, snmpd_audit, rsyslog_audit, apparmor_audit, selinux_audit,
usb_audit, docker_audit, www_audit, audit_rules, postfix_audit, nginx_audit,
mysql_config_audit, apache_audit, haproxy_audit, redis_config_audit,
php_config_audit, dovecot_audit, openvpn_audit, postgresql_config_audit,
exim_audit, elasticsearch_config_audit, squid_audit, unbound_audit,
cups_audit, rsync_audit, dhcpd_audit, krb5_conf_audit,
mongodb_config_audit, memcached_config_audit, ntpd_config_audit,
bind9_config_audit, tomcat_audit, proftpd_audit, kubelet_config_audit,
etcd_config_audit, rabbitmq_audit, consul_config_audit, vault_config_audit,
zookeeper_audit, grafana_audit, prometheus_audit, wireguard_config_audit,
ipsec_config_audit, openldap_config_audit, cron_audit, fail2ban_audit, chrony_config_audit,
apt_config_audit, login_defs_audit, pg_hba_audit, polkit_audit,
ldap_client_audit, ssl_cert_audit, timesyncd_audit, resolv_conf_audit, journald_audit,
coredump_audit, nftables_audit, dnsmasq_audit, nsswitch_audit,
jenkins_audit, pgbouncer_audit, xinetd_audit, sssd_audit, avahi_audit, logind_audit,
tftpd_hpa_audit, iscsi_audit, rpcbind_audit, kdump_audit, kafka_audit, powerdns_audit,
varnish_audit, freeradius_audit, containerd_audit, nats_audit, caddy_audit, traefik_audit,
autofs_audit, gitea_audit, minio_audit, nextcloud_audit, zabbix_audit, nrpe_audit,
unattended_upgrades_audit, gitlab_audit, vaultwarden_audit,
keepalived_audit, webmin_audit, cockpit_audit, phpmyadmin_audit, kibana_audit,
nagios_audit, synapse_audit, logstash_audit, filebeat_audit,
fluentd_audit, telegraf_audit, graylog_audit, netdata_audit, sshd_config_audit,
hosts_access_audit, profile_audit, atd_audit, securetty_audit,
tmpfiles_audit, compose_audit, k8s_manifest_audit, dockerfile_audit,
openssl_cnf_audit, curlrc_audit, wgetrc_audit, resolved_audit,
udev_audit, issue_audit, usbguard_audit, certbot_audit,
wpa_supplicant_audit, bluetooth_audit, networkmanager_audit, dbus_audit, passwd_audit,
authorized_keys_audit, ld_preload_audit, gitconfig_audit, npmrc_audit,
pip_conf_audit, podman_audit, buildkitd_audit,
supervisor_audit,
fstab_audit, modprobe_audit, grub_audit,
limits_audit, access_conf_audit, pwquality_audit,
pam_env_audit, hosts_audit, dnf_repo_audit,
anacrontab_audit, motd_audit, syslog_ng_audit, ntpd_audit, inetd_audit,
ld_so_conf_audit, rc_local_audit, opendkim_audit, spamassassin_audit, opendmarc_audit, amavis_audit, rspamd_audit,
crypttab_audit, useradd_audit,
aide_audit, nscd_audit, faillock_audit,
networkd_audit, namespace_audit, ssh_client_audit, ufw_audit, monit_audit, clamav_audit,
modules_load_audit, depmod_audit, adduser_conf_audit,
nfs_conf_audit, idmapd_audit, netplan_audit,
apt_auth_audit, aliases_audit, netgroup_audit, jetty_audit,
dhclient_audit, journal_upload_audit, fwupd_audit,
smartd_audit, tlog_audit, abrt_audit, freshclam_audit, tripwire_audit,
fapolicyd_audit, systemd_timer_audit, yara_audit, suricata_audit,
promtail_audit, otel_collector_audit, fluentbit_audit, vector_audit,
seccomp_audit, systemd_socket_audit,
icinga2_audit, falco_audit,
php_fpm_audit, uwsgi_audit, lighttpd_audit,
pam_restrict_audit, pwhistory_audit, firewalld_audit)
and ESP32 board tools (esp_info, esp_monitor,
esp_read_flash, esp_flash, esp_partition_table, esp_nvs_parse, firmware_scan,
esp_app_info, esp_image_verify).
.SH MODES
.TP
.B apex-twin
MCP over stdin/stdout, one JSON\-RPC line each way.
.TP
.BI "\-\-http " PORT
MCP over HTTP on 127.0.0.1:PORT, endpoint
.BR /mcp .
Loopback only.
.TP
.BI "\-\-proxy " PORT
Forward proxy on 127.0.0.1:PORT for clients such as
.BR "curl \-x" .
Plain HTTP is captured under
.IR traffic/ ;
CONNECT is tunnelled blind.
.TP
.B \-\-check
Print version, tool count, limits and the loaded scope as JSON, then exit.
.TP
.B \-\-version
Print the version and exit.
.SH SCOPE
The scope file is JSON; see
.I examples/scope.json
in the source tree.
Rules are applied in this order:
no scope or expired; the target is in
.IR deny_ip ;
a port is set and not in
.IR allow_port ;
the target is in neither
.I allow_ip
nor
.IR allow_domain ;
the target is private, loopback or link\-local while
.I allow_private
is false; a name outside
.I allow_domain
does not resolve entirely inside
.IR allow_ip .
A name in
.I allow_domain
may not resolve into a private net while
.I allow_private
is false.
Radio transmission additionally needs
.I serial_tx
and a command on the allowlist.
.SH ENVIRONMENT
.TP
.B APEX_HOME
State directory, default
.IR ~/.local/state/apex\-twin .
.TP
.B APEX_SCOPE
Scope file, default
.IR $APEX_HOME/scope.json .
.TP
.B APEX_REWRITE
Proxy rewrite rules, default
.IR $APEX_HOME/rewrite.json .
.TP
.B APEX_SERIAL
Marauder tty, default
.IR /dev/ttyACM0 .
.TP
.B APEX_BAUD
Serial baud, default 115200.
.TP
.B APEX_DRY_RUN
When set to 1, commands are printed but not run.
.TP
.B APEX_DEFAULT_TIMEOUT_MS
Per\-tool timeout, default 60000.
.TP
.B APEX_MAX_TIMEOUT_MS
Hard timeout cap, default 900000.
.TP
.B APEX_WEBHOOK
URL that receives a JSON event for findings at or above the severity floor.
The webhook is operator infrastructure and is not put through the scope gate.
.TP
.B APEX_WEBHOOK_MIN_SEVERITY
Floor for the webhook, default
.IR critical .
.TP
.B APEX_PROXY_MAX_CHILDREN
Concurrent proxy connections before 503, default 64, maximum 1024.
.TP
.B APEX_HTTP_MAX_CHILDREN
Concurrent HTTP MCP connections before 503, default 64, maximum 1024.
.TP
.B APEX_HTTP_HEAD_TIMEOUT_MS
Deadline for an HTTP request head and body, default 20000; 0 disables.
.TP
.B APEX_AUDIT_MAX_BYTES
Rotate
.I audit.log
to
.I audit.log.1
at this size, default 10 MiB; 0 disables.
.TP
.B APEX_EVIDENCE_MAX_BYTES
Largest single evidence blob, default 16 MiB; 0 disables the cap.
.SH FILES
.TP
.I $APEX_HOME/scope.json
The rules of engagement.
.TP
.I $APEX_HOME/audit.log
One JSON line per decision, append\-only, written before the action.
.TP
.I $APEX_HOME/findings/
One JSON file per finding.
.TP
.I $APEX_HOME/evidence/
Raw evidence blobs, mode 0600.
.TP
.I $APEX_HOME/reports/
Rendered Markdown, CSV and JSON reports.
.TP
.I $APEX_HOME/assets/
One record per target, merged on the next observation.
.TP
.I $APEX_HOME/traffic/
Captured request/response pairs.
.TP
.I $APEX_HOME/rewrite.json
Optional proxy rewrite rules, reloaded on SIGHUP.
.SH EXAMPLES
Write a scope and check it:
.PP
.nf
.RS
.B cat > ~/.local/state/apex\-twin/scope.json <<\(aqEOF\(aq
{ "label": "lab", "expires": "2026\-12\-31",
"allow_ip": ["192.0.2.0/24"], "allow_port": ["80", "443"] }
EOF
.B apex\-twin \-\-check
.RE
.fi
.PP
Use it as an MCP server over stdio, or point curl at the proxy:
.PP
.nf
.RS
.B apex\-twin
.B apex\-twin \-\-proxy 8798
.B curl \-x http://127.0.0.1:8798 http://192.0.2.10/
.RE
.fi
.SH LIMITS
HTTP MCP bodies are capped at 8 MiB; proxy chunked bodies at 1 MiB; a captured
proxy response at 1 MiB; one report covers at most 1024 findings; evidence is
capped by
.BR APEX_EVIDENCE_MAX_BYTES .
Both listeners bind loopback only and do not authenticate.
.SH SEE ALSO
.IR docs/operations.md ,
.IR docs/artex\-port.md ,
.I SECURITY.md
and
.I CHANGELOG.md
in the installed documentation directory.
.SH LICENSE
CNCL 1.1 \- Could Not Care Less License; see LICENSE.