Nunchucks - A Hack The Box machine
User's flag
Enumeration
Open ports: 22, 80, and 443.
Also http://nunchucks.htb is in results.
Adding IP and domain nunchucks.htb to /etc/hosts.
And some directory enumeration:
Results:
Trying to login into the application or signing up returns the following response message:
Now, we will try some subdomain enumeration
Results: store
We will add store.nunchucks.htb to /etc/hosts file.
Exploitation
Browsing https://store.nunchucks.htb is a simple landing page to collect emails. There is a form for this purpose. After fuzzing it with Burpsuite we find this interesting output:
Some code can get executed in that field. This vulnerability is known as Server-side Template Injection (SSTI)
Once we have an injection endpoint, it's important to identify the application server and template engine running on it, since payloads and exploitation pretty much depends on it.
From headers response we have: "X-Powered-By: Express".
Having a look at template engines in Express at https://expressjs.com/en/resources/template-engines.html, there exists a Nunjucks, which is close the domain name nunchucks.
This blog post describe how we can exploit this vulnerability: http://disse.cting.org/2016/08/02/2016-08-02-sandbox-break-out-nunjucks-template-engine
Basically, I'm using the following payloads:
The last one is a reverse shell. Before running it in BurpSuite Repeater, I've setup my listener with netcat on port 1234.
Root's flag
Privileges escalation
We'll abuse some process capability vulnerability to escalate to root. First we list processes capabilities:
Result:
We will use perl binary to escalate.
And you are root.
Last update: 2024-03-29 Created: May 24, 2023 17:04:33