apex-twin 1.30.0: MySQL, Apache and HAProxy audits, DNSSEC check

Blue:
- mysql_config_audit: my.cnf and my.cnf.d/conf.d (root prefix): bind-address
  on every interface, skip-grant-tables, local-infile, an empty
  secure-file-priv and world-writable files. conf_value now also matches
  valueless directives.
- apache_audit: apache2.conf/httpd.conf, sites-enabled and conf-enabled:
  ServerTokens Full/OS/Minor, Options Indexes, AllowOverride All,
  SSLv3/TLSv1 (including +TLSv1), ServerSignature On and world-writable files.
- haproxy_audit: stats socket without mode 600, stats page without stats auth,
  bind on 443 without ssl and a world-writable config.

Red:
- dnssec_check: dig +dnssec DNSKEY/DS, signed and DS presence, algorithm and
  decoded key size; flags unsigned domains, RSASHA1 and RSA keys under 2048
  bits. dig wraps long DNSKEY base64 with spaces, so the parser joins them.

Tests with vulnerable and hardened daemon trees plus a DNS agent serving a
2048-bit RSA key, a 1024-bit RSASHA1 key and an unsigned zone. 802 checks,
ASan suite green, analyze clean, release-check green including distcheck
1.30.0.
This commit is contained in:
lotherk committed 2026-11-21 19:57:24 +00:00
1 parent 9c9fa1e3d4
commit 874a32de08
9 files changed
+1033 -17

No files matched your search

+22 -1
View File
@@ -8,7 +8,28 @@ fields, and state from an older version is read by a newer one.
There are no git tags. The hash next to a version is the commit that introduced
it; the current entry is the commit that adds this section.
## 1.29.0 — 2026-11-21 — this change
## 1.30.0 — 2026-11-21 — this change
- **MySQL** (`mysql_config_audit`): my.cnf and my.cnf.d/conf.d (root prefix):
bind-address on every interface, skip-grant-tables, local-infile, an empty
secure-file-priv and world-writable files.
- **Apache** (`apache_audit`): apache2.conf/httpd.conf, sites-enabled and
conf-enabled: ServerTokens Full/OS/Minor, Options Indexes, AllowOverride All,
SSLv3/TLSv1 (including +TLSv1 forms), ServerSignature On and world-writable
files.
- **HAProxy** (`haproxy_audit`): stats socket without mode 600, a stats page
without stats auth, a bind on port 443 without ssl and a world-writable
config.
- **DNSSEC** (`dnssec_check`): gated dig +dnssec for DNSKEY and DS; reports
whether RRSIG/DS records exist, the algorithm and the decoded key size, and
flags unsigned domains, RSASHA1 and RSA keys below 2048 bits.
- The shared `conf_value` reader now also matches valueless directives, which
is how skip-grant-tables is written.
- Tests with vulnerable and hardened trees for all three daemons plus a DNS
agent serving 2048-bit RSA, 1024-bit RSASHA1 and an unsigned zone. 802
checks. Coverage 81.2%.
## 1.29.0 — 2026-11-21 — 9c9fa1e
- **Postfix** (`postfix_audit`): parses main.cf (root prefix) for mynetworks
covering 0.0.0.0/0 or ::/0, relay restrictions without
+15 -8
View File
@@ -5,11 +5,11 @@ no Python in the serving path. It gives an agent real reconnaissance and real we
testing behind a scope gate that refuses everything until a rules-of-engagement
file says otherwise.
**155 tools · 786 end-to-end checks · 340 fuzz cases · 81.2% line coverage · ~631 KiB**
**159 tools · 802 end-to-end checks · 340 fuzz cases · 81.2% line coverage · ~647 KiB**
```
$ ./apex-twin --check
{"version":"1.29.0","tools":155,...,"scope":{"loaded":true,...}}
{"version":"1.30.0","tools":159,...,"scope":{"loaded":true,...}}
```
APEX TWIN was inspired by [ARTEX](https://github.com/Autumn-27/artex) (scope
@@ -149,7 +149,7 @@ closes a request whose head or body does not arrive within
---
## Tools (155)
## Tools (159)
### Scope and bookkeeping
@@ -293,6 +293,7 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
| `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 |
| `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 |
@@ -352,6 +353,9 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
| `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 |
### ESP32
@@ -596,6 +600,8 @@ The full threat model, trust boundaries and a hardening checklist are in
| WinRM | one unauthenticated GET; no auth attempt |
| snmpd/rsyslog | config reads only; optional root prefix |
| postfix/nginx/redis | config reads only; optional root prefix |
| mysql/apache/haproxy | config reads only; optional root prefix |
| DNSSEC | two gated dig queries |
| USB audit | 200 devices, sysfs reads only |
---
@@ -607,7 +613,7 @@ Flags are fixed: `-std=c99 -Wall -Wextra -Wpedantic -Werror` plus
```sh
make # apex-twin
make test # version check + gate audit + 786 end-to-end checks
make test # version check + gate audit + 802 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
@@ -722,7 +728,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
email_security_audit, smtp_open_relay, dns_open_resolver,
crlf_probe, dns_version_bind, oidc_discovery,
security_txt, http2_probe, ssh_hostkey_fingerprint,
kerberos_discovery, winrm_probe
kerberos_discovery, winrm_probe, dnssec_check
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,
@@ -765,7 +771,7 @@ examples/ scope.json
## Status
1.29.0. Built and run: 155 tools, 786 checks, 340 fuzz cases and 81.2% line
1.30.0. Built and run: 159 tools, 802 checks, 340 fuzz cases and 81.2% 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
@@ -810,8 +816,9 @@ checks; 1.24 added NTP monlist and DNS version disclosure checks plus a USB
audit; 1.25 added OIDC discovery, security.txt and known-hosts checks; 1.26 added
HTTP/2 probing, SSH host-key fingerprints and a logrotate audit; 1.27 added
Kerberos discovery, NFS export and Samba audits; 1.28 added a WinRM probe and
snmpd/rsyslog config audits; 1.29 added postfix, nginx and redis config audits,
again without changing an existing file format.
snmpd/rsyslog config audits; 1.29 added postfix, nginx and redis config audits;
1.30 added MySQL, Apache and HAProxy config audits plus a DNSSEC check, again
without changing an existing file format.
Not yet wired into a fleet router, and there is no TLS interception.
+4 -1
View File
@@ -9,7 +9,7 @@ problem.
The supported line is the one printed by `apex-twin --version` for the tree you
built; this document ships with that same tree. At the time of writing the line
is **1.29.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
is **1.30.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
line. The 1.0 line promises that the on-disk JSON formats for findings, assets
and traffic only gain fields, so state stays readable; older builds are still
rebuilt rather than patched in place.
@@ -66,6 +66,9 @@ only narrow what the proxy does (the scope gate still runs first).
- **Firmware writing needs an explicit confirmation.** `esp_flash` refuses
without `confirm=true`, validates an absolute image path and audits the
attempt; it exists to provision the operator's own board.
- **DNSSEC checks are two DNS queries.** `dnssec_check` asks for DNSKEY and
DS records of an in-scope domain and decodes the public key size; it never
validates a chain or contacts a registrar.
- **Daemon configs are audited read-only.** `postfix_audit`, `nginx_audit`
and `redis_config_audit` parse their configuration files and never signal,
reload or talk to the daemon. Redis passwords are reported as present or
+3 -2
View File
@@ -1,5 +1,5 @@
.\" apex-twin.1 - manual page for APEX TWIN
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.29.0" "User Commands"
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.30.0" "User Commands"
.SH NAME
apex-twin \- scope\-gated offensive\-security MCP server
.SH SYNOPSIS
@@ -43,7 +43,7 @@ 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), defensive
ldap_search, openapi_discovery, csrf_audit, rpc_probe, ntp_probe, dnssec_check), 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,
@@ -52,6 +52,7 @@ 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) 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).
+1 -1
View File
@@ -15,7 +15,7 @@
#include "mcp.h"
#define APEX_VERSION "1.29.0"
#define APEX_VERSION "1.30.0"
#define APEX_MAX_OUT (1u << 20)
#define APEX_PATH_MAX 512
#define APEX_PATH_FULL 1024
+456 -1
View File
@@ -6758,7 +6758,8 @@ static int conf_value(const char *text, const char *key, char *out, size_t n)
while (*s == ' ' || *s == '\t')
s++;
if (*s != '#' && strncasecmp(s, key, kl) == 0 &&
(s[kl] == ' ' || s[kl] == '\t' || s[kl] == '=')) {
(s[kl] == ' ' || s[kl] == '\t' || s[kl] == '=' ||
s[kl] == '\0')) {
v = s + kl;
while (*v == ' ' || *v == '\t' || *v == '=')
v++;
@@ -7151,6 +7152,438 @@ static void t_redis_config_audit(mcp_conn *c, const mcp_json *args, void *user)
mcp_buf_free(&findings);
}
/* -------------------------------------------------------- mysql_config_audit */
static void mysql_scan_dir(mcp_buf *findings, int *first, int *count,
const char *dir, const char *suffix, int *files,
int *bind_all, int *skip_grant, int *local_infile,
int *secure_empty, char *bind_value,
size_t bind_n)
{
DIR *d;
struct dirent *ent;
d = opendir(dir);
if (d == NULL)
return;
while ((ent = readdir(d)) != NULL) {
char path[1024];
char text[32768];
char value[512];
struct stat st;
size_t nl = strlen(ent->d_name);
size_t sl = strlen(suffix);
if (ent->d_name[0] == '.')
continue;
if (nl <= sl || strcmp(ent->d_name + nl - sl, suffix) != 0)
continue;
snprintf(path, sizeof(path), "%.800s/%.160s", dir, ent->d_name);
if (stat(path, &st) != 0 || !S_ISREG(st.st_mode))
continue;
if (read_text(path, text, sizeof(text)) < 0)
continue;
(*files)++;
if ((st.st_mode & 0002) != 0) {
add_finding(findings, first, "world-writable", "high",
"%s is writable by anyone", path);
(*count)++;
}
if (conf_value(text, "bind-address", value, sizeof(value))) {
snprintf(bind_value, bind_n, "%.200s", value);
if (conf_has_word(value, "0.0.0.0") ||
conf_has_word(value, "*") ||
conf_has_word(value, "::")) {
*bind_all = 1;
}
}
if (conf_value(text, "skip-grant-tables", value, sizeof(value)))
*skip_grant = 1;
if (conf_value(text, "local-infile", value, sizeof(value)) &&
(strcasecmp(value, "1") == 0 || strcasecmp(value, "on") == 0))
*local_infile = 1;
if (conf_value(text, "secure-file-priv", value, sizeof(value)) &&
value[0] == '\0')
*secure_empty = 1;
}
closedir(d);
}
static void t_mysql_config_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *dirs[] = { "/etc/mysql/my.cnf.d",
"/etc/mysql/conf.d",
"/etc/mysql/mariadb.conf.d", NULL };
const char *root = mcp_arg_string(args, "root");
static char text[65536];
char path[1024];
char bind_value[256];
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int files = 0;
int bind_all = 0;
int skip_grant = 0;
int local_infile = 0;
int secure_empty = 0;
int i;
struct stat st;
char value[512];
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
bind_value[0] = '\0';
mcp_buf_init(&findings);
snprintf(path, sizeof(path), "%s/etc/mysql/my.cnf", root);
if (read_text(path, text, sizeof(text)) > 0) {
files++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"%s is writable by anyone", path);
count++;
}
if (!conf_value(text, "bind-address", value, sizeof(value)))
conf_value(text, "bind_address", value, sizeof(value));
if (value[0] != '\0') {
snprintf(bind_value, sizeof(bind_value), "%.200s", value);
if (conf_has_word(value, "0.0.0.0") ||
conf_has_word(value, "*") ||
conf_has_word(value, "::"))
bind_all = 1;
}
if (conf_value(text, "skip-grant-tables", value, sizeof(value)))
skip_grant = 1;
if (conf_value(text, "local-infile", value, sizeof(value)) &&
(strcasecmp(value, "1") == 0 || strcasecmp(value, "on") == 0))
local_infile = 1;
if (conf_value(text, "secure-file-priv", value, sizeof(value)) &&
value[0] == '\0')
secure_empty = 1;
}
for (i = 0; dirs[i] != NULL; i++) {
snprintf(path, sizeof(path), "%.400s%s", root, dirs[i]);
mysql_scan_dir(&findings, &first, &count, path, ".cnf", &files,
&bind_all, &skip_grant, &local_infile,
&secure_empty, bind_value, sizeof(bind_value));
}
if (files == 0) {
mcp_reply_error(c, "cannot read a MySQL configuration");
return;
}
if (bind_all) {
add_finding(&findings, &first, "bind-all", "high",
"MySQL listens on every interface");
count++;
}
if (skip_grant) {
add_finding(&findings, &first, "skip-grant-tables", "high",
"the privilege tables are bypassed");
count++;
}
if (local_infile) {
add_finding(&findings, &first, "local-infile", "medium",
"clients may read local files");
count++;
}
if (secure_empty) {
add_finding(&findings, &first, "secure-file-priv-empty", "medium",
"secure-file-priv is empty and restricts nothing");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"bind_address\":", files);
apex_json_str(&b, bind_value);
mcp_buf_printf(&b, ",\"skip_grant_tables\":%s,\"local_infile\":%s,"
"\"findings_count\":%d,\"findings\":[",
skip_grant ? "true" : "false",
local_infile ? "true" : "false", count);
if (findings.p != NULL)
mcp_buf_add(&b, findings.p, findings.len);
mcp_buf_puts(&b, "]}");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&findings);
}
/* --------------------------------------------------------------- apache_audit */
static void apache_scan_file(mcp_buf *findings, int *first, int *count,
const char *path, int *files, int *tokens_leak,
int *indexes, int *override_all,
int *weak_protocol, int *signature)
{
static char text[65536];
char value[512];
struct stat st;
if (read_text(path, text, sizeof(text)) < 0)
return;
(*files)++;
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(findings, first, "world-writable", "high",
"%s is writable by anyone", path);
(*count)++;
}
if (conf_value(text, "ServerTokens", value, sizeof(value))) {
if (strstr(value, "Full") != NULL ||
strstr(value, "OS") != NULL ||
strstr(value, "Minor") != NULL) {
if (!*tokens_leak)
add_finding(findings, first, "server-tokens",
"medium",
"%s exposes the full server banner",
path);
*tokens_leak = 1;
(*count)++;
}
}
if (conf_value(text, "Options", value, sizeof(value)) &&
conf_has_word(value, "Indexes")) {
if (!*indexes)
add_finding(findings, first, "options-indexes", "medium",
"%s allows directory listing", path);
*indexes = 1;
(*count)++;
}
if (conf_value(text, "AllowOverride", value, sizeof(value)) &&
strcasecmp(value, "All") == 0) {
if (!*override_all)
add_finding(findings, first, "allowoverride-all", "medium",
"%s lets .htaccess override everything", path);
*override_all = 1;
(*count)++;
}
if (conf_value(text, "SSLProtocol", value, sizeof(value))) {
if (conf_has_word(value, "SSLv3") ||
conf_has_word(value, "+SSLv3") ||
conf_has_word(value, "TLSv1") ||
conf_has_word(value, "+TLSv1") ||
conf_has_word(value, "TLSv1.1") ||
conf_has_word(value, "+TLSv1.1")) {
if (!*weak_protocol)
add_finding(findings, first, "weak-protocol",
"high",
"%s allows SSLv3/TLSv1", path);
*weak_protocol = 1;
(*count)++;
}
}
if (conf_value(text, "ServerSignature", value, sizeof(value)) &&
strcasecmp(value, "On") == 0) {
if (!*signature)
add_finding(findings, first, "server-signature", "low",
"%s adds a server signature to errors", path);
*signature = 1;
(*count)++;
}
}
static void apache_scan_dir(mcp_buf *findings, int *first, int *count,
const char *dir, int *files, int *tokens_leak,
int *indexes, int *override_all,
int *weak_protocol, int *signature)
{
DIR *d;
struct dirent *ent;
d = opendir(dir);
if (d == NULL)
return;
while ((ent = readdir(d)) != NULL) {
char path[1024];
struct stat st;
size_t nl = strlen(ent->d_name);
if (ent->d_name[0] == '.')
continue;
if (nl < 6 || strcmp(ent->d_name + nl - 5, ".conf") != 0)
continue;
snprintf(path, sizeof(path), "%.800s/%.160s", dir, ent->d_name);
if (stat(path, &st) != 0 || !S_ISREG(st.st_mode))
continue;
apache_scan_file(findings, first, count, path, files, tokens_leak,
indexes, override_all, weak_protocol,
signature);
}
closedir(d);
}
static void t_apache_audit(mcp_conn *c, const mcp_json *args, void *user)
{
static const char *dirs[] = { "/etc/apache2/sites-enabled",
"/etc/apache2/conf-enabled",
"/etc/httpd/conf.d", NULL };
const char *root = mcp_arg_string(args, "root");
char path[1024];
char value[512];
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int files = 0;
int tokens_leak = 0;
int indexes = 0;
int override_all = 0;
int weak_protocol = 0;
int signature = 0;
int i;
char server_tokens[128];
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
server_tokens[0] = '\0';
mcp_buf_init(&findings);
snprintf(path, sizeof(path), "%s/etc/apache2/apache2.conf", root);
if (access(path, R_OK) != 0) {
snprintf(path, sizeof(path), "%s/etc/httpd/conf/httpd.conf",
root);
}
if (read_text(path, value, sizeof(value)) <= 0) {
mcp_buf_free(&findings);
mcp_reply_error(c, "cannot read the Apache configuration");
return;
}
apache_scan_file(&findings, &first, &count, path, &files, &tokens_leak,
&indexes, &override_all, &weak_protocol, &signature);
{
static char text[65536];
if (read_text(path, text, sizeof(text)) > 0 &&
conf_value(text, "ServerTokens", server_tokens,
sizeof(server_tokens)) == 0)
server_tokens[0] = '\0';
}
for (i = 0; dirs[i] != NULL; i++) {
snprintf(path, sizeof(path), "%.400s%s", root, dirs[i]);
apache_scan_dir(&findings, &first, &count, path, &files,
&tokens_leak, &indexes, &override_all,
&weak_protocol, &signature);
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"files\":%d,\"server_tokens\":", files);
apex_json_str(&b, server_tokens);
mcp_buf_printf(&b, ",\"options_indexes\":%s,\"allowoverride_all\":%s,"
"\"findings_count\":%d,\"findings\":[",
indexes ? "true" : "false",
override_all ? "true" : "false", count);
if (findings.p != NULL)
mcp_buf_add(&b, findings.p, findings.len);
mcp_buf_puts(&b, "]}");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&findings);
}
/* -------------------------------------------------------------- haproxy_audit */
static void t_haproxy_audit(mcp_conn *c, const mcp_json *args, void *user)
{
const char *root = mcp_arg_string(args, "root");
static char config[65536];
char path[1024];
char *line;
char *save = NULL;
mcp_buf b;
mcp_buf findings;
int first = 1;
int count = 0;
int stats_socket = 0;
int socket_mode_600 = 0;
int stats_enable = 0;
int stats_auth = 0;
int tls_plain = 0;
struct stat st;
(void)user;
if (root == NULL)
root = "";
if (strlen(root) > 400) {
mcp_reply_error(c, "root path too long");
return;
}
snprintf(path, sizeof(path), "%s/etc/haproxy/haproxy.cfg", root);
if (read_text(path, config, sizeof(config)) <= 0) {
mcp_reply_error(c, "cannot read haproxy.cfg");
return;
}
mcp_buf_init(&findings);
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
add_finding(&findings, &first, "world-writable", "high",
"haproxy configuration is writable by anyone");
count++;
}
line = strtok_r(config, "\n", &save);
while (line != NULL) {
while (*line == ' ' || *line == '\t')
line++;
if (strncmp(line, "stats socket", 12) == 0) {
stats_socket = 1;
if (strstr(line, "mode 600") != NULL)
socket_mode_600 = 1;
}
if (strncmp(line, "stats enable", 12) == 0 ||
strncmp(line, "stats uri", 9) == 0)
stats_enable = 1;
if (strncmp(line, "stats auth", 10) == 0) {
char *v = line + 10;
while (*v == ' ' || *v == '\t')
v++;
if (*v != '\0')
stats_auth = 1;
}
if (strncmp(line, "bind", 4) == 0 &&
strstr(line, ":443") != NULL && strstr(line, "ssl") == NULL)
tls_plain = 1;
line = strtok_r(NULL, "\n", &save);
}
if (stats_socket && !socket_mode_600) {
add_finding(&findings, &first, "stats-socket-mode", "medium",
"the stats socket has no mode 600");
count++;
}
if (stats_enable && !stats_auth) {
add_finding(&findings, &first, "stats-no-auth", "high",
"the stats page has no authentication");
count++;
}
if (tls_plain) {
add_finding(&findings, &first, "bind-443-no-ssl", "medium",
"a bind on port 443 has no ssl keyword");
count++;
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"root\":");
apex_json_str(&b, root);
mcp_buf_printf(&b, ",\"stats_socket\":%s,\"stats_auth\":%s,"
"\"stats_enabled\":%s,\"findings_count\":%d,"
"\"findings\":[",
stats_socket ? "true" : "false",
stats_auth ? "true" : "false",
stats_enable ? "true" : "false", count);
if (findings.p != NULL)
mcp_buf_add(&b, findings.p, findings.len);
mcp_buf_puts(&b, "]}");
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&findings);
}
const mcp_tool TOOLS_BLUE[] = {
{ "hardening_audit",
"Read-only posture audit of the local host: sshd_config (root login, "
@@ -7550,6 +7983,28 @@ const mcp_tool TOOLS_BLUE[] = {
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_redis_config_audit },
{ "mysql_config_audit",
"Parse /etc/mysql/my.cnf and my.cnf.d/conf.d (root prefix): bind-address "
"on every interface, skip-grant-tables, local-infile, an empty "
"secure-file-priv and world-writable files. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_mysql_config_audit },
{ "apache_audit",
"Parse apache2.conf/httpd.conf, sites-enabled and conf-enabled (root "
"prefix): ServerTokens Full/OS, Options Indexes, AllowOverride All, "
"SSLv3/TLSv1 in SSLProtocol, ServerSignature On and world-writable "
"files. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_apache_audit },
{ "haproxy_audit",
"Parse haproxy.cfg (root prefix): stats socket without mode 600, a stats "
"page without stats auth, a bind on port 443 without ssl and a "
"world-writable config. Read-only.",
"{\"type\":\"object\",\"properties\":{"
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
t_haproxy_audit },
};
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
+321
View File
@@ -4891,6 +4891,316 @@ static void t_winrm_probe(mcp_conn *c, const mcp_json *args, void *user)
free(resp);
}
/* ----------------------------------------------------------------- dnssec_check */
static unsigned int dnssec_key_bits(unsigned int algorithm,
const unsigned char *key, size_t len)
{
size_t off = 0;
unsigned long exp_len;
const unsigned char *mod;
size_t mod_len;
unsigned int lead = 0;
unsigned char top;
if (algorithm == 13)
return 256;
if (algorithm == 14)
return 384;
if (algorithm == 15)
return 256;
if (algorithm == 16)
return 456;
if (algorithm != 1 && algorithm != 5 && algorithm != 7 &&
algorithm != 8 && algorithm != 10)
return 0;
if (len < 1)
return 0;
exp_len = key[0];
off = 1;
if (exp_len == 0) {
if (len < 3)
return 0;
exp_len = ((unsigned long)key[1] << 8) | key[2];
off = 3;
}
if (exp_len > len - off)
return 0;
off += (size_t)exp_len;
if (off >= len)
return 0;
mod = key + off;
mod_len = len - off;
while (mod_len > 0 && *mod == 0) {
mod++;
mod_len--;
}
if (mod_len == 0)
return 0;
top = *mod;
while ((top & 0x80) == 0) {
top = (unsigned char)(top << 1);
lead++;
}
return (unsigned int)(mod_len * 8 - lead);
}
static const char *dnssec_skip_tokens(const char *p, int n)
{
while (n-- > 0) {
while (*p == ' ' || *p == '\t')
p++;
while (*p != '\0' && *p != ' ' && *p != '\t')
p++;
}
return p;
}
static void dnssec_parse(mcp_buf *b, int *first, int *count,
const char *text, int *signed_flag,
int *dnskey_count, int *ds_count,
unsigned int *bits_out, unsigned int *alg_out)
{
char *copy;
char *save = NULL;
char *line;
if (text == NULL)
return;
copy = strdup(text);
if (copy == NULL)
return;
line = strtok_r(copy, "\n", &save);
while (line != NULL) {
char owner[256];
char cls[16];
char typ[16];
if (sscanf(line, "%255s %*s %15s %15s", owner, cls, typ) == 3) {
if (strcmp(typ, "RRSIG") == 0) {
char covered[32];
if (sscanf(dnssec_skip_tokens(line, 4), "%31s",
covered) == 1) {
*signed_flag = 1;
if (!*first)
mcp_buf_puts(b, ",");
*first = 0;
(*count)++;
mcp_buf_puts(b,
"{\"kind\":\"RRSIG\",\"owner\":");
apex_json_str(b, owner);
mcp_buf_puts(b, ",\"type_covered\":");
apex_json_str(b, covered);
mcp_buf_puts(b, "}");
}
} else if (strcmp(typ, "DS") == 0) {
char tag[16];
char alg_s[16];
if (sscanf(dnssec_skip_tokens(line, 4),
"%15s %15s", tag, alg_s) == 2) {
*ds_count += 1;
*signed_flag = 1;
if (!*first)
mcp_buf_puts(b, ",");
*first = 0;
(*count)++;
mcp_buf_puts(b, "{\"kind\":\"DS\",\"owner\":");
apex_json_str(b, owner);
mcp_buf_printf(b, ",\"key_tag\":%s,"
"\"algorithm\":%s}", tag, alg_s);
}
} else if (strcmp(typ, "DNSKEY") == 0) {
char flags_s[16];
char proto_s[16];
char alg_s[16];
if (sscanf(dnssec_skip_tokens(line, 4),
"%15s %15s %15s", flags_s, proto_s,
alg_s) == 3) {
const char *k = dnssec_skip_tokens(
dnssec_skip_tokens(line, 4), 3);
char b64[8192];
size_t w = 0;
unsigned long flags =
strtoul(flags_s, NULL, 10);
unsigned int alg =
(unsigned int)strtoul(alg_s, NULL,
10);
size_t blen = 0;
unsigned char *blob;
unsigned int bits = 0;
if (k != NULL) {
while ((*k == ' ' || *k == '\t') &&
*k != '\0')
k++;
while (*k != '\0' &&
*k != '\r' &&
*k != '\n' &&
w + 1 < sizeof(b64)) {
if (*k != ' ' &&
*k != '\t')
b64[w++] = *k;
k++;
}
}
b64[w] = '\0';
blob = b64_decode_alloc(b64, &blen);
(*dnskey_count)++;
if (blob != NULL) {
bits = dnssec_key_bits(alg, blob,
blen);
free(blob);
}
if (bits > *bits_out)
*bits_out = bits;
*alg_out = alg;
if (!*first)
mcp_buf_puts(b, ",");
*first = 0;
(*count)++;
mcp_buf_puts(b,
"{\"kind\":\"DNSKEY\",\"owner\":");
apex_json_str(b, owner);
mcp_buf_printf(b, ",\"flags\":%lu,"
"\"protocol\":%s,"
"\"algorithm\":%u,"
"\"bits\":%u,"
"\"zone_key\":%s,"
"\"secure_entry_point\":%s}",
flags, proto_s, alg, bits,
(flags & 256) ? "true" : "false",
(flags & 1) ? "true" : "false");
}
}
}
line = strtok_r(NULL, "\n", &save);
}
free(copy);
}
static void t_dnssec_check(mcp_conn *c, const mcp_json *args, void *user)
{
const char *domain = mcp_arg_string(args, "domain");
const char *resolver = mcp_arg_string(args, "resolver");
int port = mcp_arg_int(args, "port", 0);
char reason[512];
char portstr[16];
char at_server[300];
mcp_buf b;
mcp_buf records;
int first = 1;
int count = 0;
int signed_flag = 0;
int dnskey_count = 0;
int ds_count = 0;
unsigned int bits = 0;
unsigned int alg = 0;
int i;
(void)user;
if (domain == NULL || *domain == '\0') {
mcp_reply_error(c, "domain is required");
return;
}
if (port < 0 || port > 65535) {
mcp_reply_error(c, "port out of range");
return;
}
if (!apex_scope_check(domain, 0, reason, sizeof(reason))) {
mcp_buf_init(&b);
mcp_buf_printf(&b, "REFUSED by scope gate: %s", reason);
mcp_reply_error(c, b.p);
mcp_buf_free(&b);
return;
}
if (resolver != NULL && *resolver != '\0' &&
!apex_scope_check(resolver, port, reason, sizeof(reason))) {
mcp_buf_init(&b);
mcp_buf_printf(&b, "resolver is outside the scope: %s", reason);
mcp_reply_error(c, b.p);
mcp_buf_free(&b);
return;
}
apex_audit("dnssec_check", domain, 0, 1, "DNSSEC records", "dig +dnssec");
snprintf(portstr, sizeof(portstr), "%d", port > 0 ? port : 53);
snprintf(at_server, sizeof(at_server), "@%.200s",
resolver != NULL ? resolver : "");
mcp_buf_init(&records);
for (i = 0; i < 2; i++) {
const char *type = i == 0 ? "DNSKEY" : "DS";
char *argv[12];
int k = 0;
apex_proc p;
argv[k++] = "dig";
argv[k++] = "+dnssec";
argv[k++] = "+noall";
argv[k++] = "+answer";
argv[k++] = "-p";
argv[k++] = portstr;
if (resolver != NULL && *resolver != '\0')
argv[k++] = at_server;
argv[k++] = (char *)domain;
argv[k++] = (char *)type;
argv[k] = NULL;
if (apex_run(argv, 15000, 64 * 1024, &p) == 0) {
dnssec_parse(&records, &first, &count, p.out, &signed_flag,
&dnskey_count, &ds_count, &bits, &alg);
apex_proc_free(&p);
}
}
mcp_buf_init(&b);
mcp_buf_puts(&b, "{\"domain\":");
apex_json_str(&b, domain);
mcp_buf_puts(&b, ",\"resolver\":");
apex_json_str(&b, resolver != NULL ? resolver : "");
mcp_buf_printf(&b, ",\"signed\":%s,\"dnskey_count\":%d,\"ds_count\":%d,"
"\"algorithm\":%u,\"key_bits\":%u,\"records\":[",
signed_flag ? "true" : "false", dnskey_count, ds_count,
alg, bits);
if (records.p != NULL)
mcp_buf_add(&b, records.p, records.len);
mcp_buf_puts(&b, "],\"findings\":[");
first = 1;
{
int findings = 0;
if (!signed_flag) {
email_finding(&b, &first, "not-signed", "medium",
"the domain publishes no DNSSEC records");
findings++;
}
if (signed_flag && dnskey_count == 0 && ds_count > 0) {
email_finding(&b, &first, "no-dnskey", "medium",
"a DS exists but no DNSKEY was returned");
findings++;
}
if (dnskey_count > 0 && ds_count == 0) {
email_finding(&b, &first, "no-ds", "low",
"DNSKEYs exist but the parent has no DS");
findings++;
}
if (alg == 5 || alg == 7) {
email_finding(&b, &first, "rsasha1", "medium",
"DNSSEC uses RSASHA1");
findings++;
}
if (bits > 0 && bits < 2048 &&
(alg == 1 || alg == 5 || alg == 7 || alg == 8 || alg == 10)) {
email_finding(&b, &first, "short-rsa-key", "medium",
"the RSA DNSKEY is shorter than 2048 bits");
findings++;
}
mcp_buf_printf(&b, "],\"findings_count\":%d}", findings);
}
mcp_reply_json(c, b.p);
mcp_buf_free(&b);
mcp_buf_free(&records);
}
const mcp_tool TOOLS_RED[] = {
{ "vuln_check",
"Non-destructive verification of exposed artifacts on one web target: "
@@ -5325,6 +5635,17 @@ const mcp_tool TOOLS_RED[] = {
"\"tls\":{\"type\":\"boolean\"}},"
"\"required\":[\"target\"]}",
t_winrm_probe },
{ "dnssec_check",
"Ask for the DNSSEC records of a domain with gated dig +dnssec: DNSKEY "
"and DS, reporting whether RRSIG/DS records exist, the algorithm and the "
"key size (decoded from the DNSKEY). Flags unsigned domains, RSASHA1 and "
"RSA keys below 2048 bits. Gate: the domain (and resolver).",
"{\"type\":\"object\",\"properties\":{"
"\"domain\":{\"type\":\"string\"},"
"\"resolver\":{\"type\":\"string\",\"description\":\"optional DNS server\"},"
"\"port\":{\"type\":\"integer\",\"description\":\"dig -p, default 0\"}},"
"\"required\":[\"domain\"]}",
t_dnssec_check },
};
const size_t TOOLS_RED_N = sizeof(TOOLS_RED) / sizeof(TOOLS_RED[0]);
+1 -1
View File
@@ -21,7 +21,7 @@ import re
import sys
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
EXPECTED_TOOLS = 155
EXPECTED_TOOLS = 159
GATE = ("gated(", "gated_cmd(", "gated_run(", "apex_scope_check(")
NET = ("http_once(", "tcp_connect_host(", "tcp_probe(", "apex_run(")
# Tools whose "target" argument filters local records; they never touch it.
+210 -2
View File
@@ -134,7 +134,7 @@ res, _ = run([
], home=empty)
check("tools/list answers", any(r.get("id") == 1 for r in res))
tools = [r for r in res if r.get("id") == 1][0]["result"]["tools"]
check("155 tools registered", len(tools) == 155, len(tools))
check("159 tools registered", len(tools) == 159, len(tools))
names = {t["name"] for t in tools}
for need in ("portscan", "nmap", "http_request", "marauder_scan",
"method_playbook", "finding_add", "finding_update", "scope_check",
@@ -1560,7 +1560,7 @@ try:
check("http initialize", init["result"]["serverInfo"]["name"] == "apex-twin",
init)
listing = post({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
check("http tools/list", len(listing["result"]["tools"]) == 155)
check("http tools/list", len(listing["result"]["tools"]) == 159)
shown = post(call(3, "scope_show"))
check("http scope_show", '"loaded":true' in shown["result"]["content"][0]["text"])
# the id must be the request's id, not one found inside the arguments
@@ -7048,6 +7048,214 @@ shutil.rmtree(rd_root, ignore_errors=True)
shutil.rmtree(rd_good_root, ignore_errors=True)
shutil.rmtree(cfg_home, ignore_errors=True)
print("\n== MySQL, Apache, HAProxy and DNSSEC ==\n")
my_root = tempfile.mkdtemp(prefix="apex-my-")
os.makedirs(os.path.join(my_root, "etc", "mysql"))
my_bad = os.path.join(my_root, "etc", "mysql", "my.cnf")
with open(my_bad, "w") as f:
f.write("[mysqld]\n")
f.write("bind-address = 0.0.0.0\n")
f.write("skip-grant-tables\n")
f.write("local-infile=1\n")
f.write("secure-file-priv =\n")
os.chmod(my_bad, 0o666)
my_good_root = tempfile.mkdtemp(prefix="apex-myg-")
os.makedirs(os.path.join(my_good_root, "etc", "mysql"))
with open(os.path.join(my_good_root, "etc", "mysql", "my.cnf"), "w") as f:
f.write("[mysqld]\n")
f.write("bind-address = 127.0.0.1\n")
f.write("local-infile=0\n")
f.write("secure-file-priv = /var/lib/mysql-files\n")
ap_root = tempfile.mkdtemp(prefix="apex-ap-")
os.makedirs(os.path.join(ap_root, "etc", "apache2", "sites-enabled"))
with open(os.path.join(ap_root, "etc", "apache2", "apache2.conf"), "w") as f:
f.write("ServerTokens Full\n")
f.write("Options Indexes FollowSymLinks\n")
f.write("AllowOverride All\n")
f.write("SSLProtocol +TLSv1 +TLSv1.1\n")
f.write("ServerSignature On\n")
ap_site = os.path.join(ap_root, "etc", "apache2", "sites-enabled",
"000-default.conf")
with open(ap_site, "w") as f:
f.write("<VirtualHost *:80>\n</VirtualHost>\n")
os.chmod(ap_site, 0o666)
ap_good_root = tempfile.mkdtemp(prefix="apex-apg-")
os.makedirs(os.path.join(ap_good_root, "etc", "apache2"))
with open(os.path.join(ap_good_root, "etc", "apache2", "apache2.conf"),
"w") as f:
f.write("ServerTokens Prod\n")
f.write("Options -Indexes FollowSymLinks\n")
f.write("AllowOverride None\n")
f.write("SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1\n")
f.write("ServerSignature Off\n")
ha_root = tempfile.mkdtemp(prefix="apex-ha-")
os.makedirs(os.path.join(ha_root, "etc", "haproxy"))
ha_bad = os.path.join(ha_root, "etc", "haproxy", "haproxy.cfg")
with open(ha_bad, "w") as f:
f.write("global\n stats socket /var/run/haproxy.sock\n")
f.write("frontend web\n bind *:443\n")
f.write(" stats enable\n stats uri /stats\n")
os.chmod(ha_bad, 0o666)
ha_good_root = tempfile.mkdtemp(prefix="apex-hag-")
os.makedirs(os.path.join(ha_good_root, "etc", "haproxy"))
with open(os.path.join(ha_good_root, "etc", "haproxy", "haproxy.cfg"),
"w") as f:
f.write("global\n stats socket /var/run/haproxy.sock mode 600 level admin\n")
f.write("frontend web\n bind *:443 ssl crt /etc/ssl/site.pem\n")
f.write(" stats enable\n stats uri /stats\n")
f.write(" stats auth admin:secret\n")
def dnssec_agent():
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("127.0.0.1", 0))
sock.settimeout(0.2)
port = sock.getsockname()[1]
stop = threading.Event()
def rsa_key(alg, bits):
nbytes = bits // 8
modulus = b"\x80" + b"\x00" * (nbytes - 1)
return (struct.pack(">HBB", 257, 3, alg) +
b"\x03\x01\x00\x01" + modulus)
def ds_rdata(alg):
return struct.pack(">HBB", 12345, alg, 2) + bytes(range(32))
def loop():
while not stop.is_set():
try:
data, addr = sock.recvfrom(2048)
except socket.timeout:
continue
except OSError:
return
if len(data) < 12:
continue
tid = data[:2]
name, off = dns_name_decode(data, 12)
if off + 4 > len(data):
continue
qtype = struct.unpack(">H", data[off:off + 2])[0]
question = data[12:off + 4]
answers = []
def rr(rdata, rtype):
return (b"\xc0\x0c" +
struct.pack(">HHIH", rtype, 1, 300, len(rdata)) +
rdata)
if name == "signed.test" and qtype == 48:
answers.append(rr(rsa_key(8, 2048), 48))
elif name == "signed.test" and qtype == 43:
answers.append(rr(ds_rdata(8), 43))
elif name == "weak.test" and qtype == 48:
answers.append(rr(rsa_key(5, 1024), 48))
elif name == "weak.test" and qtype == 43:
answers.append(rr(ds_rdata(5), 43))
resp = (tid + struct.pack(">HHHHH", 0x8400, 1, len(answers), 0, 0) +
question + b"".join(answers))
sock.sendto(resp, addr)
threading.Thread(target=loop, daemon=True).start()
return sock, port, stop
dnssec_sock, dnssec_port, dnssec_stop = dnssec_agent()
cfg2_home = tempfile.mkdtemp(prefix="apex-cfg2-home-")
write_scope(cfg2_home, {"label": "cfg2", "expires": "2099-12-31T23:59:59Z",
"allow_private": True, "allow_ip": ["127.0.0.1"],
"allow_domain": ["signed.test", "weak.test",
"unsigned.test"],
"allow_port": [str(dnssec_port)]})
res, _ = run([
call(1, "mysql_config_audit", root=my_root),
call(2, "mysql_config_audit", root=my_good_root),
call(3, "apache_audit", root=ap_root),
call(4, "apache_audit", root=ap_good_root),
call(5, "haproxy_audit", root=ha_root),
call(6, "haproxy_audit", root=ha_good_root),
call(7, "dnssec_check", domain="signed.test", resolver="127.0.0.1",
port=dnssec_port),
call(8, "dnssec_check", domain="weak.test", resolver="127.0.0.1",
port=dnssec_port),
call(9, "dnssec_check", domain="unsigned.test", resolver="127.0.0.1",
port=dnssec_port),
call(10, "mysql_config_audit", root="/nonexistent-my"),
call(11, "apache_audit", root="/nonexistent-ap"),
call(12, "haproxy_audit", root="/nonexistent-ha"),
call(13, "dnssec_check", domain="evil.test"),
], home=cfg2_home)
by_id = {r.get("id"): r for r in res}
my = json.loads(text(by_id[1]))
my_kinds = {f["id"] for f in my["findings"]}
check("mysql_config_audit flags the unsafe server",
{"bind-all", "skip-grant-tables", "local-infile",
"secure-file-priv-empty", "world-writable"} <= my_kinds, my)
my_good = json.loads(text(by_id[2]))
check("mysql_config_audit accepts a hardened server",
my_good["findings_count"] == 0 and
my_good["bind_address"] == "127.0.0.1", my_good)
ap = json.loads(text(by_id[3]))
ap_kinds = {f["id"] for f in ap["findings"]}
check("apache_audit flags tokens, indexes, overrides, protocols, signature",
{"server-tokens", "options-indexes", "allowoverride-all",
"weak-protocol", "server-signature"} <= ap_kinds, ap)
check("apache_audit flags the world-writable vhost",
"world-writable" in ap_kinds and ap["files"] == 2, ap)
ap_good = json.loads(text(by_id[4]))
check("apache_audit accepts a hardened config",
ap_good["findings_count"] == 0 and
ap_good["server_tokens"] == "Prod", ap_good)
ha = json.loads(text(by_id[5]))
ha_kinds = {f["id"] for f in ha["findings"]}
check("haproxy_audit flags socket, stats and TLS",
{"stats-socket-mode", "stats-no-auth", "bind-443-no-ssl"} <= ha_kinds,
ha)
check("haproxy_audit flags a world-writable config",
"world-writable" in {f["id"] for f in ha["findings"]}, ha)
ha_good = json.loads(text(by_id[6]))
check("haproxy_audit accepts a hardened config",
ha_good["findings_count"] == 0 and ha_good["stats_auth"] is True,
ha_good)
ds = json.loads(text(by_id[7]))
check("dnssec_check reads a signed domain",
ds["signed"] is True and ds["dnskey_count"] == 1 and
ds["ds_count"] == 1 and ds["algorithm"] == 8 and
ds["key_bits"] == 2048, ds)
check("dnssec_check finds no gaps on a strong key",
ds["findings_count"] == 0, ds)
weak = json.loads(text(by_id[8]))
weak_kinds = {f["id"] for f in weak["findings"]}
check("dnssec_check flags RSASHA1 and a short key",
weak["algorithm"] == 5 and weak["key_bits"] == 1024 and
{"rsasha1", "short-rsa-key"} <= weak_kinds, weak)
unsigned = json.loads(text(by_id[9]))
check("dnssec_check flags an unsigned domain",
unsigned["signed"] is False and
"not-signed" in {f["id"] for f in unsigned["findings"]}, unsigned)
check("mysql_config_audit reports a missing config", err(by_id[10]),
text(by_id[10]))
check("apache_audit reports a missing config", err(by_id[11]),
text(by_id[11]))
check("haproxy_audit reports a missing config", err(by_id[12]),
text(by_id[12]))
check("dnssec_check refuses an out-of-scope domain", err(by_id[13]),
text(by_id[13]))
dnssec_stop.set()
dnssec_sock.close()
shutil.rmtree(my_root, ignore_errors=True)
shutil.rmtree(my_good_root, ignore_errors=True)
shutil.rmtree(ap_root, ignore_errors=True)
shutil.rmtree(ap_good_root, ignore_errors=True)
shutil.rmtree(ha_root, ignore_errors=True)
shutil.rmtree(ha_good_root, ignore_errors=True)
shutil.rmtree(cfg2_home, ignore_errors=True)
print("\n== esp32 tools ==")
esp_home = tempfile.mkdtemp(prefix="apex-esp-")
write_scope(esp_home, {"label": "esp", "expires": "2099-12-31T23:59:59Z"})