---
description: https://www.hackthebox.eu/home/machines/profile/2
---

# Legacy

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-308f9b5a8ddedc6a7285d5d490460fb23f0fb7d3%2Fimage.png?alt=media)

## Scanning & Enumeration

### Nmap

Starting off with a quick all port SYN scan we see we have SMB and RDP open.

```
nmap 10.10.10.4 -p- -sS -T4 -v

PORT     STATE  SERVICE
139/tcp  open   netbios-ssn
445/tcp  open   microsoft-ds
3389/tcp closed ms-wbt-server
```

We run a service version scan with `-sV` on the open ports. I slowed down the probe speed to `-T3` as we are dealing with so few ports. From the results this looks like the machine is Windows XP.

```
nmap 10.10.10.4 -p 139,445,3389 -T3 -sS -sV

PORT     STATE  SERVICE       VERSION
139/tcp  open   netbios-ssn   Microsoft Windows netbios-ssn
445/tcp  open   microsoft-ds  Microsoft Windows XP microsoft-ds
3389/tcp closed ms-wbt-server

Service Info: OSs: Windows, Windows XP; CPE: cpe:/o:microsoft:windows, cpe:/o:microsoft:windows_xp
```

We can confirm our results using the `--script smb-os-discovery` script.

```
nmap 10.10.10.4 --script smb-os-discovery

Host script results:
| smb-os-discovery: 
|   OS: Windows XP (Windows 2000 LAN Manager)
|   OS CPE: cpe:/o:microsoft:windows_xp::-
|   Computer name: legacy
|   NetBIOS computer name: LEGACY\x00
|   Workgroup: HTB\x00
|_  System time: 2020-11-20T00:45:42+02:00
```

Since we have SMB open and is likely the attack vector lets check the exact version before researching exploits.

```
nmap --script smb-protocols 10.10.10.4 -Pn

Host script results:
| smb-protocols: 
|   dialects: 
|_    NT LM 0.12 (SMBv1) [dangerous, but default]
```

We can take the information we now have and use Google to search for any relevant exploits.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-bb1898f55769e3871ea9f6609504f91de34c1d20%2Fimage.png?alt=media)

As you can see we have a few potential exploits in which we could try. Also looking at the related searches at the bottom of the page will give us results from other peoples searches which I find is a great way to find relevant information.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-1b79695f7791937e5a90e8bd933f4e943492751c%2Fimage.png?alt=media)

MS08-067 is of interest.

## Exploitation

### MS08-067

We can start `metasploit` with `msfconsole` command and search for MS08-067 to see if we have any modules for it.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-2f3399e29a202197d825ef53ac6fcc31d31de317%2Fimage.png?alt=media)

We have a module and select it with `use 0`. Once selected we can use `show options` command to show what options we need to set.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-25dc6cc545d4fe685fcee93c0b1200976bb71788%2Fimage.png?alt=media)

* RHOSTS - Remote host IP
* LHOST - Attacking machine IP (You can set the interface name instead)
* LPORT - Local port to use. Select any port you like. The default 4444 is usually good enough.

We can then execute the exploit with the `run` command.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-506fea8059192249099e285064c770f636a4465b%2Fimage.png?alt=media)

Once connected we can get the session GUID to confirm completed. From here we can drop into a system shell using the `shell` command.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-6a02a91d75f6add7f5814f6451694a3946cd7c60%2Fimage.png?alt=media)

Once in we can check if we can access the Administrator Desktop and can view the root.txt flag. We can also browse the Documents and Settings folder for the other user on the system to grab the user.txt flag from the desktop.

### MS17-010

When we was looking for exploits earlier we come across a fair few mentions for MS17\_010.

{% embed url="https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2017/ms17-010" %}

Under the first paragraph we see the follow mentioned.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-ba5d7087133cd041389659532a4295fe7839f724%2Fimage.png?alt=media)

As we are running SMBv1 as discovered by `nmap` earlier using the `smb-protocols` script. Lets look further into this.

Again we start `msfconsole` and search for MS17\_10. We can start with using the auxiliary scanner first to determine if the host is vulnerable.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-827f0296d35331a7d36d796bbca736113b541a84%2Fimage.png?alt=media)

We can also use the show info command on the auxiliary scanner module to see more information regarding what this checks for and references for further reading.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-fad7f30305232fed8b73c1efd1755e501fcbebde%2Fimage.png?alt=media)

We can also check if the host is vulnerable to this exploit using `nmap`.

```
nmap -Pn --script smb-vuln-ms17-010 -p 445 10.10.10.4

PORT    STATE SERVICE
445/tcp open  microsoft-ds

Host script results:
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).
|           
|     Disclosure date: 2017-03-14
|     References:
|       https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
|       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143
```

As we have determined the host is likely vulnerable we can now attempt to exploit it. From our search results I am going to use the module "exploit/windows/smb/ms17\_010\_psexec". We set the relevant options again and run the exploit.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-2a4329ed22e4ac36bcfecfb5910c975bed82f4d4%2Fimage.png?alt=media)
