root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat usage.md
// writeups

Usage

13 Apr 2024 · 18 min read · root access
Usage - maquina de Hack The Box

Executive summary — Usage combines a blind SQL injection in a Laravel blog's password-reset flow with an unvalidated file upload in its admin panel (CVE-2023-24249 in laravel-admin), which yields a PHP webshell and RCE. The escalation chains two password-reuse steps — first from a Monit config file, then a lesser-known abuse of 7-Zip: a sudo-enabled binary that archives an attacker-writable directory can be turned into a primitive to leak, line by line, any file on the system — including root's SSH private key.

PlatformHack The Box
Operating systemLinux
DifficultyEasy
StatusRetired
Target IP10.129.37.225

Attack map

[80] usage.htb — blind SQLi in /forget-password (Laravel)
   │  dump admin_users → bcrypt hash → cracked: admin:whatever1
   ▼
[80] admin.usage.htb — Laravel-Admin panel
   │  CVE-2023-24249 — unvalidated avatar upload → PHP webshell
   ▼
[RCE]  dash  (user.txt)
   │  ~/.monitrc leaks admin:3nc0d3d_pa$$w0rd, reused by xander
   ▼
[SU]  xander
   │  sudo NOPASSWD /usr/bin/usage_management → 7za -- * on /var/www/html (777)
   │  7-Zip wildcard file-read (@listfile) → /root/.ssh/id_rsa
   ▼
[ROOT]  SSH with the leaked private key → root.txt

1. Reconnaissance and web enumeration

The lab didn't offer passwordless sudo to edit /etc/hosts, so most enumeration used curl --resolve instead of real vhosts on the system:

echo "10.129.37.225 usage.htb admin.usage.htb" | sudo tee -a /etc/hosts
# No-sudo alternative:
curl --resolve usage.htb:80:10.129.37.225 --resolve admin.usage.htb:80:10.129.37.225 http://usage.htb/
nmap -sT -p- --min-rate 3000 -T4 -Pn -oN m3_allports.txt 10.129.37.225
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
nmap -sT -sCV -p22,80 -Pn -oN m3_services.txt 10.129.37.225
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.6 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://usage.htb/

nginx redirects to usage.htb — virtual hosting is in play:

curl -s --resolve usage.htb:80:10.129.37.225 http://usage.htb/ | grep -oiE '<title>|href='
<title>Daily Blogs</title>
href="http://usage.htb/login"
href="http://usage.htb/registration"
href="http://usage.htb/forget-password"
href="http://admin.usage.htb/"          <-- admin subdomain

A Laravel blog app with login, registration, password reset, and an admin panel under the admin.usage.htb subdomain. Checking the forms:

R() { curl -s -c cj.txt -b cj.txt --resolve usage.htb:80:10.129.37.225 --resolve admin.usage.htb:80:10.129.37.225 "$@"; }

# forget-password
R http://usage.htb/forget-password | grep -oiE 'name="[^"]*"|action="[^"]*"'
# name="_token"   name="email"   action=".../forget-password"

# admin.usage.htb
R http://admin.usage.htb/ | grep -oiE '<title>[^<]*|name="[^"]*"|laravel'
# <title>Admin | Login</title>   username / password / _token   (laravel-admin)

admin.usage.htb is a Laravel-Admin panel (the encore/laravel-admin package) — a key fact to remember for later.

🔒 Clearance required

This content is Root Access only. Everything else on the site — the free tier, the whole public library — stays open.

See Root Access plans

No account? Create one free then upgrade from your console.