TExcelTAD
Home › Malware Analysis, Digital Forensics & Incident Response › Process, File and Registry Activity: Process Monitor and Sysmon

Process, File and Registry Activity: Process Monitor and Sysmon

Behavioural analysis comes down to four questions about a running sample: which processes did it start, which files did it create or change, which registry keys did it touch, and where did it connect? On Windows, two free Sysinternals tools answer them. Process Monitor (Procmon) records every file, registry, process and thread operation live on the analysis VM, millions per minute, for the analyst to filter. Sysmon is a driver and service that writes selected activity to the event log as structured events, the same data in production that the analyst saw in the lab. A lab analyst uses Procmon; a detection engineer writes rules on Sysmon. This lesson does both on activity of the benign lab sample labagent.exe.

The full list of Windows Security and Sysmon event IDs is in The Key Event IDs and Sysmon; here we use the ones behaviour analysis needs.

Definitions

  • Procmon filter: rules such as Process Name is labagent.exe → Include, Operation is RegSetValue → Include, Path begins with C:\Windows\Prefetch → Exclude. Without filters the capture is unreadable; with the wrong ones you miss child processes (filter on the process tree, or add each child by PID).
  • Process Tree (Procmon's Tools menu): parent–child relations with command lines and lifetimes.
  • Regshot: takes a snapshot of the registry (and optionally files) before and after a run and prints the difference: coarser than Procmon, but quick.
  • Sysmon events used here: 1 process created (image, command line, parent, hashes), 3 network connection, 11 file created, 13 registry value set, 22 DNS query. Others: 7 image loaded, 8 CreateRemoteThread, 10 process access (reads of LSASS memory), 12 registry key create/delete, 23 and 26 file delete.
  • Sysmon configuration: an XML file that decides what is logged; community baselines (for example SwiftOnSecurity's sysmon-config and Olaf Hartong's sysmon-modular) are common starting points.

The Procmon view, filtered

A lab session on the analysis VM: Procmon with the filter Process Name is labagent.exe plus its child cmd.exe, and Operation is one of WriteFile, RegSetValue, Process Create, TCP Connect. Scope: the isolated analysis VM, benign lab sample.

console
lab session: Process Monitor, filtered (analysis VM 10.10.0.20, benign lab sample)
Time        Process        PID   Operation       Path                                                          Result
10:04:12.31 labagent.exe   4512  RegQueryValue   HKLM\System\CurrentControlSet\Control\ComputerName\...\ComputerName   SUCCESS
10:04:12.35 labagent.exe   4512  CreateFile      C:\Users\Public\Libraries\labagent.dat                        SUCCESS
10:04:12.35 labagent.exe   4512  WriteFile       C:\Users\Public\Libraries\labagent.dat                        SUCCESS  Length: 112
10:04:12.40 labagent.exe   4512  RegSetValue     HKCU\Software\Microsoft\Windows\CurrentVersion\Run\LabAgentUpdater   SUCCESS  Data: C:\Users\lab\Downloads\labagent.exe
10:04:12.52 labagent.exe   4512  Process Create  C:\Windows\System32\cmd.exe                                   SUCCESS  Command line: cmd.exe /c whoami /all
10:04:12.61 cmd.exe        4630  CreateFile      C:\Users\lab\AppData\Local\Temp\w.txt                         SUCCESS
10:04:13.02 labagent.exe   4512  TCP Connect     10.10.0.20:49712 -> 10.10.0.53:80                             SUCCESS

Seven lines tell the story the sandbox summarised: host discovery, a dropped file, an autostart entry pointing back at the sample in Downloads, a discovery command run through cmd.exe, and a connection to the (fake) Internet. In an unfiltered capture these lines sit among about 40,000 others from the same few seconds.

The Sysmon view, as data

On a monitored machine the same activity arrives as Sysmon events in the SIEM. The example holds a synthetic excerpt of such events (fields trimmed to the ones used), mixed with ordinary activity of other programs, and does what an analyst's notebook does: rebuild the process tree, summarise activity per process, and apply one behaviour rule.

python · try it yourself
import pandas as pd

ev = pd.DataFrame([
 (1,  "10:03:58", 1204, "explorer.exe", 3388, r"C:\Program Files\LabEditor\editor.exe", r"editor.exe notes.txt", None),
 (11, "10:04:01", 3388, "editor.exe", None, r"C:\Users\lab\Documents\notes.txt", None, None),
 (1,  "10:04:12", 1204, "explorer.exe", 4512, r"C:\Users\lab\Downloads\labagent.exe", r"labagent.exe", None),
 (11, "10:04:12", 4512, "labagent.exe", None, r"C:\Users\Public\Libraries\labagent.dat", None, None),
 (13, "10:04:12", 4512, "labagent.exe", None, r"HKU\S-1-5-21-1000\Software\Microsoft\Windows\CurrentVersion\Run\LabAgentUpdater", None, r"C:\Users\lab\Downloads\labagent.exe"),
 (1,  "10:04:12", 4512, "labagent.exe", 4630, r"C:\Windows\System32\cmd.exe", r"cmd.exe /c whoami /all", None),
 (22, "10:04:13", 4512, "labagent.exe", None, "update.beacon.lab.test", None, "10.10.0.53"),
 (3,  "10:04:13", 4512, "labagent.exe", None, "10.10.0.53:80", None, None),
 (13, "10:05:30", 2210, "updater.exe", None, r"HKLM\SOFTWARE\LabVendor\Updater\LastCheck", None, "2026-01-15"),
], columns=["id", "time", "pid", "image", "child_pid", "target", "cmdline", "details"])

print("process tree (event 1):")
for _, r in ev[ev.id == 1].iterrows():
    print(f"  {r.image} ({r.pid}) -> {r.target.split(chr(92))[-1]} ({int(r.child_pid)})  {r.cmdline}")

names = {1: "proc", 3: "net", 11: "file", 13: "reg", 22: "dns"}
summary = ev.assign(kind=ev.id.map(names)).groupby(["image", "kind"]).size().unstack(fill_value=0)
print(summary)

# Rule: a program started from a user-writable download folder sets an autostart registry value.
started = ev[(ev.id == 1) & ev.target.str.contains(r"\\Downloads\\|\\AppData\\Local\\Temp\\", regex=True)]
suspect_pids = set(started.child_pid)
hits = ev[(ev.id == 13) & ev.pid.isin(suspect_pids) & ev.target.str.contains(r"\\CurrentVersion\\Run\\", regex=True)]
for _, h in hits.iterrows():
    print(f"ALERT {h.time} pid {h.pid} {h.image}: autostart value {h.target.split(chr(92))[-1]!r} -> {h.details}")
process tree (event 1):
  explorer.exe (1204) -> editor.exe (3388)  editor.exe notes.txt
  explorer.exe (1204) -> labagent.exe (4512)  labagent.exe
  labagent.exe (4512) -> cmd.exe (4630)  cmd.exe /c whoami /all
kind          dns  file  net  proc  reg
image
editor.exe      0     1    0     0    0
explorer.exe    0     0    0     2    0
labagent.exe    1     1    1     1    1
updater.exe     0     0    0     0    1
ALERT 10:04:12 pid 4512 labagent.exe: autostart value 'LabAgentUpdater' -> C:\Users\lab\Downloads\labagent.exe

The rule fires once, on labagent.exe. The vendor updater also writes the registry, but under its own key, and the editor writes a document: ordinary behaviour. The rule's precision comes from combining where the program started with what it wrote, which is how good behaviour detections are built.

How this activity is detected in production

  • Autostart locations (Run keys, services, scheduled tasks, startup folders): Sysmon 13 and 12 on the Run keys, Security 4697 and System 7045 for new services, Security 4698 for new scheduled tasks; Sysinternals Autoruns lists every autostart location on a host for a periodic baseline diff.
  • Unusual parent–child pairs: Office or a PDF reader starting cmd.exe, powershell.exe or wscript.exe; a program in Downloads starting discovery commands.
  • Files written to user-writable program locations (C:\Users\Public, AppData, ProgramData) by unsigned programs.
  • DNS queries by processes that normally make none (Sysmon 22 includes the querying image).

How it is prevented and contained

  • Application control (WDAC, AppLocker) that blocks execution from Downloads and Temp for ordinary users is the strongest single control against this whole chain.
  • Users without local admin rights limit persistence to per-user locations, which are easier to monitor and clean.
  • Collect Sysmon (or EDR telemetry) centrally; logs left on the host are the first thing an intruder clears.

Pitfalls

  • Filtering out the child. Filtering on Process Name is labagent.exe hides what cmd.exe did; follow the tree.
  • Noise as a finding. Every program reads hundreds of registry keys at start-up; only writes and unusual reads matter.
  • Sysmon without a configuration logs too little or too much; test the configuration against your lab samples before deploying.
  • Time zones. Procmon shows local time; Sysmon's UtcTime field is UTC. Normalise before building a timeline.

Practice

1. Which Procmon filter shows every registry write by the sample and its children?

Include Operation is RegSetValue (and RegCreateKey, RegDeleteValue), and include the sample's PID and each child PID, or filter by the process tree. Exclude nothing else at first.

2. Extend the rule to also alert when a suspect process starts cmd.exe or powershell.exe.

Filter ev[(ev.id == 1) & ev.pid.isin(suspect_pids) & ev.target.str.lower().str.endswith(("\\cmd.exe", "\\powershell.exe"))] and print an alert per row; it would fire on the whoami /all command.

3. Why does the registry path in the Sysmon event start with HKU\S-1-5-21-… instead of HKCU?

HKCU is a per-user alias. The kernel sees the real location, HKEY_USERS\<user SID>, so Sysmon records that; detections must match both forms or the path suffix.

Test yourself

Which Sysmon event ID records a registry value being set?

  1. 1
  2. 3
  3. 13
  4. 22

What does Regshot do?

  1. Monitors network traffic
  2. Compares registry (and file) snapshots taken before and after a run
  3. Disassembles code
  4. Dumps memory

Why did the example's rule not fire on the vendor updater's registry write?

  1. It was too early
  2. It was not started from a download or temp folder, and it did not write an autostart key
  3. Sysmon ignored it
  4. Its PID was too high

Which control most directly blocks a program in Downloads from running at all?

  1. Sysmon
  2. Application control such as WDAC or AppLocker
  3. Procmon
  4. A larger disk