Internal is a hard 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. Furthemore it gives us
the instruction Ensure that you modify your hosts file to reflect internal.thm
We can do this by adding internal.thm to /etc/hosts
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.
From the scan we can see that the machine is running an ssh service on port 22 and an apache server on port 80.
We also find out that the server is running Ubuntu.
Let's visit the website on port 80 by visiting http://internal.thm
The default apache page. Maybe there is more to it. We can enumerate the directories on this server by
using gobuster:
After running the gobuster command we find several directories, one of which is a wordpress blog
After looking around on the site we discover a login form.
As this login form discloses wheter a username is taken or not we can very easily guess that the username admin is in use
But even if we would not have guessed the username we could have used wpscan to find available usernames
With this tool we also find that the wordpress theme is out of date or the XML-RPC seems to be enabled.
We note down our findings for later and move on with our wordpress login form.
With the username admin we can now bruteforce the password
Awesome! There is the password for the admin account. We now have the credentials for the wordpress login form.
Since we are now able to edit the pages on the blog, we can add a php reverse shell to the 404 page. We can find this page under
Appereance > Theme Editor > 404 Template
Let's use pentestmonkey's php reverse shell.
We can simply copy the code and paste it into the 404 template.
After that we just need to adapt the $ip and $port variables to our needs and save the template.
Now we start the netcat listener on our attacker machine.
After that we visit the 404 page with http://internal.thm/blog/wp-content/themes/twentyseventeen/404.php.
We have a reverse-shell! Let's upgrade this shell to a fully interactive shell by using python.
Now we background the process by pressing CTRL + Z, folled by this command on the host machine:
After our reverse shell is in the foreground againg we have to type
Now we have stabilized our shell. whoami shows us we are
www-data. Inspecting the home directories we find that there is another
user named aubreanna. Currently we do not have access to
this home directory.
To find a way in regardless we can try linpeas. Unfortunatly we do not find any credentials.
After some manual enumeration we find the file /opt/wp-save.txt
That's the credentials for aubreanna. Let's use them to login via ssh.
With this we can answer our first question about the user flag
User.txt Flag
User.txt FlagClick to reveal
As we connected we saw an interesting interface docker0.
We make a note of this an continue with our enumeration.
Running sudo -l shows that we can run nothing as sudo.
Maybe we find a SUID bit we can exploit by running find / -perm -u=s -type f 2>/dev/null.
Also nothing.
Looking at the files in aubreanna's home directory again we can find another interesting file
There is an jenkins server running with a ip adress differing from the
one of the target machine
With ifconfig we can verify this. We can also see that this
IP Adress belongs to the docker interface we saw earlier when connecting.
Then the Jenkins Server must be hosted in a docker container on this machine.
To connect to it we will use a ssh tunnel technique. From your attacker machine run the following command:
Now when we type http://localhost:8080/ in our browser we should see a jenkins login form
First trying some default credentials for jenkins, but unfortunatly we find no default login that works.
With hydra we can try to brute force a password.
First we need to capture a login post package so that we know how a login looks like.
For this we can use burp suite. We need to open a browser proxied
through burp suite and set intercept to on. Then we visit the login page
and enter some credentials. After that we can see the package captured
in burp suite.
Now we can use this package to brute force the password with hydra
There is our admin password. We can now login to jenkins and see the dashboard
Now that we are logged in to jenkins as admin, let's try to place a reverse shell there.
Under Manage Jenkins > Tools and Actions > Script Console we can create our script.
After a bit of research we find a reverse shell script that we can use.
But before running the script we should no forget to start our netcat listener by running nc -lvnp 4444.
Now let's run the script in the jenkins console.
Success! We now have a reverse shell to the jenkins docker container
With /bin/bash -i we should upgrade our shell to a bash shell. Now let's see whether we can escalate our privileges.
Since in our previous machine we found the user password in the
/opt directory, let's see if we can find something similar here.
Indeed, there is a note.txt file stored there containing the root password.
With this we can ssh in our original machine and get the root flag
With this we can answer our last question
Root.txt Flag
Root.txt FlagClick to reveal
Conclusion
The Internal room on TryHackMe is a fun room to practice penetration
testing. It covers a wide range of topics from web application
vulnerabilities to docker container security. The room is a good
challenge and requiring us not to only rely on automated tools. Thanks
to TheMayor for creating this room and TryHackMe for giving us free
access. And of course, thanks to you for reading this write-up. I hope
you liked it, and see you in the next one.
Relevant is a challenging room on TryHackMe that puts you in the role of a penetration tester, tasked with conducting a penetration test and delivering a detailed report.