313 words
2 minutes
Basic Pentesting Writeup - TryHackMe

Getting Started#

This machine is designed to help you practice web application exploitation and Linux privilege escalation. After deploying the machine, you’ll be provided with a vulnerable machine IP. This is a grey-box assessment; the only information provided is the company name and the server’s IP.

Start by pinging the deployed machine or use an Nmap host discovery scan to ensure it’s up.

ping

Use the following Nmap scan to enumerate services:

nmap_scan

Scan reveals 7 open ports:

nmap_result


Web Enumeration#

Visit port 80, and you’ll see:

port_80

Inspect the page source and find a comment:

comment

Run directory busting on port 80 to find hidden files:

directory_busting

Discovered files: dev.txt and j.txt

page_development

dev.txt content:

dev.txt

j.txt gives a hint that J uses a weak password:

j.txt

Q1: What is the name of the hidden directory on the web server (enter name without /)? Ans: development


SMB Enumeration#

List available shares using smbclient:

LIST_SHAREFOLDER

Connect to the anonymous share and download staff.txt:

Anonymous folder

staff.txt reveals J’s username: jan

staff.txt

Q2: What is the username? Ans: jan


Brute Forcing SSH Login#

Use Hydra to brute force Jan’s SSH password:

Terminal window
hydra -l jan -P rockyou.txt ssh://<MACHINE_IP> -I -F -V

Successful login found:

result hydra

Q3: What is the password? Ans: armando

SSH into the machine as Jan, check /etc/passwd to find another user: kay

password_file

Q4: What service do you use to access the server? (abbreviation, all caps) Ans: SSH Q5: What is the name of the other user you found? (all lowercase) Ans: kay


Privilege Escalation#

In Kay’s home directory, there’s a file pass.bk, but no read permission:

pass.bak

List hidden files. We see .ssh, which may contain Kay’s private key:

ls

id_rsa (Kay’s private key) is found:

id_rsa

Save the key, convert it for John:

output.txt

Use John to brute-force the passphrase:

john_bruteforce

Login as Kay using the cracked private key and passphrase. You now have access to pass.bk:

pass.bk

Q6: What is the final password you obtain? Ans: heresareallystrongpasswordthatfollowsthepasswordpolicy$$


  • Brute-forced private key passphrases
  • Gained root through SSH and file analysis

Nice work reaching the end!


Let me know if you’d like this exported to Markdown or formatted for a specific platform (e.g., Medium, Dev.to, GitHub Pages).

Basic Pentesting Writeup - TryHackMe
https://blog.hanzalaghayasabbasi.com/posts/basic-pentesting/
Author
Hanzala Ghayas Abbasi
Published at
2023-09-16
License
CC BY-NC-SA 4.0