infosecfamily
← Back to catalog
TryHackMe  /  Medium  /  Linux

Nax

Tested by: Testing performed by Nikolay Kravtsov, a novice information security specialist at 22:32 *(I liked the room, but it seemed simple)*

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 4444 Reverse Shell listener -
10.10.252.141 80 Nagios Web Server +

Files used:

  • user.txt - flag.
  • root.txt - flag.
  • PI3T.Png - a picture with an encoded login and password.

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

  • kex --win && sudo openvpn 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 62:1d:d9:88:01:77:0a:52:bb:59:f9:da:c1:a6:e3:cd (RSA)
|   256 af:67:7d:24:e5:95:f4:44:72:d1:0c:39:8d:cc:21:15 (ECDSA)
|_  256 20:28:15:ef:13:c8:9f:b8:a7:0f:50:e6:2f:3b:1e:57 (ED25519)
25/tcp  open  smtp     Postfix smtpd
|_smtp-commands: ubuntu.localdomain, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=ubuntu
| Not valid before: 2020-03-23T23:42:04
|_Not valid after:  2030-03-21T23:42:04
80/tcp  open  http     Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).
389/tcp open  ldap     OpenLDAP 2.2.X - 2.3.X
443/tcp open  ssl/http Apache httpd 2.4.18 ((Ubuntu))
| tls-alpn:
|_  http/1.1
|_http-title: 400 Bad Request
| ssl-cert: Subject: commonName=192.168.85.153/organizationName=Nagios Enterprises/stateOrProvinceName=Minnesota/countryName=US
| Not valid before: 2020-03-24T00:14:58
|_Not valid after:  2030-03-22T00:14:58
|_ssl-date: TLS randomness does not represent time
|_http-server-header: Apache/2.4.18 (Ubuntu)
Service Info: Host:  ubuntu.localdomain; OS: Linux; CPE: cpe:/o:linux:linux_kernel

3) Launch Gobuster to search for directories.

  • Results:
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.252.141/
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              zip,swp,rar,asp,aspx,txt,gz,html,sql,js,tar.gz,,php
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.php                 (Status: 403) [Size: 278]
/.                    (Status: 200) [Size: 1332]
/.html                (Status: 403) [Size: 278]
/index.html           (Status: 200) [Size: 1332]
/index.php            (Status: 200) [Size: 2968]
/javascript           (Status: 301) [Size: 319] [--> http://10.10.252.141/javascript/]
Progress: 51592 / 3087854 (1.67%)^C
[!] Keyboard interrupt detected, terminating.
Progress: 51592 / 3087854 (1.67%)
===============================================================
Finished
===============================================================

4) Since gobuster didn’t find anything interesting, I went to look at the site itself:

  • Result:

    5) I noticed that mercury appeared twice in the list of elements, so I tried interpreting their atomic numbers as ASCII:

  • Result:

    6) We found some page. I went to it and tried to understand what kind of image it was:

  • Result:

    7) After a long search, I found that the image could be decoded with npiet. Let’s try it:

  • Result: Most likely this is your username and password.

    8) I looked where the default nagios admin page might be located, then I entered:

  • Result:

    9) In general, after googling for a long time what can be done with this version, I found CVE-2019-15949 and connected using MetaSploit:

  • Result:

    10) Read user.txt:

  • Result:

    11) Next, we need to escalate privileges, but running whoami shows that we are already root. We can simply read root.txt:

  • Result:

Note: Not the coolest room, but I liked it. Thanks TryHackMe for the room!

Vulnerabilities found

CVE-2019-15949

PoC:

(point 9)

CVSSv3 Score: 8.8 (HIGH)

Description:

Nagios XI up to version 5.6.6 allows you to run commands as root. The exploit requires access to the server from the nagios user or access from the admin user through the web interface. The getprofile.sh script, called when loading the system profile (profile.php?cmd=download), is executed as root through a passwordless sudo login; the script executes checkplugin, which belongs to the user nagios. A user logged into Nagios XI with rights to modify plugins, or a nagios user on the server, can modify the check executableplugin and insert malicious commands into it that will be executed as root.

Reproducing the vulnerability:

PoC compliant.

Remediation recommendations:

  • View how to fix the vulnerability www.nist.gov.
  • Update nagios to the latest version.

    Video walkthrough

  • Original:

  • YouTube