> 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/reverse-engineering/b1ll_gat35.md).

# B1ll\_Gat35

I first tried debugging on a Windows 7(fuh because why tf you added a windows rev engineering cjallenge) setup using rpcclient, but the debugger(Ollydbg) failed to work, because i was fking using rpcclient and yes a dedass windows7 wasting on about an hour, I then moved to my Ghidra, where I was able to proceed successfully.

From Ghidra:

* Takes a number input
* Asks for a **key**
* Checks the key using a function
* If correct → prints flag
* If wrong → says incorrect

#### Important part:

```c
if (check_key(input) == 0)
    print("Incorrect")
else
    print("Correct") + show_flag()
```

So:

> If function returns **0 → wrong** If **non-zero → correct**

### Step 2: Easy Idea (Bypass)

Instead of finding the key, we **force the program to always go to "Correct"**

### Step 3: Patch the binary

In assembly:

```id="b2"
TEST EAX, EAX
JNZ correct_block
```

#### Meaning:

* `JNZ` → jump if NOT zero (correct case)

#### Trick

Change:

```id="b3"
JNZ → JNC
```

Why?

* `TEST` sets Carry Flag (CF) = 0
* `JNC` = Jump if CF = 0
* So it will **ALWAYS jump to correct block**

### Step 4: Run patched binary

```bash
wine patched.exe
```

Input anything:

```id="b5"
Correct input. Printing flag:
PICOCTF{These are the access codes to the vault: 1063340}
```


---

# 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/reverse-engineering/b1ll_gat35.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.
