Pilgrimage
Writeup Hack The Box Pilgrimage
Last updated
Writeup Hack The Box Pilgrimage
Last updated
First, we perform port scanning on the machine.
We found .git directory on the website.
After we found .git directory, we can dump the directory to get the source code using Git Dumper.
Now, move to Pilgrimage.
On index.php, we know that the application using the magick binary to process the image.
The "magick" binary itself is ImageMagick, open-source software suite, used for editing and manipulating digital images.
Search on Google, i found this exploit for ImageMagick 7.1.0-49.
https://www.exploit-db.com/exploits/51261
https://github.com/voidz0r/CVE-2022-44268
After download the exploit, run this command to generate image with payload.
Now, upload the image.png to the target.
Next, download the converted image, and analyze the converted image using this command:
Convert the hex to text with xxd command.
Back to index.php again, we found that the website using sqlite database, stored at /var/db/pilgrimage. We can read the db content using above exploit.
Again, upload the image to the website, and download the converted image. Next, get the hex value using xxd command.
Since the hex value is too long, you can save the command into a script.
Inside db.sh, add this line:
Then execute this command.
Now, we can use sqlite database client to read the database content.
Now, we can use the credentials to login into SSH.
After obtaining low-level user access, we can now upload pspy to the target machine and monitor Linux processes.
We found a suspicious process with UID 0 (root) that could potentially be our pathway to gaining root access.
This is the content of malwarescan.sh
In summary, this script provides a way to monitor the /var/www/pilgrimage.htb/shrunk/ directory for newly created files using binwalk and automatically deletes files that match specific criteria defined in the blacklist array.
After check the binwalk version, we know that this binwalk is vulnerable to CVE-2022-4510.
We can use this script:
Before that, nn our local machine run nc to listen at port 1337.
Upload the script to target machine, and generate the reverse shell payload.
Next, copy the generated image to /var/www/pilgrimage.htb/shrunk/ directory.
Using pspy, we can confirm that the binwalk execute our payload.
Checking our netcat, we received a connection from the target with the root user.