Forge

Gaining Access

Nmap scan:

$ nmap -p- --min-rate 5000 10.129.204.233
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-07 16:00 EDT
Nmap scan report for 10.129.204.233
Host is up (0.0087s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT   STATE    SERVICE
21/tcp filtered ftp
22/tcp open     ssh
80/tcp open     http

We have to add forge.htb to our /etc/hosts file to enumerate the website. Also, FTP is not a false positive here.

Forge.htb Enum

The website is some kind of Gallery that lets us view and upload images.

The uploads portion allow us to use URLs:

If we were to start a nc listener port and redirect the request to our machine, we would see this:

This was using a Python based website, that is sending requests. The website had nothing else to offer, and I wasn't able to download or execute any webshells. So I did some wfuzz subdomain fuzzing and gobuster directory scans.

wfuzz picked up on an administrator site:

Trying to visit it doesn't work though.

Redirect Bypass -> SSH Key

All my attempts to access the admin panel via modifying HTTP headers didn't work. So we have to try something else.

Since this server was in Python, and the administrator panel can only be accessed by localhost, I thought of creating a 'redirector' that would accept requests on the website and redirect us to the admin panel. Here's a good script for that:

When we start this, the website would generate a link to an 'image', which would always fail to display because it's not an image.

But, when we curl it, we can see it contains the page contents of the admin panel:

Let's read the announcements on the site.

This reveals some credentials for us to use for FTP, which is behind a firewall. Since the /upload endpoint supports FTP traffic, we can make our script redirect us there using the u parameter and ftp://.

When redirected, we can see the contents of the FTP server:

This looks like the user's directory, so let's check whether there's a .ssh folder present.

We can grab the id_rsa flag through this and SSH in as user.

Grab the user flag.

Privilege Escalation

Remote Manage -> Path Hijacking

When we check sudo privileges, we find that user is able to run a Python script as root.

Here's the script:

This program opens a port and then runs commands as root. The vulnerable part is when it opens pdb upon receivinig an input that is not a number.

pdb is Python Debugger, and running it as root means we can gain an easy shell.

Rooted!

Last updated