ASM2

The problem description give us asm2(0x9,0x1e) and the asm source code. Read through the code end up in a loop, once the loop breaks we got the return value, which is the flag.

    <+20>:  add    DWORD PTR [ebp-0x4],0x1
    <+24>:  add    DWORD PTR [ebp-0x8],0xa9
    <+31>:  cmp    DWORD PTR [ebp-0x8],0x47a6
    <+38>:  jle    0x501 <asm2+20>

Rewrite the function in Python

def asm2(a, b):
  while a <= 0x47a6:
    b += 1
    a += 0xa9
  return b

Invoke asm2 with given parameters to get the result.

print(asm2(0x9,0x1e))
TOP