I didn’t get time to play Hackover 15 as much as I wanted. It looked like a really fun competition but unfortunately it overlapped with Hitcon 2015. However I woke up super early (6am Saturday - eek!) to get a few hours in on Hackover before Hitcon started.
Here’s an RE challenge I did very quickly and I just want to show how sometimes the environment you work in gives you a leg up. In this case PEDA (the GDB add-on) gave me the flag faster than I could reverse the binary.
The clue was:
The file, a compressed tarball, contains just one file: “goto.bin” which identifies as “data” with file…
root@mankrik:~/hackover/re150/writeup# tar -zxvf goto-03661d1a42ad20065ef6bfbe5a06287c.tgz goto.bin root@mankrik:~/hackover/re150/writeup# file goto.bin goto.bin: data ``` </div> Small headscratch here. I look at the file in XXD and see there's some shell script header here:root@mankrik:~/hackover/re150/writeup# xxd goto.bin | head -5 0000000: 543d 743b 6361 7420 2430 207c 2074 6169 T=t;cat $0 | tai 0000010: 6c20 2d63 202b 3735 207c 2067 756e 7a69 l -c +75 | gunzi 0000020: 7020 2d20 3e20 2454 3b63 686d 6f64 202b p - > $T;chmod + 0000030: 7820 2454 3b2e 2f24 543b 726d 202e 2f24 x $T;./$T;rm ./$ 0000040: 543b 6578 6974 2030 3b0a 1f8b 0808 efae T;exit 0;....... root@mankrik:~/hackover/re150/writeup# head -1 goto.bin T=t;cat $0 | tail -c +75 | gunzip - > $T;chmod +x $T;./$T;rm ./$T;exit 0; ``` </div> Fine... Great... Mild obfuscation I am ok with I decide just to let it decode itself...root@mankrik:~/hackover/re150/writeup# sh goto.bin PASSWORD:^C root@mankrik:~/hackover/re150/writeup# ls -la t -rwxr-xr-x 1 root root 4882 Oct 19 22:01 t root@mankrik:~/hackover/re150/writeup# file t t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.24, dynamically linked (uses shared libs), stripped ``` </div> We now have the meat of the challenge, the ELF binary. Executing it, as we saw, simply asks for a PASSWORD:. I assume the flag is the password. Either way off to IDA Pro we go.... I decide to dynamically examine comparison points before diving in to perform a full static analysis. Often times simpler RE challenges can be solved rapidly with dynamic analysis, skipping a lot of time on the static analysis. I decide to set breakpoints at obvious loops. The second such loop I examine is this one, I set a breakpoint at 0x4006aa (the cmp instruction): I fire up GDB w/PEDA and watch the program execution:root@mankrik:~/hackover/re150# gdb ./t GNU gdb (GDB) 7.4.1-debian gdb-peda$ br *0x4006aa Breakpoint 1 at 0x4006aa gdb-peda$ r warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffff7ffa000 PASSWORD:a [----------------------------------registers-----------------------------------] RAX: 0x601071 ("aMTCvd@CacAOEe #EgkPTSrd#S_oAOS e#SmvSO gs# eeSODoe#GtrWOEnr$Re1OONnt%Ao5ROIa ^Nr{DaE y&TCI 20sDgo#ET_ 20l 20iu$DFU 20d 20v!% 20_S 20j 20e 20^ 20{E 20k 20 20&