Knife (Easy)

Knife Hackethebox Walkthrough

Enumeration

Nmap

nmap -sC -sV -oA nmap/Knife 10.10.10.242
# Nmap 7.91 scan initiated Thu May 27 11:23:58 2021 as: nmap -sC -sV -oA nmap/Knife 10.10.10.242
Nmap scan report for 10.10.10.242
Host is up (0.061s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 be:54:9c:a3:67:c3:15:c3:64:71:7f:6a:53:4a:4c:21 (RSA)
|   256 bf:8a:3f:d4:06:e9:2e:87:4e:c9:7e:ab:22:0e:c0:ee (ECDSA)
|_  256 1a:de:a1:cc:37:ce:53:bb:1b:fb:2b:0b:ad:b3:f6:84 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)
|_http-title:  Emergent Medical Idea
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu May 27 11:24:10 2021 -- 1 IP address (1 host up) scanned in 12.02 seconds

Port 80 is open. Lets navigate to that.

We can see this webpage is built purely on HTML and JavaScript.

Nikto

We can see this is powered by PHP 8.1.0-dev.

After googling, this exploit actually close to 0-day exploit :)

and we found this Packet Storm exploit.

Reverse Shell

Running this command will get us a reverse shell.

Privilege Escalation

We can see that user james can execute knife command with sudo

By executing sudo /usr/bin/knife --help will give us this long help manual.

After some searching,we found a documentation about knife

What we want to pay attention on is the knife exec -E command. More information can be found here.

What we can do is

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

ROOOOOT !

Congratz!

Last updated

Was this helpful?