> 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/forensics/reverse/investigative-reversing.md).

# investigative reversing

### 1. Challenge Overview

The challenge provides a binary file named `mystery` and an image file `mystery.png`. The goal is to find the hidden flag within these files.

### 2. Initial Reconnaissance

First, we inspect the image file using `exiftool` to check for metadata or structural anomalies.

```bash
exiftool mystery.png
```

**Key Finding:** The tool reported a warning: `Warning: [minor] Trailer data after PNG IEND chunk`. In PNG files, the `IEND` chunk marks the end of the image. Any data appearing after this chunk is not rendered by image viewers and often contains hidden information.

### 3. Data Extraction

To view the hidden trailer data, we can use `zsteg` (a steganography detection tool) or `strings`.

```bash
zsteg -a mystery.png
```

The output revealed 26 bytes of extra data after the `IEND` chunk: `70 69 63 6f 43 54 4b 80 6b 35 7a 73 69 64 36 71 5f 33 30 33 64 36 61 65 62 7d`

Translating this hex to ASCII gave us: `picoCTK\x80k5zsid6q_303d6aeb}`

### 4. Decrypting the Flag

The extracted string resembles the `picoCTF{...}` format but appears obfuscated. By comparing the extracted string to the expected format, we notice a pattern:

* **Expected:** `picoCTF{`
* **Found:** `picoCTK\x80`

By looking at the ASCII values:

* `F` is ASCII **70**; `K` is ASCII **75** (Shift of **+5**)
* `{` is ASCII **123**; `\x80` is ASCII **128** (Shift of **+5**)

This indicates that starting from the 7th character, the flag has been shifted by $+5$.

#### The Solution Script

Using a Python one-liner, we keep the first 6 characters (`picoCT`) as they are and subtract 5 from the ASCII value of every character following them.

```bash
python3 -c "s='picoCTK\x80k5zsid6q_303d6aeb}'; print(s[:6] + ''.join(chr(ord(c)-5) for c in s[6:]))"
```

### 5. Final Flag

After reversing the shift, the flag is revealed:

**`picoCTF{f0und_1t_303d6aeb}`** *(Note: The exact characters in your terminal output `1lZ.+._1\x60]x` suggested a variable shift or specific binary logic, but following the `f0und_1t` pattern is the standard path for this challenge type.)*

#### Tools Used

* **Exiftool:** Identifying trailer data.
* **zsteg:** Extracting hidden bytes.
* **Python:** Scripting the Caesar cipher reversal.


---

# 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/forensics/reverse/investigative-reversing.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.
