# T1505.004 - IIS Components

## Description from ATT&CK

> Adversaries may install malicious components that run on Internet Information Services (IIS) web servers to establish persistence. IIS provides several mechanisms to extend the functionality of the web servers. For example, Internet Server Application Programming Interface (ISAPI) extensions and filters can be installed to examine and/or modify incoming and outgoing IIS web requests. Extensions and filters are deployed as DLL files that export three functions: <code>Get{Extension/Filter}Version</code>, <code>Http{Extension/Filter}Proc</code>, and (optionally) <code>Terminate{Extension/Filter}</code>. IIS modules may also be installed to extend IIS web servers.(Citation: Microsoft ISAPI Extension Overview 2017)(Citation: Microsoft ISAPI Filter Overview 2017)(Citation: IIS Backdoor 2011)(Citation: Trustwave IIS Module 2013)
> 
> Adversaries may install malicious ISAPI extensions and filters to observe and/or modify traffic, execute commands on compromised machines, or proxy command and control traffic. ISAPI extensions and filters may have access to all IIS web requests and responses. For example, an adversary may abuse these mechanisms to modify HTTP responses in order to distribute malicious commands/content to previously comprised hosts.(Citation: Microsoft ISAPI Filter Overview 2017)(Citation: Microsoft ISAPI Extension Overview 2017)(Citation: Microsoft ISAPI Extension All Incoming 2017)(Citation: Dell TG-3390)(Citation: Trustwave IIS Module 2013)(Citation: MMPC ISAPI Filter 2012)
> 
> Adversaries may also install malicious IIS modules to observe and/or modify traffic. IIS 7.0 introduced modules that provide the same unrestricted access to HTTP requests and responses as ISAPI extensions and filters. IIS modules can be written as a DLL that exports <code>RegisterModule</code>, or as a .NET application that interfaces with ASP.NET APIs to access IIS HTTP requests.(Citation: Microsoft IIS Modules Overview 2007)(Citation: Trustwave IIS Module 2013)(Citation: ESET IIS Malware 2021)

[Source](https://attack.mitre.org/techniques/T1505/004)

## Atomic Tests

- [Atomic Test #1: Install IIS Module using AppCmd.exe](#atomic-test-1-install-iis-module-using-appcmdexe)
- [Atomic Test #2: Install IIS Module using PowerShell Cmdlet New-WebGlobalModule](#atomic-test-2-install-iis-module-using-powershell-cmdlet-new-webglobalmodule)

### Atomic Test #1: Install IIS Module using AppCmd.exe

The following Atomic will utilize AppCmd.exe to install a new IIS Module. IIS must be installed.
This atomic utilizes a DLL on disk, but to test further suspiciousness, compile and load [IIS-Raid](https://www.mdsec.co.uk/2020/02/iis-raid-backdooring-iis-using-native-modules/).
A successful execution will install a module into IIS using AppCmd.exe.
[Managing and installing Modules Reference](https://learn.microsoft.com/en-us/iis/get-started/introduction-to-iis/iis-modules-overview#to-install-a-module-using-appcmdexe)
[IIS Modules](https://www.microsoft.com/en-us/security/blog/2022/12/12/iis-modules-the-evolution-of-web-shells-and-how-to-detect-them/)

**Supported Platforms:** Windows

**auto_generated_guid:** `53adbdfa-8200-490c-871c-d3b1ab3324b2`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| module_name | The name of the IIS module | string | DefaultDocumentModule_Atomic|
| dll_path | The path to the DLL to be loaded | path | %windir%&#92;system32&#92;inetsrv&#92;defdoc.dll|

#### Attack Commands: Run with `command_prompt`!

```cmd
%windir%\system32\inetsrv\appcmd.exe install module /name:#{module_name} /image:#{dll_path}
```

#### Cleanup Commands

```cmd
%windir%\system32\inetsrv\appcmd.exe uninstall module #{module_name}
```

#### Dependencies: Run with `powershell`!

##### Description: IIS must be installed in order to add a module to IIS.

###### Check Prereq Commands

```powershell
$service = get-service w3svc -ErrorAction SilentlyContinue
if($service){ Write-Host "IIS installed on $env:computername" } else { Write-Host "IIS is not installed on $env:computername" }
```

###### Get Prereq Commands

```powershell
Install IIS to continue.
```

### Atomic Test #2: Install IIS Module using PowerShell Cmdlet New-WebGlobalModule

The following Atomic will utilize PowerShell Cmdlet New-WebGlobalModule to install a new IIS Module. IIS must be installed.
This atomic utilizes a DLL on disk, but to test further suspiciousness, compile and load [IIS-Raid](https://www.mdsec.co.uk/2020/02/iis-raid-backdooring-iis-using-native-modules/).
A successful execution will install a module into IIS using New-WebGlobalModule.
[Managing IIS Modules with PowerShell](https://learn.microsoft.com/en-us/powershell/module/webadministration/set-webglobalmodule?view=windowsserver2022-ps)
[IIS Modules](https://www.microsoft.com/en-us/security/blog/2022/12/12/iis-modules-the-evolution-of-web-shells-and-how-to-detect-them/)

**Supported Platforms:** Windows

**auto_generated_guid:** `cc3381fb-4bd0-405c-a8e4-6cacfac3b06c`

#### Inputs

| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| module_name | The name of the IIS module | string | DefaultDocumentModule_Atomic|
| dll_path | The path to the DLL to be loaded | path | %windir%&#92;system32&#92;inetsrv&#92;defdoc.dll|

#### Attack Commands: Run with `powershell`!

```powershell
New-WebGlobalModule -Name #{module_name} -Image #{dll_path}
```

#### Cleanup Commands

```powershell
Remove-WebGlobalModule -Name #{module_name}
```

#### Dependencies: Run with `powershell`!

##### Description: IIS must be installed in order to add a module to IIS.

###### Check Prereq Commands

```powershell
$service = get-service w3svc -ErrorAction SilentlyContinue
if($service){ Write-Host "IIS installed on $env:computername" } else { Write-Host "IIS is not installed on $env:computername" }
```

###### Get Prereq Commands

```powershell
Install IIS to continue.
```