TryHackMe / Medium / Linux
CTF Collection Vol. 2
Tested by:
Testing performed by Nikolay Kravtsov, a novice information security specialist at 00:00 *(cool room, sniffing out everything possible, I liked it)*
Testing scope and services used.
| IP/domain | Port | Service | Target Server Service |
|---|---|---|---|
| localhost | 5901 | WinKexServer | - |
| localhost | - | Nmap Port Scanner | - |
| localhost | - | DirBuster Directory Scanner | - |
| localhost | - | Obsidian Notes | - |
| localhost | - | hashcat hash cracker | - |
| 10.10.215.34 | 80 | nginx Web Server | + |
Files used:
- sqlmap.py- a tool for quick analysis of SQL databases using sql injection.
Procedure
1) Launch openvpn for access; kex to make Linux more convenient
kex --win && sudo openvpn lab_Kolya080808.ovpn2) Scanning ports using nmap.
Results:
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 1024 1b:c2:b6:2d:fb:32:cc:11:68:61:ab:31:5b:45:5c:f4 (DSA)
| 2048 8d:88:65:9d:31:ff:b4:62:f9:28:f2:7d:42:07:89:58 (RSA)
|_ 256 40:2e:b0:ed:2a:5a:9d:83:6a:6e:59:31:db:09:4c:cb (ECDSA)
80/tcp open http Apache httpd 2.2.22 ((Ubuntu))
| http-robots.txt: 1 disallowed entry
|_/VlNCcElFSWdTQ0JKSUVZZ1dTQm5JR1VnYVNCQ0lGUWdTU0JFSUVrZ1p5QldJR2tnUWlCNklFa2dSaUJuSUdjZ1RTQjVJRUlnVHlCSklFY2dkeUJuSUZjZ1V5QkJJSG9nU1NCRklHOGdaeUJpSUVNZ1FpQnJJRWtnUlNCWklHY2dUeUJUSUVJZ2NDQkpJRVlnYXlCbklGY2dReUJDSUU4Z1NTQkhJSGNnUFElM0QlM0Q=
|_http-server-header: Apache/2.2.22 (Ubuntu)
|_http-title: 360 No Scope!
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
3) Run dirsearch to search for directories.
- Results:
┌──(kolya080808㉿Nikolapc)-[~]
└─$ dirsearch -w directory-list-2.3-medium.txt -u http://10.10.131.134
/usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import DistributionNotFound, VersionConflict
_|. _ _ _ _ _ _|_ v0.4.3
(_||| _) (/_(_|| (_| )
Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: 25 | Wordlist size: 220545
Output File: /home/kolya080808/reports/http_10.10.131.134/_24-12-04_21-18-41.txt
Target: http://10.10.131.134/
[21:18:41] Starting:
[21:18:43] 301 - 245B - /login -> http://10.10.131.134/login/
[21:18:47] 200 - 38KB - /button
[21:18:48] 200 - 61KB - /cat
[21:18:48] 200 - 689B - /small
[21:18:49] 200 - 248KB - /static
[21:18:52] 200 - 341B - /robots
[21:19:03] 200 - 4MB - /who
[21:19:16] 200 - 19KB - /iphone
[21:19:53] 301 - 244B - /game1 -> http://10.10.131.134/game1/
[21:19:56] 200 - 25KB - /egg
[21:20:29] 200 - 1MB - /dinner
[21:21:03] 200 - 194KB - /ty
CTRL+C detected: Pausing threads, please wait...
[q]uit / [c]ontinue: q
[s]ave / [q]uit without saving: q
Canceled by the user
4) Firstly, from nmap, we immediately found a hint.
Result:
however, we don’t need this now.5) Next, I started analyzing the pages, and from robots.txt we found the flag:
Result:

6) And now we need that hint:
Actions:
F12- Result:

7) Then look at the /login page:
- Result:
8) DISCLAIMER
Tip:
There are a lot of flags here, so I won't announce them, just write walkthrough further.
9) Now the most interesting and lengthy part. Time Based Sql.
- Actions:

Result: we got a flag and a username with a password.
10) Cracking the hash:
Result:

11) We get the flag:
Result:

12) Now we are asked to look in Header:
Result:

13) Now cookies. This is the most interesting part, working with burp:
Result: Initially, the cookie was equal to 0. We change it to 1:

14) Now we were told some bullshit in the hint. But we know that this is the user-agent! Let's look:
Actions:
Replace the highlighted value with the one from the hint:Result:

15) Now they tell us about the redirect. I looked at all possible pages and found this:
Result:

16) On the very next page after the redirect we receive a flag for Easter 13:
Result:

17) Now I found the page /free_sub. From the hint we learn that we need to use Referer: tryhackme.com:
Result:

18) The next hint asks us to tamper with the HTML. Let’s take a look:
Result:

19) Now we are told fake js file. Let's look at the site's JavaScript files:
Result:
Let's run the function:

20) Now we are told embed image code. Well, we just get it and decode it in CyberChef:
Result:

21) So, then something incomprehensible: “Try guest the alphabet and the hash code.” We go to /game1 and try to find:
Result:

22) Then the logical solution would be to check if /game2 exists:
Result:
Press the buttons simultaneously:

23) In this case, you just need to stupidly decode:
Result:

24) So, now we need to figure out what “Request header. Format is egg: Yes” means:

25) Now you need to go to the /small page:
Result:

26) And lastly, they finally tell us what needs to be done:
Result:

Note:
This room is cool, it’s a real thrill to have fun, look for Easter eggs.
In general, I advise beginners to take it! In fact, sniffing out all the possible information on a website is also an art!
Vulnerabilities found
SQL Injection
PoC:
(point 9)
CVSSv3 Score: 7.9 (Critical)
Description:
In this case, sql injection is associated with the input. The /login page allows you to access the database without any special knowledge.
Reproducing the vulnerability:

Remediation recommendations:
Look at owasp website how it happens and how can this be prevented.
Video walkthrough