suricata结合ioc检测apt攻击

admin 2024年10月29日18:06:49评论44 views字数 7306阅读24分21秒阅读模式

suricata结合ioc检测apt攻击

前言

在高级持续性威胁(APT)检测中,使用 Suricata 结合各种 IOC(Indicator of Compromise)检测和分析全流量是一种有效的方法。我们可以借助 Suricata 强大的 DPI 功能对流量中的domain、IP、JA3/JA3S、tls.fingerprint、tls.cert_serial、tls.cert_subject和文件哈希等进行全面分析,以提高网络攻击检测和防御能力。

目录

1. 域名 和 IP地址 检测域名 和 IP地址 检测dnslog检测2. 敏感信息泄露3. TLS 指纹4. JA3S 哈希检测5. 文件哈希监控6. 整合 IOC 数据集feed汇总(maltrail)AutonomousThreatSweeperfofa7. 日志分析与告警集成8. 相关文件汇总

1. 域名 和 IP地址 检测

可以通过在 rules 文件中使用 dataset 关键字将恶意域名和 IP 地址列表进行批量加载,提升规则匹配的灵活性。

域名 和 IP地址 检测

##域名全匹配,base64#alert dns any any -> any 53 (msg:"dataset detect domain";dns.query;dataset:isset,domain.base64.list,type string,load /mnt/d/poc/blue/ioc/all.domain.base64.txt;sid:1001;)##ip#alert ip any any -> any any (msg:"dataset detect ip"; ip.dst; dataset:isset,ip.list,type ip,load /mnt/d/poc/blue/ioc/all.ip.txt;sid:1002;)

dataset支持文件行内容为ipv4、ipv6、md5、sha256、string(base64);域名归类为string,需要base64编码,一行一个

suricata结合ioc检测apt攻击

dnslog检测

利用pcrexform正则提取dns请求的主域名(oastify.com), 结合dataset检测各dnslog的子域名(abc*.oastify.com),学自kavia师傅的文章《Suricata之dnslog域名检测》

https://mp.weixin.qq.com/s/b5hyAxjqVIt-uvmYq-0NYg

##*.*子域名,base64#alert dns any any -> any 53 (msg:"pcrexform+dataset detect domain";dns.query;pcrexform:"(.[^.]+.[^.]+)$";dataset:isset,dnslog.base64.list,type string,load /mnt/d/poc/blue/ioc/dnslog.base64.txt;sid:1000;)

dnslog列表示例

.0kee.360.cn.2xss.cc.burpcollaborator.net.bxss.me.ceye.io.dnslog.cn.eu.org.exeye.io.eyes.sh.godns.vip.ngrok.io.nip.io.oastify.com.pipedream.net.r87.me.sslip.io.tu4.org.vcap.me.vuleye.pw.xip.io.xip.name.xn--9tr.com

suricata结合ioc检测apt攻击

2. 敏感信息泄露

身份证、手机号

正则匹配身份证和手机号等敏感信息

##身份证#alert tcp any any -> any any (msg:"Detected 18-digit Chinese ID card number"; pcre:"/bd{6}(19|20)d{2}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])d{3}[dXx]b/"; sid:1003;)##手机号#alert tcp any any -> any any (msg:"Detected 11-digit Chinese mobile phone number"; pcre:"/b1[3-9]d{9}b/"; sid:1004;)

suricata结合ioc检测apt攻击

3. TLS 指纹

tls证书序列号、指纹、颁发

在 APT 攻击中,许多恶意 TLS 连接会使用特定的 SNI(Server Name Indication)或证书颁发机构(Issuer)。通过分析 SNI 和 Issuer 字段,我们可以检测出可疑的加密流量。

tls.fingerprint支持dataset,可以加载一个指纹列表

##tls.cert_serial,7.0.7最高支持tls1.2#alert tls any any -> any any (msg:"tls.cert_serial";tls.cert_serial; content:"04:61:B0:D9:F5:38:89:DC:37:30:9D:0A:31:B0:58:2F:48:B2"; sid:1005;)##tls.fingerprint,7.0.7最高支持tls1.2#alert tls any any -> any any (msg:"tls.fingerprint";tls.fingerprint:"8E:DC:64:BD:3D:EA:A4:39:7A:F5:45:3A:EE:89:3F:A6:70:4D:FA:BF"; sid:1006;)##tls.cert_subject,7.0.7最高支持tls1.2,fast_pattern,CN=/O=#alert tls any any -> any any (msg:"tls.cert_subject";tls.cert_subject; content:"CN=email.instant-patch.online"; sid:1007;)

根据apt38使用过的ssl序列号381691609147718260459780208541489433626802进行检测

suricata结合ioc检测apt攻击

suricata结合ioc检测apt攻击

tls.cert_serial/tls.fingerprint/tls.cert_subject这三个关键字最高支持tls1.2不支持tls1.3,建议使用ja3指纹

suricata结合ioc检测apt攻击

平时我们在fofa搜索时使用的序列号是十进制格式,它是从证书的原始字节流转换为大整数后得到的,suricata的tls.cert_serial关键字检测的是原始字节流

suricata结合ioc检测apt攻击

十进制格式 和 原始字节流可以相互转换

suricata结合ioc检测apt攻击

4. JA3S 哈希检测

ja3s等tls指纹不用自己算,在配置文件中将outputs.eve-log.types.tls.enabled置为yes,suricata运行检测一遍pcap文件,就会自动把相关tls关键字的键值对输出到日志文件中

##ja3s.hash,7.0.7最高支持tls1.3,6aea764ee67f71caf3dc723118906199#alert tls any any -> any any (msg:"ja3s.hash"; ja3s.hash; content:"6aea764ee67f71caf3dc723118906199"; sid:100008;)

suricata结合ioc检测apt攻击

5. 文件哈希监控

APT 攻击中,恶意文件的传播通常是通过网络传输完成的。Suricata 支持从数据包中提取文件,基于文件哈希检测攻击行为。且filesha256、filemd5、filesha1支持loadfile加载百万级大列表。

##filesha256##md5: 5e0845a9f08c1cfc7966824758b6953a##sha1: 0f53892c43ccc3f64c524f7b04ab914123e36d48##sha256: 16bef09e16119f1754a6b4283e93ff7a17cfdd7c043c3ff05a3d41f128ead52e#alert tcp any any -> any any (msg:"filesha256";filesha256:/mnt/d/poc/blue/ioc/all.sha256.txt; sid:100009;)#alert tcp any any -> any any (msg:"filemd5";filemd5:/mnt/d/poc/blue/ioc/all.md5.txt; sid:100010;)#alert tcp any any -> any any (msg:"filesha1";filesha1:/mnt/d/poc/blue/ioc/all.sha1.txt; sid:100011;)

suricata结合ioc检测apt攻击

suricata的"features"跟它配置文件里的几百个项成正比,比如从http数据包中提取文件默认最大为100kb,不修改response-body-limit的话,超过100kb的文件就会被截断,生成错误hash

6. 整合 IOC 数据集

APT 攻击通常涉及大量 IOC 数据,包括域名、IP 地址、文件哈希等。可以使用 Suricata 的 dataset 功能,将数以百万 IOC 数据导入为一份独立的文件,动态更新 IOC 列表而无需更改规则。

feed汇总(maltrail

https://github.com/stamparm/maltrail/tree/28c3ef8038f0b416f584e8b63be0fbb459dd21c8/trails/feeds

maltrail汇总了feed,但只包含部分ioc数据,且没有文件hash,全量的得自己提取,每个feed文件点进去就可以看到一个开源ioc数据集,一共52个源

suricata结合ioc检测apt攻击

https://github.com/stamparm/maltrail/tree/28c3ef8038f0b416f584e8b63be0fbb459dd21c8/trails/static/malware

还按恶意行为、组织等分类了,方便研究员单独关注各个组织的行为

suricata结合ioc检测apt攻击

提取apt相关的ioc

suricata结合ioc检测apt攻击

AutonomousThreatSweeper

https://github.com/Securonix/AutonomousThreatSweeper

suricata结合ioc检测apt攻击

更新最快的repo

suricata结合ioc检测apt攻击

fofa

fofa有两个关键词category="黑客工具"和category="区块链",已经标识了BitRAT、Mythic、CS等C2,和矿池节点,方便检测人工渗透和挖矿木马等。

suricata结合ioc检测apt攻击

suricata结合ioc检测apt攻击

提取ioc

suricata结合ioc检测apt攻击

7. 日志分析与告警集成

APT 检测不仅依赖 Suricata 规则告警,还需要有效的日志分析。将 Suricata 日志整合到 SIEM 平台,如 ELK、Splunk 或 wazuh,或者arkime等全流量平台,可以帮助安全团队更快速地响应告警事件。同时,通过 Suricata 的 eve.json 文件中的 fileinfo、tls 和 alert 日志,团队可以更全面地分析攻击源和攻击路径。

suricata结合ioc检测apt攻击

8. 相关文件汇总

测试环境:

Ubuntu 22.04.4 LTSSuricata version 7.0.7 RELEASE

配置文件:

%YAML 1.1---suricata-version: "7.0"#vars:#  address-groups:#    HOME_NET: "[192.168.0.0/16,10.0.0.0/8,172.16.0.0/12]"#    EXTERNAL_NET: "!$HOME_NET"vars:  address-groups:    HOME_NET: "any"    EXTERNAL_NET: "any"outputs:  - eve-log:      enabled: yes      filename: all.json      pcap-file: yes      types:        - alert:            tagged-packets: yes       # 是否包含触发告警的数据包            payload: yes               # 启用数据包的十六进制转储(可选)            payload-printable: yes     # 可打印的数据包内容(可选)            packet: yes                # 是否记录原始数据包            http-body: no             # 启用 HTTP body 内容记录            metadata: no              # 记录规则中定义的元数据            metadata:              rule:                metadata: true        - dns:            enabled: no        - tls:            enabled: no            custom: [subject, issuer, session_resumed, serial, fingerprint, sni, version, not_before, not_after, certificate,  ja3, ja3s, ja4, client_certificate]        - files:            force-magic: no               force-hash: [md5, sha1, sha256]            enabled: noapp-layer:  protocols:    http:      enabled: yes      libhtp:         default-config:           response-body-limit: 0    tls:      enabled: yes      ja3-fingerprints: yes      ja4-fingerprints: yesrule-files:  - /mnt/d/poc/blue/suricata/rules/mine.yaml#  - /mnt/d/poc/blue/suricata/rules/*/*.rules

规则:

##*.*子域名,base64#alert dns any any -> any 53 (msg:"pcrexform+dataset detect domain";dns.query;pcrexform:"(.[^.]+.[^.]+)$";dataset:isset,dnslog.base64.list,type string,load /mnt/d/poc/blue/ioc/dnslog.base64.txt;sid:1000;)##域名全匹配,base64#alert dns any any -> any 53 (msg:"dataset detect domain";dns.query;dataset:isset,domain.base64.list,type string,load /mnt/d/poc/blue/ioc/all.domain.base64.txt;sid:1001;)##ip#alert ip any any -> any any (msg:"dataset detect ip"; ip.dst; dataset:isset,ip.list,type ip,load /mnt/d/poc/blue/ioc/all.ip.txt;sid:1002;)##身份证#alert tcp any any -> any any (msg:"Detected 18-digit Chinese ID card number"; pcre:"/bd{6}(19|20)d{2}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])d{3}[dXx]b/"; sid:1003;)##手机号#alert tcp any any -> any any (msg:"Detected 11-digit Chinese mobile phone number"; pcre:"/b1[3-9]d{9}b/"; sid:1004;)##tls.cert_serial,7.0.7最高支持tls1.2#alert tls any any -> any any (msg:"tls.cert_serial";tls.cert_serial; content:"04:61:B0:D9:F5:38:89:DC:37:30:9D:0A:31:B0:58:2F:48:B2"; sid:1005;)##tls.fingerprint,7.0.7最高支持tls1.2#alert tls any any -> any any (msg:"tls.fingerprint";tls.fingerprint:"8E:DC:64:BD:3D:EA:A4:39:7A:F5:45:3A:EE:89:3F:A6:70:4D:FA:BF"; sid:1006;)##tls.cert_subject,7.0.7最高支持tls1.2,fast_pattern,CN=/O=#alert tls any any -> any any (msg:"tls.cert_subject";tls.cert_subject; content:"CN=email.instant-patch.online"; sid:1007;)##ja3s.hash,7.0.7最高支持tls1.3,6aea764ee67f71caf3dc723118906199#alert tls any any -> any any (msg:"ja3s.hash"; ja3s.hash; content:"6aea764ee67f71caf3dc723118906199"; sid:100008;)##filesha256##md5: 5e0845a9f08c1cfc7966824758b6953a##sha1: 0f53892c43ccc3f64c524f7b04ab914123e36d48##sha256: 16bef09e16119f1754a6b4283e93ff7a17cfdd7c043c3ff05a3d41f128ead52e#alert tcp any any -> any any (msg:"filesha256";filesha256:/mnt/d/poc/blue/ioc/all.sha256.txt; sid:100009;)#alert tcp any any -> any any (msg:"filemd5";filemd5:/mnt/d/poc/blue/ioc/all.md5.txt; sid:100010;)#alert tcp any any -> any any (msg:"filesha1";filesha1:/mnt/d/poc/blue/ioc/all.sha1.txt; sid:100011;)

最后,欢迎对写规则感兴趣的师傅们加入指导,群里有kavia师傅坐镇。

suricata结合ioc检测apt攻击

公众号后台消息基本不看,有事滴滴,欢迎指正

suricata结合ioc检测apt攻击

suricata结合ioc检测apt攻击

原文始发于微信公众号(流浪猫收容所):suricata结合ioc检测apt攻击

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年10月29日18:06:49
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   suricata结合ioc检测apt攻击http://cn-sec.com/archives/3329191.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息