Part 5
Some
🚨 Remote Process Memory Injection via Rundll32
🔍 1. Attack Breakdown
📝 What is Remote Process Memory Injection via Rundll32?
Remote Process Memory Injection allows attackers to inject malicious code into the memory of a legitimate process.
Rundll32.exe, a legitimate Windows binary, is often abused because:
It’s a signed Microsoft binary.
It can execute DLLs and export functions directly.
It is often trusted by security tools, reducing detection chances.
📑 Why Attackers Use Rundll32 for Memory Injection?
Evasion: Bypass antivirus and security tools by using a trusted binary.
Stealth: Hide malicious activity within legitimate processes.
Execution Control: Load malicious DLLs directly into memory.
Credential Theft: Gain access to processes with higher privileges.
📌 How Rundll32 is Abused for Memory Injection
Technique
Description
Command Example
Execute Malicious DLL
Run exported functions from a DLL.
rundll32.exe malicious.dll,ExportedFunction
Reflective DLL Injection
Load a DLL directly into memory.
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";document.write("malicious code")
Inline Shellcode Execution
Inject and execute shellcode directly.
rundll32.exe advapi32.dll,CreateProcessAsUser
📌 Common Tools for Rundll32 Injection
Tool
Purpose
Metasploit
Shellcode injection
Cobalt Strike
Reflective DLL injection
PowerSploit
Memory injection scripts
Process Hacker
Process monitoring and analysis
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ Check for Suspicious Rundll32 Processes
🕵️ Inspect Process Command Line Arguments
🕵️ Look for Suspicious DLLs Loaded by Rundll32
🕵️ Check Remote Thread Creation
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Suspicious Rundll32 Execution
🕵️ Look for Remote Thread Creation in Rundll32
🕵️ Monitor for Reflective DLL Injection
🕵️ Identify Rundll32 Executing from Suspicious Paths
🕵️ Look for Remote Thread Activity in Memory
📊 Event Viewer Logs
Event ID
Description
4688
A new process was created (e.g., rundll32.exe
).
4689
Process termination (trace process exits).
4656
Handle to an object was requested (memory access).
4663
An attempt was made to access an object (e.g., DLL file).
7045
A service was installed in the system.
📌 Focus on Event ID 4688:
Look for:
📌 Focus on Event ID 4656:
Look for attempts to access suspicious memory regions.
📌 Focus on Event ID 7045:
Look for newly installed services linked to
rundll32.exe
.
🕵️ 3. Investigation Techniques
1️⃣ Trace Rundll32 Command History
Review command lines for suspicious patterns:
2️⃣ Inspect Loaded DLLs
Identify suspicious DLLs linked to
rundll32.exe
:
3️⃣ Analyze Remote Threads
Look for remote threads within legitimate processes:
4️⃣ Memory Dump Analysis
Dump
rundll32
process memory for further inspection:
🔧 4. Remediation Steps
📌 1. Terminate Suspicious Rundll32 Processes
📌 2. Remove Malicious DLLs
📌 3. Quarantine Suspicious Files
📌 4. Block Rundll32 Execution in Specific Folders
📌 5. Enable Advanced Threat Protection (ATP) Policies
Enable behavior-based detection and blocking.
📌 6. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Monitor Rundll32 Execution:
Block execution of
rundll32.exe
fromTemp
andAppData
.
Enable Script Block Logging:
Capture PowerShell commands with
rundll32
.
Use Windows Defender ATP:
Enable behavior monitoring and memory scanning.
Implement Application Whitelisting:
Use AppLocker or Windows Defender Application Control (WDAC).
Restrict DLL Execution in Temp Folders:
Prevent execution of DLLs from user-writable directories.
Monitor Process Relationships:
Regularly check parent-child process trees.
🧠 6. Key Takeaways
Rundll32 is a Trusted Binary: Attackers abuse it for stealth.
Monitor Command Lines: Look for
rundll32
with DLL paths inTemp
orAppData
.Focus on Event IDs: 4688, 4656, 4663, 7045.
Use Threat Intelligence: Leverage tools like VirusTotal for DLL analysis.
Implement Application Control: Block unauthorized DLL executions.
Non-Baselined LNK Target Command:
🔍 1. Attack Breakdown
📝 What is a Non-Baselined LNK Target Command?
LNK files are Windows shortcut files with a
.lnk
extension. They are used to point to an executable file or a command.Attackers can modify the "Target" field in LNK files to:
Execute malicious scripts or binaries.
Bypass security tools by using trusted processes.
Maintain persistence through startup folders.
📑 Why Attackers Use LNK Files?
Stealth: LNK files often bypass security detections.
Trusted Binary Execution: LNK files can invoke
cmd.exe
,powershell.exe
, orrundll32.exe
.Persistence: Placed in Startup folders for automatic execution.
Social Engineering: Disguised as legitimate shortcuts (e.g.,
Document.lnk
).
📌 Common Techniques for LNK Target Abuse
Technique
Description
Example Command
Malicious Target Path
Execute malware via an LNK file.
cmd.exe /c malicious.exe
PowerShell Execution
Run a malicious PowerShell script.
powershell.exe -NoProfile -ExecutionPolicy Bypass -File payload.ps1
DLL Hijacking
Run malicious DLLs via legitimate programs.
rundll32.exe malicious.dll,ExportedFunction
Environment Variable Abuse
Use environment variables to obfuscate paths.
%APPDATA%\malicious.exe
LNK in Startup Folder
Auto-execute LNK at boot.
C:\Users\<User>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\shortcut.lnk
📌 Common Attack Scenarios
Startup Folder Persistence: Place LNK file in
Startup
to run on boot.Fake Document Shortcut:
Invoice.lnk
executespowershell.exe -EncodedCommand
.Hidden Target Commands: LNK references commands that run from
%TEMP%
.Abuse of Trusted Binaries: Use
cmd.exe
,powershell.exe
, ormshta.exe
via LNK Target.
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ List LNK Files with Non-Standard Targets
🕵️ Check Startup Folder for Suspicious LNK Files
🕵️ Inspect LNK Metadata for Suspicious Targets
🕵️ Identify Recent LNK File Modifications
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Suspicious LNK File Execution
🕵️ Identify LNK Files with Malicious Targets
🕵️ Monitor PowerShell or CMD Executed via LNK
🕵️ Detect LNK in Startup Folder
🕵️ Trace Suspicious File Executions from LNK Files
📊 Event Viewer Logs
Event ID
Description
4688
A new process was created (LNK Target Execution).
4663
Object access attempt (LNK file access).
4656
Handle to an object was requested (e.g., LNK metadata access).
7045
A service was installed (LNK-based persistence via services).
📌 Focus on Event ID 4688:
Look for:
📌 Focus on Event ID 4663:
Track LNK file access activity.
🕵️ 3. Investigation Techniques
1️⃣ Inspect LNK File Metadata
Review target paths:
2️⃣ Trace Process Relationships
Check process lineage for LNK abuse:
3️⃣ Examine LNK File Creation History
Check recently modified LNK files:
4️⃣ Check Startup Folder
Review LNK files in startup paths:
🔧 4. Remediation Steps
📌 1. Remove Suspicious LNK Files
📌 2. Disable Executables from Non-Standard Paths
📌 3. Terminate Malicious Processes
📌 4. Reset User Accounts
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Script and Command Line Logging:
Capture suspicious LNK executions.
Monitor Startup Folders:
Regularly inspect
Startup
directories.
Restrict LNK File Creation:
Block LNK file creation in sensitive directories.
Implement AppLocker Policies:
Block execution of suspicious processes from LNK files.
Educate End-Users:
Train users to recognize suspicious LNK files.
🧠 6. Key Takeaways
LNK Files Are Powerful Attack Vectors: Often used for stealthy execution.
Focus on Startup and Temp Folders: Common storage for malicious LNK files.
Monitor Event IDs: 4688, 4663, 4656, 7045.
Use Threat Intelligence: Validate suspicious file hashes with VirusTotal.
Restrict Unauthorized LNK File Usage: Use AppLocker and WDAC.
🚨 Collecting UUID from a Device
🔍 1. Attack Breakdown
📝 What is UUID Collection?
UUID (Universally Unique Identifier) is a unique identifier used by operating systems to identify devices, installations, or user profiles.
Attackers often collect UUIDs to:
Fingerprint Devices: Track or uniquely identify a system.
Bypass Security Controls: UUIDs may be used in whitelisting mechanisms.
Enhance Persistence: Map UUIDs to compromised devices for long-term access.
Evasion: UUIDs may assist in developing more tailored attacks.
📑 Why Do Attackers Collect UUIDs?
Targeted Attacks: Build campaigns targeting specific devices.
Anti-Forensics: Avoid detection by profiling devices.
Authentication Abuse: UUIDs can sometimes be part of system authentication mechanisms.
System Persistence: Link malicious software or implants to specific UUIDs.
📌 Common Methods to Retrieve UUIDs
Method
Description
Command Example
SystemInfo Command
Display hardware and UUID details.
`systeminfo
WMIC Query
Query hardware UUID via WMI.
wmic csproduct get UUID
PowerShell Query
Retrieve UUID via PowerShell.
`Get-CimInstance -Class Win32_ComputerSystemProduct
Registry Query
UUIDs may exist in Windows Registry.
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography
Direct Hardware Interaction
Access BIOS/UEFI UUID directly.
dmidecode -s system-uuid
(Linux)
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ Identify UUID Queries via WMIC
🕵️ Search for UUID Retrieval Commands in PowerShell
🕵️ Monitor Registry Access for Cryptography Keys
🕵️ Track Command-Line UUID Queries
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect UUID Collection via WMIC
🕵️ Monitor UUID Retrieval via PowerShell
🕵️ Identify Registry Access to Cryptography Keys
🕵️ Trace UUID Retrieval via Command Line Tools
🕵️ Detect Suspicious Script Execution for UUID Collection
📊 Event Viewer Logs
Event ID
Description
4688
A new process was created (e.g., wmic UUID
).
4663
An attempt was made to access an object (Registry Key for Cryptography).
4104
PowerShell script block execution (UUID retrieval).
4624
Successful account logon (Tracking accounts used for UUID retrieval).
📌 Focus on Event ID 4688:
Look for:
📌 Focus on Event ID 4663:
Monitor registry access:
📌 Focus on Event ID 4104:
Look for PowerShell UUID retrieval scripts:
🕵️ 3. Investigation Techniques
1️⃣ Trace Commands Used for UUID Retrieval
Look for recent UUID queries:
2️⃣ Inspect Registry Access
Check if attackers accessed cryptography keys:
3️⃣ Trace PowerShell Activity
Review executed PowerShell commands:
4️⃣ Inspect Scripts on the Device
Search for UUID keywords in scripts:
🔧 4. Remediation Steps
📌 1. Terminate Suspicious Processes
📌 2. Block Unauthorized WMI Queries
Restrict WMI access for non-admin accounts.
📌 3. Audit and Reset Compromised Accounts
Force password reset:
📌 4. Quarantine Suspicious Scripts
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Restrict WMI Access:
Only allow trusted accounts to run
wmic
commands.
Enable Script Block Logging:
Capture all PowerShell command activity.
Audit Cryptography Registry Access:
Monitor
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography
.
Apply Least Privilege Principle:
Limit admin access to UUID-related queries.
Enable Advanced Threat Protection (ATP):
Activate behavioral analytics for WMI and PowerShell activity.
Monitor Event IDs:
4688, 4663, 4104.
🧠 6. Key Takeaways
UUIDs Are Valuable Targets: They aid in device fingerprinting and persistent access.
Monitor Command-Line Tools: Focus on
wmic
,systeminfo
, and PowerShell UUID queries.Watch Registry Activity: Pay close attention to the
Cryptography
registry key.Use Threat Intelligence Tools: Validate findings with tools like VirusTotal.
Enable Script and Command Logging: Catch malicious scripts early.
🚨 Detect Suspicious WerFault Child Process
🔍 1. Attack Breakown
📝 What is WerFault.exe?
WerFault.exe is the Windows Error Reporting (WER) service executable, responsible for handling application crash reports and collecting debugging information.
Attackers often abuse WerFault.exe because:
It is a trusted Windows binary (living-off-the-land binary - LoLBins).
It can be used to execute arbitrary payloads as a child process.
It can bypass antivirus and security monitoring tools.
📑 Why Attackers Abuse WerFault.exe?
Stealth: Bypass detection by masquerading malicious payloads as legitimate error reports.
Execution Control: Run code without leaving obvious traces.
Privilege Escalation: Gain higher-level privileges by running under system context.
Persistence: Maintain access using scheduled crashes or WER hijacking.
📌 Common WerFault Attack Techniques
Technique
Description
Example Command
Child Process Injection
Create malicious child processes under WerFault.
WerFault.exe -u -p <PID> -s <SubProcessID>
Reflective DLL Injection
Load malicious DLLs into WerFault memory.
WerFault.exe C:\malware.dll
Payload Execution
Direct execution of malicious payloads.
WerFault.exe /c C:\Temp\payload.exe
Hijacking Error Reporting Paths
Modify registry keys to redirect WER crash paths.
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WerFault.exe"
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ Identify WerFault Processes with Suspicious Command Lines
🕵️ Inspect Parent-Child Process Relationships
🕵️ Trace DLLs Loaded by WerFault
🕵️ List Suspicious Child Processes of WerFault
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Suspicious WerFault Process Execution
🕵️ Look for WerFault as a Parent Process
🕵️ Detect Suspicious DLL Loaded by WerFault
🕵️ Identify Remote Thread Activity in WerFault
🕵️ Detect Suspicious Registry Modification for WER
📊 Event Viewer Logs
Event ID
Description
4688
A new process was created (e.g., WerFault.exe
).
4689
Process termination (trace exits).
4663
Object access attempt (e.g., DLL or registry access).
7045
A service was installed in the system.
📌 Focus on Event ID 4688:
Look for:
📌 Focus on Event ID 4663:
Check DLL paths:
🕵️ 3. Investigation Techniques
1️⃣ Trace WerFault Child Processes
Identify suspicious child processes:
2️⃣ Inspect Loaded DLLs
List all DLLs loaded by WerFault:
3️⃣ Check WerFault Registry Hijacking
Look for WER registry hijacking:
4️⃣ Review Process Command Lines
Analyze command lines for suspicious arguments:
🔧 4. Remediation Steps
📌 1. Terminate Malicious WerFault Processes
📌 2. Remove Malicious DLLs
📌 3. Restore WER Registry Values
Reset registry settings:
📌 4. Block Execution from Suspicious Paths
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Monitor WerFault Execution:
Track Event IDs 4688, 4663, 7045.
Enable Command Line Auditing:
Capture suspicious arguments in process creation events.
Restrict WerFault in Non-Standard Paths:
Block execution from user-writable directories.
Implement Application Control Policies:
Use AppLocker or Windows Defender Application Control (WDAC).
Patch and Update Systems:
Apply latest Windows updates to prevent known exploits.
Educate Security Teams:
Raise awareness about WerFault abuse techniques.
🧠 6. Key Takeaways
WerFault.exe is Often Abused: Trusted by Windows, it's an ideal target for attackers.
Focus on Child Processes: Analyze processes spawned by
WerFault.exe
.Monitor DLL Loads: Pay attention to
.dll
files loaded from non-standard paths.Watch for Registry Hijacking: Registry paths under
Image File Execution Options
.Use Behavioral Analytics: Monitor arguments in
WerFault.exe
executions.
🚨 Abnormal File Extension in Public User Directory
🔍 1. Attack Breakdown
📝 What is an Abnormal File Extension in Public User Directory?
The Public User Directory (
C:\Users\Public
) is accessible to all users and is commonly used for sharing files between users and processes on the same system.Attackers often abuse this directory to:
Store malicious payloads with abnormal or uncommon file extensions.
Maintain persistence by placing executables or scripts in this directory.
Avoid detection, as the directory is often overlooked by monitoring tools.
📑 Why Attackers Use Public Directories?
Accessibility: Accessible to all users and processes by default.
Persistence: Files placed here may not be immediately flagged.
Evasion: Easier to bypass detection tools monitoring user-specific directories.
Shared Access: Facilitates multi-user access without elevated privileges.
📌 Common Abnormal File Extensions Used by Attackers
Extension
Purpose
Example File Name
.exe
Malicious executables
update.exe
.dll
Dynamic libraries for injection
malicious.dll
.bat
Batch scripts
run.bat
.cmd
Command-line scripts
payload.cmd
.ps1
PowerShell scripts
script.ps1
.js
JavaScript scripts
loader.js
.vbs
VBScript files
install.vbs
.dat
Encrypted payloads
config.dat
.tmp
Temporary executable files
tempfile.tmp
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ List Suspicious File Extensions in Public Directory
🕵️ Check Recently Created/Modified Files
🕵️ Inspect File Owners in Public Directory
🕵️ Find Executable Files in Public Directory
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Abnormal File Extensions in Public Directory
🕵️ Identify Recent File Creations in Public Directory
🕵️ Monitor Suspicious Processes Triggered from Public Directory
🕵️ Check PowerShell and CMD Files in Public Directory
🕵️ Look for DLL Files Loaded from Public Directory
📊 Event Viewer Logs
Event ID
Description
4688
A new process was created (e.g., cmd.exe
, powershell.exe
).
4663
An object access attempt was detected (e.g., file access).
4656
Handle to an object was requested (e.g., file handle).
7045
A service was installed on the system (e.g., via public executables).
📌 Focus on Event ID 4688:
Look for:
📌 Focus on Event ID 4663:
Look for file modifications:
🕵️ 3. Investigation Techniques
1️⃣ Inspect Suspicious Files in Public Directory
Check file details:
2️⃣ Trace Process Tree from Suspicious Files
Identify parent-child relationships:
3️⃣ Inspect File Hashes
Generate hashes and compare on VirusTotal:
4️⃣ Review Recent Events in Public Directory
Check event logs for file modifications:
🔧 4. Remediation Steps
📌 1. Quarantine Suspicious Files
📌 2. Terminate Malicious Processes
📌 3. Restrict Public Directory Permissions
📌 4. Block Executables in Public Directory
Create AppLocker rule:
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable File Auditing:
Enable auditing for
C:\Users\Public
.
Restrict Write Permissions:
Limit write access to trusted users.
Monitor File Extensions:
Alert on
.exe
,.dll
,.ps1
,.bat
in public directories.
Enable AppLocker or WDAC:
Block execution of files in
C:\Users\Public
.
Patch and Update:
Keep systems and security tools up to date.
Educate Users:
Train users to avoid executing files from public directories.
🧠 6. Key Takeaways
Monitor Public Directories Closely: They are common targets for malware storage.
Focus on Event IDs: 4688, 4663, 4656, 7045.
Restrict Permissions: Prevent unauthorized writes to public folders.
Regular Scanning: Ensure frequent scans of public directories.
Last updated