Binary and Malware Analysis

Table of Contents

Introduction

Why binary analysis?

Static analysis: staring at the bytes and trying to see what they mean

Dynamic analysis:

Getting code from binary

Disassembler:

Decompilation:

Analyzing a binary:

Application level Instruction level
Static analysis
  • Identify file type: file foo
  • Extract strings: strings -a -t d foo
  • Identify libraries and imported symbols
    • ldd - list shared libraries
    • nm - list symbols, unless stripped
  • Tracking control flow
  • Path slices
  • Data flow graphs
  • Value set analysis
  • Symbolic execution
Dynamic analysis
General info about the process: /proc//maps
  • Library/system call trace
    • strace - reveal system calls
    • ltrace - strace but for dynamically linked libraries
  • Network sniffer like netstat or tcpdump
    • Improve accuracy of static analyses
    • Dynamic information flow tracking, e.g. input and variable types
    • Function call monitoring
    • Combination of symbolic and dynamic execution

    What’s a binary?

    Common file formats:

    Defines things like what the file looks like on disk, what it should look like in memory

    Contains info about machine to run it on, executable or library, entry point, sections, what should be writable and what should be executable

    Binary format

    What’s malware?

    Executable that