Windows Privesc
Privilege Escalation usually involves going from a lower permission to a higher permission.
Last updated
Was this helpful?
Privilege Escalation usually involves going from a lower permission to a higher permission.
Last updated
Was this helpful?
There are some scripts that could help us in order to escalate privilege on Linux systems. These are two examples:
We can exploit some kernel vulnerabilities in order to privesc.
All Windows Server 2008 R2 without HOTFIXES are vulenrable to MS15 and MS16 (MS15-051)
Is a powershell script that we can run out of memory in order to find some vulnerabilities.
First we need to modify it and add the following line to the end of the script:
Once added, we just need to start http server and executed directly from powershell.
windows-exploit-suggester.py
or wesng
are amazing scripts that do this work.
Remember to update the database.
We just need to execute systeminfo
and save the output into a file on the windows target machine.
Once downloaded to our attacking machine we just need to execute the following command:
Sometimes we need to compile our exploits in order to get the binary or executable.
For 64-bits:
For 32-bits:
We can check the windows version by using winver
command (GUI needed).
Maybe it will fail due to missing some dependency, try the following:
Alert: SPACES are mandatory to the work of the exploit.
With the following command we can check the privileges that is assigned to the pwned user:
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.
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.
We are able to load a driver, so we can load a vulnerable driver, then exploit it.
To load the driver we need first to create a C++ Console APP on Visual Studio (Not Code!) and paste the following script.
Alert: Remove line: #include "stdafx.h"
Once compiled With Release x64 we need to download Capcom.sys driver. (https://github.com/FuzzySecurity/Capcom-Rootkit/blob/master/Driver/Capcom.sys)
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
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.
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 contains spaces or others separators like this example
, the service will try to access to the resource in the following order:C:\Program Files\First Folder\myexecutable.exe
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:
If these 2 registers are enabled (value is 0x1), any user can install .msi
** files as NT AUTHORITY\
SYSTEM
**
Note: I'd problems while exploiting it via WIN-RM. Try another way to get shell.
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:
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
When we have permissions to overwrite the DLL or the DLL is missing we can create ours.
A dll
can also be created with msfvenom
.
The following C code is an example of our malicious dll
.
Check service permissions with accesschk
from sysinternals.
And finally modify it.
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.
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:
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.
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.
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
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:
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.
Disable firewall by executing: