Module 18 · Malware Analysis · Lesson 54 of 75
Dynamic analysis, YARA rules and reverse engineering basics
Run the sample in a sandbox and watch what it does, turn your findings into a YARA rule, and take a first look at disassembly in Ghidra.
In this lesson · about 45 minutes
- Watch process, file, registry and network behaviour in a sandbox
- Write a YARA rule from strings and conditions
- Recognise what disassemblers and debuggers are used for
Dynamic analysis
Revert to a clean snapshot, start your monitoring tools, run the sample, wait, and compare.
| Watch | Tools | Look for |
|---|---|---|
| Processes | Process Explorer, Process Monitor (Procmon), Sysmon | Child processes, injection, self-deletion |
| Files | Procmon, Regshot (before/after) | Dropped files in AppData or Temp, encrypted files |
| Registry | Regshot, Autoruns | Run keys, services, scheduled tasks |
| Network | Wireshark, FakeNet-NG, INetSim | DNS lookups, HTTP beacons, the user agent |
| Memory | Process Hacker, Volatility | Unpacked code, decrypted configuration |
Automated sandboxes (CAPE, Joe Sandbox, ANY.RUN, Hybrid Analysis, Cuckoo-based systems) do this for you and produce a report with a behaviour graph and ATT&CK techniques. Many samples are sandbox-aware: they check for virtual machine drivers, few CPUs, no mouse movement or a short uptime, and sleep or exit. Analysts counter with realistic VMs and by patching the checks.
YARA: describing malware
YARA rules match files (or memory) on strings and conditions. They are how analysts share "this is how to recognise family X".
rule Loader_InvoiceUpdater
{
meta:
author = "Noviq Academy lab"
description = "Invoice-themed loader seen in case 230"
strings:
$url = "/gate.php" ascii
$ua = "InvoiceUpdater/" ascii
$inj1 = "VirtualAllocEx" ascii
$inj2 = "WriteProcessMemory" ascii
$inj3 = "CreateRemoteThread" ascii
condition:
uint16(0) == 0x5A4D and $url and 2 of ($inj*)
}
uint16(0) == 0x5A4D means "the file starts with MZ". Good rules combine several unusual strings, so they do not fire on legitimate software that happens to use one API. Test against a set of clean files before deploying.
Reverse engineering basics
- Disassemblers and decompilers (Ghidra, which is free; IDA; Binary Ninja) turn machine code into assembly and C-like pseudocode, so you can read the logic.
- Debuggers (x64dbg, WinDbg) let you run code step by step, set breakpoints on APIs such as
InternetOpenUrlA, and dump the unpacked payload from memory. - Start from clues: find where the C2 string is used (cross-references), then read that function. Assembly basics worth knowing: registers (EAX/RAX, ESP/RSP),
mov,push,call,cmpandjmp/jz. - .NET malware decompiles almost back to source with dnSpy or ILSpy; scripts (PowerShell, JavaScript, VBA macros) are de-obfuscated with CyberChef, olevba and careful step-by-step decoding.
The analysis report
Summary of what the sample does, its indicators (hashes, domains, IPs, mutex, paths), ATT&CK techniques, detection rules (YARA, Sigma), and recommended response actions.
Whiteboard · watch and try
From a sandbox run to indicators
Press Play. The tutor reads a sandbox report for invoice.bin and writes down what matters.
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Exercise
A mini YARA engine in Python
samples is a list of files, each with a name and the strings found in it. Write matches(samples) that returns the sorted names of files where the first string is "MZ" (an executable) and at least 2 of the three injection APIs VirtualAllocEx, WriteProcessMemory, CreateRemoteThread appear.
Code that runs before yours
samples = [
{"name": "invoice.exe", "strings": ["MZ", "This program cannot be run in DOS mode", "VirtualAllocEx", "WriteProcessMemory", "CreateRemoteThread", "http://203.0.113.88/gate.php"]},
{"name": "notepad.exe", "strings": ["MZ", "This program cannot be run in DOS mode", "CreateWindowExW", "GetOpenFileNameW"]},
{"name": "upd.dll", "strings": ["MZ", "VirtualAllocEx", "WriteProcessMemory", "CreateRemoteThread", "Global\\upd_mutex_77"]},
{"name": "readme.txt", "strings": ["Your files are encrypted", "bitcoin"]},
{"name": "tool.exe", "strings": ["MZ", "VirtualAllocEx", "http://203.0.113.88/gate.php"]},
]Check your understanding0 of 4 correct
Flashcards
Module 18 flashcards
0 of 10 known
Say the answer out loud, flip the card, then be honest: cards you miss come back at the end.
Practice exam
Module 18 checkpoint
10 questions, 12 minutes.
- 10 questions · 12 minutes
- No feedback until you submit. Flag questions to come back to them.
- Aim for 85% or better before you move on. The real exam's 750 out of 900 is roughly 80–83%.
Quiz score: 0 of 4
Exercises solved: 0 of 1
Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.