If you are new to TryHackMe, I recommend checking out their Tutorial room to see how the platform works and how you can access the target machine(s). I also highly recommend using your own “attack box”, be it a Kali, Parrot, or some other pentesting oriented Linux distro (in the form of a VM), as opposed to the browser based solution TryHackMe provides. I’ve found that the browser based VM is a lot slower, though others seem to have no issues with it. The only thing using your own attack VM entails is connecting it to THM’s network through VPN, but this is incredibly easy as TryHackMe will supply you with your own OpenVPN configuration file and is outlined below.
Types of Challenges
The TryHackMe platform has multiple types of challenges, each potentially having its own requirements for accessing and completing it. You can identify the type of challenge by looking at the icon on the right-hand side of the collapsible bar for that particular challenge:
Challenges using the “server rack” icon include the use of a deployable machine, and are the most common. Pressing the “Start Machine” button will launch a virtual machine that you have two ways of accessing: using THM’s “attack box”, found at the top of your browser window:
Or, you can instead opt to use your own virtual machine connected to the THM network, which is done (on Linux) by clicking your user icon, “Access”, and then “Download My Configuration File”.
Clicking “Save File”
And by running the following command in a terminal (I might suggest you move the download to another folder, such as “Documents”):
Once you see “Initialization Sequence Completed”, you’ll know you’ve successfully connected to THM’s network. Keep this terminal window open (you can minimize it, however). Return to it and press “Ctrl” + “C” twice once you are ready to disconnect.
After you’ve chosen between THM’s attack box or your own virtual machine, you’ll need the IP address of the target machine, which is what was deployed earlier with the green “Start Machine” button. That information can be seen in a banner at the top of your browser window, or in more detail at the top of the page:
In many cases you’ll be copying that IP address into your attack box/VM’s browser’s address bar, but in other cases you might be accessing it through SSH, RDP, etc. You’ll notice that you can add time to it if needed, or terminate it if you finish early – opening up more resources for other THM users.
Challenges using the “browser” icon will require interaction with a simulated website that can be accessed by pressing the “View Site” seen after expanding the challenge. These challenges will need to be completed from within your browser, and cannot be accessed through a VPN on your own machine due to the fact that they are not true websites.
Challenges with the “download” icon include files – in many cases packet captures (pcaps) or log files to be parsed through using a specific type of software. Where you would like to do this examining is up to you, but you will not be able to use one of TryHackMe’s machines. For examining something like a .pcap file, you will want to install Wireshark on one of your own computers or VMs.
Challenges without an icon focus on either reading material and answering questions, or will include a link to a publicly accessible website that doesn’t require connection to THM’s network, and therefore can be completed from any computer you choose.
Note: Bold and underlined words/phrases pertain specifically to the challenge questions
TryHackMe; Advent of Cyber 3; Day 11
Day 11 covers some of the basics of SQL, how to interact with a SQL database using sqsh, and using xp_cmdshell to interact with the database’s host OS.
We’ll begin this challenge by running Nmap against the target IP. Be sure to include the “-Pn” switch to treat the host as “up”, considering it is a Windows host and will not respond to ICMP. This will tell us the port number associated with SQL on this machine, which in this case is using the default port.
Next, connect to the database using the following command:
sqsh -S <target IP> -U sa -P t7uLKzddQzVjVFJp
This command uses the built-in “sa” (System Administrator) account to authenticate, using the THM supplied password of ” t7uLKzddQzVjVFJp”. After connecting successfully, we will know which prompt we have received.
In order to find the first name of the reindeer of id 9, we can query all columns from the “names” table in the “reindeer” database using the command pictured below.
Querying the “schedule” table in a similar fashion will reveal the destination of the trip scheduled on December 7.
With larger tables, such as in a production environment, using the “*” selector will return far too many records for practical use. We can use a more efficient query to find only the information we need for the fifth question, finding the quantity available for the present “Power Bank”.
Let’s test whether or not “xp_cmdshell” has been enabled on this SQL Server instance. Run “xp_cmdshell” and pass it ‘whoami’ to see if an error is thrown.
Now that we know xp_cmdshell is enabled, we can pass it Windows commands to discover files on the local FS. Using “dir” commands on the “grinch” account’s directories, we find a “flag.txt” within C:\Users\grinch\Documents.
xp_cmdshell 'dir c:\Users\grinch\Documents';
Using the “type” command (Windows equivalent of ‘cat’), we can print the contents of flag.txt to our terminal.