Lesson 6 of 6 · 25 min read

Worked Example: Detecting whoami Recon Across 4688, Sysmon 1, and ETW

Putting it all together: here’s a real recon scenario — an adversary runs whoami and whoami /all after initial access via a web shell. We’ll analyze what appears in each telemetry source, why the differences matter, and how to write detections that actually fire.

Scenario: An adversary exploits a vulnerable web application running on IIS (w3wp.exe) and drops a web shell. They then run:

whoami
whoami /all
systeminfo
net localgroup administrators

Source 1: Windows Security Event 4688

With the default audit policy (process creation enabled, command line auditing OFF):

<EventData>
  <Data Name="NewProcessId">0x2f8c</Data>
  <Data Name="NewProcessName">C:\Windows\System32\whoami.exe</Data>
  <Data Name="TokenElevationType">%%1938</Data>
  <Data Name="ProcessId">0x4a3c</Data>
  <Data Name="CommandLine"></Data>  <!-- EMPTY without command line auditing -->
  <Data Name="ParentProcessName">C:\Windows\System32\cmd.exe</Data>
</EventData>

You can see whoami.exe ran. Parent is cmd.exe. But:

With command line auditing ON:

<Data Name="CommandLine">whoami /all</Data>

Now you see the flag. Still no hash, still need to manually chain parent-child events.


Source 2: Sysmon Event ID 1

<EventData>
  <Data Name="UtcTime">2024-03-15 09:23:14.882</Data>
  <Data Name="ProcessGuid">{abc-001}</Data>
  <Data Name="Image">C:\Windows\System32\whoami.exe</Data>
  <Data Name="CommandLine">whoami /all</Data>
  <Data Name="Hashes">MD5=...,SHA256=6D8EE7D8...,IMPHASH=...</Data>
  <Data Name="ParentProcessGuid">{abc-000}</Data>
  <Data Name="ParentProcessId">19004</Data>
  <Data Name="ParentImage">C:\Windows\System32\cmd.exe</Data>
  <Data Name="ParentCommandLine">cmd.exe</Data>
  <Data Name="IntegrityLevel">Medium</Data>
  <Data Name="User">IIS APPPOOL\DefaultAppPool</Data>
</EventData>

Much richer. Now you have:

Now look up the parent (ParentProcessGuid = {abc-000}):

<!-- Sysmon Event 1 for cmd.exe -->
<Data Name="ProcessGuid">{abc-000}</Data>
<Data Name="Image">C:\Windows\System32\cmd.exe</Data>
<Data Name="ParentImage">C:\Windows\System32\inetsrv\w3wp.exe</Data>
<Data Name="ParentCommandLine">c:\windows\system32\inetsrv\w3wp.exe -ap "DefaultAppPool"</Data>
<Data Name="User">IIS APPPOOL\DefaultAppPool</Data>

The full chain: w3wp.exe → cmd.exe → whoami.exe /all. This is textbook web shell execution.


Source 3: ETW (Kernel-Process Provider)

At the ETW level, the same event is available with sub-millisecond timing and thread-level detail — but this only matters if you have an EDR or custom ETW consumer:

{
  "provider": "Microsoft-Windows-Kernel-Process",
  "event_name": "ProcessStart",
  "timestamp_ns": 1710491994882341200,
  "process_id": 12172,
  "parent_process_id": 19004,
  "image_file_name": "whoami.exe",
  "command_line": "whoami /all",
  "user_sid": "S-1-5-82-3006700770-...",
  "thread_id": 7844
}

ETW adds: nanosecond timestamps (enables precise sequencing), thread ID (useful for multi-threaded process analysis), and it fires before the process is fully initialized — microseconds ahead of the EVTX event.


The Full Comparison

Feature4688 (no cmd line)4688 (with cmd line)Sysmon Event 1ETW
Command line
File hash
Parent command line
ProcessGuid
Sub-millisecond timing
Tamper-resistant deliveryDepends on forwarderDepends on forwarderDepends on forwarderYes (real-time)
Required configAudit policyAudit policy + cmd lineSysmon install + configEDR / ETW consumer
T1033 — System Owner/User Discovery— MITRE ATT&CK EVTX-ATTACK-SAMPLES— GitHub (sbousseaden)