Listing MongoDB databases
A MongoDB installation may store several databases. Listing databases is useful to both system administrators and penetration testers, and there is an NSE script to do this easily when we don't have a client at hand.
This recipe describes how to use Nmap to list databases in MongoDB.
How to do it...
To list MongoDB databases, enter the following command:
$ nmap -p27017 --script mongodb-databases <target>
The databases are shown in the script output section:
PORT STATE SERVICE 27017/tcp open mongodb | mongodb-databases: | ok = 1 | databases | 1 | empty = true | sizeOnDisk = 1 | name = local | 0 | empty = true | sizeOnDisk = 1 | name = admin | 3 | empty = true | sizeOnDisk = 1 | name = test | 2 | empty = true | sizeOnDisk = 1 | name = nice%20ports%2C |_ totalSize = 0
How it works...
The previous command launches the mongodb-databases
NSE script if a MongoDB server is found running on port 27017
(-p 27017 --script mongodb-databases...