TryHackMe | Anthem Box

This box will be a little different, due to it being a Windows box. Now, given that like 98% of business infrastructure runs on Windows, I’m starting to think it’s due time for me to start branching out. I’ve got a couple more write ups coming soon, they are just very very long, so I haven’t gotten around to creating them yet.

But for this box, let’s start off with a little nmap scan.

So, we’ve got a lot of ports open. I’m going to look into the importance of each of these ports real quick, just for review:

  • Port 80 – HTTP: The port that the server expects to receive data from a web client. It can be configured differently, but this is the default.
  • Port 135 – MSRPC: This is a modified version of DCE/RPC. Stands for “Microsoft Remote Procedure Call”. It is a protocol that uses the client-server model in order to allow one program to request service from a program on another computer without having to understand the details of that computer’s network.
  • Port 139 – NetBIOS-SSN: Stands for “NETBIOS Session Service”. TCP NetBIOS connections are made over this port, usually by Windows machines, but can also be any other system running Samba (SMB). These sessions support “connection oriented file sharing activities”.
  • Port 445 – Microsoft-DS: This port is usually used for file sharing, with something like Samba. It stands for “Microsoft Directory Services”. It is the preferred port for carrying Windows file sharing and “numerous other services”.
  • Port 3389 – MS-WBT-Server: So, from the port number, we can already guess that this is an RDP instance. Also known as “msrdp” or “Microsoft Remote Display Protocol”, it sets up a terminal server that can be remoted into.

Let’s take a crack at the website first.

So, there wasn’t anything important on the main page, and robots.txt is always a great place to check when crawling directories. So if you’re feeling lazy and don’t want to start up and configure dirbuster, just add that “/robots.txt” to the end of the URL and see if it pulls up anything important. In our case it did, multiple directories to check out, and a potential password.

This just shows what the site’s URL is supposed to be. It answers one of the questions for the box.

Another question was to find out the name of the SysAdmin, which I considered this one a bit dumb, just because the whole concept of this question is flawed. You need to Google this poem that this employee wrote about the sysadmin, and it gives you the author of the original poem, which is what the sysadmin’s name is. Why this bears any relevance, how anyone was actually supposed to connect those dots, I’ll never know. I’m just glad I didn’t do the foot work on this bit of the box (haha).

^Name of the sysadmin^

This was to identify how the company creates its emails. So we have a first and last name, and we have an example email. Now we can create the sysadmin’s email, and it looks like we have his password from the robots.txt file too.

The challenge here was to just find three (maybe four? I don’t remember exactly) flags that were hidden in/on the site. Most of them were in the source code, so I just went to each page, opened the source code, and ctrl+f’d for “THM{“, which is the standard format for TryHackMe flags.

I didn’t spend too much time looking, but I feel like there should be a tool to crawl a specific website and all the links/pages it has on it and be able to look for certain parameters with the source code. I couldn’t find a tool like that, but maybe I should make one as a challenge. Could use Python + Beautiful Soup or something.

Final flag for this section was on a profile page.

I also broke into the website manager using the email and password for the sysadmin. Didn’t find anything, but it was fun to try.

So RDPing into the box works using the sysadmin and the password that we found. So now we just have to root around a bit (hehe…get it?), and then escalate our privilege to full admin to find the final text file.

First text file found just sitting on the desktop.

Interesting folders that were hidden. If going back through this box, you’ll want to check on those.

So, all we really had to do was add ourselves as owners to a hidden file, so that we now have full control.

Opening the file provides us with the administrator’s password.

Now, let’s log out, and attempt to login as admin.

And we’re in! The final flag was sitting on the desktop as well. Great box to get your feet wet with Windows and RDP, but I’m definitely looking forward to more!

TryHackMe | Bounty Hunter Box

TryHackMe has a box called “Bounty Hunter” which was a ton of fun, and definitely an experience. Let’s dive right into it.

I started off with a regular old nmap scan of the IP. It showed that there were three ports open, and so that means three potential points of entry. Now, before we start testing everything, we’d usually try to grab the versions of the software running on this ports, to make sure there is no blatantly obvious vulnerability. SSH ended up being up to date, so we’ll follow my normal approach for this type of situation. Which is immediately looking into FTP.

The most common thing that occurs for these beginner level boxes is that the FTP login is left to be anonymous. You don’t even usually NEED to use metasploit to scan it, you can just attempt to FTP in and if user: anonymous and password: anonymous doesn’t work, then it’s not anonymous login haha. Let’s go ahead and login to the FTP server.

Annnnd, success! Just like I thought. Time to poke around a bit.

So there are two files in here, locks.txt and task.txt. Let’s download and open them up.

Cool, so this looks like a password list. It’ll come in handy later, so store it somewhere safe. No, there’s one bit I missed documenting here, but I’ll do my best to explain it.

On our scan, port 80 was open, which is http. This means they are most likely running a website. Which also means there could be extra directories, code to audit, etc. Through exploring that site, I found the name “lin”. This appeared to be a username of some sorts. So we had a username, and now we have a list of passwords. There’s one service that has yet to be useful to us; SSH. So, it’s gotta be the login to that. Power up Hydra and let’s get to brute forcing.

Start her up!

Nice! Glad to know that worked out in our favor. Let’s see what we can get to through SSH.

So our goals for this challenge were to get user.txt and root.txt. We’ve got user.txt, so now we need to get root on the box, and that means a little bit of privilege escalation.

This shows that the user we are logged in as (lin) can run the following commands as root: /bin/tar. This means we need to head over our favorite site (https://gtfobins.github.io/) to see how we can escape to root using this command.

Looks like it worked, and the box is now fully completed!

Thanks for reading!

Analysis of Commands Used in TryHackMe’s “Kenobi” box

This is more just notes for me than anything, but here we go:

So this is an nmap scan being used to enumerate for SMB shares. Let’s dissect it.

  • “-p 445” means it is only scanning the specified port, AKA port 445
  • “–script=” there are a bunch of different scripts, directories, script-categories, and more in here
  • “smb-enum-shares.nse” and “smb-enum-users.nse” are scripts developed for nmap to do what their names describe; they enumerate smb shares and users of the smb shares. More info on at least one of these scripts can be found here.

The rest of this (nmap, machine_ip) is pretty self-explanatory.

Here are some of the SMB commands. Luckily, “smbclient” is a pretty simple one. It is similar to how an ftp connection works through the command line, and just connects to an SMB instance on a certain machine’s IP.

“smbget -r” downloads files from a share. The “r” is for resume, which means it automatically resumes aborted files.

So, here’s another nmap scan:

  • “nfs-ls,nfs-statfs,nfs-showmount” these can be looked at online @ nmap’s official site, the main one we are concerned with is here.

This shows NFS exports, and is what we are mainly after. The others gather the extra info that we rely on as well, but this question on the box’s page surrounds the mount that we can see.

The next question I need to answer for myself is: what is netcat?

Well, netcat is a utility that lets you read and write from connections using TCP or UDP. It has been described as a “networking swiss army knife” and can do a ton of different things. It would definitely be out of my depth to currently attempt to put into words all the things it can do, but it does look very useful.

Searchsploit is a command line search tool that checks Exploit-Db. This is useful because it lets you take an offline version of their database with you wherever you go, and is easily accessed from the command line. It can show exploits and shellcode useful for all manner of things.

Here “proftpd” is the service we are looking for exploits for, and “version” is where we will put the version number, like “1.3.5”.

Now we’ll take a look at two more commands. “SITE CPFR” specifies the file you want to copy, while “SITE CPTO” specifies where you want to copy it to.

“Mkdir” creates a directory. “mount” mounts a drive/directory. This can be used to mount an smb share. “mount machine_ip:/var /mnt/kenobiNFS” mounts this machines /var to our newly created directory. “ls -la” then displays the contents of a directory with a lot of extra info for each file, like the size in bytes, last time of modification, etc. The “a” of “la” lists all entries in the directory, including the entries that begin with a period.

  • “find” takes a path to find things, searches for the parameters you feed it.
  • “/” means find will look through every file on the system.
  • “-perm” means you are looking for a file based on permissions. Which is where this next bit comes in.
  • “-u=s” u stands for user, and the s means “set user or group ID on execution”.
  • “-type f” means that it will only look for files. So type is specifying what type of things it is looking for, and f is specifying files.
  • “2>/dev/null” is apparently a fancy way of redirecting stderr to a black hole. This means it discards the output of the command.

Now, I’m going to attempt to walk myself through this. It might be right, it might be wrong.

So since we cannot run usr/bin/sh the way we want to, we copied its contents, and created a new file named curl with the same content. Now, just running curl wouldn’t work because we still need the correct permissions inside and out. We moved it into the way of /usr/bin/menu, a file that we CAN run, and so that when menu gets run, it hits our curl, which in turn gives us the access we need. This is because it has now fully run our shell (curl) as root.

Hopefully that was a semi-correct explanation. Cool stuff though, I’m looking forwards to doing more of these!