hacktricks/network-services-pentesting/pentesting-web/put-method-webdav.md

12 KiB
Raw Blame History

WebDav


使用Trickest可以轻松构建和自动化由全球最先进的社区工具提供支持的工作流程。
立即获取访问权限:

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

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

一个启用了WebDav的HTTP服务器可能允许你更新、删除、移动、复制文件。有时候你需要有有效的凭证通常使用HTTP基本身份验证进行检查

你应该尝试上传一些webshell并从Web服务器上执行它,以控制服务器。
通常,要连接到WebDav服务器你需要有效的凭证WebDav暴力破解 (基本身份验证)

另一种常见的配置是禁止上传由Web服务器执行的文件扩展名,你应该检查如何绕过此限制

  • 上传具有可执行扩展名的文件(也许不被禁止)。
  • 上传没有可执行扩展名的文件(如.txt并尝试使用可执行扩展名重命名(移动)文件。
  • 上传没有可执行扩展名的文件(如.txt并尝试使用可执行扩展名复制文件。

DavTest

Davtest尝试使用不同的扩展名上传多个文件检查扩展名是否被执行

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

输出示例:

这并不意味着 .txt.html 扩展名被执行。这意味着你可以通过网络 访问这些文件

Cadaver

你可以使用这个工具来 连接到 WebDav 服务器并 手动执行 操作(如 上传移动删除)。

cadaver <IP>

PUT请求

The PUT method is used to update or create a resource on a server. It is commonly used in web development to upload files or modify existing resources. When performing a PUT request, the client sends the entire representation of the resource to the server, replacing the existing resource if it already exists.

PUT请求用于在服务器上更新或创建资源。它通常用于Web开发中上传文件或修改现有资源。在执行PUT请求时客户端将整个资源的表示发送到服务器如果资源已经存在则替换现有资源。

WebDAV and PUT

WebDAV (Web Distributed Authoring and Versioning) is an extension of the HTTP protocol that allows for more advanced file management operations. It includes support for the PUT method, among others.

WebDAVWeb分布式作者和版本控制是HTTP协议的扩展允许进行更高级的文件管理操作。它包括对PUT方法的支持以及其他方法。

PUT Method and Web Application Security

From a security perspective, the PUT method can introduce vulnerabilities if not properly implemented. For example, if the server does not validate the input or restrict the file types that can be uploaded, it may be possible for an attacker to upload malicious files or overwrite existing files.

从安全角度来看如果没有正确实现PUT方法可能会引入漏洞。例如如果服务器不验证输入或限制可以上传的文件类型攻击者可能会上传恶意文件或覆盖现有文件。

Testing for PUT Method Vulnerabilities

During a web application penetration test, it is important to test for vulnerabilities related to the PUT method. This can include checking for unrestricted file uploads, improper input validation, and insecure file permissions.

在Web应用程序渗透测试期间重要的是测试与PUT方法相关的漏洞。这可以包括检查无限制的文件上传、不正确的输入验证和不安全的文件权限。

Conclusion

The PUT method is a powerful tool for updating or creating resources on a server. However, it can also introduce security vulnerabilities if not implemented correctly. It is important to thoroughly test for vulnerabilities related to the PUT method during a web application penetration test.

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

MOVE 请求

The MOVE request is used in WebDAV to move a resource from one location to another. It is similar to the HTTP PUT method, but instead of creating a new resource, it moves an existing resource to a new location.

MOVE 请求在 WebDAV 中用于将资源从一个位置移动到另一个位置。它类似于 HTTP PUT 方法,但不是创建新资源,而是将现有资源移动到新位置。

Syntax

The syntax of the MOVE request is as follows:

MOVE /source-resource HTTP/1.1
Host: example.com
Destination: /destination-resource

Example

Here is an example of a MOVE request:

MOVE /file.txt HTTP/1.1
Host: example.com
Destination: /new-folder/file.txt

In this example, the file.txt resource is moved from the root directory to the new-folder directory.

Response

The server responds to the MOVE request with a status code indicating the success or failure of the operation. If the move is successful, the server will return a 201 Created status code. If the move fails, the server will return an appropriate error status code, such as 403 Forbidden or 404 Not Found.

Security Considerations

When performing a MOVE request, it is important to consider the security implications. Moving a resource can have unintended consequences, such as breaking links or causing data loss. It is recommended to thoroughly test the MOVE operation in a controlled environment before performing it on a production system.

Conclusion

The MOVE request is a powerful method in WebDAV that allows for the movement of resources within a server. It is important to use this method with caution and thoroughly test it to avoid any unintended consequences.

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


使用Trickest可以轻松构建和自动化由全球最先进的社区工具提供支持的工作流程。
立即获取访问权限:

{% 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会说移动操作失败但实际上是成功的

提交凭据

如果Webdav使用的是Apache服务器则应查看Apache中配置的站点。通常在
/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服务器可以添加更多凭据:

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

要检查新凭据是否有效,可以执行以下操作:

wget --user <USERNAME> --ask-password http://domain/path/to/webdav/ -O - -q
☁️ HackTricks云 ☁️ -🐦 推特 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥


使用Trickest可以轻松构建和自动化工作流程,使用全球最先进的社区工具。
立即获取访问权限:

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