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
Dynamic 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?
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.
It can be used to analyse Data Flow , to check how the information would flow within a program and across programs.
It can be used for a quicker turn around for fixes.
Static analysis can be used to find weaknesses in the code at the exact location.
There are some automated tools in the market that can make your job easy.
Disadvantages of Static Analysis
Since the code is being analysed without being executed,it does not help to find vulnerabilities introduced in the runtime environment.
It is a bit tedious and time consuming process, if done manually.
Automated tools do not support all programming languages.
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:
Can be used to identify vulnerabilities in a runtime environment.
Can help to identify false negatives that occured in the static code analysis.
Can be used to validate the vulnerabilites found during static analysis.
It has a down side too.
It is more difficult to trace the vulnerability back to the exact location in the code, taking longer to fix the problem
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.