Binary and Malware Analysis

Table of Contents

Packers

Binary packers

Packer takes binary program and makes a new program that has unpacker and packed version of P.

What’s a binary?

A binary is code in binary format (PE for Windows, ELF for Linux, Mach-O for Mac).

The format

ELF format:

Stripped binaries

Symbol table can be removed with strip -s <program>

Functions and global symbols

Address of global symbols imported from external libraries computed when binary loaded in memory

If code needs to call function in different module, dynamic linker creates array of read-only jump stubs: Procedure Linking Table (PLT, .plt)

Process creation in Linux

ELF auxiliary vectors

Mechanism to transfer kernel level info to user processes (such as pointer to system call entry point in memory).

ELF Loader:

Packers

Initially for compression, but convenient for malware to evade antivirus, and many packers also have anti-debugging techniques.

We want to run the malware, let it unpack itself, and dump memory at the right moment (when it’s completely unpacked).

Analysing a binary

Static

file: determine file type

readelf: display information about contents of ELF files

ldd: print shared libraries

nm: list symbols from object files

strings: print strings of printable characters

Dynamic methods

/proc/<pid>: general information about process with <pid>

strace: tracks system calls performed by process

ltrace: tracks dynamically linked library calls