MongoDB 27017
1. Nmap Scans for MongoDB
For database enumeration:
2. Brute Forcing Credentials
Single username, password list:
Username list, single password:
3. Connecting to MongoDB
Local Connection:
Remote Connection:
For authenticated access:
4. Basic Commands
List all databases:
Switch database or create if it doesn’t exist:
List collections in the current database:
List all users in the current database:
View database users:
Run a JavaScript file:
5. Data Retrieval Using Queries
Find all documents in a collection:
Find one document matching a condition:
Operators:
$eq
: Equal$ne
: Not equal$gt
: Greater than
6. Exploitation Techniques
Unsecured Instances:
Unauthenticated MongoDB instances allow direct access. Simply connect using:
Dump all databases:
Export data using
mongodump
:
Weak Credentials:
If credentials are identified (e.g., via brute force), authenticate and escalate data access.
No Authorization Restrictions:
Misconfigured MongoDB can allow creation or modification of collections:
Script Injection via
$where
:Execute JavaScript within queries:
7. Automation with Scripts
You can automate enumeration and exploitation using custom scripts or tools:
Python automation script:
Last updated