Mirai
Executive summary — Mirai is a themed Easy Linux box: the name evokes the Mirai botnet (2016), which infected hundreds of thousands of IoT devices by scanning the Internet for unchanged factory credentials. The target here is exactly that scenario in miniature: a Raspberry Pi running Pi-hole, reachable over SSH with
pi:raspberry, wherepihas unrestrictedsudo→ instant root. The real challenge comes after: the root flag isn't where it should be — you need basic forensics on a USB stick to recover a «deleted» file (spoiler: deleting on Linux doesn't destroy the data).
| Platform | Hack The Box |
| Operating system | Linux |
| Difficulty | Easy |
| Status | Retired |
| Target IP | 10.129.X.X |
Attack map
[22/53/80] Raspberry Pi + Pi-hole
│ default Raspberry Pi credentials (pi:raspberry) over SSH
▼
[SSH] pi (user.txt)
│ sudo -l → (ALL) NOPASSWD: ALL → sudo su
▼
[ROOT] but root.txt isn't in /root — it was «deleted» from a USB stick
│ lsblk → /dev/sdb (/media/usbstick)
▼
[FORENSICS] strings /dev/sdb | grep HTB (deleting ≠ wiping)
▼
[ROOT.TXT recovered]
1. Reconnaissance
As always, we start with a full port and version scan:
nmap -sC -sV -p- 10.129.X.X
22/tcp open ssh OpenSSH
53/tcp open domain dnsmasq (Pi-hole)
80/tcp open http lighttpd — Pi-hole admin panel
Key clue: port 53 running
dnsmasqplus a web panel on 80 that turns out to be Pi-hole (the DNS ad-blocker commonly installed on a home Raspberry Pi) is the device's fingerprint. And a hobbyist Raspberry Pi screams one word: default credentials.
Resumen ejecutivo — Mirai es un Linux Easy temático: el nombre evoca la botnet Mirai (2016), que infectó cientos de miles de dispositivos IoT escaneando Internet en busca de credenciales de fábrica sin cambiar. El objetivo aquí es exactamente ese escenario en miniatura: un Raspberry Pi con Pi-hole al que se entra por SSH con
pi:raspberry, y dondepitienesudosin restricciones → root inmediato. El verdadero reto llega después: la root flag no está donde debería — hay que tirar de forense básico sobre un USB para recuperar un archivo «borrado» (spoiler: borrar en Linux no destruye los datos).
| Plataforma | Hack The Box |
| Sistema operativo | Linux |
| Dificultad | Easy |
| Estado | Retired |
| IP objetivo | 10.129.X.X |
Mapa del ataque
[22/53/80] Raspberry Pi + Pi-hole
│ credenciales por defecto de Raspberry Pi (pi:raspberry) por SSH
▼
[SSH] pi (user.txt)
│ sudo -l → (ALL) NOPASSWD: ALL → sudo su
▼
[ROOT] pero root.txt no está en /root — «se borró» de un USB
│ lsblk → /dev/sdb (/media/usbstick)
▼
[FORENSE] strings /dev/sdb | grep HTB (borrar ≠ eliminar)
▼
[ROOT.TXT recuperada]
1. Reconocimiento
Como siempre, empezamos con un escaneo completo de puertos y versiones:
nmap -sC -sV -p- 10.129.X.X
22/tcp open ssh OpenSSH
53/tcp open domain dnsmasq (Pi-hole)
80/tcp open http lighttpd — panel de administración de Pi-hole
Pista clave: el puerto 53 con
dnsmasqy un panel web en el 80 que resulta ser Pi-hole (el bloqueador de anuncios DNS que suele instalarse en un Raspberry Pi doméstico) son la huella dactilar del dispositivo. Y un Raspberry Pi de andar por casa grita una palabra: credenciales por defecto.
2. Initial access — default credentials
Raspberry Pi OS (formerly «Raspbian») ships out of the box with the user pi and password raspberry. For years this pair came pre-configured without forcing a change on first boot, so countless hobbyist and home devices ended up exposed with it intact. We try it directly over SSH:
ssh pi@10.129.X.X
# password: raspberry
whoami
→ pi
Mirai's lesson, literally: the original malware didn't exploit any software flaw — it simply tried a list of ~60 default username:password pairs (routers, IP cameras, DVRs...) against any IP with Telnet open. Here we replicate the exact same pattern over SSH against a single, well-known credential pair.
3. Post-exploitation as pi
Once in, we confirm the user and locate the home directory before going for the flag:
id
ls
cd Desktop
ls
cat user.txt
The user flag sits in ~/Desktop/user.txt, with no extra enumeration required: the foothold and the user flag are the same move, courtesy of the default credentials.
4. Escalation to root
First thing on any Linux box: check the current user's sudo privileges.
sudo -l
User pi may run the following commands on raspberrypi:
(ALL) NOPASSWD: ALL
NOPASSWD: ALL means
pican run any command as root without being prompted for a password. Many hobbyist-oriented Raspberry Pi images ship this way for convenience (avoiding constant sudo prompts on a single-user device) — but combined with unchanged factory credentials, it's a perfect storm: anyone who guessespi:raspberryis root in a single hop.
Exploitation is trivial:
sudo su
whoami
→ root
5. The twist: root without a root flag
We're root, but going for the expected flag it isn't where it should be:
cd /root
ls
There's no lab bug here — this is the box's second, deliberate challenge. The flag isn't in a typical location; we need to enumerate beyond the usual
/root.
6. USB discovery
We check for extra mount points, common on devices with external storage (a Raspberry Pi running Pi-hole often has a USB stick attached, e.g. for log storage or extra disk space):
ls /media
usbstick
cd /media/usbstick
ls
damnit.txt
The file name alone hints something went wrong. We read it:
cat damnit.txt
"I accidentally deleted your files off the USB stick"
7. Forensics: deleting isn't wiping
Key concept: on Linux-style filesystems (ext4, FAT...), deleting a file doesn't erase its data from disk. All that happens is the directory entry gets removed (the name and the pointer to the data blocks), and that space is marked «free for reuse». As long as nothing new overwrites those physical blocks, the original content is still there, byte for byte, and can be read by going straight to the raw device instead of through the filesystem.
First we identify which block device the USB stick maps to:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 1 ... 0 disk /media/usbstick
8. Recovering the root flag
With /dev/sdb identified, we dump its raw content looking for readable text: strings scans the block device block by block, bypassing the filesystem and its «deletion» metadata entirely, so it finds any plaintext still physically present on disk, «deleted» or not.
strings /dev/sdb | grep HTB
Among the remnants of «deleted» data the root flag shows up, in the usual HTB format. Box solved. 🏴☠️
Key concept (recap): «the filesystem hides, the disk doesn't». A normal delete is a logical operation on metadata; to actually destroy data you need to physically overwrite the disk (
shred,wipe, or encrypt the volume from the start).
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Recon | Ports 53/80 | Pi-hole/dnsmasq fingerprint → identifies a Raspberry Pi | Guides the default-credential guess |
| Foothold | SSH · Raspberry Pi | Unchanged factory credentials (pi:raspberry) | Access as pi + user flag |
| PrivEsc | sudo | pi with NOPASSWD: ALL (factory convenience config) | Instant root |
| Recovery | USB / /dev/sdb | «Deleted» data is recoverable (deleting ≠ wiping at the filesystem level) | Root flag recovered via forensics |
Lessons learned
- ALWAYS change default credentials on any device (
pi:raspberryis the textbook example): that's literally how the Mirai botnet was built at global scale. - IoT and «casual» devices are a critical attack surface: one forgotten Raspberry Pi with factory credentials can be the entry point into an entire home or corporate network.
- Convenience ≠ security: a
NOPASSWD: ALLmeant to avoid annoying a personal device's single user becomes a trivial privilege escalation the moment someone else gets that account. - Deleting isn't wiping: to actually destroy data you must overwrite it (
shred), or better, encrypt the disk from first use so «deleted» data is useless without the key. - Basic forensics with
stringsagainst the raw device is a surprisingly powerful and simple data-recovery technique — useful both offensively and for incident investigation.
2. Acceso inicial — credenciales por defecto
Raspberry Pi OS (antes «Raspbian») trae de fábrica el usuario pi con contraseña raspberry. Durante años este par de credenciales venía preconfigurado y sin forzar su cambio en el primer arranque, así que muchísimos dispositivos domésticos y de aficionados quedaron expuestos con él intacto. Lo probamos directamente por SSH:
ssh pi@10.129.X.X
# contraseña: raspberry
whoami
→ pi
La lección de Mirai, literal: el malware original no explotaba ningún fallo de software — simplemente probaba una lista de ~60 pares usuario:contraseña de fábrica (routers, cámaras IP, DVRs...) contra cualquier IP con Telnet abierto. Aquí replicamos ese mismo patrón pero por SSH contra un único par de credenciales conocido.
3. Post-explotación como pi
Con la sesión abierta, confirmamos el usuario e identificamos el home antes de ir a por la flag:
id
ls
cd Desktop
ls
cat user.txt
La user flag se obtiene en ~/Desktop/user.txt, sin necesidad de ningún paso adicional de enumeración: el foothold y el user flag son el mismo movimiento gracias a las credenciales por defecto.
4. Escalada a root
Lo primero al entrar en cualquier caja Linux: comprobar los privilegios sudo del usuario actual.
sudo -l
User pi may run the following commands on raspberrypi:
(ALL) NOPASSWD: ALL
NOPASSWD: ALL significa que
pipuede ejecutar cualquier comando como root, sin que se le pida contraseña. En muchas imágenes de Raspberry Pi orientadas a hobbyistas esto viene así por comodidad (evitar pedir sudo constantemente en un dispositivo de un solo usuario) — pero combinado con credenciales de fábrica sin cambiar, es la tormenta perfecta: cualquiera que adivinepi:raspberryes root en un solo salto.
La explotación es trivial:
sudo su
whoami
→ root
5. El giro: root sin root flag
Ya somos root, pero al ir a por la flag esperada no aparece donde debería:
cd /root
ls
Aquí no hay ningún fallo del laboratorio: es el segundo reto de la máquina, deliberado. La flag no está en una ruta típica — toca enumerar más allá del
/rootde siempre.
6. Descubrimiento del USB
Revisamos puntos de montaje adicionales, algo habitual en dispositivos con almacenamiento externo (una Raspberry Pi con Pi-hole suele tener un USB conectado, por ejemplo para el almacenamiento de logs o un disco extra):
ls /media
usbstick
cd /media/usbstick
ls
damnit.txt
El nombre del archivo ya es una pista de que algo salió mal. Lo leemos:
cat damnit.txt
"I accidentally deleted your files off the USB stick"
7. Análisis forense: borrar no es eliminar
Concepto clave: en sistemas de ficheros tipo Linux (ext4, FAT...), borrar un archivo no borra sus datos del disco. Lo único que ocurre es que se elimina la entrada del directorio (el nombre y el puntero a los bloques de datos) y se marca ese espacio como «libre para reutilizar». Mientras nada nuevo sobrescriba esos bloques físicos, el contenido original sigue ahí, byte a byte, y puede leerse accediendo al dispositivo en crudo en lugar de al sistema de ficheros.
Primero identificamos qué dispositivo de bloque corresponde al USB:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
└─sda1 8:1 0 20G 0 part /
sdb 8:16 1 ... 0 disk /media/usbstick
8. Recuperación de la root flag
Con /dev/sdb identificado, volcamos su contenido crudo buscando cadenas de texto legibles: strings escanea el dispositivo bloque a bloque, sin pasar por el sistema de ficheros ni sus metadatos de «borrado», así que encuentra cualquier texto plano que quede físicamente en el disco, esté o no «borrado».
strings /dev/sdb | grep HTB
Entre los restos de datos «borrados» aparece la root flag, con el formato habitual de HTB. Máquina resuelta. 🏴☠️
Concepto clave (resumen): «el sistema de ficheros oculta, el disco no». Un borrado normal es una operación lógica sobre metadatos; para destruir datos de verdad hace falta sobrescribir físicamente el disco (
shred,wipe, o cifrado del volumen desde el principio).
Resumen de vulnerabilidades
| Fase | Componente | Vulnerabilidad | Impacto |
|---|---|---|---|
| Reconocimiento | Puertos 53/80 | Huella de Pi-hole/dnsmasq → identifica un Raspberry Pi | Guía la elección de credenciales por defecto |
| Foothold | SSH · Raspberry Pi | Credenciales de fábrica sin cambiar (pi:raspberry) | Acceso como pi + user flag |
| PrivEsc | sudo | pi con NOPASSWD: ALL (config. de comodidad de fábrica) | Root inmediato |
| Recuperación | USB / /dev/sdb | Datos «borrados» recuperables (borrar ≠ eliminar en el sistema de ficheros) | Root flag recuperada por forense |
Lecciones aprendidas
- Cambia SIEMPRE las credenciales por defecto de cualquier dispositivo (
pi:raspberryes el ejemplo de libro): así se construyó literalmente la botnet Mirai a escala global. - IoT y dispositivos «de andar por casa» son superficie crítica: un solo Raspberry Pi olvidado con credenciales de fábrica puede ser la puerta de entrada a toda una red doméstica o corporativa.
- Comodidad ≠ seguridad: un
NOPASSWD: ALLpensado para no fastidiar al usuario de un dispositivo personal es una escalada de privilegios trivial en cuanto alguien más accede a esa cuenta. - Borrar no es eliminar: para destruir datos de verdad hay que sobrescribirlos (
shred) o, mejor aún, cifrar el disco desde el primer uso para que los datos «borrados» sean inútiles sin la clave. - Forense básico con
stringssobre el dispositivo en crudo es una técnica de recuperación de datos sorprendentemente potente y sencilla — útil tanto para atacar como para investigar incidentes.