Malware analysis
Malware analysis
S
1Q)
Types of Malware Analysis
1. Static Malware Analysis
Here, the malware components or properties are analyzed without actually
executingthecode.Staticmalwareanalysisisusedtoexaminethefileforsignsof
malicious intent. It is a signature-based technique, i.e., the signature of the
malware's binary is determined by calculating its cryptographic hash.
2. Dynamic Malware Analysis
Malware components are executed within a safe virtual environment (called
sandbox) to observe its behavior. Dynamic malware analysis is a behavior-based
approach to detect and analyze the malware under observation.
3. Hybrid Malware Analysis
Security teams resort to a combination of static and dynamic malware analysis,
known as hybrid analysis that is the best of both approaches. Hybrid Malware
Analysis can easily detect hidden malicious codes and extract indicators of
compromise (IOCs) statically from the unseen code. Italsohelpsinthedetection
of unknown threats from some of the most sophisticated malware.
2 Q)
Dead Malware Analysis
Deadmalwareanalysis,alsoknownasstaticmalwareanalysis,isatechniqueused
to examine a malware sample without executing it. This method is crucial for
understanding a malware’s structure, functionality, and potential impact in a safe
and controlled environment.
alware authors often write programs in high-level languages (e.g., C, C++,
M
Python) but compile them into machine code.
Disassemblers (e.g., IDA Pro, Ghidra) translate machine code into assembly,
allowing analysts to study the malware’s logic.
Understanding assembly helps in identifying malicious functions, API calls, and
obfuscation techniques.
Common Assembly Instructions in Malware Analysis
nit-2
U
In malware analysis, understanding the x86 architecture and the main memory
(RAM) is crucial for analyzing and reverse engineering malicious software. The
x86 architecture is widely used in personal computers and servers, and malware
often targets systems based onthisarchitecture.Mainmemoryisaprimarytarget
for malwarebecauseitallowsthemtoinjectcode,manipulatedata,andhidetheir
presence in the system.
Here are some key aspects of x86 architecture and main memory relevant to
malware analysis:
1. Registers:
● Registers are small, fast storage locations within the CPU thatareusedfor
temporary data storage and manipulation.
● EAX,EBX,ECX,andEDXaregeneral-purposeregistersoftenusedinx86
assembly language.
● ESP (stack pointer) and EBP(basepointer)areimportantformanagingthe
stack.
2. Memory Segmentation:
● The x86 architecture uses a segmented memory model, where memory is
divided intosegments.Segmentationinvolvesspecifyingasegmentregister
and an offset within that segment to access memory.
● Understanding segment registers(CS,DS,ES,FS,GS,SS)isimportantfor
analyzing memory references in assembly code.
3. Memory Protection:
● x86 architecture supports memory protection mechanisms, including read,
write, and execute permissions. Malware often tries to modify memory
permissions to execute code in data sections, which is a common evasion
technique.
● Analyzing memory protection flags helps identify suspicious behavior in
emory.
m
4. Stack and Heap:
● The stack is used for storing local variables and function call information.
Malware often manipulates the stack to hide its activities or execute
shellcode.
● The heap is used for dynamic memory allocation. Understanding heap
structures and allocations is essential for detecting memory-related attacks.
5. Code Injection:
● Malwareofteninjectsitscodeintotheaddressspaceoflegitimateprocesses.
This can involve overwriting existing code or injecting new code into
specific memory regions.
● Analyzing code injection techniques and the modified memory regions is
crucial for understanding malware behavior.
6. API Hooking:
● Malware may use techniques like API hooking tointerceptandmanipulate
calls to system functions. This involves modifying memory to redirect
program flow.
● Identifying changes to function pointers in memory is important for
detecting API hooking.
7. Anti-Analysis Techniques:
● Malware may employ anti-analysis techniques, such as encryption,
obfuscation, and self-modifying code, to make analysis more challenging.
● Understanding how malware uses main memory for these techniques is
crucial for effective analysis.
In malware analysis, tools like debuggers, disassemblers, and memory analysis
tools are commonly used to examine the behavior of malicious code in main
memory. Analyzing memory dumps, identifying patterns,andunderstandingcode
execution flow are key components of effective malware analysis on x86
architectures.
Instructions, Opcodes and Endianness, Operands, Registers, Simple Instructions,
The Stack, Conditionals, Branching, Rep Instructions, C Main Method and Offsets
nit-3
U
Analysing traces of malware across various aspectslikesystemcalls,APIcalls,
registrymodifications,andnetworkactivitiesindeadmalwareanalysisprovidesa
comprehensive understanding of its behaviour without executing it. Here's a
step-by-step guide to conducting such an analysis:
Collecting Malware Sample:
Obtain the malware sample from a reliable source and ensure proper handlingto
avoid accidental execution or contamination.
Static Analysis:
Conductinitialstaticanalysistogatherbasicinformationaboutthemalware,such
as file properties, size, and metadata.
Calculate cryptographic hashes (MD5, SHA1, SHA256) for identification and
sharing purposes.
System Call Analysis:
Usesystemcalltracingtools(e.g.,straceforLinux,trussforUnix-likesystems,or
API monitoring tools for Windows) to analyse system call activity.
Capturesystemcalltraceswhileemulatingthemalware'sexecutioninacontrolled
environment.
Identify system calls related to file manipulation, process creation, memory
operations, and privilege escalation attempts.
API Call Analysis:
Analysedynamic-linklibrary(DLL)importsandexportstoidentifyAPIsinvoked
by the malware.
Cross-referenceAPIcallswithsystemcalltracestocorrelatehigh-leveloperations
with low-level system interactions.
Identify API calls related to file operations, network communication, process
management, and registry manipulation.
Registry Analysis:
xamine registry modifications made by the malware to persist across system
E
reboots or alter system configurations.
Use registry analysis tools (e.g., Registry Editor on Windows, RegShot) to
compare system snapshots before and after malware execution.
Identify registry keys and values created, modified, or deleted by the malware,
particularly those related to autostart mechanisms or malware persistence.