Let's get dynamic
Problem
Can you tell what this file is reading? chall.S
Solution
First, compile the program:
gcc -g chall.S -o chall. The-gflag compiles with debugging symbols.If we run the program and enter some text, we get
Correct! You entered the flag., which doesn't seem correct.I decompiled the
challbinary using Ghidra to look at a c representation. There is amemcmpinstruction which looks like it compares our input to the flag.We can run the binary in gdb with
gdb challto debug it. I placed a breakpoint at thememcmpstatement withb memcmpand then ran the program withr. We reach the breakpoint and now we can look at the source index and destination index registers, which arersiandrdirespectively. We can view the source index as a string like so:printf "%s\n", $rsi, which prints the flag.GDB output:
$ gdb chall Reading symbols from chall... (gdb) b memcmp Breakpoint 1 at 0x1060 (gdb) r Starting program: ./chall a Breakpoint 1, __memcmp_avx2_movbe () at ../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S:59 59 ../sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S: No such file or directory. (gdb) printf "%s\n", $rsi picoCTF{dyn4m1c_4n4ly1s_1s_5up3r_us3ful_14bfa700}
Flag
picoCTF{dyn4m1c_4n4ly1s_1s_5up3r_us3ful_14bfa700}
Last updated
Was this helpful?