NodeBlog

H

Gaining Access

Nmap scan:

$ nmap -p- --min-rate 5000 10.129.96.160
Starting Nmap 7.93 ( https://nmap.org ) at 2023-03-08 07:30 EST
Nmap scan report for 10.129.96.160
Host is up (0.013s latency).
Not shown: 65533 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
5000/tcp open  upnp

NoSQL Login Bypass

This was a UHC qualifier box in 2021.

There was a login functionality there. I tested some SQL Injection but to no avail. Because this was a UHC box, this was probably the way in. I tested some NoSQL injection and it worked in bypassing it!

XXE Injection

All of the functions do nothing much, except for the Upload one. When trying to upload something, I get this error:

This indidates that we have to upload a malicious XML file to achieve XXE injection for our reverse shell. Taking a look at the POST request in Burpsuite reveals that we need this format:

I headed to PayloadAllTheThings to try some XXE injection payloads, and it worked rather well:

Then we can save this into a file and upload it. The output would be printed in the markdown area:

Earlier while testing my NoSQL injections, I did run across an error like this:

So the source code files are in /opt/blog. A bit more testing revealed the main file to be server.js.

First thing I notice is that there is unserialisation going on. This web application must be vulnerable to RCE through Deserialisation. This article showed up when I searched for this exploit:

I tested the token given there and it worked: (after URL encoding)

Now, we can replace the ping command I used above with a reverse shell:

This uses base64 to encode the shell one-liner and connect to port 8888.

When trying to read the user flag, I found out that we did not have access to our own home directory. This was because of the permissions set:

We can correct this with chmod 777 admin.

Privilege Escalation

I ran a LinPEAS scan on this machine and found the mongoDB credentials file.

Earlier we used NoSQL injection to access this, and perhaps we can find the actual credentials for the admin user (so that I can check sudo privleges). Some DBs and collections can be found here.

I could find a password from the users collections.

We can use this to check sudo privileges and find an easy root path: