Pentesting Microsoft Internet Information Services (IIS)
IIS tilde directory enumeration
IIS tilde directory enumeration is a technique utilised to uncover hidden files, directories, and short file names (aka the 8.3 format
) on some versions of Microsoft Internet Information Services (IIS) web servers. This method takes advantage of a specific vulnerability in IIS, resulting from how it manages short file names within its directories.
When a file or folder is created on an IIS server, Windows generates a short file name in the 8.3 format
, consisting of eight characters for the file name, a period, and three characters for the extension. Intriguingly, these short file names can grant access to their corresponding files and folders, even if they were meant to be hidden or inaccessible.
The tilde (~
) character, followed by a sequence number, signifies a short file name in a URL. Hence, if someone determines a file or folder's short file name, they can exploit the tilde character and the short file name in the URL to access sensitive data or hidden resources.
The attack
Assume the server contains a hidden directory named SecretDocuments. When a request is sent to http://example.com/~s
, the server replies with a 200 OK
status code, revealing a directory with a short name beginning with "s". Otherwise, it will return another status. The cool part is that you can guess one letter by one. The server delivers a 200 OK
status code for the request http://example.com/~sec
, further narrowing the short name to "sec".
Once the short name secret~1
is identified, enumeration of specific file names within that path can be performed, potentially exposing sensitive documents.
Enumeration
The initial phase involves mapping the target and determining which services are operating on their respective ports.
IIS 7.5 is running on port 80. Executing a tilde enumeration attack on this version could be a viable option.
Tilde Enumeration using IIS ShortName Scanner
Manually sending HTTP requests for each letter of the alphabet can be a tedious process. Fortunately, there is a tool called IIS-ShortName-Scanner
that can automate this task.
Download it from: https://github.com/irsdl/IIS-ShortName-Scanner
Requirements:
install Oracle Java and now you can run:
Expected output:
Upon executing the tool, it discovers 2 directories and 3 files. However, the target does not permit GET
access to http://10.129.204.231/TRANSF~1.ASP
, necessitating the brute-forcing of the remaining filename.
Output: