Mercury - Walkthrough [Vulnhub]
Here's my solution for Mercury.
The machine can be downloaded from here.
Nmap
Scanning for all TCP ports.
$ nmap -sC -sV -p- 192.168.1.106

We find 2 ports open.
Directory Scan
Browsing the web.

We scan for directories using dirb.
$ dirb http://192.168.1.106 -X .html,.php,.txt

Browsing /robots.txt

No any information or hint yet.
But when we enter any random string as a directory name, an error is occurred which reveals a directory name, and we browse it.
We click on- Load a fact, and put a single quote(') after 1. We see a SQL error.

Also after clicking- See list, we put single quote(') after todo a SQL error is occurred.

This makes the chance for SQL Injection. We use sqlmap to automate the process.
Enumerating database names.
$ sqlmap -u http://192.168.1.106:8080/mercuryfacts/* --batch --dbs
Enumerating tables of the database name- mercury.
$ sqlmap -u http://192.168.1.106:8080/mercuryfacts/* --batch --tables -D mercury
Dumping column data of the table- users.
$ sqlmap -u http://192.168.1.106:8080/mercuryfacts/* --batch --columns -T users -D mercury --dump
Getting Access.
The only credential works is the username: webmaster and its associated password.
Accessing SSH.
$ ssh webmaster@192.168.1.106
Password: mercuryisthesizeof0.056Earths

User Flag.
Privilege Escalation
From webmaster>linuxmaster.
We find a file- notes.txt under the directory /mercury_proj
Noticing the contents in it, seems to be the password of another user- linuxmaster in base64 format.

We can verify the user by checking the file- /etc/passwd.

Lets decode the base64 encoded password and switch to the user.


From linuxmaster>root.
We check for SUDO rights.

We see that the .sh file is trying to run the tail command, which is a genuine file under /usr/bin.

Since the absolute path of- tail command, is absent we can take advantage of it by manipulating it's path.

We run the .sh file as user- root and obtain the root flag.
Comments
Post a Comment