Schooled
Executive summary — Schooled is an entirely application-layer chain: an outdated Moodle 3.9 running on FreeBSD. Student self-registration, combined with a confirmation trick that needs no real email server, opens the door to a stored XSS (CVE-2020-25627) that steals a teacher's cookie; that session is escalated with CVE-2020-14321 (a teacher can self-assign the Manager role while enrolling users) all the way up to a system Manager, who redefines their own role to grab
site:configand install a plugin containing a webshell. From there, Moodle's own database credentials yield password hashes that, once cracked and reused over SSH, give the user shell; the final root is a FreeBSD classic: an unrestrictedsudo pkg installruns any package's post-install script as root, signed or not.
| Platform | Hack The Box |
| Operating system | FreeBSD 13.0 |
| Difficulty | Medium |
| Status | Retired |
| Target IP | 10.129.96.53 |
| Domain | schooled.htb · vhost moodle.schooled.htb |
| Starting point | No credentials (student self-registration on Moodle) |
Attack map
Student self-registration (confirmation embedded in /login/confirm.php, no real email)
│ student @student.schooled.htb
▼
Stored XSS in the "MoodleNet profile" field (CVE-2020-25627)
│ the teacher review bot visits the profile -> MoodleSession cookie stolen
│ (not HttpOnly)
▼
Teacher Manuel Phillips's session
│ CVE-2020-14321: enrol/manual/ajax.php with roletoassign=1 (Manager)
▼
COURSE-level Manager -> login as Lianne Carter (SYSTEM-level Manager)
│ redefine the Manager role -> grant moodle/site:config
▼
Install plugins -> block_rce (PHP webshell)
│ RCE as www
▼
config.php (DB creds) -> mdl_user hashes -> bcrypt cracked
│ jamie:!QAZ2wsx (reused) <- user.txt (SSH)
▼
[ROOT] sudo pkg install <local package with a malicious post-install script>
│ post-install runs as root -> SUID /bin/sh
▼
root.txt
1. Reconnaissance
sudo nmap -p- --min-rate 2000 -T4 -Pn 10.129.96.53 -oN nmap/allports.txt
sudo nmap -p 22,80,33060 -sCV -Pn 10.129.96.53 -oN nmap/services.txt
22/tcp OpenSSH 7.9 (FreeBSD)
80/tcp Apache 2.4.46 (FreeBSD) PHP/7.4.15 -> "Schooled - A new kind of educational institute"
33060/tcp MySQL X protocol
The site at schooled.htb is static; its teachers.html page lists the faculty — including Manuel Phillips (Mathematics) and Lianne Carter (Manager) — two names that reappear as key pieces of the attack. Enumerating vhosts turns up moodle.schooled.htb, serving a Moodle 3.9 instance (confirmed by lib/upgrade.txt).
echo '10.129.96.53 schooled.htb moodle.schooled.htb' | sudo tee -a /etc/hosts
Port 33060 (MySQL X Protocol) confirms Moodle's database lives on the same box and will be reachable later once there's RCE — worth noting now even though it's not reachable from outside yet.
Resumen ejecutivo — Schooled es una cadena íntegramente de aplicación: un Moodle 3.9 desactualizado en un FreeBSD. Un registro de estudiante con un truco de confirmación sin correo real abre la puerta a un XSS almacenado (CVE-2020-25627) que roba la cookie de un profesor; esa sesión se escala con CVE-2020-14321 (un profesor puede auto-asignarse el rol Manager al enrolar usuarios) hasta Manager de sistema, desde donde se redefine el propio rol para obtener
site:confige instalar un plugin con una webshell. Desde ahí, las credenciales de la base de datos de Moodle entregan hashes que, crackeados y reutilizados por SSH, dan el user; el root final es un clásico de FreeBSD:sudo pkg installsin restricciones ejecuta como root el script post-install de cualquier paquete, firmado o no.
| Plataforma | Hack The Box |
| Sistema operativo | FreeBSD 13.0 |
| Dificultad | Medium |
| Estado | Retired |
| IP objetivo | 10.129.96.53 |
| Dominio | schooled.htb · vhost moodle.schooled.htb |
| Punto de partida | Sin credenciales (auto-registro de estudiante en Moodle) |
Mapa del ataque
Auto-registro (confirmación embebida en /login/confirm.php, sin correo real)
│ estudiante @student.schooled.htb
▼
Stored XSS en el campo "MoodleNet profile" (CVE-2020-25627)
│ bot del profesor visita el perfil -> cookie MoodleSession robada
│ (sin HttpOnly)
▼
Sesión de Manuel Phillips (profesor del curso)
│ CVE-2020-14321: enrol/manual/ajax.php con roletoassign=1 (Manager)
▼
Manager de CURSO -> login as Lianne Carter (Manager de SISTEMA)
│ redefine rol Manager -> concede moodle/site:config
▼
Install plugins -> block_rce (webshell PHP)
│ RCE como www
▼
config.php (creds DB) -> hashes mdl_user -> bcrypt crackeado
│ NT/bcrypt jamie:!QAZ2wsx (reutilizado) <- user.txt (SSH)
▼
[ROOT] sudo pkg install <paquete local con post-install malicioso>
│ post-install corre como root -> /bin/sh SUID
▼
root.txt
1. Enumeración
sudo nmap -p- --min-rate 2000 -T4 -Pn 10.129.96.53 -oN nmap/allports.txt
sudo nmap -p 22,80,33060 -sCV -Pn 10.129.96.53 -oN nmap/services.txt
22/tcp OpenSSH 7.9 (FreeBSD)
80/tcp Apache 2.4.46 (FreeBSD) PHP/7.4.15 -> "Schooled - A new kind of educational institute"
33060/tcp MySQL X protocol
La web en schooled.htb es estática; su página teachers.html lista al profesorado — entre ellos Manuel Phillips (Matemáticas) y Lianne Carter (Manager) — dos nombres que reaparecerán como piezas clave del ataque. Enumerando vhosts aparece moodle.schooled.htb, que sirve una instancia de Moodle 3.9 (confirmado por lib/upgrade.txt).
echo '10.129.96.53 schooled.htb moodle.schooled.htb' | sudo tee -a /etc/hosts
El puerto 33060 (MySQL X Protocol) confirma que la base de datos de Moodle vive en la misma máquina y será accesible más adelante una vez haya RCE — merece la pena anotarlo ya, aunque de momento no sea alcanzable desde fuera.
Root Access unlocks the content you can't see — everything else on the site is already open.
See Root Access plansNo account? Create one free then upgrade from your console.
Root Access desbloquea el contenido que no puedes ver — todo lo demás de la web ya está abierto.
Ver planes de Root Access¿Sin cuenta? Crea una gratis y luego mejora desde tu consola.