Canape

#Linux #PythonScript #Git #CouchDB #Sudo

This is a medium difficulty Linux machine from HackTheBox created by overcast. In this scenario, my IP is 10.10.14.36 and the target’s IP is 10.129.177.254

The use of a file (.git) with the default name, makes the site easy to find by using Nmap scripts, this machine requires a basic understanding of Python and Burpsuite to get the parameters.

Recon

This step is always the same, you must ping the machine to see if is alive, and then use Nmap to scan all the ports to avoid surprises.

Local Terminal
$ ping -c 1 10.129.177.254

Pinging 10.129.177.254 with 32 bytes of data:
Reply from 10.129.177.254: bytes=32 time=175ms TTL=63
Reply from 10.129.177.254: bytes=32 time=158ms TTL=63
Reply from 10.129.177.254: bytes=32 time=186ms TTL=63
Reply from 10.129.177.254: bytes=32 time=164ms TTL=63

Ping statistics for 10.129.177.254:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 158ms, Maximum = 186ms, Average = 170ms
Local Terminal
$ nmap -p- --open -sS --min-rate 5000 -vvv -n 10.129.177.254 -oN Ports

Nmap scan report for 10.129.177.254
Host is up, received echo-reply ttl 63 (0.40s latency).
Scanned at 2023-06-05 10:02:24 Pacific SA Standard Time for 28s
Not shown: 65533 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT      STATE SERVICE REASON
80/tcp    open  http    syn-ack ttl 63
65535/tcp open  unknown syn-ack ttl 63

Read data files from: C:\Program Files (x86)\Nmap
Nmap done: 1 IP address (1 host up) scanned in 28.88 seconds
           Raw packets sent: 131089 (5.768MB) | Rcvd: 77 (3.372KB)

Here we have valuable information, there is a .git and the port for SSH is different, once discovered makes no difference. Let's explore the website

  • Browser: http://10.129.177.254/.git/

http://10.129.177.254/.git/config

Add both sites to etc host.

Nothing here!

  • Browser: http://canape.htb

At the view:source (CTRL+U) there is a hash, it does not change after a reload, so save it.

Hash: c8a74a098a60aaea1af98945bd707a7eab0ff4b0

The result when exploring each site:

  • /submit Submit page, it has some fillable text box.

  • /static JS & CSS

  • /quotes Quotes list page, nothing.

  • /check Method not accepted

  • /server-status Forbidden

Testing

Now, the only thing that we can do, is to test many payloads.

  • Browser: http://10.129.177.254/submit

The character text box is restringed to a list of names, the Quote box is more flexible.

No response at the http server

Information captured:

  • It uses "MATCH", so something like "asdasdHomerasdasd" will work

  • ID = MD5 of char+quote

Reverse Shell [www-data]

cPickle is a dangerous library because it represent a python object in a string of bytes and viceversa.

  • vi exploit.py

Open two terminals, one to execute the exploit and the other one to connect

User Scalation [Homer]

Do a shell upgrade before continue.

At the git project we found a database.

Couch 2.0.0, now that we have the version we can check at exploitdb.

Download the python script at your local machine and send it to the target.

Now we are going to explore inside the data base, there is a link about how to explore couchdb by using Curl.

Now we have to see the information to each id.

If there are MAAANY users, you can use the following command:

Thanks S4vitar for this class, soon I will do it by myself.

Now we know 4 users and 4 password to test, after trying, the correct one is:

Privilege Scalation [Root]

Now we have to find a way to escalate.

That was easy, at GTFOBins you can find the steps to scalate through pip.

Last updated