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:
- SMB Enumeration
- CMS exploit for RCE
- SUID binary exploit for Privilege Exploitation
I always start my exploitation from the autorecon scan. Initial Nmap scan results are as below:
Scanned at 2022-04-19 20:02:11 EDT for 23s
Not shown: 996 closed tcp ports (reset)
PORT STATE SERVICE REASON VERSION
80/tcp open http syn-ack ttl 64 Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: Photographer by v1n1v131r4
139/tcp open netbios-ssn syn-ack ttl 64 Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn syn-ack ttl 64 Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP)
8000/tcp open http syn-ack ttl 64 Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-generator: Koken 0.22.24
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
|_http-title: daisa ahomi
MAC Address: 08:00:27:D1:77:8A (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Uptime guess: 14.447 days (since Tue Apr 5 09:18:57 2022)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Host: PHOTOGRAPHER
TRACEROUTE
HOP RTT ADDRESS
1 0.57 ms 10.0.0.26
My autorecon scan mentions a share in SMB that has anonymous read access.
I downloaded the files and they consisted of potential credentials.
Now I moved to web enumeration. Nmap script scan on port 8000 showed me a few potential interesting web directories. /admin
/admin has a login page, which requires email and password.
We do have the email address from the file extracted form SMB. [email protected] . For the password, according to email, I will try a few combinations of my babygirl .
I was successful to log in using [email protected]: babygirl combination.
A Quick search for the koken in searchsploit result shows us the arbitary file upload vulnerability.
Reading at the POC text file. We need to upload the PHP file with .php.jpg extension and edit the request in burp to remove that .jpg extension.
Following the steps from above and using the pentest monkey PHP reverse shell script I get the reverse shell.
Looking around for any more credentials did not result in anything interesting and fruitful. As always, I ran the linpeas script. And I got a potential SUID binary exploitation.
Now going to our old friend gtfobins, we can do privilege escalation exploiting the SUID permission on PHP.
So the following one-line code gives us a root shell.
/usr/bin/php7.2 -r "pcntl_exec('/bin/sh', ['-p']);"