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

# ARMssembly 1

Detailed writeup: <https://medium.com/@alhamrizvi.in/armssembly-picoctf-walkthrough-reverse-engineering-by-alham-rizvi-e642402b0972>

### ARMssembly — PicoCTF Walkthrough (Reverse Engineering)

We’re given an ARM binary and asked to find the input that makes the program print **“You win!”**. Instead of guessing, we reverse the logic.

After analyzing the assembly (or converting it to C), the core function looks like this:

```c
int func(int input) {
    int a = 88;
    int b = 4;
    int c = 3;

    int result = (a << b);
    result = result / c;
    result = result - input;

    return result;
}
```

The `main()` function simply does:

```c
int val = atoi(argv[1]);
int res = func(val);

if (res == 0) {
    puts("You win!");
} else {
    puts("You Lose :(");
}
```

***

### Understanding the Logic

The program computes a value internally, then subtracts your input from it. To win, the result must be zero.

So the condition becomes:

```
(a << b) / c - input = 0
```

Rearranging:

```
input = (a << b) / c
```

***

### Solve It

Now compute step by step:

```
a = 88
b = 4
c = 3

a << b = 88 << 4 = 88 × 16 = 1408
1408 / 3 = 469   (integer division)
```

So the correct input is:

```
input = 469
```

***

### Exploit

Run the binary with:

```bash
./chall 469
```

It prints:

```
You win!
```

***

### Final Flag

```
picoCTF{000000e5}
```


---

# 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/armssembly-1.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.
