> 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/the-add-on-trap.md).

# The Add ON trap

A Firefox browser extension (.xpi) that hides a flag inside its source code, disguised as an encryption key.

`.xpi` files are just ZIP archives:

```bash
unzip 56102ec0438646c68605-1.0.xpi -d extension/
cat extension/background/main.js
```

Inside `main.js`, two suspicious values stood out:

```javascript
const key = "cGljb0NURnt5b3UncmUgb24gdGhlIHJpZ2h0IHRyYX0="
const webhookUrl = 'gAAAAABmfRjw...'
```

The comment said the key must be a **32-byte url-safe base64 Fernet key**. Decoding the "key" directly:

```python
import base64
base64.b64decode("cGljb0NURnt5b3UncmUgb24gdGhlIHJpZ2h0IHRyYX0=")
# → picoCTF{you're on the right tra}  ← truncated!
```

The real flag was in the Fernet-encrypted `webhookUrl`, decrypted using the key:

```python
from cryptography.fernet import Fernet

key = b"cGljb0NURnt5b3UncmUgb24gdGhlIHJpZ2h0IHRyYX0="
token = b"gAAAAABmfRjwFKUB-X3GBBqaN1tZYcPg5oLJVJ5XQHFogEgcRSxSis1e4qwicAKohmjqaD-QG8DIN5ie3uijCVAe3xiYmoEHlxATWUP3DC97R00Cgkw4f3HZKsP5xHewOqVPH8ap9FbE"

f = Fernet(key)
print(f.decrypt(token).decode())

# → picoCTF{...}
```

* `.xpi` extensions are ZIP files — always unpack and read the JS
* Extensions have access to `webNavigation` — every URL you visit was being silently exfiltrated to a webhook
* Secrets hardcoded in extensions are never safe — even "encrypted" ones expose both the key and ciphertext


---

# 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/the-add-on-trap.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.
