EoP - Incorrect permissions in services
Key Concepts
1. Service Permissions
Writable services: Only trusted users should have write permissions.
Service path vulnerabilities: Writable paths may allow DLL hijacking or binary replacement.
2. Common Vulnerabilities
Orphaned installs: Services with missing or unmaintained binaries.
DLL hijacking: Services load malicious DLLs from writable locations.
Weak PATH permissions: Writable PATH directories allow privilege escalation.
Step-by-Step Guide to Identifying and Exploiting Vulnerable Services
1. Checking File Permissions
Use the icacls
command to inspect service binary permissions:
Look for vulnerable permissions like:
BUILTIN\Users:(F)
- Full accessBUILTIN\Users:(M)
- Modify accessBUILTIN\Users:(W)
- Write access
Example:
Output:
2. Finding Vulnerable Services
List services with their executable paths:
Inspect individual service configurations:
3. Identifying Potential DLL Hijacking
Using PowerUp to find DLL hijacking paths:
Using Process Monitor (ProcMon):
Filter for
NAME NOT FOUND
entries during service startup to identify missing DLLs.
4. Compiling a Malicious DLL
Create a DLL to execute commands upon injection. Use the following sample code:
C Code for Malicious DLL:
Compile the DLL:
For x64:
For x86:
5. Exploiting the Vulnerability
Stop the Service:
Modify the Service Binary Path:
Start the Service:
Example: Exploiting UsoSvc (CVE-2019-1322)
Stop the Service:
Modify Binary Path to Execute Payload:
Start the Service:
6. Post-Exploitation
After gaining elevated privileges:
Maintain access: Establish persistence (e.g., backdoor or scheduled tasks).
Further exploitation: Explore lateral movement or sensitive data exfiltration.
Tools for Service Permission Analysis
Accesschk (Sysinternals)
Analyze permissions on a specific service:
Metasploit Module
Automate the process using Metasploit:
Security Considerations
Monitor permissions on critical services and binaries.
Restrict write access to trusted users.
Regularly audit PATH directories for inappropriate permissions.
Last updated