Table of Contents


Checklist

  • System enumeration
    • - “The 5 W’s” commands
      • - whoami - See the name of the current user
      • - hostname - See the name of the current host
      • - pwd - Look what directory you’re in
      • - doskey /history and Get-History - Look through the terminal history to see if there aren’t any low-hanging fruit. Also look through .bash_history, .bashrc and .bash_profile
      • - systeminfo | findstr /C:"Domain" or Get-WmiObject Win32_ComputerSystem | Select-Object Domain - Check if you’re on a domain joined host
    • - systeminfo - Enumerate system information. KBs installed under HotFixes to get an idea of when the box has been patched. TheSystem Boot Time and OS Version can also be checked to get an idea of the patch level. If the host has not been restarted in over six months, chances are it is also not being patched. You can alternatively use wmic qfe (or wmic qfe list brief) to check present hotfixes if there don’t shown with systeminfo or use the Get-Hotfix cmdlet in PS. Additionally, [environment]::OSVersion.Version can give us the build and system versions. You can cross check build and windows versions using this page
      • - Check for known public exploits when you get to know a system version, build version or kernel version. Useful to check this site, this note and search in OSINT in general - Exploit DB perhaps the best option. There is also a number of other exploits explained in this HTB section
    • - UAC
      • - Confirm if 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. This could lead to a priv esc for example with an Invalid DLL injection
    • - DLL Injection - Look for writable .dll files. Check if you don’t have any in %PATH%. You could also use ProcMon to spot processes looking for missing DLLs. I’m not really familiar with this attack.
    • - Check for service binaries suffering from weak ACLs using SharpUp from the GhostPack. You can later use AccessChk from the Sysinternals suite to enumerate permissions on the service and if you have write permissions on it, you could change the service binary path.
    • - wmic service get name,displayname,pathname,startmode |findstr /i "auto" | findstr /i /v "c:\windows\\" | findstr /i /v """ - Search for unquoted service paths
    • - accesschk.exe /accepteula "mrb3n" -kvuqsw hklm\System\CurrentControlSet\services - Checking for weak service ACLs in the registry
    • - Get-CimInstance Win32_StartupCommand | select Name, command, Location, User |fl - Check for start-up programs. Suppose we have write permissions to the registry for a given binary or can overwrite a binary listed. In that case, we may be able to escalate privs to another user the next time that the user logs in
  • Users & Groups
    • - View the live users on the host with query user and all users with net user
    • - Check current user details for interesting rights with whoami /priv or whoami /all for all details
      • SeImpersonatePrivilege - Can be used to escalate privileges using a tool like Juicy Potato (can also utilize PrintSpoofer and RoguePotato)
      • SeDebugPrivilege and SeAssignPrimaryToken - Can be used with Mimikatz and ProcDump to easily dump LSASS creds. We can also get RCE with different scripts like this one or this one
      • SeTakeOwnershipPrivilege - Allows to write and change owners of specific files. HTB has a good section about this
      • SeBackupPrivilege - Can make shadow copies of the SAM/NTDS database, read the registry remotely, and access the file system on the DC via SMB
      • SeSecurityPrivilege - Can view and clear the Security log in Event Viewer
      • You can enabled all assigned privileges using this script or with Set-XYZ if you have a AD module imported
      • You can find more user rights here and here
    • - Enumerate the groups the current user is a part of with whoami /groups
      • DnsAdmins - We can use mimilib.dll or perform manual attack to escalate privileges
      • Event Log Readers - Can read through all logs
      • Hyper-V Administrators - This group has A LOT of attack surface. Here’s relevant HTB section. If Domain Controllers have been virtualized, then the virtualization admins should be considered Domain Admins
      • Print Operators - This group grants its members the SeLoadDriverPrivilege. You can use the ExploitCapcom tool or even better use EoPLoadDriver
      • Server Operators - This group allows members to administer Windows servers without needing assignment of Domain Admin privileges. It is a very highly privileged group that can log in locally to servers, including Domain Controllers
      • Backup Operators - Membership of this group grants its members the SeBackup and SeRestore privileges. You can traverse the file system and copy any file you want. I believe you can’t copy normally and instead need to use a script like this PoC or restic
      • You can find a reference list of interesting groups here
    • - net localgroup - Check all local groups. Check groups details with a command like net localgroup administrators
    • - net accounts - Get password policy and other account information
  • Network & Shares
    • - ipconfig /all - Check for other networks
    • - arp -a - Look for any other commonly connecting hosts on the network
    • - route - Looking what other networks are accessible through which interface
    • - netstat -ano - Check locally open ports
      • - Look for the loopback addresses (127.0.0.1 and ::1) or broadcast (0.0.0.0 and ::/0)
      • - Look for Erlang Port if it’s present on the port 25672
    • - Look for browsers to enumerate credentials hashed inside of them
    • - Passively look for NTLMv2 creds using Responder, Inveigh, or InveighZero
  • Web servers
    • - Check for IIS webserver at C:\inetpub\wwwroot
    • - Check for a PHP server at C:\xampp\htdocs\
    • - If there is a webserver, make a webshell for lateral movement to gain the web server account
  • Automation
    • WinPEAS - Scripted local Windows enumeration & privilege escalation checks
    • LaZagne - Use Lazagne for looking for passwords
    • SessionGopher - Used to extract saved PuTTY, WinSCP, FileZilla, SuperPuTTY, and RDP credentials
    • Snaffler - Scans shared drives along with files, folders, permissions, filenames, extensions such as .kdbx, .vmdk, .vdhx, .ppk, timestamps, and metadata to find sensitive information
    • PowerUp - PowerShell script for finding common Windows privilege escalation vectors that rely on misconfigurations. It can also be used to exploit some of the issues found
  • Processes & Services
    • - tasklist /svc - Check for running processes
    • - wmic product get name - Check installed programs
    • - dir "C:\Program Files" - Check installed applications
      • 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
    • - Check for process command lines passively sending credentials. This process is described here
  • Environmental
    • - set - To view all environmental variables
    • - Look for any relative file path in PATH variables
    • - Check if you can run languages like Python or Java due to them being in file path added to the PATH variable
    • - Check for a folder in PATH that we have writable privileges on - possible DLL injection. Look for any interesting folders in PATH before the system32 folder (on the left of it)
    • - Check the HOME DRIVE variable as it is often a share drive in enterprise environments. You can enumerate it for further intel
  • Pipes
    • - gci \\.\pipe\ or - Look for the named pipes (or with pipelist.exe /accepteula using PipeList from the Sysinternals)
    • - accesschk.exe -w \pipe\* -v - Check a pipe for write permissions - Accesschk
  • Credentials search
    • - findstr /SIM /C:"password" *.txt *.ini *.cfg *.config *.xml - Look for the filename “password” in different file formats. Can be adjusted as see fit
    • - Look for specific file extensions
      • dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config* - Method 1
      • where /R C:\ *.config - Method 2
      • Get-ChildItem C:\ -Recurse -Include *.rdp, *.config, *.vnc, *.cred -ErrorAction Ignore - Using Powershell
      • Look for .vhd, .vhdx, and .vmdk extensions for mountable drives
    • - Look for a string inside a given folder. Can be adjusted as see fit
      • cd c:\Users\htb-student\Documents & findstr /SI /M "password" *.xml *.ini *.txt - Method 1
      • findstr /spin "password" *.* and findstr /si password *.xml *.ini *.txt *.config - Method 2
      • select-string -Path C:\Users\htb-student\Documents\*.txt -Pattern password - Using Powershell
    • - gc 'C:\Users\htb-student\AppData\Local\Google\Chrome\User Data\Default\Custom Dictionary.txt' | Select-String password - Look for the word “password” in browser and email dictionaries
    • - foreach($user in ((ls C:\users).fullname)){cat "$user\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt" -ErrorAction SilentlyContinue} and less detailed gc (Get-PSReadLineOption).HistorySavePath - View PS history. I think you can do the same with CMD using history but I’m not 100% sure
    • - cmdkey /list - List of stored windows credentials. We can also attempt to reuse the credentials using runas to send ourselves a reverse shell as that user, run a binary, or launch a PowerShell or CMD console with a command such as runas /savecred /user:inlanefreight\bob "COMMAND HERE"
    • - We can use a tool such as SharpChrome to retrieve cookies and saved logins from Google Chrome
    • - We can attempt to search the user’s email for terms such as “pass,” “creds,” “credentials,” etc. using the tool MailSniper
    • - req query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" - Look for autologon credentials
    • - We can enumerated Putty credentials first by viewing available sessions using reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions and then credentials of the specific session with reg query HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\Sessions\kali%20ssh
    • - netsh wlan show profile ilfreight_corp key=clear - retrieve the wifi pre-shared key (Key Content in the output)
    • - Check if you can find sticky notes database in C:\Users\<user>\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite
    • - Checking local user description field
      • Get-LocalUser - Method 1
      • Get-WmiObject -Class Win32_OperatingSystem | select Description - Method 2
  • Registry
    • - Enumerate if “Always Install Elevated” 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
  • Scheduled tasks
    • - Enumerate scheduled tasks on the system
      • schtasks /query /fo LIST /v - Using CMD
      • Get-ScheduledTask | select TaskName,State - Using PS
  • Cookies
    • - Use SharpChromium to get cookie values from the current user. HTB section on it can be found here
  • Last chance
    • - Search through OSINT information
    • - Search through your notes, HTB sections and cheatsheets
    • - Rest and repeat the whole process, you must have missed something

References

Checklist - Local Windows Privilege Escalation
Windows Local Privilege Escalation
Windows - Privilege Escalation - Internal All The Things