Monday, May 18, 2015

Defcon 2015 : Coding Challenge

This was an interesting challenge where you connect to a remote machine and you're given a set of x64 registers(no rsp, rbp), some bytes and are expected to send back a reply in the "same format". We can assume that the bytes correspond to some shellcode that we are supposed to emulate and send the results of.
I first tried using pyasmjit but for some reason had trouble getting it up and running. Later on, I ended up writing a solution that involves a python script to interact with the server, pwntools to disassemble the bytes received, nasm to assemble a binary, and a pintool to instrument the binary and print out the register state at the end.

The python script can be found here and the pintool can be found here. The pintool emulates the instructions till the "ret" instruction, prints out the registers then exits.