By the end of this lesson you can
- Recognise the normal Windows process tree and spot impostors
- Know which folders and registry keys malware uses to hide and persist
- Explain SIDs, access tokens, integrity levels and what UAC really does
- Read key Security and System event IDs and query them with PowerShell
- Use cmd and PowerShell to answer basic incident response questions
Know normal: the Windows process family
Most Indian offices, colleges and government departments run Windows, so most incidents you investigate will touch it. The first skill is not a fancy tool; it is knowing what a healthy Windows machine looks like, so the odd thing jumps out.
| Process | Normal location | Normal parent | How many | Notes |
|---|---|---|---|---|
| System | kernel, no file | none | 1 | always PID 4 |
| smss.exe | C:\Windows\System32 | System | 1 lasting copy | first user mode process |
| csrss.exe | C:\Windows\System32 | smss.exe (exited) | 2 or more | one per session |
| wininit.exe | C:\Windows\System32 | smss.exe (exited) | 1 | starts services.exe and lsass.exe |
| services.exe | C:\Windows\System32 | wininit.exe | 1 | Service Control Manager |
| lsass.exe | C:\Windows\System32 | wininit.exe | 1 | checks passwords, holds credentials; never more than one |
| svchost.exe | C:\Windows\System32 | services.exe | many | hosts services; launched with -k group arguments |
| explorer.exe | C:\Windows | userinit.exe (exited) | one per logged in user | the desktop and taskbar |
The Windows file system and where malware likes to live
Windows uses NTFS with drive letters (C:, D:). A few folders matter far more than others:
| Folder | What it holds | Who can write |
|---|---|---|
C:\Windows\System32 | the core 64-bit system files and tools | administrators and the system only |
C:\Windows\SysWOW64 | 32-bit versions of system files on 64-bit Windows (yes, the names look backwards) | administrators |
C:\Program Files and Program Files (x86) | installed software | administrators |
C:\ProgramData | shared app data, hidden by default | often any user can create files |
C:\Users\<name>\AppData\Roaming, Local, LocalLow | per user app settings and caches | that user |
%TEMP% (usually AppData\Local\Temp) | temporary files | that user |
C:\Users\Public | files shared with every user | every user |
Permissions on NTFS are access control lists: a list of entries like "Users: Read and Execute" or "Administrators: Full control". View them in a file's Properties, Security tab, or with icacls.
C:\> icacls C:\ProgramData
C:\> icacls "C:\Program Files"The registry: Windows' giant settings database
The registry is a tree database holding almost every setting: installed software, services, drivers, user preferences and security policy. Its building blocks are keys (like folders) and values (name, type, data). Common types are REG_SZ (text), REG_DWORD (32-bit number) and REG_BINARY.
| Root key | Short | What it holds |
|---|---|---|
| HKEY_LOCAL_MACHINE | HKLM | machine wide settings: software, services, drivers, security |
| HKEY_CURRENT_USER | HKCU | settings for the logged in user (loaded from their NTUSER.DAT) |
| HKEY_USERS | HKU | every loaded user profile |
| HKEY_CLASSES_ROOT | HKCR | file associations and COM objects (a merged view of HKLM and HKCU) |
| HKEY_CURRENT_CONFIG | HKCC | current hardware profile |
On disk, the main hives are files in C:\Windows\System32\config: SAM (local accounts and password hashes), SECURITY, SOFTWARE and SYSTEM. Each user's HKCU is C:\Users\<name>\NTUSER.DAT.
C:\> reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run
C:\> reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
PS> Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'Accounts, SIDs, tokens and UAC
Windows identifies every user and group by a security identifier (SID), not by name. A few are worth memorising:
| SID or ending | Means |
|---|---|
| S-1-5-18 | Local System (NT AUTHORITY\SYSTEM), the most powerful local account |
| S-1-5-19 / S-1-5-20 | Local Service / Network Service, lower privilege service accounts |
| ...-500 | the built in Administrator account (relative ID 500), disabled by default on modern Windows |
| ...-501 | the built in Guest account |
| S-1-5-32-544 | the local Administrators group |
| ...-1001 and up | ordinary user accounts you create |
When you log in, Windows builds an access token listing your SID, groups and privileges. Every process you start carries a copy, and the kernel checks it against each object's ACL.
User Account Control
If you are an administrator, Windows actually gives you two tokens: a filtered standard user token used for normal work and a full admin token. UAC is the prompt that switches a program to the full token. Processes also get an integrity level (Low, Medium, High, System); a browser sandbox runs at Low so it cannot write to most of your files.
C:\> whoami /user
C:\> whoami /groups
C:\> whoami /priv
C:\> net localgroup administratorsServices and scheduled tasks
A service is a background program managed by the Service Control Manager (services.exe). It can start at boot before anyone logs in and usually runs as LocalSystem, LocalService, NetworkService or a dedicated account. A scheduled task runs a program at a time or on a trigger such as logon or idle.
PS> Get-Service | Where-Object Status -eq 'Running'
C:\> sc qc Spooler
C:\> schtasks /query /fo LIST /v | more
PS> Get-ScheduledTask | Where-Object State -ne 'Disabled'| Startup type | Meaning |
|---|---|
| Automatic | starts at boot |
| Automatic (Delayed Start) | starts shortly after boot to speed up login |
| Manual | starts when something asks for it |
| Disabled | cannot start |
Event Viewer: the machine's diary
Open eventvwr.msc. Under Windows Logs you find Application, Security, Setup, System and Forwarded Events, and under Applications and Services Logs hundreds of detailed channels such as PowerShell and Windows Defender. Each record has a time, source, event ID, level and details. Learn the IDs and you can read the story of an attack.
PS> Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 10
PS> Get-WinEvent -FilterHashtable @{LogName='System'; Id=7045} | Format-List TimeCreated, Messagecmd and PowerShell for defenders
cmd.exe is the old command prompt, still everywhere. PowerShell is far more powerful: commands (cmdlets) follow a Verb-Noun pattern and pass objects through the pipeline, not just text, so you can filter and sort on real properties.
| Question | cmd | PowerShell |
|---|---|---|
| Who am I, what privileges? | whoami /all | [Security.Principal.WindowsIdentity]::GetCurrent() |
| Local users | net user | Get-LocalUser |
| Who is admin? | net localgroup administrators | Get-LocalGroupMember Administrators |
| Running processes | tasklist /svc | Get-Process | Sort-Object CPU -Descending |
| Network connections | netstat -ano | Get-NetTCPConnection -State Established |
| IP configuration | ipconfig /all | Get-NetIPConfiguration |
| File hash | certutil -hashfile file SHA256 | Get-FileHash file -Algorithm SHA256 |
| Hidden files too | dir /a | Get-ChildItem -Force |
| System details and patches | systeminfo | Get-HotFix |
PS> Get-NetTCPConnection -State Established | Select-Object LocalPort, RemoteAddress, RemotePort, OwningProcess
PS> Get-Process -Id (Get-NetTCPConnection -State Established).OwningProcess | Select-Object Id, ProcessName, PathFlashcards: do you remember?
Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.
Quick quiz
Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.
Q1You find svchost.exe running from C:\Users\Public\svchost.exe. What do you conclude?
Correct name, wrong place. Classic masquerading.
Q2Which registry location makes a program start each time the current user logs in?
The Run key (and RunOnce) under HKCU applies at that user's logon.
Q3200 events with ID 4625 for the account admin in 10 minutes most likely means:
4625 is a failed logon; many against one account is brute force.
Q4Which event suggests someone tried to hide their tracks?
1102 is logged when the Security log is cleared.
Q5A Word document launches powershell.exe -w hidden -enc SQBFAFgA.... Best description?
Office spawning hidden, encoded PowerShell is a textbook malware pattern.
Q6What is the safest daily setup for a home PC?
Least privilege limits what malware gets if you click something bad.
Hands-on lab
Lab: create evidence on your own Windows VM, then find it
You need: A Windows VM in VirtualBox. Microsoft offers free time limited evaluation copies of Windows 11 Enterprise and Windows Server at microsoft.com/evalcenter. Use a VM, not your main PC, because you will create accounts and settings.
Only on machines you own. Do this lab on your own VM or computer. Scanning, testing or accessing anyone else's system without written permission can be an offence under the Information Technology Act, 2000 (for example Sections 43 and 66).
Snapshot first
Install Windows in the VM, then take a snapshot called
clean. Everything below can be undone by restoring it.Turn on the useful logging
C:\> auditpol /set /subcategory:"Process Creation" /success:enable C:\> reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit /v ProcessCreationIncludeCmdLine_Enabled /t REG_DWORD /d 1 /f C:\> auditpol /get /category:"Logon/Logoff"Run these in an administrator Command Prompt. The second line adds command lines to event 4688.
Make some events
PS> $p = Read-Host -AsSecureString 'Password for labuser' PS> New-LocalUser -Name labuser -Password $p PS> Add-LocalGroupMember -Group Administrators -Member labuser C:\> runas /user:labuser cmdUse an administrator PowerShell. At the
runasprompt type a wrong password twice. You just created events 4720, 4732 and 4625.Find them in Event Viewer and PowerShell
PS> Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4720,4732,4625} -MaxEvents 20 | Format-Table TimeCreated, Id, Message -WrapOpen
eventvwr.msc, Windows Logs, Security, and use Filter Current Log with4720,4732,4625. Read who did what and when.Plant and hunt a harmless persistence entry
C:\> reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v LabNotepad /t REG_SZ /d notepad.exe /f C:\> reg query HKCU\Software\Microsoft\Windows\CurrentVersion\RunSign out and in: Notepad opens. Now download Autoruns from Microsoft Sysinternals and find
LabNotepadin the Logon tab. Delete it there or withreg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v LabNotepad /f.Clean up
PS> Remove-LocalUser -Name labuserOr simply restore the
cleansnapshot.
You are done when: You created a user, an admin group change, failed logons and a Run key, and found every one of them in the logs or in Autoruns.
Key takeaways
- Learn normal first: right name, right path, right parent, right count.
- User writable folders (AppData, Temp, ProgramData, Public) are where payloads run from.
- Run keys, services and scheduled tasks are the big three persistence spots; Autoruns shows them all.
- 4624, 4625, 4672, 4688, 4720, 4732, 1102 and 7045 tell most attack stories.
- PowerShell is a gift to admins and attackers alike. Log it.
Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.