Practice library / Windows, Active Directory and macOS
Workbook · Easy · 3 hours
Windows Fundamentals
Windows OS, registry, services, file system, and PowerShell basics.
On this page 5 sections
Windows runs most enterprise endpoints, so a security engineer must understand how the platform makes access decisions. The kernel, the registry, the SID and the access token together decide who can read a file, start a service or load a driver. Weak NTFS permissions, unquoted service paths and over-privileged tokens are the paths real attackers take, and the same paths defenders audit first. The chapters cover the architecture, the security model, NTFS and share permissions, and the built-in command-line tools for services, tasks and the event log. Each idea is paired with a command you run and output you compare, so the mental model stays close to the box.
What You'll Learn
- Explain the user/kernel-mode split and read the registry the way an attacker and a defender do
- Reason about principals, SIDs, access tokens, privileges and UAC — the machinery of "who can do what"
- Read and change NTFS and share permissions with
icacls, and understand inheritance - Drive Windows from the command line with the built-in tools, services and scheduled tasks
About This Workbook
Windows dominates the enterprise, so understanding it is not optional — it is the platform you will attack and defend most. This workbook is hands-on: every idea is followed by a command you can run in a terminal and output you can compare against your own. Work in a Windows VM you control, at an elevated prompt where noted.
Commands are shown for both the classic Command Prompt (cmd.exe) and PowerShell, because you will meet both on real systems. Where output appears, it is illustrative — machine names, SIDs and paths will differ on your host.
Authorisation first. Several techniques here — enumerating privileges, reading credential storage, inspecting service permissions — are the same steps an attacker takes. Run them only against systems you own or have written authorisation to test. That single rule separates training from a crime.
Chapter 1 — Architecture & Registry
How Windows is put together, and where its configuration lives.
Kernel vs user mode
The CPU runs code in one of two privilege levels, and Windows maps its world onto them. User mode (ring 3) is where your applications, services and even most of the OS's own processes run. Each user-mode process gets its own private virtual address space and cannot touch another's memory or the hardware directly. Kernel mode (ring 0) is where the core of the OS and device drivers run, in a single shared address space with full access to hardware.
The heart of kernel mode is ntoskrnl.exe (the kernel and executive), sitting on hal.dll (the Hardware Abstraction Layer). When a program calls something like CreateFile, the call travels down through subsystem DLLs — kernel32.dll, user32.dll — into ntdll.dll, which issues the actual system-call transition into the kernel.
Why this matters for security: a user-mode exploit gets you code execution as some account, but you are still boxed in by that account's token. A kernel-mode compromise (a malicious or vulnerable driver) hands an attacker ring 0, above most defences. That asymmetry is why 64-bit Windows enforces Driver Signature Enforcement and protects kernel structures with Kernel Patch Protection (PatchGuard). You can see the split yourself: Get-Process reports how much time each process spent in each mode.
Get-Process | Sort-Object CPU -Descending |
Select-Object -First 5 Name, Id, UserProcessorTime, PrivilegedProcessorTimeThe registry
The registry is Windows' central, hierarchical configuration database. On disk it is a set of binary hives under C:\Windows\System32\config (SYSTEM, SOFTWARE, SECURITY, SAM, DEFAULT) plus a per-user NTUSER.DAT in each profile. In a running system you see it through five root keys:
- HKLM (
HKEY_LOCAL_MACHINE) — machine-wide settings - HKCU (
HKEY_CURRENT_USER) — the current user's settings - HKU (
HKEY_USERS) — all loaded user profiles - HKCR (
HKEY_CLASSES_ROOT) — file associations and COM registration, a merged view - HKCC (
HKEY_CURRENT_CONFIG) — the active hardware profile
Keys hold values, each with a type: REG_SZ (string), REG_DWORD (32-bit number), REG_EXPAND_SZ, REG_MULTI_SZ and REG_BINARY. Read it from Command Prompt with reg query:
C:\> reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Run"
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
SecurityHealth REG_EXPAND_SZ %windir%\system32\SecurityHealthSystray.exe
RTHDVCPL REG_SZ C:\Program Files\Realtek\Audio\HDA\RtkNGUI64.exePowerShell exposes the registry as a drive, so the same key is browsable with the file cmdlets:
Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run"Those Run keys — and their HKCU counterpart — are among the most-abused persistence locations on Windows: anything listed there launches at logon. A defender enumerates them during triage; an attacker (with authorisation) plants persistence there. Knowing the key path is essential.
Key system processes
A handful of processes appear on every Windows box, and knowing their normal shape lets you spot the abnormal. tasklist /svc shows them and the services each hosts:
C:\> tasklist /svc
Image Name PID Services
================= ===== ============================================
System 4 N/A
smss.exe 340 N/A
csrss.exe 456 N/A
wininit.exe 540 N/A
services.exe 640 N/A
lsass.exe 648 KeyIso, SamSs, VaultSvc
svchost.exe 820 BrokerInfrastructure, DcomLaunch, ...
winlogon.exe 612 N/A- System (PID 4) and smss.exe (Session Manager) start the OS.
- csrss.exe is the client/server runtime; wininit.exe and winlogon.exe handle session and logon.
- services.exe is the Service Control Manager — it is the expected parent of the
svchost.exeprocesses that host most Windows services. - lsass.exe is the Local Security Authority Subsystem. It validates logons and holds credential material in memory, which makes it a frequent target on the system.
The defensive value is the tree, not the list. lsass.exe is normally a child of wininit.exe; if you see lsass.exe spawning cmd.exe, or a svchost.exe whose parent is not services.exe, treat it as suspicious. Legitimate credential access happens inside lsass; illegitimate access reaches into it from outside — and doing so requires privileges we cover next.
Chapter 2 — Security Model
How Windows decides who can do what. Every access decision comes down to a token meeting a security descriptor.
Users, groups and SIDs
Windows does not identify principals by name internally — it uses a Security Identifier (SID), a variable-length value like S-1-5-21-1004336348-1177238915-682003330-1001. The trailing number is the Relative Identifier (RID), and some RIDs are fixed and worth memorising: 500 is the built-in Administrator, 501 is Guest, and in a domain 512 is Domain Admins and 519 is Enterprise Admins. Some SIDs are the same on every machine — S-1-5-18 is LocalSystem, S-1-5-32-544 is the built-in Administrators group.
whoami is your fastest way to see who the current process actually is:
C:\> whoami /user
USER INFORMATION
----------------
User Name SID
=============== =============================================
desktop\alice S-1-5-21-1004336348-1177238915-682003330-1001
C:\> whoami /groups
... Mandatory Label\Medium Mandatory Level S-1-16-8192 ...Enumerate local accounts and group membership with the built-in net commands, or the newer PowerShell cmdlets:
Get-LocalUser
Get-LocalGroupMember -Group Administrators
# classic equivalents:
# net user
# net localgroup administratorsAccess tokens
When you log on, LSA builds an access token for your session and stamps it on every process you run. The token carries your user SID, the SIDs of every group you belong to, and a list of privileges. When a thread touches a securable object, the kernel compares that token against the object's DACL (covered in Chapter 3) — the token is your identity for every access check.
Privileges are the rights that are not tied to a specific object, and a few of them grant very broad control. SeDebugPrivilege lets you open any process (including lsass); SeBackupPrivilege and SeRestorePrivilege bypass file ACLs; SeImpersonatePrivilege lets a process act as another security context and is the hinge of several well-known service-account escalation techniques. List what your token holds — and whether each is enabled — with whoami /priv:
C:\> whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ==================================== ========
SeShutdownPrivilege Shut down the system Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeImpersonatePrivilege Impersonate a client after auth EnabledReading whoami /priv is the first move in local privilege-escalation assessment. A service account showing SeImpersonatePrivilege as Enabled is a finding worth noting in an authorised engagement, and a control worth restricting on the defensive side.
UAC
An account in the Administrators group does not run with admin rights all the time. Under User Account Control, logging on as an admin mints two tokens: a filtered, standard-user token that your desktop and most processes use, and a full elevated token that is only attached when you explicitly elevate (the "Run as administrator" / consent prompt). This is Admin Approval Mode.
UAC is expressed through integrity levels, a mandatory label on every process: Low, Medium, High, System. A normal admin session runs at Medium; an elevated one runs at High. You already saw yours in whoami /groups — Mandatory Label\Medium Mandatory Level (S-1-16-8192) versus High Mandatory Level (S-1-16-12288):
C:\> whoami /groups | findstr /i "Mandatory Level"
Mandatory Label\Medium Mandatory Level Label S-1-16-8192Treat UAC as a safeguard, not a hard boundary. Microsoft itself describes the elevation prompt as a convenience feature rather than a hard security boundary, and bypass techniques exist — which is exactly why a defender monitors for elevation events and an assessor checks whether the box hands out High integrity too easily.
Chapter 3 — Filesystem & Permissions
Controlling access to data on disk. NTFS is where the security model of Chapter 2 meets storage.
NTFS permissions
Every file and folder on an NTFS volume carries a security descriptor: an owner, a DACL (the list of allow/deny entries that grant access) and an optional SACL (audit rules). Each entry in the DACL is an ACE naming a principal and the rights it gets. The GUI shows friendly names — Read, Write, Read & Execute, Modify, Full Control — but the command-line tool icacls shows the compact form:
C:\> icacls C:\Windows\System32\drivers\etc\hosts
C:\Windows\System32\drivers\etc\hosts
NT AUTHORITY\SYSTEM:(I)(F)
BUILTIN\Administrators:(I)(F)
BUILTIN\Users:(I)(RX)
APPLICATION PACKAGE AUTHORITY\ALL APPLICATION PACKAGES:(I)(RX)
Successfully processed 1 files; Failed processing 0 filesRead the codes: (F) full control, (M) modify, (RX) read and execute, (R) read, (W) write. The (I) means the ACE was inherited from the parent folder rather than set directly. Change permissions with the same tool — /grant, /deny and /remove — for example icacls report.docx /grant alice:(M) to give Alice Modify. When assessing a host, look for files or service binaries where non-privileged principals (like Users or Everyone) hold (M) or (F) on something that runs as SYSTEM: that write is a privilege-escalation primitive.
Shares
NTFS permissions govern access on the machine; share permissions govern access over the network via SMB. When a user reaches a folder across the network, both sets apply and the more restrictive of the two wins. Every Windows machine also exposes hidden administrative shares by default — C$ (the C: volume), ADMIN$ (the Windows directory) and IPC$ — reachable by administrators, which is why lateral movement so often rides on C$.
List shares and their access with the built-in commands or the SMB cmdlets:
C:\> net share
Share name Resource Remark
-------------------------------------------------------------
C$ C:\ Default share
IPC$ Remote IPC
ADMIN$ C:\Windows Remote Admin
Data D:\DataGet-SmbShare
Get-SmbShareAccess -Name DataEnumerating shares — net view \\host against a target — is standard reconnaissance on an authorised engagement and standard hygiene review on the defensive side: an open share with sensitive data is a finding either way.
Inheritance
By default a new file or folder inherits the ACEs of its parent, which is why so many entries above carried (I). Inheritance flags on a folder's ACE control the propagation: (OI) object-inherit (files below get it), (CI) container-inherit (subfolders get it), (IO) inherit-only (applies to children, not the folder itself). This is what makes permissions manageable at scale — set them once at the top and let them flow down.
Sometimes you need to stop the flow — a sensitive folder that should not carry its parent's broad access. icacls controls this with /inheritance: (r removes inherited ACEs, d disables inheritance but copies the current ones, e re-enables it):
C:\> icacls D:\Payroll /inheritance:r /grant:r "Administrators:(OI)(CI)F" "HR:(OI)(CI)M"
processed file: D:\Payroll
Successfully processed 1 files; Failed processing 0 filesThat command detaches D:\Payroll from inherited permissions and replaces them with an explicit set — Administrators full, an HR group modify, everyone else nothing. One more point on ownership: the owner of an object can always rewrite its DACL, and a holder of SeTakeOwnershipPrivilege (or takeown) can seize ownership. So a permission model is only as strong as the ownership behind it — a fact both attackers and auditors exploit.
Chapter 4 — Management Tools
The built-in tools for running Windows. You rarely need third-party software to administer — or assess — a box.
Management consoles
Most graphical administration lives in the Microsoft Management Console (MMC), which hosts snap-ins you can launch directly by their .msc name: services.msc (Services), eventvwr.msc (Event Viewer), compmgmt.msc (Computer Management), taskschd.msc (Task Scheduler), secpol.msc (Local Security Policy) and lusrmgr.msc (Local Users and Groups). Note that some — gpedit.msc, lusrmgr.msc, secpol.msc — are absent from Windows Home editions.
Event Viewer is the main console for monitoring, and its Security log is the record of who did what. A few event IDs are worth knowing by heart: 4624 a successful logon, 4625 a failed logon, 4634 a logoff, 4672 special privileges assigned at logon, 4688 a new process created, and 4720 a new account. Logon events carry a logon type — 2 is interactive (at the keyboard), 3 is over the network, 10 is RemoteInteractive (RDP). Read the log from PowerShell rather than clicking through the GUI:
Get-WinEvent -FilterHashtable @{ LogName='Security'; Id=4625 } -MaxEvents 5 |
Select-Object TimeCreated, Id, MessageA burst of 4625 (failed logon) events with logon type 3 is a network password-guessing attempt; a 4624 type 10 at an odd hour is an RDP session worth explaining. This is where detection engineering starts.
Command line essentials
Beyond whoami, hostname and ipconfig, a few commands do most of the enumeration work. systeminfo dumps the OS build, hotfixes and domain membership in one shot:
C:\> systeminfo
Host Name: DESKTOP-ALICE
OS Name: Microsoft Windows 11 Pro
OS Version: 10.0.22631 N/A Build 22631
System Type: x64-based PC
Domain: WORKGROUPnetstat -ano lists every connection and the owning PID, which you then resolve back to a process — the fastest way to answer "what is talking to the network, and is it meant to?":
C:\> netstat -ano | findstr LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 1288
TCP 0.0.0.0:5985 0.0.0.0:0 LISTENING 4
C:\> tasklist /fi "pid eq 1288"PowerShell is the more powerful shell because it passes objects, not text, down the pipeline. Get-Command, Get-Help and Get-Member are the three cmdlets to learn first — they let you discover and inspect everything else. A note on the older wmic utility: it still appears in many guides but is deprecated; prefer Get-CimInstance (for example Get-CimInstance Win32_OperatingSystem) for anything new.
Services and tasks
Services are background programs the Service Control Manager starts, often before anyone logs on and often as a high-privilege account (LocalSystem, LocalService or NetworkService). List them, then inspect one's configuration with sc qc — which reveals the crucial BINARY_PATH_NAME and the account it runs as:
C:\> sc qc Spooler
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: Spooler
TYPE : 110 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
BINARY_PATH_NAME : C:\Windows\System32\spoolsv.exe
SERVICE_START_NAME : LocalSystemGet-Service | Where-Object Status -eq 'Running' | Select-Object Name, DisplayNameTwo service misconfigurations recur in assessments: an unquoted service path that contains spaces (Windows may then execute an attacker-planted binary earlier in the path), and weak permissions on the service binary or its config (a non-admin who can overwrite a SYSTEM binary can take control of the system). Both are found by reading sc qc output and the icacls of the target.
Scheduled tasks are the other automation surface — and another persistence favourite. Enumerate them fully with schtasks or the PowerShell cmdlet:
C:\> schtasks /query /fo LIST /v | findstr /i "TaskName Run Author"Get-ScheduledTask | Where-Object State -eq 'Ready' |
Select-Object TaskName, TaskPathWhether you are hardening a host or hunting on one, the routine is the same: enumerate the services and tasks, check who they run as, and check who is allowed to modify what they run. That single habit — read the config, then read the permissions on what the config points at — is the thread that ties this whole workbook together.
Keep going. Work through each chapter in order, then apply what you learned in the matching labs. From here, the natural next step is Active Directory: everything above scales up when a domain controller, not a single box, holds the tokens and permissions.
Sign in to track progress and send feedback.