Problem Overview
We are given an assembly file. We are asked to output what asm1(0x2e0)
returns.
Let’s take a look at the assembly file:
|
|
Some quick observations:
- It looks like we are using Intel syntax
- It looks like we just need to run through some conditional checks for the given input value. We should focus on jumping to the right labels.
Walking Through the Code
First Comparison
Our input, 0x2e0
, is 736 in decimal. I will leave some notes on converted hexadecimal values as we work through the code.
|
|
In this first block, we check if the value on the stack is greater than 1019. With our input value of 736, we don’t jump. Instead, we keep walking through the assembly.
Second Comparison
|
|
Here, we check if the input is not equal to 640. It actually is not, so let’s jump to 0x50a
.
EAX Shenanigans
|
|
Here, we move the input value, 736, on the stack into the eax
register.
Then, we subtract 10 from eax
, leaving its value at 726. Let’s jump to 0x529
.
Return
|
|
Here, we just pop the base pointer and return. After converting 726 from the eax register to hexadecimal, we get 2D6
.
The CTF asks us to input the value in the format 0x<RETURN_VALUE>
, so the flag is just 0x2D6
.