asm1
Problem
What does asm1(0x610) return? Submit the flag as a hexadecimal value (starting with '0x'). NOTE: Your submission for this question will NOT be in the normal flag format. Source located in the directory at /problems/asm1_1_95494d904d73b330976420bc1cd763ec.
Solution
Let's look at the source:
We call
asm1(0x610)
so we are putting0x610
into the stack. This value gets pushed into ebp and then moved into esp on lines 0 and 1. Normally ebp is used to backup esp, so if esp is changed by the code in a function, all it takes to restore esp is mov esp, ebp. Also since ebp is normally left unchanged by the code in a function, it can be used to access passed parameters or local variables without having to adjust the offsets. More info about esp and ebp: StackOverflow answer.First Condition:
Here, we are comparing (cmp) first value in the stack (which is
0x610
) to 0x3b9. The jg means "jump if greater". Since0x610
is indeed greater than 0x3b9, we jump to the line given by this condition: line 34.Second Condition:
Here, we have another comparison, this time between the first value in the stack and
0x477
. The condition jne means "jump if not equal". Since0x610
is not equal to0x477
, this is true and jump to line 51.Addition
Here, the value in the stack is moved to the variable that will be returned eax. We then add
0x11
to it, so now eax is equal to0x610+0x11=0x621
.Ending
On line 57, the stack is popped and eax is returned. Since eax is equal to
0x621
, that is our flag.
Flag
0x621
Last updated