Windows PrivEsc
Room Link: https://tryhackme.com/r/room/windows10privesc
Generate a Reverse Shell Executable
On Kali, generate a reverse shell executable (reverse.exe) using msfvenom. Update the LHOST IP address accordingly:
Kali
Transfer the reverse.exe file to the C:\PrivEsc directory on Windows. There are many ways you could do this, however the simplest is to start an SMB server on Kali in the same directory as the file, and then use the standard Windows copy command to transfer the file.
On Kali, in the same directory as reverse.exe:
Kali
On Windows (update the IP address with your Kali IP):
Victim
Victim
Test the reverse shell by setting up a netcat listener on Kali:
Kali
Then run the reverse.exe executable on Windows and catch the shell:
Victim
The reverse.exe executable will be used in many of the tasks in this room, so don't delete it!
Service Exploits - Insecure Service Permissions
Use accesschk.exe to check the "user" account's permissions on the "daclsvc" service:
Victim
Note that the "user" account has the permission to change the service config (SERVICE_CHANGE_CONFIG).
Query the service and note that it runs with SYSTEM privileges (SERVICE_START_NAME):
Victim
Modify the service config and set the BINARY_PATH_NAME (binpath) to the reverse.exe executable you created:
Victim
Start a listener on Kali and then start the service to spawn a reverse shell running with SYSTEM privileges:
Kali
Victim
Service Exploits - Unquoted Service Path
Query the "unquotedsvc" service and note that it runs with SYSTEM privileges (SERVICE_START_NAME) and that the BINARY_PATH_NAME is unquoted and contains spaces.
VICTIM
Using accesschk.exe, note that the BUILTIN\Users group is allowed to write to the C:\Program Files\Unquoted Path Service\ directory:
Victim
Copy the reverse.exe executable you created to this directory and rename it Common.exe:
Victim
Start a listener on Kali and then start the service to spawn a reverse shell running with SYSTEM privileges:
Kali
Victim
Service Exploits - Weak Registry Permissions
Query the "regsvc" service and note that it runs with SYSTEM privileges (SERVICE_START_NAME).
Victim
Using accesschk.exe, note that the registry entry for the regsvc service is writable by the "NT AUTHORITY\INTERACTIVE" group (essentially all logged-on users):
Victim
Overwrite the ImagePath registry key to point to the reverse.exe executable you created:
Victim
Start a listener on Kali and then start the service to spawn a reverse shell running with SYSTEM privileges:
Kali
Victim
Service Exploits - Insecure Service Executables
Query the "filepermsvc" service and note that it runs with SYSTEM privileges (SERVICE_START_NAME).
Victim
Using accesschk.exe, note that the service binary (BINARY_PATH_NAME) file is writable by everyone:
Victim
Copy the reverse.exe executable you created and replace the filepermservice.exe with it:
Victim
Start a listener on Kali and then start the service to spawn a reverse shell running with SYSTEM privileges:
Kali
Victim
Registry - AutoRuns
Query the registry for AutoRun executables:
Victim
Using accesschk.exe, note that one of the AutoRun executables is writable by everyone:
Victim
Copy the reverse.exe executable you created and overwrite the AutoRun executable with it:
Victim
Start a listener on Kali and then restart the Windows VM. Open up a new RDP session to trigger a reverse shell running with admin privileges. You should not have to authenticate to trigger it, however if the payload does not fire, log in as an admin (admin/password123) to trigger it. Note that in a real world engagement, you would have to wait for an administrator to log in themselves!
Kali
Kali
Registry - AlwaysInstallElevated
Query the registry for AlwaysInstallElevated keys:
Victim
Note that both keys are set to 1 (0x1).
On Kali, generate a reverse shell Windows Installer (reverse.msi) using msfvenom. Update the LHOST IP address accordingly: Kali
Transfer the reverse.msi file to the C:\PrivEsc directory on Windows (use the SMB server method from earlier).
Kali
Victim
Start a listener on Kali and then run the installer to trigger a reverse shell running with SYSTEM privileges:
Kali
Victim
Passwords - Registry
(For some reason sometimes the password does not get stored in the registry. If this is the case, use the following as the answer: password123)
The registry can be searched for keys and values that contain the word "password":
Victim
If you want to save some time, query this specific key to find admin AutoLogon credentials:
Victim
On Kali, use the winexe command to spawn a command prompt running with the admin privileges (update the password with the one you found):
Kali
Passwords - Saved Creds
List any saved credentials:
Victim
Note that credentials for the "admin" user are saved. If they aren't, run the C:\PrivEsc\savecred.bat script to refresh the saved credentials.
Start a listener on Kali and run the reverse.exe executable using runas with the admin user's saved credentials:
Kali
Victim
Passwords - Security Account Manager (SAM)
The SAM and SYSTEM files can be used to extract user password hashes. This VM has insecurely stored backups of the SAM and SYSTEM files in the C:\Windows\Repair\ directory.
Transfer the SAM and SYSTEM files to your Kali VM:
Kali
Victim
On Kali, clone the creddump7 repository (the one on Kali is outdated and will not dump hashes correctly for Windows 10!) and use it to dump out the hashes from the SAM and SYSTEM files:
Kali
Crack the admin NTLM hash using hashcat:
Kali
You can use the cracked password to log in as the admin using winexe or RDP.
Passwords - Passing the Hash
Why crack a password hash when you can authenticate using the hash?
Use the full admin hash with pth-winexe to spawn a shell running as admin without needing to crack their password. Remember the full hash includes both the LM and NTLM hash, separated by a colon:
Scheduled Tasks
View the contents of the C:\DevTools\CleanUp.ps1 script:
Victim
The script seems to be running as SYSTEM every minute. Using accesschk.exe, note that you have the ability to write to this file:
Victim
Start a listener on Kali and then append a line to the C:\DevTools\CleanUp.ps1 which runs the reverse.exe executable you created:
Kali
Victim
Wait for the Scheduled Task to run, which should trigger the reverse shell as SYSTEM.
Insecure GUI Apps
Start an RDP session as the "user" account:
Victim
Double-click the "AdminPaint" shortcut on your Desktop. Once it is running, open a command prompt and note that Paint is running with admin privileges:
Victim
In Paint, click "File" and then "Open". In the open file dialog box, click in the navigation input and paste: file://c:/windows/system32/cmd.exe
Press Enter to spawn a command prompt running with admin privileges.
Startup Apps
Using accesschk.exe, note that the BUILTIN\Users group can write files to the StartUp directory:
Victim
Using cscript, run the C:\PrivEsc\CreateShortcut.vbs script which should create a new shortcut to your reverse.exe executable in the StartUp directory:
Victim
Start a listener on Kali, and then simulate an admin logon using RDP and the credentials you previously extracted:
Kali
Victim
A shell running as admin should connect back to your listener.
Token Impersonation - Rogue Potato
Set up a socat redirector on Kali, forwarding Kali port 135 to port 9999 on Windows:
Kali
Start a listener on Kali. Simulate getting a service account shell by logging into RDP as the admin user, starting an elevated command prompt (right-click -> run as administrator) and using PSExec64.exe to trigger the reverse.exe executable you created with the permissions of the "local service" account:
Victim
Start another listener on Kali.
Kali
Now, in the "local service" reverse shell you triggered, run the RoguePotato exploit to trigger a second reverse shell running with SYSTEM privileges (update the IP address with your Kali IP accordingly):
Victim
Token Impersonation - PrintSpoofer
Start a listener on Kali. Simulate getting a service account shell by logging into RDP as the admin user, starting an elevated command prompt (right-click -> run as administrator) and using PSExec64.exe to trigger the reverse.exe executable you created with the permissions of the "local service" account:
Kali
Victim
Start another listener on Kali.
Kali
Now, in the "local service" reverse shell you triggered, run the PrintSpoofer exploit to trigger a second reverse shell running with SYSTEM privileges (update the IP address with your Kali IP accordingly):
Victim
Last updated