> 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/some-assembly-required1.md).

# some-assembly-required1

### 🔍 Challenge Overview

We are given a web application that validates a flag using client-side logic. The JavaScript file is heavily obfuscated and loads a **WebAssembly (.wasm)** binary for validation.

### 🧩 Step 1: Analyze JavaScript

We fetch the JS file:

```bash
curl -v http://wily-courier.picoctf.net:53140/G82XCw5CX3.js
```

<img src="https://github.com/user-attachments/assets/3cd31dba-d8d8-4e18-a078-2ad1708d91d1" alt="image" height="730" width="1418">

#### Key Observations:

* The code is **obfuscated**, but we can still identify:
  * `fetch("./JIFxzHyW8W")` → loads a WASM file
  * `WebAssembly.instantiate(...)`
  * Functions used:
    * `copy_char`
    * `check_flag`

#### Logic:

```javascript
for (let i = 0; i < input.length; i++) {
    exports.copy_char(input.charCodeAt(i), i);
}
exports.copy_char(0, input.length);

if (exports.check_flag() == 1) {
    "Correct!"
} else {
    "Incorrect!"
}
```

👉 So:

* Input is passed character-by-character into WASM memory
* `check_flag()` validates it

***

### 🧩 Step 2: Extract WASM File

```bash
curl -O http://wily-courier.picoctf.net:53140/JIFxzHyW8W
```

Check file type:

```bash
file JIFxzHyW8W
```

<img src="https://github.com/user-attachments/assets/ab49ccdf-6ac1-430d-87de-655491781ed1" alt="image" height="450" width="1170">

Output:

```
WebAssembly (wasm) binary module
```

***

### 🧩 Step 3: Reverse / Inspect WASM

Instead of fully reversing (hard), we use a shortcut:

```bash
strings JIFxzHyW8W
```

#### Output:

```
picoCTF{68ff4bc93f6d67637b2f471be209d132}
```

🔥 The flag is directly embedded in the binary.

***

### 🏁 Final Flag

```
picoCTF{68ff4bc93f6d67637b2f471be209d132}
```

***

### 💡 Key Takeaways

* **WebAssembly ≠ secure** → client-side validation can always be reversed
* Always check:
  * JS files
  * WASM binaries
  * Network requests
* `strings` is OP for beginner CTFs
* If logic looks complex → **look for shortcuts first**


---

# 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/some-assembly-required1.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.
