infosecfamily
← Back to catalog
TryHackMe  /  Medium  /  Linux

CMesS

Tested by: Testing performed by Nikolay Kravtsov and Arseny, novice information security specialists at 21:14 *(the room is broken... recorded for the first time with a microphone)*

Testing scope and services used.

IP/domain Port Service Target Server Service
localhost 5901 WinKexServer -
localhost - Nmap Port Scanner -
localhost - GoBuster Directory Scanner -
localhost - Obsidian Notes -
localhost 8000 Python HTTP Simple Server -
localhost - john the ripper hash cracker -
localhost 80 Python HTTP Simple Server -
localhost 1234 NetCat listener for Reverse Shell (user) -
localhost 1337 NetCat listener for Reverse Shell (root) -
10.10.215.34 80 nginx Web Server +

Files used:

  • linpeas.sh - Privilege Escalation Awesome Scripts SUITE new generation.
  • hash.txt - the file containing the hash to crack.
  • root.sh - a privilege escalation script.
  • php.php - easy simple php web shell, with which we got Reverse Shell.
  • user.txt - flag.
  • root.txt - flag.

    Procedure

1) Launch openvpn for access; kex to make Linux more convenient

  • kex --win && sudo openvpn lab_Kolya080808.ovpn

    2) Scanning ports using nmap.

  • Results:

PORT   STATE SERVICE VERSION              
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)                          
| ssh-hostkey:
|   2048 d9:b6:52:d3:93:9a:38:50:b4:23:3b:fd:21:0c:05:1f (RSA)
|   256 21:c3:6e:31:8b:85:22:8a:6d:72:86:8f:ae:64:66:2b (ECDSA)
|_  256 5b:b9:75:78:05:d7:ec:43:30:96:17:ff:c6:a8:6c:ed (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))        
|_http-generator: Gila CMS
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
| http-robots.txt: 3 disallowed entries
|_/src/ /themes/ /lib/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

3) Run dirsearch to search for directories.

  • Results:
┌──(kolya080808㉿Nikolapc)-[~]
└─$ dirsearch -e extensions.txt -w directory-list-2.3-medium.txt -u http://cmess.thm
/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: extensions.txt | HTTP method: GET | Threads: 25 | Wordlist size: 220545

Output File: /home/kolya080808/reports/http_cmess.thm/_24-11-27_19-14-34.txt

Target: http://cmess.thm/

[19:14:34] Starting:                                                                                                                                                                                                                       
[19:14:35] 200 -    1KB - /about
[19:14:35] 200 -    1KB - /index
[19:14:35] 200 -    1KB - /blog
[19:14:36] 200 -    2KB - /01
[19:14:36] 200 -    2KB - /1
[19:14:36] 200 -  693B  - /login
[19:14:36] 200 -    1KB - /category
[19:14:36] 200 -    1KB - /0
[19:14:36] 301 -  318B  - /themes  ->  http://cmess.thm/themes/?url=themes  
[19:14:36] 200 -  389B  - /feed
[19:14:38] 200 -  693B  - /admin
[19:14:38] 301 -  318B  - /assets  ->  http://cmess.thm/assets/?url=assets
[19:14:39] 200 -    1KB - /search
[19:14:39] 200 -    1KB - /tag
[19:14:39] 200 -    1KB - /author
[19:14:39] 200 -    1KB - /Search
[19:14:39] 301 -  316B  - /sites  ->  http://cmess.thm/sites/?url=sites
[19:14:40] 200 -    1KB - /About
[19:14:40] 301 -  312B  - /log  ->  http://cmess.thm/log/?url=log
[19:14:40] 200 -    1KB - /Index
[19:14:40] 200 -    1KB - /tags
[19:14:40] 200 -    2KB - /1x1
[19:14:40] 301 -  312B  - /lib  ->  http://cmess.thm/lib/?url=lib
[19:14:40] 301 -  312B  - /src  ->  http://cmess.thm/src/?url=src
[19:14:42] 200 -    0B  - /api
[19:14:46] 200 -    2KB - /001
[19:14:47] 500 -    0B  - /cm
[19:14:52] 200 -    2KB - /1pix
[19:14:53] 200 -    0B  - /fm
[19:14:53] 301 -  312B  - /tmp  ->  http://cmess.thm/tmp/?url=tmp
[19:14:55] 200 -    2KB - /1a
[19:14:59] 200 -    2KB - /0001
[19:15:01] 200 -    2KB - /1x1transparent
[19:15:03] 200 -    1KB - /INDEX
[19:15:04] 200 -    2KB - /1px
[19:15:11] 200 -    2KB - /1d
[19:15:13] 200 -    2KB - /1_1
CTRL+C detected: Pausing threads, please wait...             
Task Completed                                                 

4) After looking at the site, I came to a dead end on the /admin page

  • Result:

    5) What to enter there is not written anywhere. I assumed that you need to look for subdomains:

  • Result:

    6) Add it to /etc/hosts/ and look at the subdomain:

  • Result:

    7) Go to the admin panel and look around:

  • Result: Hooray! We can load the reverse shell)

    8) Upload a PHP web shell and use it to obtain a reverse shell:

  • 9) Read the config:

  • Result:

    10) Go to the database and look at the password:

  • Result:

11) Using John The Ripper, crack andre’s password:

  • Result:

    12) I think we need to look somewhere else. And I found:

  • Result:

    13) Change the user, read User.txt and look at the interesting directory:

  • Result:

    14) Let's see what's in it:

  • Result:

    15) I think that a backup of this folder is created every few minutes. Then, let's try to do something:

  • Result:

    16) We get the second revshell:

  • Result:

    17) Read root.txt

  • Result:

Note: This room is pretty broken, so if you pass through, you will most likely have to constantly restart the reverse shell or something else Still, the room feels realistic: it recreates the sort of poor system administration that makes a machine vulnerable. Thanks to TryHackMe for a great machine!

Vulnerabilities found

Information Disclosure

PoC:

(point 6)

CVSSv3 Score: 8.9 (Critical)

Description:

Information Disclosure in this case is related to the access of all users to the dev.cmess.thm subdomain, where development logs are located. The new password for user andre is also located there.

Reproducing the vulnerability:

(point 5) (point 6)

Remediation recommendations:

  • Restrict user access to the dev.* subdomain.
  • Store logs and passwords in another place that is inaccessible to other developers.
  • Do not add user passwords to the site.

    Insecure Temporary File Handling

PoC:

(point 16)

CVSSv3 Score: 10.0 (Critical)

Description:

During the analysis of the system, it was revealed that every two minutes a file of the format is saved in the /tmp directory .tar.gz, containing the contents of the user's home folder. This led to sensitive data leakage and Privilege Escalation on the system.

Reproducing the vulnerability:

(point 15) (point 16)

Remediation recommendations:

  • Use secure backup locations.
  • Encrypt files before saving them.
  • Configure access rights to these files.
  • Do you even need permanent archiving...?

    Video walkthrough

  • YouTube