Static vs Dynamic Analysis

Description

After the code has been compiled it becomes necessary to perform Code Analysis to ensure that it is performing in a favourable way.

In Reverse Engineering, we analyse code to either find loop holes in the target application/code,etc. or to audit the security performace, or even to optimise its performance.

Types of Analysis

There are two ways to perform analysis.

Static Analysis

If you are performing analysis of a program without executing it, then this type of analysis is called Static Analysis.

But why would you analyse a program without executing it?

  1. It can be used to analyse the Control Flow of the program to check what piece of the code would get executed and in what sequence.
  2. It can be used to analyse Data Flow , to check how the information would flow within a program and across programs.
  3. It can be used for a quicker turn around for fixes.
  4. Static analysis can be used to find weaknesses in the code at the exact location.
  5. There are some automated tools in the market that can make your job easy.
Disadvantages of Static Analysis
  1. Since the code is being analysed without being executed,it does not help to find vulnerabilities introduced in the runtime environment.
  2. It is a bit tedious and time consuming process, if done manually.
  3. Automated tools do not support all programming languages.
  4. Automated tools are likely to provide false positives and negatives.

Some tools that can be used for static analysis: ghidra,gdb,radare2,IDA Pro,etc.

Dynamic Analysis

The analysis performed on a program during its execution is called Dynamic Analysis. It analyses the properties of a program while it is executing.It is more precise than static analysis as there are lot other things that come into view during execution like dynamic binding,threads,polymorphism, etc

The advantages of Dynamic Analysis are:

  1. Can be used to identify vulnerabilities in a runtime environment.
  2. Can help to identify false negatives that occured in the static code analysis.
  3. Can be used to validate the vulnerabilites found during static analysis.

It has a down side too.

  1. It is more difficult to trace the vulnerability back to the exact location in the code, taking longer to fix the problem
  2. Doing Dynamic analysis on a malicious program can result in your computer being infected to it.

Tools like OllyDbg,etc.can help you perform Dynamic Analysis.