Nunchucks - Easy

Introduction@Nunchucks:~$
Name
IP
10.10.11.122
Points
40
OS
Linux
Difficulty
Easy
Creator
Release Date
02 / Nov / 2021
Recon
Nmap
Only 3 Ports are opened and we can see a DNS name nunchucks.htb. So add our /etc/hosts
echo 10.10.11.122 nunchucks.htb | sudo tee -a /etc/hosts
Web

I tried directory bruteforce but noting interesting. There is also a signup page which is currently closed. So noting much we can do. Let's find vhosts for this.
Finding Vhosts
Found a subdomain called store.nunchucks.htb . Add this again to /etc/hosts
If we go this domain, we can see another web page running Express which is Javascript Framework.

When we enter an email and click on Notify Me , It will reflected a message to us.

So I tried SSTI like this.

Now we can confirmed there is Server Site Template Injection .
After wasting some times in google , I found a website that we can get code execution for Nunchucks Template Engine.
Intercept with Burp and enter payload like this
Note: if you copy from original website, don't forget to esacpe double quote.

Now we get the content of /etc/passwd .
Getting User David
I generate ssh-key with ssh-keygen in my localhost.
Put it our ssh public key to /home/david/.ssh/authorized_keys.
And then we can login with ssh.
Privilege Escalaption
After some enumerating, there is some interesting file in /opt directory
backup.pl
This script is seem like to backup files into web_backups directory which is owned by root.
It' s also using POSIX::setuid(0); to run as root but It must be SUID or capability.
As a linpeas output ,we can see it has CAP_SETUID.

You can also check wit this command : getcap -r / 2>/dev/null
GTFObin
I run this one line command from GTFObin but it not worked.When we try to run whoami
It will return as root, we can't even read root.txt , it said permission denied.
But when we create this one line command into a script and run it.
Now we get a shell as root.
Note: But we can' execute like this. It said permission denied.
This is weird. I tried to search on Google and I found an Article about this. If a script including the shebang of the restricted application is used, then the script will not be allocated the same restrictions and will be executed as shown in the link. Knowing that we can execute scripts with the shebang and they won't apply the AppArmor profile to the script. That's it.

Author Account : https://app.hackthebox.com/profile/237587
Last updated