当前位置: 移动技术网 > IT编程>脚本编程>VBScript > 用VBS来代替BAT或CMD文件进行命令第1/2页

用VBS来代替BAT或CMD文件进行命令第1/2页

2017年12月12日  | 移动技术网IT编程  | 我要评论

rdg濒危物种少女漫画,何燕照片,etf黄金持仓量

自动导入注册表的,带检测:
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("注册表未导入,游戏可能无法启动,如无法进游戏请叫网管~",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:\网络游戏\劲乐团\o2jam.exe"

自动加载虚拟光驱的:

dim oshell
set oshell= wscript.createobject("wscript.shell")
oshell.run "c:\progra~1\daemon~1\daemon.exe -mount 0,d:\lan\战地2\bf2cd1mini.mds"
wscript.sleep 5000
oshell.run "d:\lan\战地2\bf2.exe"

另一例子:

dim wsh,dmpath,isopath
dmpath = "x:\y\daemon.exe" '设置dm路径
isopath = "z:\大富翁七\rich7b.mds" '设置镜像文件路径
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" '设置你要执行的文件夹


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

//排除指定文件或文件夹删除多余的文件或文件夹,黑火原创
option explicit

''''''''''''''说明''''''''''''
'网盟-黑火制作,送给需要的朋友。
'配置文件“listfile.ini”的格式如下:
'要删除什么(文件|目录)=要执行删除的文件夹=排除1;排除2;排除3............
'配置文件可以有多行,以便对多个目录进行操作。
'配置文件里以“/”开头的行为注释行。
'排除多个内容时,使用分号“;”进行分隔。
'↓↓↓ 配置文件例子:↓↓↓
'/配置文件开始
'目录=d:\=system volume information;网络游戏;单机游戏;小游戏
'目录=c:\program files=qq;winrar
'文件=d:\网络游戏=文件1.exe;文件2.exe
'/配置文件结束
'''''''''''''说明完''''''''''''

dim fso,listfile,objlistfile
listfile = "" '设置配置文件路径,如果配置文件和脚本放在一起,请保持原样

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,"执行完毕"
'不需要显示报告的话,注释掉上面这一行

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()函数)

set wsshell = createobject("wscript.shell")
desktoppath = wsshell.specialfolders("desktop")


!获取当前用户名称
set wshnetwork = wscript.createobject("wscript.network")

username= wshnetwork.username


!获取系统变量%systemroot%(当然其他的系统变量可以类推,只是不只是不是都要通过process中转一下)

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 的对话框,不同的选择执行不同的代码

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)&代替

!忽略代码错误继续执行

on error resume next
放置于代码的最开头,当代码运行出错后并不停止跳出而是继续执行下一条。适当应用会很有效果。
!破解下载限制
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("现在您可以下载程序了!") 

!读本机“计算机名”


'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) '禁用“开始”菜单中的“关闭系统”功能

!向windows中添加自启动程序


该程序能在开机时自动运行。
'addautorunprogram.vbs
'假设该程序在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!") 
一、给注册表编辑器解锁

  用记事本编辑如下内容:

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为扩展名的文件,使用时双击即可。

  二、关闭win nt/2000的默认共享

  用记事本编辑如下内容: 

dim wshshell'定义变量
set wshshell=createobject("wscript.shell") '创建一个能与操作系统沟通的对象wshshell
dim fso,dc
set fso=createobject("scripting.filesystemobject")'创建文件系统对象 
set dc=fso.drives '获取所有驱动器盘符
for each d in dc 
dim str 
wshshell.run("net share"&d.driveletter &"$ /delete")'关闭所有驱动器的隐藏共享
next 
wshshell.run("net share admin$ /delete")
wshshell.run("net share ipc$ /delete")'关闭admin$和ipc$管道共享

  现在来测试一下,先打开cmd.exe,输入net share命令就可以看到自己机子上的共享。双击执行stopshare.vbs后,会看见窗口一闪而过。然后再在cmd里输入net share命令,这时候没有发现共享列表了

  三、显示本机ip地址

  有许多时候,我们需要知道本机的ip地址,使用各种软件虽然可以办到,但用vbs脚本也非常的方便。用记事本编辑如下内容:

dim ws
set ws=createobject("mswinsock.winsock")
ipaddress=ws.localip
msgbox "local ip=" & ipaddress

  将上面的内容保存为showip.vbs,双击执行即可得到本机ip地址。

  四、利用脚本编程删除日志

  入侵系统成功后黑客做的第一件事便是清除日志,如果以图形界面远程控制对方机器或是从终端登陆进入,删除日志不是一件困难的事,由于日志虽然也是作为一种服务运行,但不同于http,ftp这样的服务,可以在命令行下先停止,再删除,在命令行下用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 ()方法删除日志。建立一个数组,application,security,system,如果还有其他日志也可以加入数组。然后用一个for循环,删除数组中的每一个元素,即各个日志。

  五、利用脚本伪造日志

  删除日志后,任何一个有头脑的管理员面对空空的日志,马上就会反应过来被入侵了,所以一个聪明的黑客的学会如何伪造日志。利用脚本编程中的eventlog方法创造日志非常简单,请看下面的代码:

set ws=wscript.createobject("wscript.shell")
ws.logevent 0 ,"write log success" '创建一个成功执行日志

  将上面的代码保存为createlog.vbs即可。这段代码很容易理解,首先获得wscript的一个shell对象,然后利用shell对象的logevent方法。logevent的用法:logevent eventtype,"description" [,remote system],其中eventtype为日志类型,可以使用的参数如下:0代表成功执行,1执行出错,2警告,4信息,8成功审计,16故障审计。所以上面代码中,把0改为1,2,4,8,16均可,引号中的内容为日志描述。利用这种方法写的日志有一个缺点,即只能写到应用程序日志,而且日志来源只能为 wsh,即windows scripting host,所以不能起太多的隐蔽作用,在此仅供大家参考。

  六、禁用开始菜单选项

  用记事本编辑如下内容:

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) '禁用“开始”菜单中的“关闭系统”功能

  将以上代码保存为changestartmenu.vbs文件,使用时双击即可。

  七、执行外部程序

  用记事本编辑如下内容:

dim objshell
set objshell=wscript.createobject("wscript.shell")
ireturn=objshell.run("cmd.exe /c set var=world", 1, true)

  保存为.vbs文件即可。在这段代码中,我们首先设置了一个环境变量,其名为var,而值为world,用户可以使用%comspec%来代替cmd.exe,并且可以把命令:set var=world改成其它的命令,这样就可以使它可以运行任意的命令。

  八、重新启动指定的iis服务

  用记事本编辑如下内容:

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目录中的特定文件中的特定字符并将结果放入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

//妙用脚本和批处理清除电脑中的痕迹
实现本功能使用了两个文件,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浏览器地址栏留下的曾经浏览过的网页地址名;第九、十、十一行为清除ie地址栏里的网络实名。
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\*.* 
1

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网