c964c59d0d3aa473b6b4b450f8e9fdf6.png

0. Preface

This box is a pretty straightforward one. Just gotta sift through the LinPEAS output and you’re pretty much golden for privilege escalation.

In this box, we will be tackling:

  1. Koken CMS exploit
  2. Careful reading through LinPEAS output

1. Preliminary NMAP Scan

sudo nmap -sC -sV -oN nmap.txt 192.168.32.7 -v

ef928a49bb248f003031a1dc907cfeb0.png

This is a Ubuntu box running Apache. A couple of ports we can look through - 445, 80 and 8000.

2. SMB Share

Let’s start off with anonymous SMBMap.

smbmap -u "" -p "" -H 192.168.32.7

c132c71c1a2d540b6a1bd8b03fb4aae9.png

Looks like we have read access to sambashare. Let’s download everything from there.

smbclient -N \\\\192.168.32.7\\sambashare

fa2120e21423e30ce450109c68017a62.png

94ca1eb631a3a9d652e0c4faabd4da5e.png

Taking a look at mailsent.txt gives us two potential usernames - daisa and agi, as well as two potential email addresses - daisa@photographer.com and agi@photographer.com.

Next, move on to extracting and looking inside wordpress.bkp.zip.

2ea30280fd7abc103e5d021d81557360.png

Nothing much of interest here.

3. Web Server Enumeration, Hydra Brute Force

Let’s move on to the web server.

433ea947ed3483851e6659f6438fcbf0.png

This seems to be a photography site running on html. We can start off by running gobuster to brute force directories.

gobuster dir -u http://192.168.32.7 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x html

9474ea5345f868a3ca7f77b3bc71f860.png

There’s nothing much of use here, so let’s move on to the web server on :8000.

9f3375a854a2b5a7ca8a71c4ec60fbec.png

Navigating to timeline gives us this shell.php.

6650300ba3e5c9cf72465e9394fcad4a.png

Clicking on this bring us to a pretty familiar php reverse shell message. Interesting.

caeb9c49737436f54ecf47ccf8e540d3.png

Moving on to look at the page source, there appears to be a /admin directory. Let’s try accessing it.

8c29ead2bb79187216b82fca58f3f526.png

f9c3267eaf06763fe66f19f204112c3f.png

So we got a login page. Let’s try to login with daisa@photographer.com and proxy the POST request to burpsuite.

75476784e93b280d878dba3aa7e957ed.png

This seems to be running Koken CMS, based on the HTTP cookie headers.

Back to the login page, let’s first trigger a failed login and try to reset the password for agi@photographer.com.

e37fbf59d746ddc71c00a99ca5dbdeb8.png

This gives us an error message that the email address was not found. Let’s try resetting the password for daisa@photographer.com instead.

9ad3fc8c7326746606236844374a7597.png

Nice, we seem to have a valid email address. Let’s use hydra to bruteforce with rockyou.txt.

hydra -l "daisa@photographer.com" -P /usr/share/wordlists/rockyou.txt 192.168.32.7 -s 8000 http-post-form "/api.php?/sessions:email=^USER^&password=^PASS^:User not found"

45d45d29033e9edabd0254423015c159.png

Awesome, we got the credentials daisa@photographer.com:babygirl. Let’s login with those credentials.

03fa869c9153623d9d0c889e7a23a0a2.png

4. Koken CMS Exploit, Reverse Shell

Looking at the console page, we see that this is running Koken 0.22.24.

9877d44b440cbfd270df19166d850c3a.png

There is an exploit for this, which is written by the same guy who made this box.

So, following the POC, we will try to upload an “image” with phpinfo().

31983cbfa3ff1ff9e6a2bb5750cbd1b3.png

Now that we know it works, we can upload a php reverse shell with the following LHOST IP and LPORT.

fba77017b91eb57ccec93c5309599839.png

After the upload has completed, we setup a netcat listener on port 8000, then navigate to http://192.168.32.7:8000/storage/originals/02/a9/image.php to trigger the reverse shell.

a9357f7c2b1f50e035daf4865bbd3258.png

Let’s first grab the user flag on /home/daisa.

58b539724a1405677b5eae18e928060a.png

5. Linpeas Enumeration, Root

Now let’s upload and run linpeas.sh to enumerate the box automatically.

14c771bbed00e1238d5e923b8fbd1e0e.png

Looking through the linpeas output, we notice that php7.2 has the SUID bit set. Let’s take a look at the php7.2 binary.

b246ccf5ecda5a13e935e676c4389906.png

Since php7.2 is owned by root, anything we run through this binary will also be run as root due to the SUID bit.

Using GTFOBins, we find that we are able to execute /bin/bash using php. This should give us a root shell.

031944984f9873b881def4cbea24ba85.png

php -r "pcntl_exec('/bin/bash', ['-p']);"

6982ca4e2bfb0a8c6c521cf51a09680e.png