> 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/race-conditions/race-conditions-that-bypass-limits.md).

# Состояния гонки, обходящие ограничения

### Состояния гонки при превышении лимита

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

#### Цель

Успешно купите **Лёгкая кожаная куртка L33t**.

#### Данные / Предварительные условия

* Учетные данные: `wiener:peter`
* Код скидки (20%): `PROMO20`
* Доступный кредит: **$50**

<figure><img src="/files/023c0d29348c3a0d6781bb4ff26eb279a2b76579" alt=""><figcaption></figcaption></figure>

* Стоимость куртки: **$1300**

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

### Наблюдение за поведением

1. Добавьте куртку в корзину.
2. Примените `PROMO20` купон.
3. Если попытаться применить купон во второй раз, приложение отвечает: **Купон уже применён**.

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

Запрос на применение купона выглядит так (URL-кодирование формы):

```bash
csrf=7QYFGBaACc8P5YOfUHR4S85oo95uA0Vb&coupon=PROMO20
```

### Ручная эксплуатация (Burp Repeater)

1. Отправьте запрос на применение **Repeater**.
2. Создайте **группы** в Repeater.

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

* Дублируйте вкладку запроса примерно 20 раз (**Дублировать вкладку**).

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

<figure><img src="/files/7273af43970895056be229f3238d1595aeece0a7" alt=""><figcaption></figcaption></figure>

Отправить запросы **параллельно**.

<figure><img src="/files/13c6b6a4ae5e3b64f26de77d70fb407935882562" alt=""><figcaption></figcaption></figure>

В результате большинство запросов **проходят проверку**, а итоговая сумма становится **/\~37**, что позволяет совершить покупку, несмотря на исходную цену ($1300) и ограниченный кредит.

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

### Автоматизированная эксплуатация (пользовательское действие Burp Suite Pro)

Лабораторная работа рекомендует использовать **Вызывать состояния гонки** (Burp Suite Professional) через **пользовательское действие**.

#### 1) Добавьте скрипт (Bambda Library)

Перейдите в **Расширения → библиотека Bambda** и добавьте:

* **id**: `eb57d5bd-33e2-4a8c-bf51-bc81bd26613a`
* **name**: `Проверка на состояние гонки`
* **функция**: `CUSTOM_ACTION`
* **расположение**: `REPEATER`

```javascript
id: eb57d5bd-33e2-4a8c-bf51-bc81bd26613a
name: Проверка на состояние гонки
функция: CUSTOM_ACTION
расположение: REPEATER
source: |+
  /**
  * Повторяет запрос 10 раз, чтобы вызвать состояния гонки или контрабанду запросов, используя атаку одним пакетом для HTTP/2 и синхронизацию по последнему байту для HTTP/1
  *
  * @author James Kettle
  **/
  int NUMBER_OF_REQUESTS = 10;
  var reqs = new ArrayList<HttpRequest>();
  for (int i = 0; i < NUMBER_OF_REQUESTS; i++) {
      reqs.add(requestResponse.request());
  }

  var responses = api().http().sendRequests(reqs);
  var codes = responses.stream().map(HttpRequestResponse::response).map(HttpResponse::statusCode).toList();
  logging().logToOutput(codes);
```

<figure><img src="/files/8a537e6866043c3bde4f47fb14f5e1816077e9a5" alt=""><figcaption></figcaption></figure>

#### 2) Запустите из Repeater

1. В Repeater: **пользовательское действие** → добавить из примеров.

<figure><img src="/files/6d19b24c3f0cdc46ca2e064dcd6c929cadc4f56a" alt="" width="548"><figcaption></figcaption></figure>

* Загрузите созданное пользовательское действие.

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

Проверьте с **30 запросов**.

мы видим **коды состояния** (для 30 отправок) и мы можем легче вызвать состояние гонки

<figure><img src="/files/8d4d8752820d166cc5f9d922501225d85d73ecfb" 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/race-conditions/race-conditions-that-bypass-limits.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.
