Table of Contents
Summery
This note was created as a quick access, general purpose reference for assessing a host in term of privilege escalation.
For more detailed breakdowns refer to Full windows privilege escalation checklist.
As always with automation, especially of privilege escalation. Be sure to perform manual privilege escalation as well.
Checker
Here are the sections that will be covered.
- - Automation
- - Current user
- - Permissive privileges
- - Permissive group membership
- - Host details
- - Kernel exploits
- - OS version exploits
- - Hotfix exploits
- - Existing users and groups
- - Kerberoasting
- - AS-REP roasting
- - Network information
- - New networks
- - Locally opened ports
- - Binaries and DLLs
- - Confidential data in random files
- - Binary hijacking
- - DLL hijacking
- - Processes
- - Privileged process abuse
- - Services
- - Weak ACLs
- - Unquoted service paths
- - Confidential data in service and config files
- - Writable services
- - Scheduled tasks
- - Writable binaries or scripts
- - Writable tasks
- - Installed applications
- - Public exploits
To add?:
PATH injection
Windows object handles
Windows registry
Automation
Run winpeas in the background while you perform a manual check.
You can also run PrivescCheck.ps1 if you feel like you need a second opition.
Also, get AccessChk, PowerView and Pentesting/The Grimoire/Tools/Mimikatz on the target as they will likely be needed soon.
Current user
Attacks: User Privileges & Rights, Windows Groups
Basic
whoami - Identify who is your current user
whoami /all - Enumerate privileges and groups
secedit /export /cfg C:\rights.inf /areas USER_RIGHTS - Read current account rights
System
Attacks: OS exploits, Hotfix exploits
History
doskey /history or Get-History - Check terminal history
(Get-PSReadlineOption).HistorySavePath - View PsReadLine’s path
If the above command works, check the full folder, not only the mentioned, singular file - ls C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; Id=4104} -MaxEvents 10 | ForEach-Object { $_.Message } - View PowerShell Script Block Logging
Identity
hostname - Confirm host’s identity
print env or Get-ChildItem Env: - View all environmental variables
$env:PATH or (Get-Item Env:PATH).Value - View the PATH environmental variables
System details
systeminfo | findstr /C:"Domain" or Get-CimInstance Win32_ComputerSystem | Select Domain,PartOfDomain - Check if your host is in a domain or not.
systeminfo - Get information about the operating system, version and architecture
wmic os get Caption,Version,BuildNumber,OSArchitecture - Get the build and system version
Hot-fixes
Get-CimInstance -Class win32_quickfixengineering | Where-Object { $_.Description -eq "Security Update" } - Get exact security patches installed on the system
wmic qfe or wmic qfe list brief Check present hotfixes
Password Policy
net accounts - Get password policy and other account information
Get-DomainPolicy - Get password policy with PowerView
You can also check it with netexec.
Registry
Enumerate if “AlwaysInstallElevated” settings are set
reg query HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Installer - Use both to make sure
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer - Use both to make sure
UAC
Confirm if User Account Control (UAC) is enabled and, if so, at what level
REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUA
REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v ConsentPromptBehaviorAdmin
Look for UAC bypasses by checking the system version and cross-checking it with the UACME tool.
Existing users and groups
Attacks: Kerberoasting, AS-REP roasting
Users
query user - View all live users on the host
net user or Get-LocalUser - List all local users
net user /domain - List all domain users
Get-DomainUser -Domain <DOMAIN NAME> | select SamAccountName List all domain users with PowerView
User details
net user leon or Get-LocalUser leon | Format-List * - Get information about a local user
net user leon /domain - Get information about a domain user
Get-ADUser leon -Properties * | Format-List * - Get information about a domain user with the ActiveDirectory module
Get-DomainUser leon -Properties * - Get information about a domain user with PowerView
Groups
net localgroup or Get-LocalGroup - List of all local groups
net group /domain - List of all domain groups
Get-ADGroup -Filter * - List of all domain groups with the ActiveDirectory module
Get-DomainGroup | Select-Object Name,Description,GroupScope,GroupCategory - List of all domain groups with PowerView
Group members
Get-LocalGroupMember <GROUP NAME> - Check members of a local group
net group "<GROUP NAME>" /domain - Check members of a domain group
Get-ADGroupMember "<GROUP NAME>" - Check members of a domain group with the ActiveDirectory module
Get-DomainGroupMember -Identity "<GROUP NAME>" \| Select MemberName - Check members of a domain group with PowerView
Network information
Attacks: Network discovery, Locally opened ports
ipconfig /all - List all network interfaces
route print - Display the routing table, which contains all routes of the system
netstat -ano - List all active network connections - (Look for Erlang Port if it’s present on the port 25672)
Binaries and DLLs
Attacks: Confidential data in random files, Binary Hijacking, DLL Hijacking
Files and folders
Get-ChildItem -Path C:\Users\ -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,*.kdbx,*.ini,*.cfg,*.config,*.xml,*.vhd,*.vhdx,*.vmdk,*.exe,*.msi -Recurse -ErrorAction SilentlyContinue - Look for a number of interesting extensions
Get-ChildItem -Path C:\Users\ -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,*.kdbx,*.cfg,*.config,*.vhd,*.vhdx,*.vmdk,*.exe,*.msi -Recurse -Force -ErrorAction SilentlyContinue or Get-ChildItem -Path C:\ -Force -ErrorAction SilentlyContinue - Look for interesting hidden files
Get-ChildItem -Path C:\ -Include *.pdf,*.xls,*.xlsx,*.doc,*.docx,*.kdbx,*.cfg,*.config,*.vhd,*.vhdx,*.vmdk -File -Recurse -Force -ErrorAction SilentlyContinue - Look for a number of interesting extensions
.\accesschk.exe /accepteula -uws "<USER>" C:\ - Find writable files/directories recursively
Get-CimInstance Win32_StartupCommand | select Name, command, Location, User |fl - Check for start-up programs
Get-ChildItem 'C:\$Recycle.Bin' -Force -Recurse or dir "C:\$Recycle.Bin" /s /a - Check the recycle bins of users for any loot
Get-ChildItem C:\Users -Recurse -File -ErrorAction SilentlyContinue | Select-String -Pattern "password" - Recursively look for a given string in multiple files
Credentials
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" - Look for Autologon credentials
cmdkey /list - Check stored credentials in Credential Manager
Check for AppData credentials:
dir "C:\Users\<USER>\AppData" -Recurse -File
dir "C:\Users\<USER>\AppData" /s /b /a-d
dir /S /B *pass*; dir /S /B *cred* or Get-ChildItem C:\ -Recurse -File -Include *pass*,*cred* -ErrorAction SilentlyContinue - Look for the filenames with possible credentials
findstr /spin "password" *.* or Get-ChildItem C:\ -Recurse -File -ErrorAction SilentlyContinue | Select-String -Pattern "password" -ErrorAction SilentlyContinue - Look for files mentioning credentials
Services
Attacks: Weak ACLs, Unquoted service paths, Confidential data in service and config files, Writable services
References: Windows services, Enumerating Windows services
Enumeration of services
-
Get-CimInstance
Get-CimInstance -ClassName win32_service | Select Name,State,PathName | Where-Object {$_.State -like 'Running'}- List only running services
Get-CimInstance -ClassName win32_service | Select Name,State,PathName- List all services
Get-CimInstance Win32_Service -Filter "Name='<SERVICE NAME>'" | Format-List *- List all details of a specific service -
Get-Service
Get-Service | Select-Object -ExpandProperty Name- List all service names
Get-Service -Name '<SERVICE>' | Format-List *- List all details of a specific service -
accesschk.exe
.\accesschk.exe /accepteula -ucqv *- List all services
.\accesschk.exe /accepteula -quvcw "<USER>" *oraccesschk.exe /accepteula -qvcw "<GROUP>" *- Find services where your user/group has write/change permissions
.\accesschk.exe /accepteula -quvcw <SERVICE NAME>- Check your rights over a specific service
.\accesschk.exe /accepteula "<USER>" -kvuqsw hklm\System\CurrentControlSet\Services- Check what user can do to a specific Windows service registry keys -
req
Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Services | % { $p=Get-ItemProperty $_.PSPath; if ($p.ImagePath) { [PSCustomObject]@{Name=$_.PSChildName;Path=[Environment]::ExpandEnvironmentVariables($p.ImagePath)} } } | Format-Table -AutoSize -Wrap- List all services and their basic information
reg query HKLM\SYSTEM\CurrentControlSet\Services /s /v ImagePathandreg query HKLM\SYSTEM\CurrentControlSet\Services- List just image paths and names. Pretty much the above command, just uses less complicated syntax in case the former gets is blocked.
reg query "HKLM\SYSTEM\CurrentControlSet\Services\<SERVICE NAME>" /s- Show basic registry data about a specific service
Unquoted service paths
Get-CimInstance Win32_Service | Where-Object {$_.PathName -notmatch "C:\\Windows\\" -and $_.PathName -notmatch '"'} | Select Name,State,PathName - Look for unquoted service paths
wmic service get name,displayname,pathname,startmode |findstr /i "auto" | findstr /i /v "c:\windows\\" | findstr /i /v """ - Look for unquoted service paths
wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v """ - Look for unquoted service paths
wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v "\" - Look for unquoted service paths
Service modification
accesschk -uwcqv "Authenticated Users" * - Check whether Authenticated Users can modify any service’s permissions or configuration
Scheduled tasks
Attacks: Writable binaries or scripts, Writable tasks
Task enumeration
Get-ScheduledTask | Where-Object { $_.Author -and $_.Author -notmatch "Microsoft" -and $_.Author -notmatch "^\$\(@" } | Format-List * - View more custom tasks - be wary, can exclude a lot
schtasks /query /fo LIST /v | findstr /C:"TaskName" - View all scheduled tasks’ names
schtasks /query /fo LIST /v or Get-ScheduledTask | Format-List * - View all scheduled tasks
Task details
schtasks /query /tn "<URI>" /fo LIST /v or Get-ScheduledTask <NAME> | Format-List * - View details about the task
(Get-ScheduledTask -TaskName "NAMe").Actions | Format-List * - View the exact action the task will perform
Processes
Attacks: Privileged process abuse
Processes enumeration
Get-Process | Select-Object Id, ProcessName, Path or tasklist - View running processes
while ($true) { Clear-Host; Get-Process; Start-Sleep 5 } - View running processes live
Get-Process | Format-List * - View all available information about every running process
Process details
Get-CimInstance <PROCESS> | Select-Object ProcessId,Name,ParentProcessId,ExecutablePath, @{N="User";E={$_.GetOwner().Domain + "\" + $_.GetOwner().User}}, CommandLine - View detailed process information
Get-Process -Name <PROCESS> -IncludeUserName | Select-Object Id, Name, Path, UserName - View the executable path of a specific process
Get-Process -Name explorer | Format-List * - View all available information about a specific process
Installed applications
Attacks: Public exploits
You can query two registry keys to list both 32-bit and 64-bit Installed applications:
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname, displayversion - 64-bit
Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select displayname, displayversion - 32-bit
Additionally, always check ls 'C:\Program Files'; ls 'C:\Program Files (x86)', and the user’s Downloads folder for additional installed or downloaded programs.
Here are yet another commands to check for those
wmic product get name - Check installed programs
You can use this 3 command combo to have a really nice view of the installed applications:
$INSTALLED = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, InstallLocation
$INSTALLED += Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, InstallLocation
$INSTALLED | ?{ $_.DisplayName -ne $null } | sort-object -Property DisplayName -Unique | Format-Table -AutoSize
PuTTy
reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions - Enumerated Putty credentials by viewing available sessions
reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions\kali%20ssh - Then enumerated credentials of a specific session