用VBS來代替BAT或CMD文件進行命令第1/2頁
更新時間:2008年06月04日 08:35:33 作者:
忽然想到要用VBS來代替BAT或CMD文件進行命令集成,于是開始下苦工學習了一番!在網(wǎng)上找了好久終于找到東西。
自動導入注冊表的,帶檢測:
On Error Resume Next
dim msg,fso,shell
Set fso = Wscript.createobject("scripting.filesystemobject")
set wshshell = wscript.CreateObject("wscript.shell")
set shell = wscript.createobject("wscript.shell")
IF (fso.FileExists("e:\勁樂團\reg.reg")) Then
shell.run "c:\windows\Regedit.exe /s e:\勁樂團\reg.reg "
shell.run "e:\勁樂團\O2Jam.exe"
Else
msg=msgbox("注冊表未導入,游戲可能無法啟動,如無法進游戲請叫網(wǎng)管~",1,"出問題啦??!")
shell.run "e:\勁樂團\O2Jam.exe"
end if
不帶檢測的:
On Error Resume Next
Dim oShell,fso
Set oShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.filesystemobject")
oShell.Run "regedit /s 9you.reg"
oShell.Run "d:\網(wǎng)絡(luò)游戲\勁樂團\O2Jam.exe"
自動加載虛擬光驅(qū)的:
Dim oShell
Set oshell= WScript.CreateObject("WScript.Shell")
oShell.Run "c:\progra~1\daemon~1\daemon.exe -mount 0,D:\lan\戰(zhàn)地2\BF2CD1mini.mds"
wscript.sleep 5000
oShell.Run "D:\lan\戰(zhàn)地2\BF2.exe"
另一例子:
Dim Wsh,DMpath,ISOpath
DMpath = "X:\Y\daemon.exe" '設(shè)置DM路徑
ISOpath = "Z:\大富翁七\RICH7B.mds" '設(shè)置鏡像文件路徑
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.run chr(34) & DMpath & chr(34) &" -mount 0,"&ISOpath,0,true
Wscript.Sleep 3000 '最好延時幾秒等待鏡像加載完畢 1000 = 1 秒
Wsh.run "Z:\大富翁七\rich7.exe"
Set WSH = Nothing
WScript.quit
//每次開機的時候自動導入注冊表和程序
Option Explicit
Dim Folder
Folder = "d:\aaa" '設(shè)置你要執(zhí)行的文件夾
Dim Wsh,fso
Set Wsh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim f,fc,f1,ext
Set f = fso.GetFolder(Folder)
Set fc = f.Files
For Each f1 in fc
ext = LCase(fso.GetExtensionName(f1))
Select Case ext
Case "exe"
wsh.run f1,,true
Case "reg"
wsh.run "Regedit /s "& f1,,true
end Select
Next
Set fso=NoThing
Set Wsh = Nothing
WScript.quit
//排除指定文件或文件夾刪除多余的文件或文件夾,黑火原創(chuàng)
Option Explicit
''''''''''''''說明''''''''''''
'網(wǎng)盟-黑火制作,送給需要的朋友。
'配置文件“Listfile.ini”的格式如下:
'要刪除什么(文件|目錄)=要執(zhí)行刪除的文件夾=排除1;排除2;排除3............
'配置文件可以有多行,以便對多個目錄進行操作。
'配置文件里以“/”開頭的行為注釋行。
'排除多個內(nèi)容時,使用分號“;”進行分隔。
'↓↓↓ 配置文件例子:↓↓↓
'/配置文件開始
'目錄=D:\=System Volume Information;網(wǎng)絡(luò)游戲;單機游戲;小游戲
'目錄=C:\Program Files=qq;WinRAR
'文件=D:\網(wǎng)絡(luò)游戲=文件1.exe;文件2.exe
'/配置文件結(jié)束
'''''''''''''說明完''''''''''''
Dim Fso,Listfile,objListfile
Listfile = "" '設(shè)置配置文件路徑,如果配置文件和腳本放在一起,請保持原樣
If Listfile = "" Then Listfile = "Listfile.ini"
Set Fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set objListfile = Fso.OpenTextFile(Listfile,1)
If Err Then
err.Clear
Msgbox "沒有找到配置文件 "&Listfile,16,"錯誤"
WScript.quit
End If
On Error GoTo 0
Dim flnum,fdnum,t1,t2,tm
flnum=0
fdnum=0
t1 = timer()
Dim Myline,LineArr,ListArr
Do While objListfile.AtEndOfStream <> True
Myline = LCase(Replace(objListfile.ReadLine,"==","="))
If Left(Myline,1) = "/" Then
'objListfile.SkipLine
ElseIf CheckLine(Myline) = 2 Then
LineArr = Split(Myline,"=")
'DoFolder = LineArr(1)
ListArr = Split(LineArr(2),";")
'MsgBox LineArr(0)
If LineArr(0) = "目錄" Then DelFolder LineArr(1),ListArr
If LineArr(0) = "文件" Then DelFile LineArr(1),ListArr
End If
Loop
t2 = timer()
tm=cstr(int(( (t2-t1)*10000 )+0.5)/10)
MsgBox "掃描完畢,共刪除 "&fdnum&" 個目錄, "&flnum& "個文件。"& vbCrLf &"耗時 "&tm&" 毫秒",64,"執(zhí)行完畢"
'不需要顯示報告的話,注釋掉上面這一行
Set Fso=NoThing
WScript.quit
Sub DelFolder(Folder,ListArr)
Dim objFolder,subFolders,subFolder
Set objFolder=Fso.Getfolder(Folder)
Set subFolders=objFolder.subFolders
For Each subFolder In subFolders
If Not InArray(LIstArr,LCase(subFolder.name)) Then
On Error Resume Next
subfolder.Delete(True)
If Err Then
err.Clear
Msgbox "不能刪除目錄,請檢查 "&subFolder,16,"錯誤"
Else
fdnum = fdnum + 1
End If
On Error GoTo 0
End If
Next
End Sub
Sub DelFile(Folder,ListArr)
Dim objFolder,Files,File
Set objFolder=Fso.Getfolder(Folder)
Set Files=objFolder.Files
For Each File In Files
If Not InArray(LIstArr,LCase(File.name)) Then
On Error Resume Next
File.Delete(True)
If Err Then
err.Clear
Msgbox "不能刪除文件,請檢查 "&File,16,"錯誤"
Else
flnum = flnum + 1
End If
On Error GoTo 0
End If
Next
End Sub
Function CheckLine(strLine)
Dim LineRegExp,Matches
Set LineRegExp = New RegExp
LineRegExp.Pattern = ".=."
LineRegExp.Global = True
Set Matches = LineRegExp.Execute(strLine)
CheckLine = Matches.count
End Function
Function InArray(Myarray,StrIn)
Dim StrTemp
InArray = True
For Each StrTemp In Myarray
If StrIn = StrTemp Then
Exit Function
Exit For
End If
Next
InArray = False
End Function
!獲得特定文件夾的路徑(例如當前用戶的桌面在磁盤中的實際位置,等等,相當于vc中的SHGetSpecialFolderPath()函數(shù))
Set wsShell = CreateObject("WScript.Shell")
DesktopPath = wsShell.SpecialFolders("Desktop")
!獲取當前用戶名稱
Set WshNetwork = WScript.CreateObject("WScript.Network")
UserName= WshNetwork.UserName
!獲取系統(tǒng)變量%SystemRoot%(當然其他的系統(tǒng)變量可以類推,只是不只是不是都要通過PROCESS中轉(zhuǎn)一下)
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshSysEnv = wsShell.Environment("PROCESS")
SystemRoot = WshSysEnv("WINDIR")
!將域用戶或租添加到本地組
Set objGroup = GetObject("WinNT://./Administrators")
Set objUser = GetObject("WinNT://testnet/Engineers")
objGroup.Add(objUser.ADsPath)
!修改本地管理員密碼
Set objcnlar = GetObject("WinNT://./administrator, user")
objcnla.SetPassword "P@ssW0rd"
objcnla.SetInfo
!彈出 YES or NO 的對話框,不同的選擇執(zhí)行不同的代碼
intAnswer = Msgbox("Do you want to delete these files?", vbYesNo, "Delete Files")
If intAnswer = vbYes Then
Msgbox "You answered yes."
Else Msgbox "You answered no."
End If
!運行CMD命令行命令
set obshell=wscript.createobject("wscript.shell")
obshell.run ("ipconfig"),,true
如果要運行的命令中包含雙引號,可使用&chr(34)&代替
!忽略代碼錯誤繼續(xù)執(zhí)行
On Error Resume Next
放置于代碼的最開頭,當代碼運行出錯后并不停止跳出而是繼續(xù)執(zhí)行下一條。適當應(yīng)用會很有效果。
!破解下載限制
DIM WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL")
WSH.POPUP("本程序的作用是解決無法下載的問題")
WSH.POPUP("特別是在注冊表禁用的情況下破解")
WSH.POPUP("由曾誠制作")
WSH.Regwrite"HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1803",0,"REG_DWORD"
WSH.POPUP("現(xiàn)在您可以下載程序了!")
!讀本機“計算機名”
'ReadComputerName.vbs
Dim ReadComputerName
Set ReadComputerName=WScript.CreateObject("WScript.Shell")
Dim ComputerName,RegPath
RegPath="HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
ComputerName=ReadComputerName.RegRead(RegPath)
MsgBox("計算機名為"&ComputerName)
!隱藏快捷方式圖標上的小箭頭
'Hidden.vbs
Dim HiddenArrowIcon
Set HiddenArrowIcon=WScript.CreateObject("WScript.Shell")
Dim RegPath1,RegPath2
RegPath1="HKCR\lnkfile\IsShortCut"
RegPath2="HKCR\piffile\IsShortCut"
HiddenArrowIcon.RegDelete(RegPath1)
HiddenArrowIcon.RegDelete(RegPath2)
!改造“開始”菜單
'ChangeStartMenu.vbs
Dim ChangeStartMenu
Set ChangeStartMenu=WScript.CreateObject("WScript.Shell")
RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\"
Type_Name="REG_DWORD"
Key_Data=1
StartMenu_Run="NoRun"
StartMenu_Find="NoFind"
StartMenu_Close="NoClose"
Sub Change(Argument)
ChangeStartMenu.RegWrite RegPath&Argument,Key_Data,Type_Name
MsgBox("Success!")
End Sub
Call Change(StartMenu_Run) '禁用“開始”菜單中的“運行”功能
Call Change(StartMenu_Find) '禁用“開始”菜單中的“查找”功能
Call Change(StartMenu_Close) '禁用“開始”菜單中的“關(guān)閉系統(tǒng)”功能
!向Windows中添加自啟動程序
該程序能在開機時自動運行。
'AddAutoRunProgram.vbs
'假設(shè)該程序在c:\myfile文件夾中,文件名為autorun.exe
Dim AutoRunProgram
Set AutoRunProgram=WScript.CreateObject("WScript.Shell")
RegPath="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
Type_Name="REG_SZ"
Key_Name="AutoRun"
Key_Data="C:\Myfile\autorun.exe"
'該自啟動程序的全路徑文件名
AutoRunProgram.Write RegPath&Key_Name,Key_Data,Type_Name
'在啟動組中添加自啟動程序autorun.exe
MsgBox("Success!")
一、給注冊表編輯器解鎖
用記事本編輯如下內(nèi)容:
DIM WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL") '擊活WScript.Shell對象
WSH.POPUP("解鎖注冊表編輯器!")
'顯示彈出信息“解鎖注冊表編輯器!”
WSH.Regwrite"HKCU\Software\Microsoft\Windows\CurrentVersion
\Policies\System\DisableRegistryTools",0,"REG_DWORD"
'給注冊表編輯器解鎖
WSH.POPUP("注冊表解鎖成功!")
'顯示彈出信息“注冊表解鎖成功!”
保存為以.vbs為擴展名的文件,使用時雙擊即可。
二、關(guān)閉Win NT/2000的默認共享
用記事本編輯如下內(nèi)容:
Dim WSHShell'定義變量
set WSHShell=CreateObject("WScript.shell") '創(chuàng)建一個能與操作系統(tǒng)溝通的對象WSHShell
Dim fso,dc
Set fso=CreateObject("Scripting.FileSystemObject")'創(chuàng)建文件系統(tǒng)對象
set dc=fso.Drives '獲取所有驅(qū)動器盤符
For Each d in dc
Dim str
WSHShell.run("net share"&d.driveletter &"$ /delete")'關(guān)閉所有驅(qū)動器的隱藏共享
next
WSHShell.run("net share admin$ /delete")
WSHShell.run("net share ipc$ /delete")'關(guān)閉admin$和ipc$管道共享
現(xiàn)在來測試一下,先打開cmd.exe,輸入net share命令就可以看到自己機子上的共享。雙擊執(zhí)行stopshare.vbs后,會看見窗口一閃而過。然后再在cmd里輸入net share命令,這時候沒有發(fā)現(xiàn)共享列表了
三、顯示本機IP地址
有許多時候,我們需要知道本機的IP地址,使用各種軟件雖然可以辦到,但用VBS腳本也非常的方便。用記事本編輯如下內(nèi)容:
Dim WS
Set WS=CreateObject("MSWinsock.Winsock")
IPAddress=WS.LocalIP
MsgBox "Local IP=" & IPAddress
將上面的內(nèi)容保存為ShowIP.vbs,雙擊執(zhí)行即可得到本機IP地址。
四、利用腳本編程刪除日志
入侵系統(tǒng)成功后黑客做的第一件事便是清除日志,如果以圖形界面遠程控制對方機器或是從終端登陸進入,刪除日志不是一件困難的事,由于日志雖然也是作為一種服務(wù)運行,但不同于http,ftp這樣的服務(wù),可以在命令行下先停止,再刪除,在命令行下用net stop eventlog是不能停止的,所以有人認為在命令行下刪除日志是很困難的,實際上不是這樣,比方說利用腳本編程中的VMI就可以刪除日志,而且非常的簡單方便。源代碼如下:
strComputer= "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup)}!\\" & _
strComputer & "\root\cimv2")
dim mylogs(3)
mylogs(1)="application"
mylogs(2)="system"
mylogs(3)="security"
for Each logs in mylogs
Set colLogFiles=objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='"&logs&"'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
Next
next
將上面的代碼保存為cleanevent.vbs文件即可。在上面的代碼中,首先獲得object對象,然后利用其clearEventLog ()方法刪除日志。建立一個數(shù)組,application,security,system,如果還有其他日志也可以加入數(shù)組。然后用一個for循環(huán),刪除數(shù)組中的每一個元素,即各個日志。
五、利用腳本偽造日志
刪除日志后,任何一個有頭腦的管理員面對空空的日志,馬上就會反應(yīng)過來被入侵了,所以一個聰明的黑客的學會如何偽造日志。利用腳本編程中的eventlog方法創(chuàng)造日志非常簡單,請看下面的代碼:
set ws=wscript.createobject("Wscript.shell")
ws.logevent 0 ,"write log success" '創(chuàng)建一個成功執(zhí)行日志
將上面的代碼保存為createlog.vbs即可。這段代碼很容易理解,首先獲得wscript的一個shell對象,然后利用shell對象的logevent方法。logevent的用法:logevent eventtype,"description" [,remote system],其中eventtype為日志類型,可以使用的參數(shù)如下:0代表成功執(zhí)行,1執(zhí)行出錯,2警告,4信息,8成功審計,16故障審計。所以上面代碼中,把0改為1,2,4,8,16均可,引號中的內(nèi)容為日志描述。利用這種方法寫的日志有一個缺點,即只能寫到應(yīng)用程序日志,而且日志來源只能為 WSH,即Windows Scripting Host,所以不能起太多的隱蔽作用,在此僅供大家參考。
六、禁用開始菜單選項
用記事本編輯如下內(nèi)容:
Dim ChangeStartMenu
Set ChangeStartMenu=WScript.CreateObject("WScript.Shell")
RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\"
Type_Name="REG_DWORD"
Key_Data=1
StartMenu_Run="NoRun"
StartMenu_Find="NoFind"
StartMenu_Close="NoClose"
Sub Change(Argument)
ChangeStartMenu.RegWrite RegPath&Argument,Key_Data,Type_Name
MsgBox("Success!")
End Sub
Call Change(StartMenu_Run) '禁用“開始”菜單中的“運行”功能
Call Change(StartMenu_Find) '禁用“開始”菜單中的“查找”功能
Call Change(StartMenu_Close) '禁用“開始”菜單中的“關(guān)閉系統(tǒng)”功能
將以上代碼保存為ChangeStartMenu.vbs文件,使用時雙擊即可。
七、執(zhí)行外部程序
用記事本編輯如下內(nèi)容:
DIM objShell
set objShell=wscript.createObject("wscript.shell")
iReturn=objShell.Run("cmd.exe /C set var=world", 1, TRUE)
保存為.vbs文件即可。在這段代碼中,我們首先設(shè)置了一個環(huán)境變量,其名為var,而值為world,用戶可以使用%Comspec%來代替cmd.exe,并且可以把命令:set var=world改成其它的命令,這樣就可以使它可以運行任意的命令。
八、重新啟動指定的IIS服務(wù)
用記事本編輯如下內(nèi)容:
Const ADS_SERVICE_STOPPED = 1
Set objComputer = GetObject("WinNT://MYCOMPUTER,computer")
Set objService = objComputer.GetObject("Service","MYSERVICE")
If (objService.Status = ADS_SERVICE_STOPPED) Then
objService.Start
End If
//檢查Search目錄中的特定文件中的特定字符并將結(jié)果放入Result.txt中
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Const ForReading = 1
Const ForAppending = 8
Dim arrFileLines()
i=0
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "
ootcimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = '\search\'")
For Each objFile in colFiles
If objFile.Extension = "log" Then
FileName = objFile.Name
Wscript.Echo FileName
End IF
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("input.txt",ForReading)
InputLine = objFile.ReadLine
objFile.Close
set objFile = objFSO.OpenTextFile(FileName,ForReading)
Do Until objFile.AtEndOfStream
SearchLine = objFile.ReadLine
If InStr(SearchLine,InputLine) = 0 Then
Else
Redim Preserve arrFileLines(i)
arrFileLines(i) = SearchLine
i=i+1
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("result.txt", ForAppending)
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
objFile.WriteLine arrFileLines(l)
Next
objFile.Close
//在用戶登陸的時候清除所有的管理員賬戶,只保留Administrator和NetShowServices,并修改Administrator的密碼為55555555
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
StrUser = objNetwork.Name
StrStat = "False"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
For Each objUser in objGroup.Members
If objUser.name = StrUser Then
If objGroup.Name = "Aadministrators" Then
StrStat = "True"
End If
End If
Next
Next
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in objGroup.Members
If objUser.Name = "Administrator" OR objUser.Name = "NetShowServices" Then
If objUser.Name = "Administrator" AND StrStat = " True " Then
objUser.SetPassword "55555555"
End If
Else
objGroup.Remove(objUser.ADsPath)
End If
Next
//妙用腳本和批處理清除電腦中的痕跡
實現(xiàn)本功能使用了兩個文件,VBS腳本文件reg.vbs(可以自己定義文件名);批處理文件reg.bat(可以自己定義文件名)。
1.VBS腳本文件如下:
Dim WSHShell
Set WSHShell=WScript.CreateObject("WScript.Shell")
WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\reg","reg.vbs"
WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\deldel","reg.bat"
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", "about:blank"
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\",""
WSHShell.RegDelete "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\"
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\",""
WSHShell.RegWrite "HKCU\Software\3721\InputCns\",""
WSHShell.RegDelete "HKCU\Software\3721\InputCns\"
WSHShell.RegWrite "HKCU\Software\3721\InputCns\",""
本腳本前二行為定義變量,請大家照著寫。從第三行開始,是對注冊表的處理。第三行、第四行為在注冊表中添加計算機啟動時自動運行的過程文件,一個是該腳本自身為reg.vbs,另一個是reg.bat批處理文件。第五行為還原IE開始頁為“about:blank”;第六、七、八行為清除IE瀏覽器地址欄留下的曾經(jīng)瀏覽過的網(wǎng)頁地址名;第九、十、十一行為清除IE地址欄里的網(wǎng)絡(luò)實名。
2.批處理文件如下:
@deltree -y c:\windows\temp\*.*
@deltree -y c:\windows\"Temporary Internet Files"\*.*
@deltree -y c:\windows\History\*.*
@deltree -y C:\Windows\Recent\*.*
@deltree -y C:\RECYCLED\*.*
@deltree -y C:\WINDOWS\Cookies\*.*
On Error Resume Next
dim msg,fso,shell
Set fso = Wscript.createobject("scripting.filesystemobject")
set wshshell = wscript.CreateObject("wscript.shell")
set shell = wscript.createobject("wscript.shell")
IF (fso.FileExists("e:\勁樂團\reg.reg")) Then
shell.run "c:\windows\Regedit.exe /s e:\勁樂團\reg.reg "
shell.run "e:\勁樂團\O2Jam.exe"
Else
msg=msgbox("注冊表未導入,游戲可能無法啟動,如無法進游戲請叫網(wǎng)管~",1,"出問題啦??!")
shell.run "e:\勁樂團\O2Jam.exe"
end if
不帶檢測的:
On Error Resume Next
Dim oShell,fso
Set oShell = WScript.CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.filesystemobject")
oShell.Run "regedit /s 9you.reg"
oShell.Run "d:\網(wǎng)絡(luò)游戲\勁樂團\O2Jam.exe"
自動加載虛擬光驅(qū)的:
Dim oShell
Set oshell= WScript.CreateObject("WScript.Shell")
oShell.Run "c:\progra~1\daemon~1\daemon.exe -mount 0,D:\lan\戰(zhàn)地2\BF2CD1mini.mds"
wscript.sleep 5000
oShell.Run "D:\lan\戰(zhàn)地2\BF2.exe"
另一例子:
Dim Wsh,DMpath,ISOpath
DMpath = "X:\Y\daemon.exe" '設(shè)置DM路徑
ISOpath = "Z:\大富翁七\RICH7B.mds" '設(shè)置鏡像文件路徑
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.run chr(34) & DMpath & chr(34) &" -mount 0,"&ISOpath,0,true
Wscript.Sleep 3000 '最好延時幾秒等待鏡像加載完畢 1000 = 1 秒
Wsh.run "Z:\大富翁七\rich7.exe"
Set WSH = Nothing
WScript.quit
//每次開機的時候自動導入注冊表和程序
Option Explicit
Dim Folder
Folder = "d:\aaa" '設(shè)置你要執(zhí)行的文件夾
Dim Wsh,fso
Set Wsh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim f,fc,f1,ext
Set f = fso.GetFolder(Folder)
Set fc = f.Files
For Each f1 in fc
ext = LCase(fso.GetExtensionName(f1))
Select Case ext
Case "exe"
wsh.run f1,,true
Case "reg"
wsh.run "Regedit /s "& f1,,true
end Select
Next
Set fso=NoThing
Set Wsh = Nothing
WScript.quit
//排除指定文件或文件夾刪除多余的文件或文件夾,黑火原創(chuàng)
Option Explicit
''''''''''''''說明''''''''''''
'網(wǎng)盟-黑火制作,送給需要的朋友。
'配置文件“Listfile.ini”的格式如下:
'要刪除什么(文件|目錄)=要執(zhí)行刪除的文件夾=排除1;排除2;排除3............
'配置文件可以有多行,以便對多個目錄進行操作。
'配置文件里以“/”開頭的行為注釋行。
'排除多個內(nèi)容時,使用分號“;”進行分隔。
'↓↓↓ 配置文件例子:↓↓↓
'/配置文件開始
'目錄=D:\=System Volume Information;網(wǎng)絡(luò)游戲;單機游戲;小游戲
'目錄=C:\Program Files=qq;WinRAR
'文件=D:\網(wǎng)絡(luò)游戲=文件1.exe;文件2.exe
'/配置文件結(jié)束
'''''''''''''說明完''''''''''''
Dim Fso,Listfile,objListfile
Listfile = "" '設(shè)置配置文件路徑,如果配置文件和腳本放在一起,請保持原樣
If Listfile = "" Then Listfile = "Listfile.ini"
Set Fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
Set objListfile = Fso.OpenTextFile(Listfile,1)
If Err Then
err.Clear
Msgbox "沒有找到配置文件 "&Listfile,16,"錯誤"
WScript.quit
End If
On Error GoTo 0
Dim flnum,fdnum,t1,t2,tm
flnum=0
fdnum=0
t1 = timer()
Dim Myline,LineArr,ListArr
Do While objListfile.AtEndOfStream <> True
Myline = LCase(Replace(objListfile.ReadLine,"==","="))
If Left(Myline,1) = "/" Then
'objListfile.SkipLine
ElseIf CheckLine(Myline) = 2 Then
LineArr = Split(Myline,"=")
'DoFolder = LineArr(1)
ListArr = Split(LineArr(2),";")
'MsgBox LineArr(0)
If LineArr(0) = "目錄" Then DelFolder LineArr(1),ListArr
If LineArr(0) = "文件" Then DelFile LineArr(1),ListArr
End If
Loop
t2 = timer()
tm=cstr(int(( (t2-t1)*10000 )+0.5)/10)
MsgBox "掃描完畢,共刪除 "&fdnum&" 個目錄, "&flnum& "個文件。"& vbCrLf &"耗時 "&tm&" 毫秒",64,"執(zhí)行完畢"
'不需要顯示報告的話,注釋掉上面這一行
Set Fso=NoThing
WScript.quit
Sub DelFolder(Folder,ListArr)
Dim objFolder,subFolders,subFolder
Set objFolder=Fso.Getfolder(Folder)
Set subFolders=objFolder.subFolders
For Each subFolder In subFolders
If Not InArray(LIstArr,LCase(subFolder.name)) Then
On Error Resume Next
subfolder.Delete(True)
If Err Then
err.Clear
Msgbox "不能刪除目錄,請檢查 "&subFolder,16,"錯誤"
Else
fdnum = fdnum + 1
End If
On Error GoTo 0
End If
Next
End Sub
Sub DelFile(Folder,ListArr)
Dim objFolder,Files,File
Set objFolder=Fso.Getfolder(Folder)
Set Files=objFolder.Files
For Each File In Files
If Not InArray(LIstArr,LCase(File.name)) Then
On Error Resume Next
File.Delete(True)
If Err Then
err.Clear
Msgbox "不能刪除文件,請檢查 "&File,16,"錯誤"
Else
flnum = flnum + 1
End If
On Error GoTo 0
End If
Next
End Sub
Function CheckLine(strLine)
Dim LineRegExp,Matches
Set LineRegExp = New RegExp
LineRegExp.Pattern = ".=."
LineRegExp.Global = True
Set Matches = LineRegExp.Execute(strLine)
CheckLine = Matches.count
End Function
Function InArray(Myarray,StrIn)
Dim StrTemp
InArray = True
For Each StrTemp In Myarray
If StrIn = StrTemp Then
Exit Function
Exit For
End If
Next
InArray = False
End Function
!獲得特定文件夾的路徑(例如當前用戶的桌面在磁盤中的實際位置,等等,相當于vc中的SHGetSpecialFolderPath()函數(shù))
Set wsShell = CreateObject("WScript.Shell")
DesktopPath = wsShell.SpecialFolders("Desktop")
!獲取當前用戶名稱
Set WshNetwork = WScript.CreateObject("WScript.Network")
UserName= WshNetwork.UserName
!獲取系統(tǒng)變量%SystemRoot%(當然其他的系統(tǒng)變量可以類推,只是不只是不是都要通過PROCESS中轉(zhuǎn)一下)
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshSysEnv = wsShell.Environment("PROCESS")
SystemRoot = WshSysEnv("WINDIR")
!將域用戶或租添加到本地組
Set objGroup = GetObject("WinNT://./Administrators")
Set objUser = GetObject("WinNT://testnet/Engineers")
objGroup.Add(objUser.ADsPath)
!修改本地管理員密碼
Set objcnlar = GetObject("WinNT://./administrator, user")
objcnla.SetPassword "P@ssW0rd"
objcnla.SetInfo
!彈出 YES or NO 的對話框,不同的選擇執(zhí)行不同的代碼
intAnswer = Msgbox("Do you want to delete these files?", vbYesNo, "Delete Files")
If intAnswer = vbYes Then
Msgbox "You answered yes."
Else Msgbox "You answered no."
End If
!運行CMD命令行命令
set obshell=wscript.createobject("wscript.shell")
obshell.run ("ipconfig"),,true
如果要運行的命令中包含雙引號,可使用&chr(34)&代替
!忽略代碼錯誤繼續(xù)執(zhí)行
On Error Resume Next
放置于代碼的最開頭,當代碼運行出錯后并不停止跳出而是繼續(xù)執(zhí)行下一條。適當應(yīng)用會很有效果。
!破解下載限制
DIM WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL")
WSH.POPUP("本程序的作用是解決無法下載的問題")
WSH.POPUP("特別是在注冊表禁用的情況下破解")
WSH.POPUP("由曾誠制作")
WSH.Regwrite"HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1803",0,"REG_DWORD"
WSH.POPUP("現(xiàn)在您可以下載程序了!")
!讀本機“計算機名”
'ReadComputerName.vbs
Dim ReadComputerName
Set ReadComputerName=WScript.CreateObject("WScript.Shell")
Dim ComputerName,RegPath
RegPath="HKLM\System\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
ComputerName=ReadComputerName.RegRead(RegPath)
MsgBox("計算機名為"&ComputerName)
!隱藏快捷方式圖標上的小箭頭
'Hidden.vbs
Dim HiddenArrowIcon
Set HiddenArrowIcon=WScript.CreateObject("WScript.Shell")
Dim RegPath1,RegPath2
RegPath1="HKCR\lnkfile\IsShortCut"
RegPath2="HKCR\piffile\IsShortCut"
HiddenArrowIcon.RegDelete(RegPath1)
HiddenArrowIcon.RegDelete(RegPath2)
!改造“開始”菜單
'ChangeStartMenu.vbs
Dim ChangeStartMenu
Set ChangeStartMenu=WScript.CreateObject("WScript.Shell")
RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\"
Type_Name="REG_DWORD"
Key_Data=1
StartMenu_Run="NoRun"
StartMenu_Find="NoFind"
StartMenu_Close="NoClose"
Sub Change(Argument)
ChangeStartMenu.RegWrite RegPath&Argument,Key_Data,Type_Name
MsgBox("Success!")
End Sub
Call Change(StartMenu_Run) '禁用“開始”菜單中的“運行”功能
Call Change(StartMenu_Find) '禁用“開始”菜單中的“查找”功能
Call Change(StartMenu_Close) '禁用“開始”菜單中的“關(guān)閉系統(tǒng)”功能
!向Windows中添加自啟動程序
該程序能在開機時自動運行。
'AddAutoRunProgram.vbs
'假設(shè)該程序在c:\myfile文件夾中,文件名為autorun.exe
Dim AutoRunProgram
Set AutoRunProgram=WScript.CreateObject("WScript.Shell")
RegPath="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
Type_Name="REG_SZ"
Key_Name="AutoRun"
Key_Data="C:\Myfile\autorun.exe"
'該自啟動程序的全路徑文件名
AutoRunProgram.Write RegPath&Key_Name,Key_Data,Type_Name
'在啟動組中添加自啟動程序autorun.exe
MsgBox("Success!")
一、給注冊表編輯器解鎖
用記事本編輯如下內(nèi)容:
DIM WSH
SET WSH=WSCRIPT.CreateObject("WSCRIPT.SHELL") '擊活WScript.Shell對象
WSH.POPUP("解鎖注冊表編輯器!")
'顯示彈出信息“解鎖注冊表編輯器!”
WSH.Regwrite"HKCU\Software\Microsoft\Windows\CurrentVersion
\Policies\System\DisableRegistryTools",0,"REG_DWORD"
'給注冊表編輯器解鎖
WSH.POPUP("注冊表解鎖成功!")
'顯示彈出信息“注冊表解鎖成功!”
保存為以.vbs為擴展名的文件,使用時雙擊即可。
二、關(guān)閉Win NT/2000的默認共享
用記事本編輯如下內(nèi)容:
Dim WSHShell'定義變量
set WSHShell=CreateObject("WScript.shell") '創(chuàng)建一個能與操作系統(tǒng)溝通的對象WSHShell
Dim fso,dc
Set fso=CreateObject("Scripting.FileSystemObject")'創(chuàng)建文件系統(tǒng)對象
set dc=fso.Drives '獲取所有驅(qū)動器盤符
For Each d in dc
Dim str
WSHShell.run("net share"&d.driveletter &"$ /delete")'關(guān)閉所有驅(qū)動器的隱藏共享
next
WSHShell.run("net share admin$ /delete")
WSHShell.run("net share ipc$ /delete")'關(guān)閉admin$和ipc$管道共享
現(xiàn)在來測試一下,先打開cmd.exe,輸入net share命令就可以看到自己機子上的共享。雙擊執(zhí)行stopshare.vbs后,會看見窗口一閃而過。然后再在cmd里輸入net share命令,這時候沒有發(fā)現(xiàn)共享列表了
三、顯示本機IP地址
有許多時候,我們需要知道本機的IP地址,使用各種軟件雖然可以辦到,但用VBS腳本也非常的方便。用記事本編輯如下內(nèi)容:
Dim WS
Set WS=CreateObject("MSWinsock.Winsock")
IPAddress=WS.LocalIP
MsgBox "Local IP=" & IPAddress
將上面的內(nèi)容保存為ShowIP.vbs,雙擊執(zhí)行即可得到本機IP地址。
四、利用腳本編程刪除日志
入侵系統(tǒng)成功后黑客做的第一件事便是清除日志,如果以圖形界面遠程控制對方機器或是從終端登陸進入,刪除日志不是一件困難的事,由于日志雖然也是作為一種服務(wù)運行,但不同于http,ftp這樣的服務(wù),可以在命令行下先停止,再刪除,在命令行下用net stop eventlog是不能停止的,所以有人認為在命令行下刪除日志是很困難的,實際上不是這樣,比方說利用腳本編程中的VMI就可以刪除日志,而且非常的簡單方便。源代碼如下:
strComputer= "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Backup)}!\\" & _
strComputer & "\root\cimv2")
dim mylogs(3)
mylogs(1)="application"
mylogs(2)="system"
mylogs(3)="security"
for Each logs in mylogs
Set colLogFiles=objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='"&logs&"'")
For Each objLogfile in colLogFiles
objLogFile.ClearEventLog()
Next
next
將上面的代碼保存為cleanevent.vbs文件即可。在上面的代碼中,首先獲得object對象,然后利用其clearEventLog ()方法刪除日志。建立一個數(shù)組,application,security,system,如果還有其他日志也可以加入數(shù)組。然后用一個for循環(huán),刪除數(shù)組中的每一個元素,即各個日志。
五、利用腳本偽造日志
刪除日志后,任何一個有頭腦的管理員面對空空的日志,馬上就會反應(yīng)過來被入侵了,所以一個聰明的黑客的學會如何偽造日志。利用腳本編程中的eventlog方法創(chuàng)造日志非常簡單,請看下面的代碼:
set ws=wscript.createobject("Wscript.shell")
ws.logevent 0 ,"write log success" '創(chuàng)建一個成功執(zhí)行日志
將上面的代碼保存為createlog.vbs即可。這段代碼很容易理解,首先獲得wscript的一個shell對象,然后利用shell對象的logevent方法。logevent的用法:logevent eventtype,"description" [,remote system],其中eventtype為日志類型,可以使用的參數(shù)如下:0代表成功執(zhí)行,1執(zhí)行出錯,2警告,4信息,8成功審計,16故障審計。所以上面代碼中,把0改為1,2,4,8,16均可,引號中的內(nèi)容為日志描述。利用這種方法寫的日志有一個缺點,即只能寫到應(yīng)用程序日志,而且日志來源只能為 WSH,即Windows Scripting Host,所以不能起太多的隱蔽作用,在此僅供大家參考。
六、禁用開始菜單選項
用記事本編輯如下內(nèi)容:
Dim ChangeStartMenu
Set ChangeStartMenu=WScript.CreateObject("WScript.Shell")
RegPath="HKCR\Software\Microsoft\Windows\CurrentVersion\Policies\"
Type_Name="REG_DWORD"
Key_Data=1
StartMenu_Run="NoRun"
StartMenu_Find="NoFind"
StartMenu_Close="NoClose"
Sub Change(Argument)
ChangeStartMenu.RegWrite RegPath&Argument,Key_Data,Type_Name
MsgBox("Success!")
End Sub
Call Change(StartMenu_Run) '禁用“開始”菜單中的“運行”功能
Call Change(StartMenu_Find) '禁用“開始”菜單中的“查找”功能
Call Change(StartMenu_Close) '禁用“開始”菜單中的“關(guān)閉系統(tǒng)”功能
將以上代碼保存為ChangeStartMenu.vbs文件,使用時雙擊即可。
七、執(zhí)行外部程序
用記事本編輯如下內(nèi)容:
DIM objShell
set objShell=wscript.createObject("wscript.shell")
iReturn=objShell.Run("cmd.exe /C set var=world", 1, TRUE)
保存為.vbs文件即可。在這段代碼中,我們首先設(shè)置了一個環(huán)境變量,其名為var,而值為world,用戶可以使用%Comspec%來代替cmd.exe,并且可以把命令:set var=world改成其它的命令,這樣就可以使它可以運行任意的命令。
八、重新啟動指定的IIS服務(wù)
用記事本編輯如下內(nèi)容:
Const ADS_SERVICE_STOPPED = 1
Set objComputer = GetObject("WinNT://MYCOMPUTER,computer")
Set objService = objComputer.GetObject("Service","MYSERVICE")
If (objService.Status = ADS_SERVICE_STOPPED) Then
objService.Start
End If
//檢查Search目錄中的特定文件中的特定字符并將結(jié)果放入Result.txt中
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Const ForReading = 1
Const ForAppending = 8
Dim arrFileLines()
i=0
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "
ootcimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = '\search\'")
For Each objFile in colFiles
If objFile.Extension = "log" Then
FileName = objFile.Name
Wscript.Echo FileName
End IF
Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("input.txt",ForReading)
InputLine = objFile.ReadLine
objFile.Close
set objFile = objFSO.OpenTextFile(FileName,ForReading)
Do Until objFile.AtEndOfStream
SearchLine = objFile.ReadLine
If InStr(SearchLine,InputLine) = 0 Then
Else
Redim Preserve arrFileLines(i)
arrFileLines(i) = SearchLine
i=i+1
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("result.txt", ForAppending)
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
objFile.WriteLine arrFileLines(l)
Next
objFile.Close
//在用戶登陸的時候清除所有的管理員賬戶,只保留Administrator和NetShowServices,并修改Administrator的密碼為55555555
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
StrUser = objNetwork.Name
StrStat = "False"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")
For Each objGroup In colGroups
For Each objUser in objGroup.Members
If objUser.name = StrUser Then
If objGroup.Name = "Aadministrators" Then
StrStat = "True"
End If
End If
Next
Next
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
For Each objUser in objGroup.Members
If objUser.Name = "Administrator" OR objUser.Name = "NetShowServices" Then
If objUser.Name = "Administrator" AND StrStat = " True " Then
objUser.SetPassword "55555555"
End If
Else
objGroup.Remove(objUser.ADsPath)
End If
Next
//妙用腳本和批處理清除電腦中的痕跡
實現(xiàn)本功能使用了兩個文件,VBS腳本文件reg.vbs(可以自己定義文件名);批處理文件reg.bat(可以自己定義文件名)。
1.VBS腳本文件如下:
Dim WSHShell
Set WSHShell=WScript.CreateObject("WScript.Shell")
WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\reg","reg.vbs"
WSHShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\deldel","reg.bat"
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", "about:blank"
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\",""
WSHShell.RegDelete "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\"
WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\",""
WSHShell.RegWrite "HKCU\Software\3721\InputCns\",""
WSHShell.RegDelete "HKCU\Software\3721\InputCns\"
WSHShell.RegWrite "HKCU\Software\3721\InputCns\",""
本腳本前二行為定義變量,請大家照著寫。從第三行開始,是對注冊表的處理。第三行、第四行為在注冊表中添加計算機啟動時自動運行的過程文件,一個是該腳本自身為reg.vbs,另一個是reg.bat批處理文件。第五行為還原IE開始頁為“about:blank”;第六、七、八行為清除IE瀏覽器地址欄留下的曾經(jīng)瀏覽過的網(wǎng)頁地址名;第九、十、十一行為清除IE地址欄里的網(wǎng)絡(luò)實名。
2.批處理文件如下:
@deltree -y c:\windows\temp\*.*
@deltree -y c:\windows\"Temporary Internet Files"\*.*
@deltree -y c:\windows\History\*.*
@deltree -y C:\Windows\Recent\*.*
@deltree -y C:\RECYCLED\*.*
@deltree -y C:\WINDOWS\Cookies\*.*
相關(guān)文章
用vbs腳本實現(xiàn)運行DOS批處理不再出現(xiàn)黑屏cmd窗口
用vbs腳本實現(xiàn)運行DOS批處理不再出現(xiàn)黑屏cmd窗口...2007-02-02vbs shellcode轉(zhuǎn)換escape加密
用vbs轉(zhuǎn)換加密代碼2008-05-05VBS教程:VBscript屬性-HelpContext 屬性
VBS教程:VBscript屬性-HelpContext 屬性...2006-11-11用VBS實現(xiàn)腳本結(jié)束進程與防止進程啟動
用VBS實現(xiàn)腳本結(jié)束進程與防止進程啟動...2007-03-03VBScript 中的字節(jié)數(shù)據(jù)操作函數(shù)
VBScript 中的字節(jié)數(shù)據(jù)操作函數(shù)...2006-06-06VBS基礎(chǔ)篇 - vbscript class類的定義與使用
vbs Class就是聲明一個類的名稱,以及組成該類的變量、屬性和方法的定義,需要的朋友可以參考下2018-05-05WScript.Shell對象SpecialFolders屬性未公開文檔分享
WshShell對象的SpecialFolders屬性返WshSpecialFolders 對象,該對象是一個特殊文件夾集合,其中包含整套Windows特殊文件夾2013-01-01