Malware Analysis: Beginner's Guide to Static & Dynamic Analysis in Kali Linux
Learn malware analysis from scratch: build a safe isolated lab, triage samples with static and dynamic analysis, write YARA rules, and report IOCs.
What Is Malware Analysis?
Malware analysis is the controlled examination of suspicious software to determine what it does, how to detect it, and what systems it may have affected. Analysts combine static inspection, safe execution, code review, and evidence collection inside isolated labs. The goal is defensive understanding and reliable indicators, not creating or improving malware.
Malware analysis turns an unknown or suspicious file into documented evidence. It answers three practical questions:
Malware analysis is not malware development. A defensive analyst studies existing artifacts, validates observations, produces detections, and helps incident responders contain affected systems.
The Four Types of Malware Analysis
The four types overlap. A normal investigation begins with low-risk static triage, moves to controlled behavior monitoring, and uses code or memory analysis only when the earlier evidence is insufficient.
| Type | What it is | Skill level | Speed | Relative risk | What it reveals |
|---|---|---|---|---|---|
| Static analysis | Examining a file without intentionally executing it | Beginner to intermediate | Fast | Low | File type, hashes, strings, imports, sections, metadata, and packing clues |
| Dynamic analysis | Running a sample in an instrumented, isolated environment | Intermediate | Medium | High | Processes, files, registry activity, services, tasks, and network traffic |
| Code analysis | Reading disassembly, decompiled code, or debugger state | Intermediate to advanced | Slow | Medium to high | Algorithms, configuration parsing, hidden branches, API use, and unpacked logic |
| Behavioral analysis | Correlating endpoint, memory, and network effects over time | Intermediate | Medium | High | The sample's operational pattern and impact across the system |
"Low risk" never means safe for a normal workstation. File parsers can have vulnerabilities, archives can be mishandled, and a double-click can accidentally execute a sample. Perform every type of analysis inside the lab.
Is Malware Analysis Legal and Safe?
Malware analysis is generally performed for legitimate research, education, incident response, and defense. Analyze only files you obtained legally, on systems you own or are explicitly authorized to test. Laws and license terms vary by jurisdiction, so organizational or legal guidance takes priority.
Ethical analysis means you do not deploy malware against another person, redistribute dangerous samples carelessly, expose victim data, or use findings to improve malicious operations.
Never analyze malware on a machine you care about. Never download a sample to the host. Never give a lab VM unrestricted Internet access.
A safe workflow requires:
Isolation reduces risk but does not make malware harmless. Stop immediately if containment is uncertain.
Build a Safe, Isolated Lab First
This is the most important part of malware analysis. Tools cannot compensate for weak containment.
Recommended lab architecture
Use VirtualBox or VMware to create the following environment:
Windows 10 FLARE-VM guest
|
Isolated virtual switch
|
REMnux guest running INetSim and packet capture
|
Optional Kali guest for triage and analysis
No NAT, bridge, host LAN, or real Internet uplink
An internal virtual network is preferable because it has no host interface. If your hypervisor calls the available option "host-only," firewall the host-side interface, expose no host services, and verify that the guest cannot reach the host LAN. Host-only networking is not automatically the same as complete host isolation.
Build the Windows analysis VM
Create a disposable Windows 10 VM with enough storage and memory for FLARE-VM, debuggers, logs, and snapshots. During a clean provisioning phase, before any sample has entered the guest, install tools from official sources. If installation requires temporary Internet access, use it only on this clean VM and remove the uplink afterward.
Once provisioning is complete:
TOOLS-INSTALLED-CLEAN.An unprotected Windows guest must never be used for browsing, email, normal work, or real Internet access.
Add REMnux and Kali
REMnux is a Linux distribution designed for malware analysis. Use it as the second machine on the isolated switch for:
Kali is useful for hashing, YARA, packet analysis, scripting, and general Linux utilities. Kali is not containment by itself. Keep it as a VM, and do not run Windows malware through Wine.
INetSim on REMnux can emulate common services. FakeNet-NG can provide similar network simulation from the Windows guest. Both let a sample believe services exist without exposing it to a real command-and-control server.
Snapshot and revert discipline
Maintain at least these snapshots:
Before each dynamic run, create or restore a known snapshot. After collecting evidence, shut down or power off the guest and revert it. Do not continue using a contaminated VM because it appears normal. Snapshots support recovery, but network isolation remains the primary control.
Lab checklist
| Control | Required state |
|---|---|
| Host | Patched, protected, and never stores or extracts samples |
| Hypervisor | Current version with integration features disabled |
| Windows guest | Disposable Windows 10 VM with FLARE-VM |
| Guest security | Defender, updates, and third-party antivirus off only after isolation |
| Network | Internal or carefully controlled host-only switch with no real uplink |
| Simulation | REMnux with INetSim or Windows with FakeNet-NG |
| Data transfer | No shared folders, clipboard, drag-and-drop, or USB |
| Snapshots | Clean baseline plus pre-run snapshot |
| Credentials | No personal, corporate, or production credentials |
| Verification | Isolation checked before every execution session |
Your Malware Analysis Toolkit
| Tool | Primary use |
|---|---|
| FLARE-VM | Windows malware-analysis tool collection installed in a disposable Windows guest |
| REMnux | Linux analysis environment for triage, network simulation, memory work, and document analysis |
| Kali Linux | Hashing, scripting, YARA, packet analysis, and supporting command-line work |
| Ghidra | Disassembly, decompilation, function analysis, and cross-references |
| x64dbg | User-mode debugging of 32-bit and 64-bit Windows programs |
| Volatility | Process, network, memory-region, and artifact analysis from memory images |
| YARA | Pattern-based file and memory classification |
| Wireshark and TShark | Interactive and command-line packet analysis |
| Process Monitor | Windows process, file, registry, and thread event collection |
| PE-bear | Portable Executable header, section, import, and resource inspection |
| Detect It Easy | File identification, compiler clues, and packer detection |
| FLOSS | Extraction of static, stack, and decoded strings |
| capa | Identification of likely program capabilities from code features |
| peframe and the pev suite | PE metadata, sections, imports, resources, and suspicious characteristics |
| strings, xxd, and ExifTool | Printable text, raw bytes, and metadata inspection |
| Binwalk | Embedded content and signature discovery |
| INetSim and FakeNet-NG | Simulated DNS, HTTP, and other network services |
| Scylla | Dumping a debugged Windows process and rebuilding its import table |
No single tool supplies a verdict. Treat every result as a clue that must be corroborated.
Basic Static Triage: Your First 10 Minutes
Work from a copy inside the isolated VM. Preserve an original with restricted permissions and record every transformation.
mkdir -p ~/cases/case-001/{original,working,output}
chmod 400 ~/cases/case-001/original/suspicious.bin
cp ~/cases/case-001/original/suspicious.bin ~/cases/case-001/working/suspicious.bin
cd ~/cases/case-001/working
1. Hash the file
sha256sum suspicious.bin
md5sum suspicious.bin
Use SHA-256 as the primary identifier. MD5 remains useful for correlation with older reports, but it should not be treated as collision-resistant proof.
2. Perform a hash-only threat-intelligence lookup
Search an approved VirusTotal-style service using the SHA-256 value. Do not upload the sample. Public services may retain and distribute uploaded files. A missing result means only that the service has no matching record; it does not prove the file is safe.
3. Identify the real file type
Extensions are untrusted.
file suspicious.bin
xxd -l 64 suspicious.bin
exiftool suspicious.bin
Magic bytes can reveal a PE file beginning with MZ, an ELF file, a script, an archive, or a document despite a misleading name.
4. Extract strings
strings -a -n 6 suspicious.bin | tee ../output/strings.txt
floss suspicious.bin | tee ../output/floss.txt
Look for URLs, domains, user agents, registry paths, commands, error messages, mutex names, file paths, and configuration labels. Ordinary library strings are not proof of malicious behavior.
5. Inspect executable structure
For ELF files:
readelf -h suspicious.elf
For PE files:
peframe suspicious.exe
readpe suspicious.exe
diec suspicious.exe
capa suspicious.exe
Review architecture, section names, section permissions, imports, resources, entry point, entropy, and timestamp fields. High entropy can suggest compression or encryption, but legitimate installers can also have high entropy. PE timestamps can be forged or copied.
6. Check for embedded content and packing
binwalk suspicious.bin
diec suspicious.exe
Packing clues include a small import table, an entry point inside an unusual section, high-entropy sections, and known packer signatures. These are heuristics, not conclusions.
7. Form a hypothesis before execution
Write down:
Running first and investigating later leads to missed evidence and unnecessary risk.
Worked Example: Triaging a Safe Practice File
This walkthrough uses only the EICAR antivirus test file. EICAR is a harmless standardized test string, not real malware, although security products intentionally detect it. Create it only inside the isolated lab. Never weaken host security to keep it from being quarantined.
1. Create the test file
In the REMnux or Kali lab VM:
mkdir -p ~/cases/eicar-demo
cd ~/cases/eicar-demo
printf '%s' 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > eicar.com
wc -c eicar.com
Illustrative output:
68 eicar.com
The byte count confirms that no newline was appended.
2. Record hashes
sha256sum eicar.com
md5sum eicar.com
Illustrative output format:
<64 hexadecimal characters> eicar.com
44d88612fea8a8f36de82e1278abb02f eicar.com
The hash uniquely identifies this exact byte sequence for case correlation. If your value changes, first check for an added newline or altered character.
3. Identify the file
file eicar.com
xxd -l 24 eicar.com
Illustrative output:
eicar.com: EICAR virus test files
Some file signature databases instead describe it as ASCII text.
Illustrative output:
00000000: 5835 4f21 5025 4041 505b 345c 505a 5835 X5O!P%@AP[4\PZX5
00000010: 3428 505e 2937 4343 4(P^)7CC
The .com extension does not make this a normal Windows executable. The bytes show printable text rather than a PE MZ header.
4. Extract strings
strings -a -n 6 eicar.com
Illustrative output:
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
A single distinctive string explains why signature-based controls identify the file.
5. Try format-specific parsers
readelf -h eicar.com
Illustrative output:
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
Now test it as a PE file:
peframe eicar.com
Illustrative outcome:
The parser reports that the input does not contain a valid PE/DOS header.
Exact peframe wording varies by version. Both results support the hypothesis that the file is a text-based test artifact, not an ELF or PE program.
6. Match it with YARA
Create eicar.yar:
rule eicar_training_test
{
meta:
description = "Detects the harmless EICAR training string"
purpose = "lab validation"
strings:
$eicar = "EICAR-STANDARD-ANTIVIRUS-TEST-FILE" ascii
condition:
$eicar
}
Run the rule:
yara eicar.yar eicar.com
Illustrative output:
eicar_training_test eicar.com
7. Interpret the evidence
| Observation | Meaning |
|---|---|
| Stable hashes | The exact artifact can be tracked and compared |
| Printable content | There is no hidden executable structure in this practice file |
| No ELF or PE header | Native executable parsers correctly reject it |
| Distinctive EICAR text | Signature-based detection is expected |
| YARA match | The rule works against a known, harmless fixture |
| No execution required | Static evidence fully answers this exercise |
Do not execute the file. There is no behavioral value to gain, and static triage has already explained it.
Dynamic Analysis: Watching Malware Run
Dynamic analysis intentionally executes a file, so use only a verified isolated snapshot. If the network, snapshot, or data-transfer controls are uncertain, do not proceed.
A basic detonation workflow is:
Use Process Monitor to capture:
Noriben can summarize Process Monitor activity, while ProcDOT can combine process and network logs into a graph.
On REMnux, identify capture interfaces and start TShark:
tshark -D
sudo tshark -i 1 -w case-001.pcap
Review selected protocols afterward:
tshark -r case-001.pcap -Y 'dns or http or tls'
INetSim can be started on the isolated REMnux machine:
sudo inetsim
Configure the victim's DNS and gateway only toward the simulator. Never reconnect the victim to real Internet access to "see whether it works."
Record process lineage, dropped files, registry keys, persistence, mutexes, DNS names, HTTP paths, TLS server names, destination ports, timing intervals, and failed actions. Distinguish observed behavior from assumptions.
Static Code Analysis with Ghidra
Ghidra lets you inspect code without intentionally executing it.
A stripped PE may not contain an obvious function named main. Start from the entry point, runtime initialization, exported functions, or references to meaningful strings.
Suspicious API combinations can guide review:
VirtualAlloc or VirtualProtect for memory allocation and permission changesCreateRemoteThread with process-access APIs for possible injectionInternetOpen, InternetConnect, and HttpSendRequestThese APIs also appear in legitimate software. The decompiler output is an approximation, so verify important conclusions against the disassembly and cross-references.
Dynamic Code Analysis with x64dbg
Use x64dbg only in the isolated FLARE-VM snapshot. A debugger executes the target under analyst control; it does not make the target safe.
A beginner workflow is:
When the original code has been unpacked in memory, Scylla can dump the process and help rebuild imports. Preserve hashes for both the packed original and the dumped artifact.
A beginner should stop and report when the sample loads a kernel driver, attempts destructive actions, triggers unknown exploit behavior, requires real credentials, defeats containment, or enters complex anti-debugging logic. Do not move it to the host or restore Internet access to bypass a limitation.
Unpacking Malicious Code
Packing compresses, encrypts, or transforms a program and adds a small stub that reconstructs the original code at runtime. Packing can reduce the value of strings, imports, and decompilation.
Useful signs include:
None of these proves maliciousness.
If Detect It Easy confirms ordinary UPX, test and unpack only a working copy:
cp packed.exe packed.work.exe
upx -t packed.work.exe
upx -d packed.work.exe
Modified UPX samples may not unpack successfully. Do not overwrite the original.
For other packers, a controlled debugger workflow can allow the stub to unpack into memory. Once execution reaches the reconstructed code, dump the process and rebuild imports with Scylla. This is a working artifact for analysis, not a trusted executable.
If unpacking fails, document the packer clues, memory regions, entry point, and limitations. Try FLOSS, capa, memory forensics, and behavioral evidence. Do not download unknown "unpacker" programs or upload the sample to an unapproved service.
Writing Your First YARA Rule
A YARA rule has three main parts:
meta: documentation such as purpose, author, source, and confidencestrings: text, hexadecimal patterns, or regular expressionscondition: the logic required for a matchStart with two or more distinctive strings from triage instead of one common word.
rule lab_unique_string_demo
{
meta:
description = "Matches two strings in a harmless training fixture"
author = "Analyst"
scope = "lab"
strings:
$marker = "LAB-TRAINING-MARKER-2026" ascii wide
$url = "training.example.invalid/checkin" ascii
condition:
filesize < 2MB and all of them
}
Create a harmless fixture and test it:
printf '%s\n' 'LAB-TRAINING-MARKER-2026 training.example.invalid/checkin' > harmless-fixture.txt
yara lab_demo.yar harmless-fixture.txt
Illustrative output:
lab_unique_string_demo harmless-fixture.txt
The following training rule models a Cobalt-Strike-style beacon configuration pattern. Its strings are invented generic lab markers, not real family strings, and it must not be used for attribution.
rule generic_beacon_style_training
{
meta:
description = "Training-only beacon-style configuration pattern"
warning = "Generic example, not family attribution"
strings:
$b1 = "LAB_BEACON_CONFIG" ascii wide
$b2 = "sleep_interval_ms" ascii wide
$b3 = /\/api\/v[0-9]+\/checkin/ ascii
condition:
uint16(0) == 0x5A4D and
filesize < 5MB and
2 of ($b*)
}
Test real rules against confirmed matches and a broad benign corpus. Reduce false positives with file-type checks, size limits, combinations of uncommon strings, byte patterns, and clear scope.
Store rules in version control with separate experimental, production, and tests directories. Record the source, date, confidence, false-positive notes, and change history. Do not commit live malware samples to the rule repository.
Memory Forensics with Volatility
Memory analysis matters when a payload is unpacked only in RAM, injected into another process, deleted from disk, or otherwise fileless. Memory images can contain credentials, private documents, and encryption material, so protect them as sensitive evidence.
With Volatility 3, begin by validating the image:
python3 vol.py -f memory.raw windows.info
python3 vol.py -f memory.raw windows.psscan
python3 vol.py -f memory.raw windows.netscan
python3 vol.py -f memory.raw windows.malfind
Each plugin answers a different question:
windows.psscan scans for process objects, including candidates not present in a normal active-process list.windows.netscan finds network endpoints and associates them with processes where possible.windows.malfind highlights memory regions with characteristics associated with injected or unusual executable code.A hit is not automatic proof of malware. Correlate process lineage, signatures, mapped files, network activity, and disassembly.
To dump a selected process address space for further analysis:
mkdir -p dumps
python3 vol.py -f memory.raw -o dumps windows.memmap --pid 1234 --dump
Hash every resulting file. Run strings, FLOSS, capa, YARA, and code analysis against the dump, but do not execute it outside the isolated lab.
Extracting IOCs and Writing the Report
Indicators of compromise can include:
Hashes are precise but easy for an attacker to change. Domains and IP addresses can be shared, reassigned, or sinkholed. Include context and confidence rather than publishing an unexplained list.
IOC extraction checklist
Recommended report structure
SOC analysts need searchable indicators and detection logic. Incident responders need timelines, scoping clues, containment guidance, and confidence levels. Write for both audiences without overstating attribution.
Where to Get Practice Samples Safely
Begin with EICAR and self-made harmless programs. Move to live samples only after the lab has been reviewed and you can demonstrate snapshot and network discipline.
| Source | Use |
|---|---|
| MalwareBazaar | Tagged malware samples and hashes for authorized research |
| theZoo | A deliberately dangerous research repository with documented handling warnings |
| vx-underground | Research archives intended for experienced defensive analysts |
| Practical Malware Analysis labs | Controlled exercises associated with the book and its authorized lab materials |
Handling rules are non-negotiable:
"infected" where the source documents it.Avoid random file-sharing sites, unsolicited attachments, and unknown sample links.
Malware Analysis Cheat Sheet
Commands below assume you are already inside the isolated analysis VM.
Static triage commands
| Goal | Command |
|---|---|
| SHA-256 hash | sha256sum sample.bin |
| MD5 correlation hash | md5sum sample.bin |
| Identify file type | file sample.bin |
| View first 64 bytes | xxd -l 64 sample.bin |
| Extract strings | strings -a -n 6 sample.bin |
| Find decoded strings | floss sample.exe |
| Read metadata | exiftool sample.bin |
| Inspect ELF header | readelf -h sample.elf |
| Inspect PE characteristics | peframe sample.exe |
| Inspect PE with pev | readpe sample.exe |
| Detect compiler or packer | diec sample.exe |
| Identify capabilities | capa sample.exe |
| Find embedded data | binwalk sample.bin |
| Test a YARA rule | yara rules/index.yar sample.bin |
| Test UPX integrity | upx -t sample.exe |
| Unpack confirmed UPX copy | upx -d sample.work.exe |
Dynamic analysis tools and commands
| Goal | Tool or command |
|---|---|
| Capture file and registry activity | Process Monitor |
| Summarize Process Monitor events | python Noriben.py |
| Visualize process and PCAP relationships | ProcDOT |
| List capture interfaces | tshark -D |
| Capture isolated traffic | sudo tshark -i 1 -w case.pcap |
| Review DNS, HTTP, and TLS | tshark -r case.pcap -Y 'dns or http or tls' |
| Simulate network services | sudo inetsim |
| Simulate services on Windows | FakeNet-NG |
| Debug a Windows process | x64dbg or x32dbg |
| Dump and rebuild imports | Scylla |
| Scan memory processes | python3 vol.py -f memory.raw windows.psscan |
| Scan memory connections | python3 vol.py -f memory.raw windows.netscan |
| Find suspicious memory regions | python3 vol.py -f memory.raw windows.malfind |
| Clean the environment | Power off and revert the VM snapshot |
Troubleshooting Malware Analysis Problems
| Problem | Safe response |
|---|---|
| Sample will not run in the VM | Verify architecture, file type, required arguments, dependencies, and loader errors. Do not restore real Internet access to fetch dependencies. |
| Sample detects the VM or debugger | Document the anti-analysis evidence. Check ordinary resource and clock problems, but do not weaken containment or move the sample to the host. Escalate advanced work. |
| No network traffic appears | Confirm the capture interface, simulated DNS, victim gateway, and INetSim or FakeNet-NG logs. The behavior may also be delayed or conditional. |
| Sample appears packed | Preserve the original, inspect it with Detect It Easy and peframe, try upx -d only for confirmed UPX, or plan a controlled memory dump. |
| Strings show nothing useful | Try FLOSS, Unicode strings, resources, embedded files, memory analysis, and unpacking. Empty output does not mean no configuration exists. |
| YARA rule matches everything | Replace common strings with distinctive combinations, add file-type and size constraints, and test against a large benign corpus. |
| Volatility profile is missing | With Volatility 3, run windows.info and verify symbols and image integrity. Preload required symbols before isolation. Use legacy profiles only when working with Volatility 2. |
| FLARE-VM installation fails | Rebuild from a clean supported VM, verify administrator access, disk space, memory, and installer logs. Use trusted provisioning access only before samples enter the VM. |
Common Mistakes Beginners Make
Best Practices
Your Learning Path: From First Sample to Job-Ready
Four weeks can establish a repeatable foundation, but job-ready judgment requires continued practice, reporting, and feedback.
| Week | Focus | Deliverable |
|---|---|---|
| 1 | Build the isolated lab; practice hashes, file, strings, and YARA with EICAR and harmless files | Lab diagram, safety checklist, and EICAR triage report |
| 2 | Study PE structure, imports, sections, entropy, Detect It Easy, FLOSS, and capa | Static report and tested training YARA rule |
| 3 | Monitor a self-made harmless Windows program with Process Monitor, TShark, INetSim, and FakeNet-NG | Process timeline, PCAP notes, and IOC table |
| 4 | Analyze a harmless compiled program with Ghidra and x64dbg; review a practice memory image | Full report with static, dynamic, code, and memory findings |
After this foundation:
Summary
Malware analysis combines static triage, controlled execution, code review, memory forensics, and reporting. The safest workflow begins with hashes and file identification, forms a hypothesis before execution, uses simulated services instead of real Internet access, and reverts the victim after every run.
The essential rules are simple:
Knowledge Check
windows.psscan, windows.netscan, and windows.malfind examine?Answers: 1. NAT can expose the sample to real systems and the Internet; 2. SHA-256; 3. Static analysis does not intentionally execute the file, while dynamic analysis observes execution; 4. It can be forged, copied, or altered; 5. Simulated network services; 6. To reduce false positives; 7. Processes, network endpoints, and suspicious memory regions; 8. Power it off and revert to a clean snapshot.
Keep Learning
Guides
Tools
Frequently Asked Questions
Continue Learning
Reverse Engineering for Beginners: Learn to Analyze Binaries with Ghidra & GDB
Learn reverse engineering from scratch: analyze binaries with Ghidra and GDB, read assembly, crack a practice binary, and build a starter toolkit.
Ethical Hacking · IntermediateCloud Penetration Testing: Complete Guide to AWS, Azure and GCP Security Testing
Cloud penetration testing for AWS, Azure, and GCP: the 6-phase methodology, IAM analysis, chained attack paths, and tools — with a worked lab example.
Ethical Hacking · BeginnerEthical Hacking Fundamentals: Principles, Methodology, and Best Practices
Learn the core principles of ethical hacking, the five-phase penetration testing methodology, types of security testing, and how to build your own hacking lab.
Ethical Hacking · BeginnerSteganography Tools: Best Free Tools to Hide & Detect Hidden Data in Kali Linux
Learn the best free steganography tools for Kali Linux: hide files in images with Steghide and OpenStego, then detect hidden data with zsteg.
Related Security Tools
Autopsy
Learn how to use Autopsy, the free digital forensics software, in a hands-on practice case. Start with a verified disk image, run ingest modules, look for deleted files, and use keyword hits and timeline entries to build a report.
ForensicsBinwalk
Learn how to use Binwalk to scan a firmware image, read the signature table, extract embedded filesystems, and spot encrypted regions — a beginner tutorial for Kali Linux.
Reverse EngineeringGDB
Learn how to use GDB, the GNU Debugger, by building a small C program with debug symbols and following it from the first breakpoint to a crash. Use the same steps to inspect variables, read a backtrace, and tell when a core dump or a look at the assembly would help.
ForensicsVolatility
Volatility is an advanced open-source memory forensics framework used for incident response and malware analysis, allowing extraction of digital artifacts from volatile memory (RAM) samples.