Skip to main content

Enumeration

Run Nmap Scan

Looking at the http title, we can see that it redirects to artcorp.htb. We are going to update the hostname.

Add Hostname

We are going to add artcorp.htb to the hostname list as http is redirecting to the link

Directory Bruteforcing (Run Gobuster)

View Website

Untitled

Enumerating the subdomain

We found dev01.artcorp.htb using the subdomain fuzzer.

Update Hostname

Exploitation

dev01.artcorp.htb (exiftool vulnerability)

View Website

Untitled Clicking metaview button, it will redirect us to the image upload website

/metaview

Untitled Untitled If we upload file that isn’t image related file, it is not allowing it. Even though we did change the file extension and modified the file hex at the front

Testing in normal case scenario

Untitled Looking at the output, it looks like a linux program called exiftool which is a metadata editor.

Searching for Exiftool Exploit

Generating Reverse Shell Embedded Image

Checking generated image’s attributes using exiftool

Listen to Reverse Shell and Exploit

Untitled Turn on the reverse shell and upload the reverse shell embedded jpeg image to the website

Privilege Escalation

www-data to thomas

Monitoring Processes using pspy

Download pspy64 https://github.com/DominicBreuker/pspy Execute pspy inside the target system
If we look at the process, it is executing /usr/local/bin/convert_images.sh with the permission of user thomas. Unfortunately, abusing PATH variables are not allowed here as it uses full path

Checking Convert_Images.sh

Looking at the script, the script is not alterable Viewing the script
It’s using the mogrify program to format the file to png.

Checking Mogrify

Program Mogrify can be altered, but it is pointing to another program magick
Checking the Version of mogrify
Here it is not outputing Mogrify, instead it is outputing the version of ImageMagick. Looks like it’s a packaged program

Exploiting ImageMagick (CVE-2020-29599)

exploit.svg is a script directly copied from the CVE_2020-29599 analysis blog. Online - Reverse Shell Generator The reverse shell (Bash -i Option) should be generated in base64 format After copying base64 Bash -i Revshell code, replace the code with <reverse shell code>
Place the file inside /var/www/dev01.artcorp.htb/convert_images
Tip: make the filename as the image attribute xlink:href. The exploit will not work if the filename is different

Listen to Reverse Shell and Exploit

Thomas to Root

Checking Sudo Permissions

We can use the command /usr/bin/neofetch \"\" in sudo permission without the root credentials

Adding malicious configuration file

Add a bash execution command inside the configuration file, so the root shell will be called when we call the sudo neofetch command. Checking environment

Exploit

Reference