Relevant is a medium room on try hack me which lets you slip in the role
of a penetration tester which has the job to conduct a penetration test
Pre-Engagement Briefing
The first task is to read the pre-engagement briefing which gives you
the scope of the penetration test. The briefing includes the virtual
machine, the scope of the test, the instruction to find and report all
vulnerabilities and as a proof of exploitation, to secure the two flags
User.txt and Root.txt.
Scanning
We will begin with an nmap scan:
This command will scan all ports on the remote machine and will run
default scripts and enumerate versions of services.
While the scan runs we try to find a website on the remote machine and
indeed on port 80 the default IIS page is running.
Let's try to find some directories on the website. We can use gobuster for this.
Unfortunatly nothing. In the meanwhile our nmap scan finished. Let's look at the results:
From the nmap scan result we find that several ports are open including
80 - IIS Server
135 - RPC
139 - NetBios
445 - SMB
3389 - RDP
49663 - IIS Server
Since we already enumerated the IIS server on port 80 we can next try to enumerate the SMB server on port 445.
We can use smbclient for this.
This command will list all shares on the SMB server. As we do not know any password we can simply confirm an emtpy password by pressing Enter
This gives us following output:
We find that a non-standard share nt4wrksv is enabled.
Since we are tasked to find all vulnerabilities we could at this stage
now scan the SMB share for vulnerabilities, for example using nmap with
the scripts smb-vuln-ms*. But first let's try to connect to the share nt4wrksv without
credentials by calling smb client with the share name and accepting an
empty password by pressing Enter
This command will connect to the share nt4wrksv on the SMB server.
With ls we find the file passwords.txt and with get passwords.txt
we download the file to our local machine.
On investigation of the passwords.txt file on our local machine we find that it contains two base64 encoded strings.
We can decode these strings with base64 on our local machine.
This gives us the passwords for the users Bob and Bill:
But trying them in RDP or using them in the smbclient it seems that the credentials are invalid.
Let's get back to our previous idea scanning this smb instance for vulnerabilities with nmap:
This command will run nmap with the scripts vuln on the ports 80, 135, 139, 445, 3389
We find that the smb server is vulnerable to the ms17-010
exploit due to CVE-2017-0143.
On Exploit-DB we
learn that there is an exploit with metasploit. But since the room
descriptions explicitly states that
Nothing in this room requires Metasploit, we take note
the vulnerability and move on.
Since we also have ports yet to investigate we pick another one. Port
49663 looks interesting since it seems to be another IIS
Server. On the website we also find just another default IIS page.
As we did with the webserver on port 80 we can try to find directories with gobuster.
We find that this webserver has a directory nt4wrksv which
looks quite similar to the smb share we found earlier. When going to
this directory we just get a blank page. Let's try to find the file
passwords.txt here.
We open http://REMOTE_IP:49663/nt4wrksv/passwords.txt in the browser and indeed, we find the same file as on the smb share.
So if we could upload a reverse shell in aspx since this is a IIS server
we could get a foothold on this machine. Let's try first by testing if
we can upload a file to smb and view it in the browser.
Now we can try to view the file in the browser by navigating to http://REMOTE_IP:49663/nt4wrksv/test.txt.
This works, so we can upload files to the IIS server. Let's try to upload a reverse shell.
Great, so let's create a reverse shell. We can use msfvenom
for this. We will use the payload
windows/x64/shell_reverse_tcp. We can list all options with
We will set the LHOST to our IP and the LPORT as a good practice to a common port.
With put shell.aspx we can upload the file when we are connected to the smb share.
With msfconsole we start a listener and navigate to http://REMOTE_IP:49663/nt4wrksv/shell.aspx to get a reverse shell.
Great! Now to our initial recon. Looking at the files on the desktop we find the user flag:
This is the answer to our first question:
User Flag
User FlagClick to reveal
Since we now gained access to the User Flag, let's attempt to escalate our privileges to gain access to the root flag.
With getprivs we can show our current privileges.
After a bit of research we find that SeImpersonatePrivilege can be used to escalate our privileges.
We will use the PrintSpoofer Github Repository to exploit this privilege.
First we must download the executable by calling:
Now we can upload it to the smb share:
Switch back to meterpreter and start a shell:
Now we can run the PrintSpoofer executable from the inetpub to escalate our privileges:
Perfect! Now we can read the root flag:
Which is the answer to our last question:
Root Flag
Root FlagClick to reveal
Conclusion
This free medium room was a great experience to practice enumeration and privilege escalation.
In offering a variety of services and supporting different approaches to gain access to the machine it was a great learning experience.
Thanks to TheMayor for creating this room and thanks to TryHackMe for giving access to this room for free.
And thanks to you of course for reading this write-up.
The Internal room on TryHackMe is an hard challenge that let's you slip in the role of a penetration tester, where your objective is to perform a thorough penetration test