Posts Couch
Post
Cancel

Couch

Description

Hack into a vulnerable database server that collects and stores data in JSON-based document formats, in this semi-guided challenge.

RoomCouch
OSLinux
DifficultyEasy
Creatorstuxnet

Let’s deploy the machine and we’ll start with scanning open ports quickly with rustscan,

1
rustscan -a 10.10.93.56

image

we got 2 open ports. Let’s scan these ports in detail using nmap.

1
nmap -sV -sC -p22,5984 10.10.93.56 -oN nmap.txt

image

Okay so, port 22 is running openssh service and port 5984 is running a CouchDB on a webserver.

Let’s enumerate port 5984 by visiting http://10.10.93.56,

image

and we’ll be presented with data presented in JSON format. With this data, we got to know that database running is ******* and we can confirm this with nmap scan result.

Now, that we know that database is CouchDB and we don’t know what hidden pages we’ve, so let’s bruteforce directories using dirsearch,

1
dirsearch -u http://10.10.93.56:5984/ -w /usr/share/seclists/Discovery/Web-Content/common.txt -i 200,301

image

After running gobuster scan, I got to know that there are few hidden paths which we can enumerate.

Let’s start with /_config path and visit http://10.10.93.56/_config,

image

We’ll be presented with enormous amount of data which we can’t comprehend now. As we can see that the data is presented in JSON format, so it is difficult to gather information from this presentation.

But I figured it how somehow to present data in a great way. First, let’s read the source code of this page and copy everything from there. Then, visit CodeBeautify and paste the data we copied from source code on left panel and then there is a Beautify button on middle, click that. What it’ll do is that, it’ll beautify all JSON data and present in human readable format.

image

We can also zoom in as per our comfort.

From here, we can see httpd_global_handlers function which holds many value,

image

and there is a ****** key, which has value of /usr/share/couchdb/www means this is a actual website path.

Let’s visit https://10.10.93.56/_utils,

image

and there we go, we’re presented with a web application. We can see there is a table of database which contains names of entries.

Let’s click on secret entry,

image

we’ll get a random number entry (which seriously I have no idea about), let’s click on it.

image

We get data like id, rev and passwordbackup. We got username and password. Maybe those will work on SSH? Let’s try.

1
ssh atena@10.10.93.56

image

entering the password will get us authenticated. We’re now atena user and we can confirm this with whoami command.

Establish directory content using ls -la ,

image

we can see our user flag.

Now comes in the privilege escalation part. After enumeration I found that there isn’t much I can do with to get system access but fortunately, I found great thing in history.

Issuing history command will get us all the history of commands that user or root user issued till date,

image

and there is a command in the history which seems interesting. Maybe after running this command will elevate our privileges to root? Let’s try.

Let’s run this docker command and see what happens,

1
docker -H 127.0.0.1:2375 run --rm -it --privileged --net=host -v /:/mnt alpine

image

and we got root. Confirm this by issuing id command.

Let’s navigate to /root directory for our root flag,

image

and establish directory content using ls -la we don’t have our root.txt file. Wait, so where is it? If it’s not here then it maybe possible that owner have changed it’s location.

Let’s find this file on system,

1
find / -name *root*.txt -type f 2>/dev/null

image

we and there we got our root flag path.

Let’s navigate to /mnt/root and establish directory content using ls -la,

image

and there we can see our root.txt file.

This post is licensed under CC BY 4.0 by the author.