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.

WatchToolsLook for
ProcessesProcess Explorer, Process Monitor (Procmon), SysmonChild processes, injection, self-deletion
FilesProcmon, Regshot (before/after)Dropped files in AppData or Temp, encrypted files
RegistryRegshot, AutorunsRun keys, services, scheduled tasks
NetworkWireshark, FakeNet-NG, INetSimDNS lookups, HTTP beacons, the user agent
MemoryProcess Hacker, VolatilityUnpacked 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, cmp and jmp/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.

4 steps
Press Play and the tutor will talk you through it while writing on the board. Pause any time to write on the board yourself.

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

Question 1

1.A sample does nothing in the sandbox but runs on a real PC. Most likely?

Question 2

2.In YARA, what does uint16(0) == 0x5A4D check?

Question 3

3.Which free tool decompiles native code into C-like pseudocode?

Question 4

4.Regular HTTP requests every 60 seconds to the same server are called...

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.

10 left in the deck

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

Tip: answer every quiz question correctly first.

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.