My first TryHackMe room
How I scanned, explored, and got in for the first time in a beginner room, without spoiling the flags.
I finished my first TryHackMe room. No flags here.
Connect to the room
The room page has an Access section. Start the machine. Wait for the target IP to appear. Download the OpenVPN config. A VPN is a private tunnel between your computer and the TryHackMe network.
You need OpenVPN installed. If you use TryHackMe's AttackBox, you can skip the VPN and use the AttackBox terminal.
# Run this from the folder where you saved the config, or use the full path.
sudo openvpn --config ~/Downloads/your_config.ovpn
# In another terminal, check that the tunnel is up.
ip a show tun0
# Try to reach the target. If this fails, do not panic yet.
ping -c 3 10.10.10.10 # replace with the room's target IP
You are connected when tun0 shows an inet address. If the ping fails, the target may block ICMP, the protocol ping uses. Try the scan anyway.
Scan the target
A port is a numbered door on a machine. SSH is usually 22. HTTP is 80. HTTPS is 443. A scan checks which doors are open.
nmap is a program that scans ports. It is already on Kali. On other systems, install it with your package manager.
# -Pn: scan even if the host does not answer ping.
# Top 1000 TCP ports, service versions, default scripts, save the output.
nmap -Pn -sV -sC -oN nmap_initial.txt 10.10.10.10
Save the output. You will forget what was on port 8080 by the time you look at port 22.
I use -sV to see versions and -sC to run default scripts. -oN saves the output. If the first scan finds little, -p- scans all 65,535 ports.
# Scan every TCP port, then probe the ports that came back open.
nmap -Pn -p- --min-rate 1000 -oN nmap_allports.txt 10.10.10.10
nmap -Pn -sV -sC -p 22,80,8080 -oN nmap_deep.txt 10.10.10.10
Replace 22,80,8080 with the ports you actually found.
Explore what is running
A scan tells you which doors are open. It does not tell you what is behind them. That takes time.
I answer three questions before I try to break in:
- What program is running? Which version?
- What pages, folders, or files exist that are not linked on the front page?
- Does this version have a known bug?
For a web server on port 80, gobuster tries common folder names from a wordlist:
# Try common folder names.
gobuster dir -u http://10.10.10.10/ -w /usr/share/wordlists/dirb/common.txt -o gobuster.txt
# Also look for backup and source files.
gobuster dir -u http://10.10.10.10/ -w /usr/share/wordlists/dirb/common.txt -x php,txt,html,bak -o gobuster_files.txt
That wordlist is common on Kali. If it is missing, install dirb or point -w at any wordlist you have.
If the target runs SMB, the Windows file-sharing service, enum4linux is a good start:
enum4linux -a 10.10.10.10 | tee enum4linux.txt
tee shows the output and saves it at the same time.
Take notes. One file per target. Write down ports, versions, folders, passwords you tried, and dead ends. Five minutes of reading beats an hour of scanning again.
Get in
These are the rules I follow, even in a lab:
- I only run an exploit, a way to break in, if I can explain it in one sentence. If I cannot say why it works, I stop and read.
- I use public examples from known sources, not random forum posts.
- I read the code before I run it.
In a beginner Linux room, the way in is usually one of these:
- A known CVE, a public bug ID, in an old service.
- A weak or default password on an admin page.
- A file upload that does not check what it receives.
- Command injection, where a form passes input to the operating system.
Get root
You have a command line as a normal user. Now you want root, the admin account. On Linux, I check these:
- Run
idandwhoami. Note your groups. - Run
sudo -l. It shows what you can run as root, includingNOPASSWDentries. - Look for SUID programs:
find / -perm -4000 -type f 2>/dev/null - Check for scripts that cron or systemd run and that you can write to.
- Look at environment variables,
PATH, and~/.bashrc.
SUID means the program runs as its owner, often root. It is a common way to gain privileges.
When you find something, look it up on GTFOBins. Do not memorize the list. Learn what to search for.
On Windows, winPEAS is the usual script for finding weak spots. LOLBAS is different: it lists built-in Windows programs that can be abused.
What I learned
- Enumeration is the whole game. The target tells you how it wants to be attacked.
- Notes save you from repeating work.
- Hints are part of the room. Use them.
- The method matters more than the flag.
Next, I will do a few more beginner rooms with the same process. Then I will try intermediate rooms, plus some HackTheBox and PortSwigger Web Security Academy for variety.