Hi Hackers Welcome Back, Today we are going to look at Hack The Box Mongod Machine.
Info Table
Room Name | Mongod |
---|---|
Category | Hack The Box |
OS | Linux |
Difficulty | Very Easy |
Maker | Hack The Box |
Kill Chain Summery
While enumerating ports and services we can able to find the port 27017 ware open. which is mongodb service, connected as a anonymous user.
Recon
Lets start with default script scan
|
|
Expect 1 port all other ports are filtered by firewall, default scri[t scan will perform scan on top 1000 ports, for better enumeration lets scan entire port
|
|
Databases are a collection of organized information that can be easily accessed, managed and updated. In most environments, database systems are very important because they communicate information related to your sales transactions, product inventory, customer profiles and marketing activities. There are different types of databases and one among them is MongoDB, which is a document-oriented NoSQL database. It is crucial to be aware of how the data is stored in different types of databases and how we can connect to these remote database servers and retrieve the desired data. In a document-oriented NoSQL database, the data is organized into a hierarchy of the following levels:
- databases
- collections
- documents
Databases make up the top level of data organization in a MongoDB instance. Databases are organized into collections which contain documents. Documents contain literal data such as strings, numbers, dates, etc. in a JSON-like format. It often happens that the database server is misconfigured to permit anonymous login which can be exploited by an attacker to get access to sensitive information stored on the database. Mongod is a Linux box that features a MongoDB server running on it which allows anonymous login without a username or
password. We can remotely connect to this MongoDB server using the mongo command line utility and enumerate the database in it to retrieve the flag.
MongoDB
MongoDB is a document-oriented NoSQL database. Instead of using tables and rows like in traditional relational databases, MongoDB makes use of collections and documents. Each database contains collections which in turn further contain documents. Each document consists of key-value pairs which are the basic unit of data in a MongoDB database. A single collection can contain multiple documents and they are schema-less meaning that the size and content of each document can be different from each another.
Connecting to MongoDB
In order to connect to the remote MongoDB server running on the target box, we will need to install the mongodb utility, which can be done on Debian-based Linux distributions (like Parrot, Kali and Ubuntu) by downloading the following tar archive file.
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.7.tgz
tar xvf mongodb-linux-x86_64-3.4.7.tgz
cd mongodb-linux-x86_64-3.4.7/bin
./mongo mongodb://{target_IP}:27017
|
|
We have successfully connected to the remote MongoDB instance as an anonymous user. We can list the databases present on the MongoDB server using the following command.
|
|
We can see that there exists a single collection named flag . We can dump the contents of the documents present in the flag collection by using the db.collection.find() command. Let’s replace the collection name flag in the command and also use pretty() in order to receive the output in a beautified format.
|
|