Sitemap
A1iw4r3

A1iw4r3

Learn2secure

RED-TryHackMe

4 min readFeb 29, 2024

--

Press enter or click to view image in full size

Note: I completed this machine in different chunks of time. That’s why the IP of the victim machine is different.

Nmap Scan

Two open ports were found. SSH opened at port 22 had 8.2, I simply ignored it because it was one of the latest versions of SSH. Next one was port 80 on which http is running. That means I had to get initial access through the web.

Press enter or click to view image in full size

When I ran scripts of nmap, I found an interesting thing which was LFI.

Press enter or click to view image in full size

I ran 10.10.194.228/index.php?page=file:///etc/passwd and found content of /etc/passwd file.

Press enter or click to view image in full size

Here two users found i.e red and blue.

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

I tried to open .ssh, bash_history. Fortunately, the bash_history directory gave me some text. I found a hashcat command running having a rule for creating different passwords from one password.

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

I opened the .reminder file and found a password.

Press enter or click to view image in full size

I tried this password to login blue and red users through this password found in .reminder file but couldn’t.

I used the below command to create passwords using the rules of hashcat as shown below.

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

After that I bruteforce the ssh using this password list for a user named blue and found the password.

Press enter or click to view image in full size

I logged in and got the first flag.

THM{Is_thAt_all_y0u_can_d0_blU3?}

Get A1iw4r3’s stories in your inbox

Join Medium for free to get updates from this writer.

Now I tried to get the red user but could not succeeded.

After some minutes shell got closed, I thought there were a script running behind which closed the session of blue user and change password which I got through brute forcing the SSH.

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

I again brute forced the SSH through hydra to get a new password.

Press enter or click to view image in full size

After getting new session, I check the /etc/crontab for cronjob but couldn’t find any user defined script running.

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

I copied the pspy file to the victim machine to check the script running on it. Surprisingly I found a amazing thing that was bash reverse shell script running in background which was transferring shelling to redrules.thm.

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

I tried to send my machine with hostname “redrules.thm” into the /etc/hosts and succeeded.

Press enter or click to view image in full size

I switched on the listening of netcat at port 9001 which was mentioned in bash reverse shell and got red user shell.

2nd flag is given below

THM{Y0u_won’t_mak3_IT_furTH3r_th@n_th1S}

After getting the second flag, I started privilege escalation, I looked the .git directory. I got into it and found pkexec file with suid.

I found the pkexec exploit at given github link, I just changed the path of pkexec at the end of the exploit.

https://github.com/Almorabea/pkexec-exploit/blob/main/CVE-2021-4034.py

Change the path

After transferring the exploit to the victim machine, I ran this exploit and got the root user shell.

Third flag is given below.

THM{Go0d_Gam3_Blu3_GG}

--

--