Advanced Static Malware Analysis
I would like to share some of my notes of the advanced static malware analysis from what I learned from PMAT (Practical Malware Analysis & Triage) course of TCM Security.
If you missed my notes of the basic static malware analysis, you find them here: https://www.dhirubhai.net/pulse/basic-static-malware-analysis-yusuf-amr/?trackingId=VPQaQHSOSImQBWPAhMCVIA%3D%3D
Introduction
In this article, we will focus on the advanced static malware analysis of the windows portable executables. So we have malware.exe, and we want to get the source code. To do this we need to do reverse engineering to this executable malware to create something that looks very close to the original source code and that's the advanced static analysis.
When we want to create a program, we write it in a high level programming language such C++ or C#. Afterwards, when we run the program, it's compiled to a low level language till it reaches to zeroes and ones that the computer hardware can understand. In the advanced static analysis, we will do the opposite of this flow process. We will look at the possible lowest level language which is the Assembly and fortunately Assembly is a human-readable CPU instruction set.
Malware authors write their malware in a high level language, and we will try to decompile the program to extract the and know how this program was written and its logical execution flow.
What is great about Assembly is that there are no hidden layers that somebody can hide, so this is the absolute truth of what is going on the operating system when the program is called.
We can see the Assembly code through a tool called “Cutter”. What is special about Cutter is its graph feature, which shows a nice view of what is going and where the program will jump, move data and locations of the memory register.
The Assembly
To illustrate Assembly we will need to define three main concepts, and they are: x86 CPU instructions, memory registers and stack.
Those are the common instruction of the CPU instructions:
Let's talk about the Stack. We assign a certain location in memory. We refer to the location by three parts:
So the top location in the stack is 0xffffffff and the lowest location is 0x00000000.
An important thing to know about the stack, that it's LIFO (Last Input First Output).
领英推荐
Last thing is the memory register and common registers are:
These registers are used for temporary data storage and memory access.
Example
Here's an example of malware after uploading it to Cutter to see the Assembly:
Code Explanation:
NOTE: we write an instruction for example, we write "mov ebp, esp" mov is the instruction action, ebp is the destination and the source is esp.
Sr. Marine Pilot SPM & CBM
2 年Good job bro