Pilgrimage
Gaining Access
Nmap scan:
$ nmap -p- --min-rate 3000 10.129.29.28
Starting Nmap 7.93 ( https://nmap.org ) at 2023-06-25 16:31 +08
Warning: 10.129.29.28 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.129.29.28
Host is up (0.17s latency).
Not shown: 60710 closed tcp ports (conn-refused), 4823 filtered tcp ports (no-response)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open httpWe have to add pilgrimage.htb to our /etc/hosts file to view the web application.
Image Shrinker -> .git
The website offers a service to shrink images.

If we upload an image, we would get back a URL:

Interesting! This image is probably being passed somewhere into a command line instance. Anyways, before going that route, I did a directory and subdomain enumeration first using gobuster and wfuzz.
A few directories were picked up by the more popular wordlists, but all led to nothing much. I ran one with the dirsearch.txt wordlist, and found that a .git directory exists on the machine:
We can download this entire directory using git-dumper:
This tool also checks out for us, and we get the source code of the website:
Image Magick -> LFI
One of the files is the magick binary, which is probably referring to Image Magick. Running it with the --version flag reveals that this is using an oudated version of it:
This version has an LFI vulnerability that can be found on ExploitDB:
The login.php file also has some interesting stuff, showing us how the login authentication works and where the database file is:
The exploit path would be to get an LFI and download the entire database to find credentials. The ExploitDB PoC brings us to this repository:
I cloned it and ran this as a first test:
Afterwards, we can upload the image.png file to the website and download it again. When we run identify on it, it would some hex stuff appended at the end:
If we convert this to text, we would get the /etc/passwd file, meaning it worked:

Now we can replace the file with /var/db/pilgrimage. This would give us a humongous hex output, and after removing the irrelevant parts, we can convert it using xxd to get a SQLite file.
We can use sqlite3 to view the file and find some credentials:
Then, we can ssh as the user emily.

Privilege Escalation
Pspy64 -> Binwalk RCE
Running pspy64 would show this process:
Here's the contents of this script:
This uses inotifywait to wait for files present in the /shrunk directory (which is where images uploaded are stored), and then it uses binwalk on them to make sure that there's no hidden stuff within it.
We can enumerate the version of binwalk being used:
There are public RCE exploits for this particular version:
We can use this script to embed a payload within an empty image (run touch sample.png).
Afterwards, we can download this file to the /var/www/pilgrimage.htb/shrunk folder as anything. If you monitor pspy64 output, this would cause the malwarescan.sh script to be run, and our listener port would have a reverse shell!

Rooted!
Last updated