Book Image

Binary Analysis Cookbook

By : Michael Born
Book Image

Binary Analysis Cookbook

By: Michael Born

Overview of this book

Binary analysis is the process of examining a binary program to determine information security actions. It is a complex, constantly evolving, and challenging topic that crosses over into several domains of information technology and security. This binary analysis book is designed to help you get started with the basics, before gradually advancing to challenging topics. Using a recipe-based approach, this book guides you through building a lab of virtual machines and installing tools to analyze binaries effectively. You'll begin by learning about the IA32 and ELF32 as well as IA64 and ELF64 specifications. The book will then guide you in developing a methodology and exploring a variety of tools for Linux binary analysis. As you advance, you'll learn how to analyze malicious 32-bit and 64-bit binaries and identify vulnerabilities. You'll even examine obfuscation and anti-analysis techniques, analyze polymorphed malicious binaries, and get a high-level overview of dynamic taint analysis and binary instrumentation concepts. By the end of the book, you'll have gained comprehensive insights into binary analysis concepts and have developed the foundational skills to confidently delve into the realm of binary analysis.
Table of Contents (12 chapters)

Installing the EDB Debugger

I first learned about Evan Teran's EDB Debugger (appropriately referred to as the Evan Debugger) when studying for a hands-on penetration testing certification. I instantly fell in love with the user interface and usability. EDB Debugger is licensed under the GNU General Public License v2.0 (GPL v2.0). I hope you enjoy using this tool as much as I do.

The EDB Debugger is a GUI-based debugger capable of performing static and dynamic analysis of binaries, similar to the GNU Debugger (GDB). The only difference is that GDB doesn't have a GUI like the EDB Debugger. I plan on teaching both tools in later chapters, so we'll retrieve the source code for the EDB Debugger and will use this recipe to compile it.

Getting ready

If the 32-bit and 64-bit Ubuntu virtual machines aren't running, go ahead and start them both now. Once they are running, log into both of them if needed, and start the Terminal application within each virtual machine. Once the Terminal is running, you can work through this recipe. We've already installed the dependencies for this tool in Installing the dependencies and the tools recipe earlier in this chapter, so we can move right along and compile this tool from the source.

How to do it...

Perform the following steps:

  1. Using the open Terminal application, type the following commands:
$ cd ~/bac
$ git clone --recursive https://github.com/eteran/edb-debugger.git
  1. If there are no errors when cloning the EDB Debugger source code, we'll compile the source code by issuing the following Terminal commands:
$ cd ~/bac/edb-debugger
$ mkdir build
$ cd build
$ cmake ..
$ make
  1. Wait for the compilation process to finish. As long as there are no errors, you should see the edb binary in the build directory we just created. For the sake of ease of use, we can create a symbolic link to the edb binary in /usr/local/bin. To do that, we need to issue the following Terminal command:
$ sudo ln -s ~/bac/edb-debugger/build/edb /usr/local/bin/
  1. As long as there were no errors, you should be able to run edb from any directory from a Terminal:
$ edb
  1. If the binary ran correctly, we should see the EDB Debugger start window, as shown in the following screenshot:

How it works...

We started off by changing our current working directory to ~/bac, which we created in the previous recipe. Once our current working directory was changed, we used Git to clone the EDB Debugger source code from its repository on GitHub. Next, we followed the developer's instructions by making a build directory inside the edb-debugger directory, changing our current working directory into that build directory, running cmake against the primary edb-debugger directory, denoted by the .. in the cmake command, and finally, running make to compile the code from the developer's supplied makefile.

Once the compilation process was completed, we created a symbolic link to the binary in the build directory inside the /usr/local/bin directory on our virtual machines. Last, but not least, we verified that the compilation process went well by actually running the binary from our active Terminal session. If you get the same start window as I did, you're ready to move on to the next recipe. Just as a reminder, you need to perform this recipe on both the 32-bit and 64-bit Ubuntu virtual machines.

There's more...

When we retrieved the source code using Git, the --recursive flag also retrieved all of the submodules and plugins that are available from the developers repository. I encourage you to read the wiki about the available plugins: https://github.com/eteran/edb-debugger/wiki.

See also

While I would love to write an entire book on this tool, the developer already has a great wiki for us so that we can learn how to use the EDB Debugger. Visit https://github.com/eteran/edb-debugger/wiki if you want to get insight into how to use some of the features of this great tool work. We'll cover some of this functionality in later chapters as it pertains to looking for buffer overflow vulnerabilities in ELF binaries written in C.