Windows Privilege Escalation
Windows Privilege Escalation
Harvesting Passwords from Usual Spots
Unattended Windows Installations
Unattended installations use an admin account to do initial setup, might end up being stored in the machine in these locations:
C:\Unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\system32\sysprep.inf
C:\\Windows\system32\sysprep\sysprep.xml
As part of these files you might find credentials
Unattended Windows Installations
Unattended installations use an admin account to do initial setup, might end up being stored in the machine in these locations:
C:\Unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\system32\sysprep.inf
C:\\Windows\system32\sysprep\sysprep.xml
As part of these files you might find credentials
PowerShell History
If a user runs a command that includes a password it can be retrieved by using the following command"
Saved Windows Credentials
Windows allows the use of other users' credentials. The command below lists saved credentials
IIS Configuration
IIS config is stored in a file called
web.config
and can store passwords for databases or authentication mechanisms.File can be found here:
C:\inetpub\wwwroot\web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config
Quick way to find database strings on the file:
Retrieve Credentials from PuTTY
PuTTY doesn't allow users to store their SSH password, but it will store proxy configurations that include cleartext authentication credentials
Command to retrieve stored proxy credentials
Scheduled Tasks
Look for scheduled tasks that either lost its binary or are using a binary you can modify
AlwaysInstallElevated
Windows installer files usually run with the privilege level of the user that starts it.
These can be configured to run with higher privileges from any user account, this could allow us to generate a malicious MSI file that would run with admin privileges
This method requires two registry values to be set. You can query these from the command line using the commands below
Abusing Service Misconfigurations
Windows Services
Service Control Manager (SCM) is a process in charge of managing the state of services as needed
Insecure Permissions on Service Executable
If executable associated with a service has weak permissions that allows us to modify or replace it, we can gain privileges of the service's account
Unquoted Service Paths
Particular behavior happens when the service is configured to point to an "unquoted" executable. This means the path of the associated executable isn't properly quoted to account for spaces on the command
When the SCM tries to execute the associated binary, a problem arises. Since there are spaces on the name of the "Disk Sorter Enterprise" folder, the command becomes ambiguous, and the SCM doesn't know which of the following you are trying to execute:
This has to do with how the command prompt parses a command. Usually, when you send a command, spaces are used as argument separators unless they are part of a quoted string. This means the "right" interpretation of the unquoted command would be to execute
C:\\MyPrograms\\Disk.exe
and take the rest as arguments.Instead of failing as it probably should, SCM tries to help the user and starts searching for each of the binaries in the order shown in the table:
First, search for
C:\\MyPrograms\\Disk.exe
. If it exists, the service will run this executable.If the latter doesn't exist, it will then search for
C:\\MyPrograms\\Disk Sorter.exe
. If it exists, the service will run this executable.If the latter doesn't exist, it will then search for
C:\\MyPrograms\\Disk Sorter Enterprise\\bin\\disksrs.exe
. This option is expected to succeed and will typically be run in a default installation.
Insecure Service Permissions
If the service DACL lets you modify the configuration then you can reconfigure the service
This will let you point to any executable you need and run it with any account you prefer, including SYSTEM itself
Insecure Service Permissions
If the service DACL (not the service's executable DACL) lets you modify the configuration of a service, then you can reconfigure the service
This let's you point to any executable and run it with the account you prefer.
Abusing Dangerous Privileges
Windows Privileges
A complete list of available privileges on Windows systems is available here.
You can find a comprehensive list of exploitable privileges on the Priv2Admin Github project.
SeBackup / SeRestore
Allows users to read and write to any file in the system, ignoring any DACL in place
Allows certain users to perform backups from a system without needing full admin privileges
We can escalate privileges by copying the SAM and SYSTEM registry hives to extract local Admin's password hash
Technique: Copy SAM and SYSTEM registry hives to extract the local Admin's password hash
SeTakeOwnership
Allows users to take ownership of any object on the system, including files and registry keys
Opens up possibilities for an attacker to elevate privileges. For example, search for a service running as SYSTEM and take over the service's executable
SeImpersonate / SeAssignPrimaryToken
Allow a process to impersonate other users and act on their behalf
Usually consists of being able to spawn a process or thread under the security context of another user
As attackers if we can take control of a process with SeImpersonate or SeAssignPrimaryToken privileges, we can impersonate any user connecting and authenticating to that process
The LOCAL SERVICE and NETWORK SERVICE ACCOUNTS already have such privileges
Things we need to elevate privileges
To spawn a process so that users can connect and authenticate to it for impersonation to occur
Find a way to force privileged users to connect and authenticate to the spawned malicious process
Abusing vulnerable software
Unpatched Software
Use the
wmic
tool to list software installed on the target system and its versions
Search for existing exploits on installed software online
Tools of the Trade
Script developed to enumerate the target system to uncover privilege escalation paths
PowerShell script that searches common privilege escalation on the target system
To run PrivescCheck on target system, you might need to bypass the execution policy restrictions using
Set-ExecutionPolicy Bypass -Scope process -Force
Avoids making unnecessary noise that can attract attention because it runs on your attacking machine
Before using it, type
wes.py --update
command to update the databaseTo use the script run
systeminfo
command on the target systemDirect the output to a .txt file you will need to move to your attacking machine
Last updated