> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/web-exploitation/crack-the-gate-2.md).

# Crack the gate 2

in this challenge, we are given a login panel and a known email:

```
ctf-player@picoctf.org
```

along with a password list (`passwords.txt`). the goal is to brute-force the correct password and retrieve the flag.

#### initial testing

we start by manually trying a few passwords. after a couple of failed attempts, the application responds with:

```
Try again in 20 minutes
```

this confirms that **rate limiting** is implemented, preventing normal brute-force attacks.

#### identifying the weakness

since brute force is blocked, the next step is to understand how the rate limiting works.

in many web apps, rate limiting is based on the client IP address. if the backend relies on headers like:

```
X-Forwarded-For
```

to identify the client, and does not validate it properly, we can **spoof the IP address**.

this means every request can appear to come from a different user → effectively bypassing the rate limit.

#### exploitation

instead of using burp intruder, we automate the attack using `ffuf`.

we fuzz two things simultaneously:

* fake IPs via `X-Forwarded-For`
* passwords from `passwords.txt`

command used:

```bash
ffuf -X POST \
-u http://amiable-citadel.picoctf.net:port/login \
-H "Content-Type: application/json" \
-H "X-Forwarded-For: FUZZ1" \
-d '{"email":"ctf-player@picoctf.org","password":"FUZZ2"}' \
-w numbers.txt:FUZZ1 \
-w passwords.txt:FUZZ2 \
-mode pitchfork \
-mc all
```

**key idea:**

* `FUZZ1` → rotates fake IP addresses
* `FUZZ2` → rotates passwords
* `pitchfork` → pairs both lists line-by-line

so each request looks like:

> new IP + new password → no rate limit triggered

#### results

most responses return:

```
429 Too Many Requests
```

but one request returns:

```
200 OK
```

this indicates a successful login.

we extract the corresponding password and log in manually:

```
Email: ctf-player@picoctf.org
Password: <found password>
```

after login, the application reveals the flag:

```
picoCTF{xff_byp4ss_brut3_1c447e47}
```


---

# 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://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/web-exploitation/crack-the-gate-2.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.
