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.
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 |
Defender's view
Mirai has no vulnerable software at all: everything is a default left in place. That makes it easy to fix, and surprisingly easy to see.
Factory credentials over SSH
How it shows up in logs / telemetry
auth.logshowsAccepted password for pifrom an address outside the home network; on an Internet-facing Pi it is usually preceded by manyFailed passwordlines forpi,rootandadmin, the same pattern the Mirai botnet produced against Telnet.- Tools such as fail2ban or a simple SIEM rule on failed-then-successful logins for well-known default users turn this into an alert.
How to fix it
- Change the default password on first boot (current Raspberry Pi OS images force you to create a user instead of shipping
pi:raspberry). - Use SSH keys, disable password authentication, and never expose SSH on IoT devices directly to the Internet.
NOPASSWD: ALL for the default user
How it shows up in logs / telemetry
- Every
sudoinvocation is logged with its full command line;sudo suorsudo -ifrompiright after a remote login is worth flagging.
How to fix it
- Remove the
NOPASSWDrule (or the whole sudoers drop-in forpi) so that sudo requires the user's password. - Better still, create a named admin account and lock or delete the default one.
"Deleted" files on removable media
How it shows up in logs / telemetry
- Raw reads of a block device (
/dev/sdb) by an interactive root shell are unusual on an appliance; auditd rules on block-device access can record them.
How to fix it
- Wipe data properly (
shredor overwriting the free space) before trusting it is gone. - Encrypt removable storage from first use, so recovered blocks are useless without the key.
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.