> 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/gogo.md).

# gogo

We are given a binary (`enter_password`) and a remote service. The goal is to find:

* The correct password
* The unhashed key

### Step 1: Reverse Engineering

Opened the binary in Ghidra and found a function:

```c
checkPassword()
```

Inside it, the program checks the password using this logic:

```
input[i] ^ secret[i] == expected[i]
```

* Loop runs 32 times (0x20), so password length is 32
* Uses XOR operation

### Step 2: Debugging with GDB

Started GDB:

```bash
gdb ./enter_password
```

Set breakpoint at XOR instruction:

```bash
b *0x080d4b28
```

Run program:

```bash
r
```

Entered 32 'a' characters.

### Step 3: Extract values

From registers:

Input:

```bash
x/32bx $ecx
```

Secret array:

```bash
x/32bx $esp+0x4
```

Expected array:

```bash
x/32bx $esp+0x24
```

### Step 4: Recover password

Using:

```
input = secret ^ expected
```

Python script:

```python
secret = [...]
expected = [...]

password = ''.join(chr(s ^ e) for s,e in zip(secret, expected))
print(password)
```

Password:

```
reverseengineericanbarelyforward
```

***

### Step 5: Find unhashed key

Secret array converted to ASCII:

```
861836f13e3d627dfa375bdb8389214e
```

This is an MD5 hash.

Cracked using an online tool, result:

```
goldfish
```

### Step 6: Connect to service

```bash
nc wily-courier.picoctf.net 62523
```

Enter:

```
reverseengineericanbarelyforward
goldfish
```

### Flag

```
picoCTF{p1kap1ka_p1c0b187f1db}
```

### Key Takeaways

* XOR logic can be reversed easily
* GDB helps extract runtime values
* Hashes like MD5 can often be cracked using public databases


---

# 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/gogo.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.
