Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 37 ยท Dynamic Analysis

Monitoring Processes and Files

Learn to read process trees, command lines and file events from monitors like Process Monitor, spot suspicious parent-child chains and detect ransomware-style file activity.

When a sample runs, the operating system records a constant stream of events: processes starting, files being created and written, handles opening. Monitoring tools capture them, and your job is to separate the few meaningful events from the thousands of normal ones. This lesson teaches you to read process trees, command lines and file activity, with data from synthetic logs that look like what real monitors export.

Tools you will meet on Windows (read-only here): Process Monitor (Procmon) records file, registry, process and network events; Process Explorer shows the live process tree; Sysmon, a free system service, writes rich process-creation and network records to the event log that defenders collect everywhere.

Process trees and parent-child relationships

Every process has a parent (the one that started it). Normal chains are predictable: explorer.exe starts programs you double-click; services.exe starts services; winword.exe starts almost nothing. A chain that breaks these habits is a strong signal.

flowchart TD
    A["explorer.exe"] --> B["winword.exe (opened invoice.docm)"]
    B --> C["powershell.exe -enc ..."]
    C --> D["upd.exe (dropped in Public folder)"]
    D --> E["cmd.exe /c whoami"]

Word launching PowerShell is a textbook sign of a malicious macro. Office programs rarely have a good reason to start a shell.

Common suspicious parent-child pairs:

Parent Child Why it is suspicious
winword.exe, excel.exe, outlook.exe cmd.exe, powershell.exe, wscript.exe Macro or exploit launching a shell
explorer.exe rundll32.exe with an odd DLL path Executing a DLL payload
Any user program svchost.exe without -k argument Impersonation of a system process
services.exe executable in Temp or AppData Persistence through a rogue service
wmiprvse.exe powershell.exe Remote or WMI-driven execution

Reading command lines

The command line shows exactly how a program was started. Features that deserve attention:

  • powershell.exe -enc <long base64> or -EncodedCommand: hidden, encoded script.
  • -nop -w hidden -ep bypass: no profile, hidden window, execution policy bypass.
  • cmd.exe /c followed by chained commands.
  • rundll32.exe path\x.dll,Export: running a DLL.
  • regsvr32 /s /u /i:http://... scrobj.dll: a known abuse of a signed system tool.
  • certutil -urlcache -f http://... file: using a built-in tool to download.

Abusing legitimate tools like these is called living off the land, and it makes detection harder because the programs themselves are trusted.

A process-tree analyzer

The script below takes a synthetic list of process-creation events (like Sysmon event ID 1), builds the tree and flags suspicious pairs and command-line patterns. It reads only data, never touches a real system.

Python Build a process tree and flag oddities

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The tree prints the whole chain from the document to the dropped program and the discovery commands. Real triage does exactly this on thousands of events: build the tree, then let rules point at branches worth reading.

File activity

Monitors log every CreateFile, WriteFile, SetInformation (rename, delete) and read. Most are noise: the operating system touches thousands of files per second. Strategies for finding the signal:

  1. Filter by process: show only events from the sample and its children.
  2. Filter by operation: keep creates, writes, renames and deletes; drop reads.
  3. Exclude known noise: prefetch files, system caches, the monitor's own writes.
  4. Look at locations: Temp, AppData, Public, startup folders, System32, and the user's documents.
  5. Look at volume and pattern: one file written is ordinary; a thousand renamed in a minute is not.

Spotting ransomware-style behaviour

Ransomware has a recognisable file signature: it reads, rewrites and renames many user files in sequence, often adding a new extension and leaving a note in each folder. A simple rate check catches that. The next example analyses a made-up event list.

Python Detect mass file changes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

In the lab the damage is only the fake files in a snapshot you will revert, which is why dynamic analysis is run in a VM. The same rate-and-pattern idea powers real ransomware detection in endpoint products.

Other things to watch

  • Process injection: a process writing into another's memory. In monitors you see a handle opened with write rights, then a new thread in a different process. Chapter 5 and later lessons explain it.
  • Mutexes: malware often creates a named mutex to ensure only one copy runs. Names like Global\... are indicators.
  • Dropped files: copy them out of the VM (via a safe channel) and hash them. Each dropped file is a new sample and should enter your intake process.
  • Deleted evidence: self-deleting programs remove themselves; monitors record the deletion.
  • Created services and drivers: these tie into persistence in the next lesson.

Common mistakes

  • Reading unfiltered logs for hours.
  • Ignoring child processes: the interesting work often happens in the third process of the chain.
  • Forgetting to collect dropped files before reverting.
  • Mistaking normal Windows activity (prefetch, antivirus scans) for malware.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which parent-child pair is the most suspicious?

    Office programs seldom need a shell. This chain is the classic result of a malicious macro.
  2. 2. What does the PowerShell argument -enc usually mean?

    -EncodedCommand takes a base64 script. It is common in malicious use because it hides the command from casual reading.
  3. 3. A process renames sixty documents to a new extension within a minute and drops a text note in the folder. What does this fit?

    Mass rewriting and renaming with a note is the typical ransomware pattern.
  4. 4. What does living off the land mean?

    Attackers use trusted tools such as PowerShell or certutil because they are already allowed and trusted.

Summary

  • Process trees and parent-child relationships expose how execution progressed; Office spawning a shell is a red flag.
  • Command lines show how programs were started: encoded commands, hidden windows, built-in tools used as downloaders.
  • Filter file events by process, operation and location, then look for volume and patterns.
  • Mass renames with a new extension and notes indicate ransomware.
  • Always collect dropped files and treat each as a new sample.

Next: Registry and Persistence Mechanisms