7 - Weak Service Permissions
Topics
Introduction to the Windows Shells
Windows Permissions
Reverse Shells in Windows
SeImpersonatePrivilege Exploitation
On Cross Compilation
Windows Services
Weak Service Permissions
Unquoted Service Path
DLL Hijacking
Always Install Elevated
Files with Sensitive Data
Windows Hashes
Stored Credentials and the Windows Vault
Scheduled Task
Critical Registry Paths
Useful Tools
AMSI Bypass
Weak Permissions on Service Configuration
Weak service configurations and binaries present significant security risks, infact service configurations can be altered if a user or group has sufficient permissions.
Viewing Service Configuration
Use the sc.exe
command to check a service's configuration:
Sample Output:
Checking Permissions with AccessChk
AccessChk is a Microsoft utility that permits to know what kind of accesses specific users or groups have to resources including files, directories, Registry keys, global objects and Windows services. AccessChk quickly answers these questions with an intuitive interface and output. (Download it from here)
Than, using accesschk64
we can verify permissions over a service:
Sample Output:
The output shows the permissions for users/groups. "SERVICE_ALL_ACCESS" indicates full control over the service as System and Administrators user.
After checking the configuration, the goal is to change the path and replace it with the malicious one, stop the service and run it again.
Exploitation Steps
Create a Malicious Executable Generate a reverse shell payload:
Modify the Service Executable Path Change the
binpath
to point to the malicious binary:Go into listening mode with netcat on linux attacker machine (we'll obtain the connection after next step):
Restart the Service Restart the service to execute the malicious binary:
Weak Permissions on Service Binary
If the service binary itself has weak file permissions, it can be overwritten with a malicious executable.
Identifying Service Binaries
List the binary paths of running services:
Checking Binary Permissions with ICACLS
Use the icacls
utility to view file permissions:
Sample Output:
If the current user has "Full Control" ((F)
), they can overwrite the binary.
Exploitation Steps
Generate and Transfer a Malicious Binary
Backup and Replace the Service Binary
Go into listening mode with netcat on linux attacker machine (we'll obtain the connection after next step):
Restart the Service
Service Enumeration with winPEAS
winPEAS
is a tool used to enumerate potential misconfigurations, including weak service permissions.
Downloading winPEAS
Download the binary:
Running winPEAS to Enumerate Services
Use the servicesinfo
option to gather information about services:
winPEAS
will display information about services, including configuration details, permissions, and potential vulnerabilities.
Other Resources
Windows Privilege Escalation Awesome Scripts: https://github.com/peass-ng/PEASS-ng/...
Weak Service Permissions: https://www.ired.team/offensive-secur...
Windows local privilege escalation: https://xorond.com/posts/2021/04/wind...
Service Misconfiguration: https://www.narycyber.com/posts/privi...
Weak Service Permissions: https://juggernaut-sec.com/weak-servi...
Insecure Service Permissions: https://akimbocore.com/article/privil...
Disclaimer
❗ Never use tools and techniques on real IP addresses, hosts or networks without proper authorization!❗
Last updated