16. IIS Tilde Enumeration

Tilde directory enumeration is a technique utilised to uncover hidden files, directories, and short file names

When file/folder is created on IIS windows generates a short file name in 8.3 format.

These short filenames can grant access to their corresponding files+folders even if they were meant to be hidden or inaccessible The ~ character followed by a sequence number signifies a short file name in a URL If someone determines a file or folder's short file name they can exploit the tilde char and short file name in URL to access sensitive data or hidden resources

IIS tilde directory enum primarily involves sending http reqs to a server with distinct char combinations in the url to identify valid short file names. Once a valid short filename is detected this info can be utilised to access the relevant resource or further enumerate the directory structure.

http://example.com/~a
http://example.com/~b
http://example.com/~c
...

Assume server has hidden dir named SecretDocuments When request is sent to /~s the serv replies with 200 OK status revealing a dir with shortname beginning with s - enum process continues by appending more characters:

http://example.com/~se
http://example.com/~sf
http://example.com/~sg

and so on, and so forth until: http://example.com/~secret.

Once short name secret~1 is ID'd enumeration of specific filenames within that path can be performed potentially exposing sensitive documents. For instance if short name secret~1 determined for concealed directory Secretdocuments, files in that dir can be accessed by

http://example.com/secret~1/somefile.txt
http://example.com/secret~1/anotherfile.docx

Same tilde directory enum can also detect 8.3 short filenames for files within dir. In 8.3 short filenames such as somefi~1.txt the number 1 is a unique identifier that distinguishes files with similar names within the same directory. The numbers following the tilde assist filesys in differentiating between files that share similarities in their names ensuring each file has a distinct 8.3 short file name.

stejwes@htb[/htb]$ nmap -p- -sV -sC --open 10.129.224.91

Starting Nmap 7.92 ( https://nmap.org ) at 2023-03-14 19:44 GMT
Nmap scan report for 10.129.224.91
Host is up (0.011s latency).
Not shown: 65534 filtered tcp ports (no-response)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT   STATE SERVICE VERSION
80/tcp open  http    Microsoft IIS httpd 7.5
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/7.5
|_http-title: Bounty
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Detection of IIS server

Tilde enumeration using IIS ShortName scanner https://github.com/irsdl/IIS-ShortName-Scanner https://ubuntuhandbook.org/index.php/2022/03/install-jdk-18-ubuntu/ You need oracle java installed for this to work.

stejwes@htb[/htb]$ java -jar iis_shortname_scanner.jar 0 5 http://10.129.204.231/

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Do you want to use proxy [Y=Yes, Anything Else=No]? 
# IIS Short Name (8.3) Scanner version 2023.0 - scan initiated 2023/03/23 15:06:57
Target: http://10.129.204.231/
|_ Result: Vulnerable!
|_ Used HTTP method: OPTIONS
|_ Suffix (magic part): /~1/
|_ Extra information:
  |_ Number of sent requests: 553
  |_ Identified directories: 2
    |_ ASPNET~1
    |_ UPLOAD~1
  |_ Identified files: 3
    |_ CSASPX~1.CS
      |_ Actual extension = .CS
    |_ CSASPX~1.CS??
    |_ TRANSF~1.ASP

Generating a wordlist

egrep -r ^transf /usr/share/wordlists/* | sed 's/^[^:]*://' > /tmp/list.txt

Combines egrep and sed to filter + modify input and save results. egrep - search lines containing pattern, -r is recurisve. ^transf pattern matches any line that starts with transf. Output will be lines that begin with transf along with source filenames

Sed command find+replaces operation on its input - the output of above egrep. This sed expression finds any sequence of characters at the beginning of a line up to the first colon : and replaces them with nothing (effectively removing matched text), the result is lines starting with transf but without filenames and colons.


┌──(root㉿kali)-[~/cpts/common-webapps/iis/IIS-ShortName-Scanner]
HTTP request sent, awaiting response... 200 OK
Length: 5836 (5.7K) [text/plain]
Saving to: ‘config.xml’

config.xml                                           100%[=====================================================================================================================>]   5.70K  --.-KB/s    in 0s      
2025-01-20 20:20:27 (113 MB/s) - ‘config.xml’ saved [5836/5836]
                                                                                                                                                                                                                   
|_ Used HTTP method: OPTIONS
  |_ Number of sent requests: 571
    |_ UPLOAD~1
    |_ CSASPX~1.CS
    |_ TRANSF~1.ASP
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/cpts/common-webapps/iis/IIS-ShortName-Scanner]
└─# egrep -r ^transf /usr/share/wordlists/* | sed 's/^[^:]*://' > /tmp/list.txt
                                                                                                                                                                                                                   
┌──(root㉿kali)-[~/cpts/common-webapps/iis/IIS-ShortName-Scanner]
└─# tail -f /tmp/list.txt                                                                   
transflux
transfluvial
transfixture
transfigurate
transferrotype
transferral
transferotype