Reverse Engineering
Welcome to your introduction to Reverse Engineering! Reverse Engineering is a critical art that you will evolve during your journey through pwn.college, and this journey starts here with the Connor Image Format, cIMG. You have never heard of cIMG before, and it does not actually exist in the wider world, but throughout this module you will reverse engineer it by analyzing various iterations of cIMG rendering binaries. By the time you solve the last level, you will have gone from no knowledge about cIMG to complete understanding of it, a path that you will walk many times with many different programs.
Reverse Engineering: Introduction
Fundamentals: Binary Files
Fundamentals: Linux Process Loading
Fundamentals: Linux Process Execution
Reverse Engineering: Functions and Frames
Reverse Engineering: Data Access
Reverse Engineering: Static Tools
Reverse Engineering: Dynamic Tools
Reverse Engineering: Real-world Applications
Other Resources
There are many resources related to reverse engineering around the internet.
- A good place to start is a series of walkthroughs of several hacking challenges by ASU's own Adam Doupe on his YouTube channel.
- A comprehensive reverse engineering tutorial series.
Useful Tools
As mentioned in the slides, there are a number of useful tools for this assignment! Here is a (non-exhaustive) list:
gdbwill let you run and inspect the state of these programs. Please check out the Debugging Refresher module. We have also provided a quick briefer here. Some useful gdb concepts:- Know the difference between
step instruction(si) andnext instruction(ni). It boils down to the fact thatsiwill follow jumps, andniwill step over jumps. This means that if you usesi, you will quickly find yourself crawling through libc code, which is insane and unnecessary. - You can use
x/i $ripto disassemble the next instruction that will be executed. You can calldisplay/i $ripto make the next instruction display every time gdb prompts you for input. You can also dox/2ianddisplay/2ito print two (or other quantities of) instructions. - The
disascommand will disassemble the current function that you are looking at. - gdb can be scripted! Look up conditional breakpoints and scriptable breakpoints in the gdb manual.
- Modern binaries are position independent, meaning that they can be loaded anywhere in memory when they run.
GDB will load them at the offset
0x555555554000. This means that if objdump is telling you that main starts at some address like,0x100, the address when debugging with GDB will be0x555555554100
- Know the difference between
stringswill list printable strings in the file. This is useful for looking for constant strings that the program checks for (such as file names and so on) in the course of getting input. Keep in mind that the options for string include a minimum size that it will print.- Don't forget about pwntools! You will need to interact heavily with these programs. Do it right (with pwntools).
rappelis a nice tool to help you figure out what certain instructions do.- Tools for reverse engineering actual binaries, included in the dojo:
- IDA is the industry standard of reverse-engineering tools.
- Ghidra is an open source direct competitor to IDA that is used and loved by many.
- Binary Ninja is an alternative product that competes with IDA in the space.
- angr-management is an open source up-and-coming reversing tool with some advanced functionality.
- In a pinch,
objdump -d -M intel the_binarywill disassemble the binary you want to look at.-M intel, in that command, makes objdump give you nice and readable Intel assembly syntax.