This box was downloaded from VulnHub and is also on the TJnull list of practice boxes for OSCP preparation. The box involved the following steps:

  • Enumerating SSH
  • Web Directory Enumeration
  • SQL Injection
  • Linux Kernel Exploitation for Privilege Escalation

I started with the initial Nmap scan and can only find one port open and that too ssh. The initial Nmap Scan result is as below.

Host is up, received arp-response (0.00040s latency).
Scanned at 2022-04-04 21:44:39 EDT for 7s
Not shown: 999 filtered tcp ports (no-response)
PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 64 OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.3 (Ubuntu Linux; protocol 2.0)

Uptime guess: 198.046 days (since Sat Sep 18 20:38:01 2021)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=258 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT     ADDRESS
1   0.40 ms 10.0.0.17

Now when there is only one port open and if that is ssh then I always guess there must be a ssh banner and there must be some information hidden in it. There did exist a banner.

It says Knock Friend to Enter, Easy as 1,2,3. Let’s try knocking using 1,2,3.

nc -w 1 10.0.0.17 1;nc -w 1 10.0.0.17 2; nc -w 1 10.0.0.17 3

Now we have a new port on our Nmap scan. port:1337 . I will start a new nmap script scan on port 1337.

It turns out to be a web page.

I run the gobuster but couldn’t find anything interesting. Then I ran a nikto scan and found something interesting.

nikto -h 10.0.0.17:1337

Nikto can showed /icons/README . Going to the page, I was greeted with another picture.

Looking at the source code I find a base64 encoded message. Going to cyberchef I found it double encoded.

we are closer as mentioned in the code.

So I found a new directory. /978345210/index.php. So the page is a login to Gates of Mordor.

Now I tried everything to perform the manual injection. Failed miserable. So I went on with using sqlmap. Leter if I am able to perform manual exploit I will update thee blog.

sqlmap -o -u http://10.0.0.17:1337/978345210/index.php --forms -dbs -vvv

It gives us name of database on the server.

From those database I am interested in Webapp. So lets find the tables inside the Webapp database.

sqlmap -o -u http://10.0.0.17:1337/978345210/index.php --forms -D Webapp --tables -vvv

Now lets find the columns inside the table Users. i can see interesting column names.

Lets dump all data from the table Users.

I am going to ssh into the system with these username and password combination. Only the smeagol:MyPreciousR00t combination worked. And I am into the system.

I ran linpeas script and there are few avenues for priv escalation.

Quick search on the linux version priv escalation led me to the exploit-db page.

Lets upload that 39166.c file to the target system and compile it. We get root after executing the compiled file.