Splodge
Gaining Access
Nmap scan:
$ nmap -p- --min-rate 3000 -Pn 192.168.157.108
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-16 10:08 +08
Nmap scan report for 192.168.157.108
Host is up (0.17s latency).
Not shown: 65530 filtered tcp ports (no-response)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
1337/tcp open waste
5432/tcp open postgresql
8080/tcp open http-proxyDid a detailed scan for the web ports too:
$ sudo nmap -p 80,1337,8080 -sC -sV --min-rate 3000 192.168.157.108
[sudo] password for kali:
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-16 10:09 +08
Nmap scan report for 192.168.157.108
Host is up (0.17s latency).
PORT STATE SERVICE VERSION
80/tcp open http nginx 1.16.1
|_http-server-header: nginx/1.16.1
| http-git:
| 192.168.157.108:80/.git/
| Git repository found!
| .gitignore matched patterns 'bug' 'key'
| .git/config matched patterns 'user'
| Repository description: Unnamed repository; edit this file 'description' to name the...
| Last commit message: initial commit
|_ Project type: node.js application (guessed from .gitignore)
|_http-title: 403 Forbidden
1337/tcp open http nginx 1.16.1
|_http-server-header: nginx/1.16.1
|_http-title: Commando
8080/tcp open http nginx 1.16.1
|_http-title: Splodge | Home
|_http-server-header: nginx/1.16.1
Service detection performed. Please report any incorrect results at https://nmap.org/submitThere's a .git repository.
Git Repo -> Creds
I downloaded the .git repository and looked through the logs with git log -p -2. However, it was way too long for me to analyse. Instead, I checked out the repository and checked for passwords:
Web Enum + Source Code -> RCE
Port 80 just showed us a 403 page, which was not helpful. Port 1337 did show some potential for RCE:

However, I was unable to make anything happen. Port 8080 showed a blog page with an admin login:

We can login to the admin panel using admin:SplodgeSplodgeSplodge:

So now we know that the Git repository is for this application. This panel was rather interesting, because it has a 'Profanity Filter Regex' option, which I presume allows us to specify Regex strings within it.
I was unable to find any source code for this Admin Panel specifically, but I can find some code to see what it does within app/Http/Controllers:
It seems that there's a preg_replace function that replaces the regex matches with our replacement.
Googling for PHP Regex exploits brings this up:
From the article above, we can use regex of /a/e to inject PHP code. I tested this out:

Afterwards, I sent one comment with the letter 'a' in it. When I did, I got a hit on my HTTP server:

We now have RCE over the machine, and we can easily get a reverse shell on port 8080:

Privilege Escalation
PostgresSQL Creds -> User Shell
We spawned in the /usr/share/nginx/html folder, which had a .env file:
There's a database password there. We can then login with psql after fixing the PATH variable of this shell:
There's a feature within PostgreSQL that allows us to execute commands:

We can just get another reverse shell using this:

The payload is taken from Hacktricks.
Root
User can run bash as root:

Last updated