Disassembling a binary: linear sweep and recursive traversal
Building your own set of analysis tools is a great exercise for those who already have some basics in static analysis. It even allows you to later move on to implement more complex analyses in reverse engineering. Even just seeing how the different algorithms can be implemented provides an interesting framework that may help when reverse engineering more difficult-to-analyse binaries, i.e. obfuscated ones.
Excluding the specification of a file format, an executable file contains two main types of information: the instructions (what the CPU executes) and the data (what information the CPU uses to execute instructions). In order to build the high-level information, each analysis pipeline implements several steps: parsing of the executable file, disassembly of instructions, data-flow analysis, reconstruction of the control-flow graph, and type inference. Obtaining the several types of information is very complex due to the nature of static analysis where many undecidable problems are faced: being able to derive correct information is a difficult matter and each step in the analysis pipeline affects the final result.
nicolo.dev