Static Analysis Techniques
Malware Analysis Fundamentals · Advanced Reverse Engineering track
6 min read
In this module
Looking Without Touching
Static analysis examines malware without executing it. You inspect the file, its structure, and its code to understand what it does — without the risk of it actually running. It's always the first step, because it's safe and can produce a lot of useful intelligence in minutes.
Think of it like examining a suspicious parcel without opening it: you weigh it, X-ray it, read the postmark, check the return address. You learn a lot before you expose yourself to whatever is inside.
File Identification
Before doing anything else, identify what you are dealing with:
File type: Use the file command (Linux/macOS) or read the magic bytes directly. Is it a Windows PE, an ELF binary, a script, a document with macros, or a disguised executable renamed to .pdf? Always verify from the header bytes — never trust the extension.
Hashing: Compute SHA-256 (MD5 optionally). Search on VirusTotal, Malware Bazaar, or similar platforms. A hash match against a known family gets you prior analysis reports and detection signatures for free.
File size and entropy: High entropy — close to 8 bits per byte — usually means the file is packed or encrypted. Normal code sits around 5–6 bits per byte. That delta is your first clue about what's hiding underneath.
$ file suspicious.exesuspicious.exe: PE32 executable (GUI) Intel 80386, for MS Windows
$ sha256sum suspicious.exea3f2b8c9d4e5... suspicious.exe
$ python -c "import math; data=open('suspicious.exe','rb').read(); ..."Entropy: 7.89 bits/byte # Very high - likely packedStatic analysis is safe because the malware never runs. Start with file identification (type, hash, entropy), then examine strings and imports for behavioural clues, and finally disassemble the code if the malware is not too heavily obfuscated. Each layer of analysis reveals more about the malware's purpose and capabilities.
String Analysis
Embedded strings are one of the richest sources of intelligence:
- URLs and IP addresses reveal command-and-control (C2) servers
- File paths show what the malware reads or writes
- Registry keys indicate persistence mechanisms on Windows
- Error messages reveal the malware's internal logic and development language
- Encryption keys are sometimes stored as plaintext strings
- Mutex names prevent multiple copies from running simultaneously
$ strings suspicious.exe | grep -i "http"http://evil-server.example.com/gate.phphttp://backup-c2.example.com/beacon
$ strings suspicious.exe | grep -i "\\Software\\Microsoft\\Windows"\Software\Microsoft\Windows\CurrentVersion\RunThe registry path \CurrentVersion\Run is a persistence tell — the malware is adding itself to auto-start. Two C2 URLs means it has a backup in case the primary server is taken down.
Tools like FLOSS (the FLARE Obfuscated String Solver, maintained by Mandiant's FLARE team) go further and try to recover obfuscated strings automatically. Lots of malware XORs or otherwise encodes its strings specifically to dodge basic analysis; FLOSS finds the program's likely decoding functions and emulates them, and also rebuilds strings assembled byte by byte on the stack, so you don't have to do it by hand.
Import Analysis
A PE file's import table lists which DLL functions it uses. The imports reveal capabilities:
- CreateProcess, ShellExecute - executes other programs
- InternetOpen, HttpSendRequest - makes HTTP requests
- RegSetValueEx - modifies the registry
- VirtualAllocEx, WriteProcessMemory, CreateRemoteThread - injects code into other processes (plain
VirtualAlloconly allocates in the calling process, though withVirtualProtectit's a common sign of unpacking or shellcode loading) - CryptEncrypt - encrypts data (potential ransomware indicator)
- WSAStartup, socket, connect, send, recv - raw network communication
- CreateRemoteThread - creates threads in other processes (code injection)
A binary importing process creation, memory manipulation, network communication, and registry writes is deeply suspicious — even before you've read a single instruction. The import list is a capability advertisement.
PE Structure Analysis
For Windows executables, examining the PE structure reveals:
- Sections: Unusual section names (like
.UPX0), sections with both write and execute permissions, or high-entropy sections suggest packing - Resources: Embedded files, icons, and data in the resource section may contain additional payloads that the malware extracts at runtime
- Timestamps: The compilation timestamp (can be faked but is sometimes revealing, especially when cross-referenced with other samples)
- Digital signatures: Signed malware sometimes uses stolen or fraudulently obtained certificates
Tools like PE-bear, CFF Explorer, and pefile (Python library) parse PE structures and lay them out visually, making anomalies considerably harder to miss.
The chart below shows entropy per section for the same program before and after UPX packing. Switch between the two and watch UPX1 jump past the threshold line while UPX0 has no bytes on disk at all.
Clean PE (illustrative)
Illustrative dataA small 64-bit Windows program as the compiler produced it.
Example
Mode
- .text5.99raw 104 KiB · virtual 103.6 KiB
Not compressed or encrypted. Compiled x86-64 code. Opcodes like 0x48 (REX.W) and 0x8B (MOV) repeat, which keeps it around 6.
- .rdata4.92raw 40 KiB · virtual 39.8 KiB
Not compressed or encrypted. Strings, import tables and constants. Readable text is very repetitive.
- .data1.18raw 4 KiB · virtual 10.6 KiB
Not compressed or encrypted. Initialised globals, mostly zeros. Zeros pull entropy down fast.
- .pdata5.22raw 5 KiB · virtual 4.9 KiB
Not compressed or encrypted. Exception tables: rows of climbing 32-bit addresses.
- .rsrc3.87raw 8 KiB · virtual 7.5 KiB
Not compressed or encrypted. A small icon bitmap, the manifest XML and version info.
Verdict: Not packed. Every section sits below the threshold and .text reads like ordinary code.
- Low, below 3
Zeros, 0xFF padding, sparse tables - Medium, 3 to 7.2
Machine code, text, structured data - High, 7.2 and up
Compressed or encrypted data
Entropy here is Shannon entropy in bits per byte, from 0 (one byte value repeated) to 8 (all 256 values equally likely). The values are computed from synthetic bytes that mimic each kind of content, so the shapes are realistic but the exact numbers are illustrative.
YARA Rules
YARA is a pattern-matching tool designed specifically for malware identification. A YARA rule defines strings and conditions that identify a malware family:
rule Suspicious_AutoStart { strings: $reg = "CurrentVersion\\Run" nocase $http = "http://" nocase $inject = "WriteProcessMemory" condition: uint16(0) == 0x5A4D and // PE file (MZ header) $reg and $http and $inject}This rule fires on PE files referencing the Run key, containing HTTP URLs, and importing WriteProcessMemory. Not conclusive on its own — but that combination warrants a closer look. Security teams keep libraries of YARA rules encoding the fingerprints of known families and suspicious behaviour patterns.
Limitations of Static Analysis
Static analysis struggles with:
- Packed or encrypted malware: The real code is hidden behind compression/encryption layers that only unpack at runtime
- Heavily obfuscated code: Decompiled output may be incomprehensible due to control flow flattening, opaque predicates, or junk code insertion
- Dynamic behaviour: Malware that downloads additional payloads at runtime reveals nothing about its true capabilities through static analysis alone
- Environment-dependent behaviour: Malware that checks for sandbox indicators and behaves differently based on system configuration
When static analysis hits a wall, you move to dynamic analysis — running the malware in a controlled environment and watching what it actually does. The two approaches are genuinely complementary; experienced analysts run them in parallel rather than in sequence.