With the following command we can check the privileges that is assigned to the pwned user:
SeImpersonatePrivilege
RottenPotato (Juicy Potato)
Juicy Potato is another Local Privilege Escalation tool, from a Windows Service Accounts to NT AUTHORITY\SYSTEM. Is a sugared version of Rotten Potato. Download the latest realese and execute it.
PrintSpoofer
One way to gain system user on latest Operative System such as Windows10 or Server 2016/2019, is using the printspoofer exploit. Donwload the latest release and execute it on the target machine to gain privs.
SeLoadDriverPrivilege
We are able to load a driver, so we can load a vulnerable driver, then exploit it.
Load Capcom.sys
To load the driver we need first to create a C++ Console APP on Visual Studio (Not Code!) and paste the following script.
Copy the driver and the binary to the target machine and execute it.
NTSTATUS codes:
0xC000003B - STATUS_OBJECT_PATH_SYNTAX_BAD
0x00000034 - STATUS_OBJECT_NAME_NOT_FOUND
Exploiting Capcom.sys
I modified the following project: https://github.com/tandasat/ExploitCapcom. Download the project and open the ExploitCapcom.sln (Visual Studio Project) with Visual Studio.
Modify the line 410 of ExpliotCapCom.cpp and compile it.
ExploitCapcom.cpp
Create the exploit.exe payload with msfvenom:
And upload all the files and execute the ExploitCapcom.exe:
Every Windows service has his access route to the executable. If this route is not quoted and containsspaces or others separators like this example C:\Program Files\First Folder\myexecutable.exe , the service will try to access to the resource in the following order:
C:\Program.exe
C:\Program Files\First.exe
C:\Program Files\First Folder\myexecutable.exe
If we can put our executable in one of the paths that it is checked before the real route, when we restart the service we will obtain a shell.
We need to ensure that the service is running by LocalSystem:
Once we've found the binaries that are vulnerable to unquoted service path, we need to find where we have permissions to write, for that work we can use icacls:
Info: We need to find some with write permissions (W)
Once we've found the writeable path, we will need to create our malicious binary with msfvenom and upload in the right directory:
Finally we need to restart the service to gain access to system:
Always Install Elevated
If these 2 registers are enabled (value is 0x1), any user can install .msi ** files as NT AUTHORITY\SYSTEM**
Creating the malicious .msi file
Executing the .msi
Note: I'd problems while exploiting it via WIN-RM. Try another way to get shell.
Incorrect permissions in services
A service running as NT AUTHORITY/SYSTEM with incorrect file permissions might allow to escalate privileges. You can replace the binary, restart the service and get system.
Sometimes services are pointing to writeable folders:
Writeable Folders
Check permissions on folders.
Permissions:
Full access (F): Change the binary to the malicious one. PRIV PATH
Modify access (M) : Rename the binary to bin.bak and copy the malicious binary to the original path bin.exe. PRIV PATH
Read and Execute access (RX): Can read and execute, nothing here.
Read-only acess (R): Only can read, nothing here.
Write-only acess (W): Only can write, same as (F), change the binary to the malicious one. PRIV PATH
Changing the original binary:
Check the configuration of the service to see how to restart the service.
Restart Manually
If you have sufficient permissions over the service restart it manually.
AUTO_START enabled
If AUTO_START flag is enabled restart the machine
DLL Hijacking
When we have permissions to overwrite the DLL or the DLL is missing we can create ours.
Msfvenom
A dll can also be created with msfvenom.
Manual DLL
The following C code is an example of our malicious dll.
Compiling the DLL
Modifying the service
Check service permissions with accesschk from sysinternals.
And finally modify it.
WSL (Windows Subsystem for Linux)
Windows Subsystem for Linux is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019.
Location:
Executing wsl.exe we can get a subsystem shell (Linux) or we can search the subsystem fileroot on the windows machine.
Inside the Linux filesystem as root, you can search for passwords or some other interesting things.
From Administrator to System
As it is known the maximum privilege account of windows systems is NT AUTHORITY\SYSTEM , so we need to spawn a shell with that account.
Once our user is already on Administrators group, we can check it with different forms:
There are different forms to spawn a system shell, but I will explain one, creating a service.
After starting our new service we will get the System shell on our handler:
Windows Scheduler
Similar to crontab, Windows Scheduler is a component of Microsoft Windows that provides the ability to schedule the launch of programs or scripts at pre-defined times.
If you found some of this running proceses tasklist, maybe you need to take a look:
So we will examinate the Events System Sheduler directory: C:\Program Files (x86)\SystemScheduler\Events
Find some logs files to see which program is scheduled, and replace the binary with yout malicious one.
Bypass UAC
User Account Control (UAC) is an access control system that forces applications and tasks to run in the context of a non-administrative account until an administrator authorizes elevated access.
Mandatory Levels
Exists three types of Mandatory Level:
Low Mandatory Level: Services like IE has no permissions, it can not write on any directory, but IE for example need to write cache on a directory. So with Low Mandatory Level we will only able to write data on the following path. C:\Users\Victim\AppData\LocalLow
Medium Mandatory Level: Permissions as a normal user.
High Mandatory Level: Permissions as NT AUTHORITY/SYSTEM.
UAC can be bypassed in various ways.
fodhelper.exe
fodhelper.exe is a Microsoft support application responsible for managing language changes in the operating system. This binary runs as high integrity on Windows 10.
With sigcheck.exe from SysInternals is posible to inspect the application manifest.
Note: Search for requestedExecutionLevel as requireAdministrator and autoElevate in true.
First we need to add some registries with REG:
Antivirus and Firewall
Antivirus
Check status:
Need NT AUTHORITY/SYSTEM rights if the UAC is enabled.
If it is not possible login via RDP with an Administrator user and disable it manually.
net start
wmic service list brief
sc query
Get-Service
C:\>icacls exacqVisionEsm
icacls exacqVisionEsm
exacqVisionEsm NT AUTHORITY\NETWORK SERVICE:(RX)
S-1-5-21-1861402468-3453913150-4246083462-1001:(RX)
BUILTIN\Administrators:(I)(OI)(CI)(F)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
BUILTIN\Users:(I)(OI)(CI)(RX)
NT AUTHORITY\Authenticated Users:(I)(M)
NT AUTHORITY\Authenticated Users:(I)(OI)(CI)(IO)(M)
WScheduler.exe
WService.exe
# Some other binary that starts with WS (WindowsScheduler)
whoami /all
GROUP INFORMATION
-----------------
Group Name Type SID Attributes
=================================== ================ ============ ==================================================
Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
BUILTIN\Remote Desktop Users Alias S-1-5-32-555 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
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
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\Low Mandatory Level Unknown SID type S-1-16-4096 Mandatory group, Enabled by default, Enabled group
sigcheck.exe -a -m C:\Windows\System32\fodhelper.exe