How Windows Works Behind the Scenes: A Pentester’s Field Guide

Windows might seem like a maze of pop-ups, processes, and services — and that’s because it is. For pentesters, understanding how these core parts of the operating system fit together is crucial. It’s how you move stealthily, escalate privileges, set persistence, and stay undetected.

  • Kernel Mode: Where the OS core, drivers, and sensitive system components live.
  • User Mode: Where regular applications (like browsers, PowerShell, malware) run.

Pentesters operate mostly in User Mode, but understanding both helps during privilege escalation and process injection.

  • A process is an instance of a running program.
  • Every app, script, or service you start becomes a process.
  • Each process:
    • Has a PID (Process ID)
    • Runs under a user context
    • Loads DLLs (code libraries) to function
    • Can contain threads (units of execution)
Get-Process
# Lists running processes
  • A service is a background task managed by Windows.
  • Services can:
    • Start on boot
    • Run in the background invisibly
    • Run as SYSTEM, NETWORK SERVICE, or a regular user
  • When a service starts, Windows launches it as a process — often inside svchost.exe.
Get-Service | Where-Object {$_.Status -eq "Running"}
# Lists all running services

Pentesting tip: Look for services with modifiable binaries or weak configurations.

TermDescriptionExample
ServiceBackground-managed componentwuauserv (Windows Update)
ProcessActual running instance of a programsvchost.exe hosting wuauserv
  • Many services run inside shared host processes, like svchost.exe.
  • One process can host multiple services to conserve memory.
tasklist /svc
# Shows which services are running inside which processes
  • DLLs are shared code libraries that processes load as needed.
  • A process can load dozens of DLLs to handle tasks like networking, I/O, crypto, UI, etc.
Get-Process -Id <PID> | Select-Object -ExpandProperty Modules
# Lists DLLs used by a specific process

Attack tip: DLL hijacking is common — placing a malicious DLL where a process expects a legit one.

WMI (Windows Management Instrumentation) is a built-in interface for querying and interacting with system components.

Why pentesters use it:

  • Native to Windows
  • Stealthier than PowerShell
  • Allows remote execution
  • Can be used for persistence
Get-WmiObject Win32_OperatingSystem
# System info

Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "cmd.exe"
# Spawns a process silently

Lateral movement tip: Use wmiexec.py (Impacket) to execute commands remotely.

  • PowerShell is a powerful admin shell built on .NET.
  • It gives you full access to the Windows API and system internals.
  • Used for automation, recon, execution, and scripting attacks.
Get-LocalUser
whoami /priv
Start-Process "calc.exe"

Detection note: PowerShell is heavily logged by default (Event ID 4104, AMSI, etc.).

  • The registry is a hierarchical database of system and application settings.
  • It’s used for:
    • Autostart programs
    • Service configs
    • User preferences
    • Installed software
  • HKLM: HKEY_LOCAL_MACHINE (system-wide)
  • HKCU: HKEY_CURRENT_USER (user-specific)
Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run"
# View autostart programs

Persistence tip: Drop a key into a Run path to re-execute payloads on reboot or login.

  • Scheduled Tasks allow Windows to run commands or scripts on a timer or event.
  • Can be abused for:
    • Fileless persistence
    • Privilege escalation
    • Execution at login or system boot
Get-ScheduledTask
# Lists all tasks

schtasks /create /tn evil /tr "C:\reverse.exe" /sc minute /ru SYSTEM
# Creates a malicious scheduled task
  1. A service (like Windows Update) is defined in the registry
  2. At boot, Windows starts the service — it spawns a process
  3. The process loads required DLLs to operate
  4. An admin or attacker uses PowerShell or WMI to query or control the system
  5. Persistence can be set using:
    • The registry
    • Scheduled Tasks
    • WMI Event Subscriptions
TaskTool or Technique
Enumerate usersGet-LocalUser, WMI
List servicesGet-Service, sc query
Process recontasklist, Get-Process
DLL hijackReplace expected DLL in path
Remote executionInvoke-WmiMethod, wmiexec.py
PersistenceRegistry run key, WMI subscription, Scheduled Task
PrivEscMisconfigured services, token abuse, UAC bypass
  • TryHackMe: Windows Fundamentals
  • Hack The Box: Blue, Bastard, Forest
  • Build a Windows VM and practice PowerShell, WMI, and DLL hijacking techniques

Scroll to Top