网络入侵检测系统之 Suricata(一)-- 概览
What is Suricata
Suricata 是一个免费,开源,成熟,高性能,稳定的网络威胁检测引擎
系统功能包括:实时入侵检测(IDS)、内联入侵预防(IPS)、网络安全监控(NSM)和离线 pcap 处理
Suricata 依靠强大的可扩展性的规则和特征语言过滤网络流量,并支持 LUA 脚本语言
输出文件格式为 YAML 或 JSON,方便与其他数据库或安全数据分析平台集成
Suricata 采用社区驱动开发,有利于版本的维护和新特性的迭代
Features
IDS / IPS
High Performance
Automatic protocol detection
NSM: More than an IDS
Lua scripting
Industry standard outputs
Operation System
Configuration
TCP/IP engine
HTTP engine
Detection engine
Packet acquire
Muti threading
Architecture
Packet Capture
AF_PACKET and PF_RING 通过 flow (5 tuple)对称哈希到线程上
RSS 技术通过分发到网卡上不同队列来分发流量,但缺点是非对称加密会使类似 TCP 的双向流量检测有误,所以通常我们配置一个 rss 队列或用对称哈希算法,并且不启用网卡流量卸载,卸载会会无法跟踪某些流状态,举个配置例子:
PF_RING: 1 RSS queue and use cluster-type ‘cluster_flflow’. Disable NIC offlfloading except the rx/tx csum
Hyperscan
Hyperscan is a high-performance multiple regex matching library, In Suricata it can be used to perform multi pattern matching (mpm).
其次默认情况,suricata 在编译时没有启用 hyperscan, 我们需要显示的编译 suricata 时加入以下命令:
–with-libhs-includes=/usr/local/include/hs/ –with-libhs-libraries=/usr/local/lib/然后再 suricata.yaml 中修改 mpm-algo and spm-algo values to ‘hs’.
Statistics
每隔 8s 中会向 stats.log file 写入包数数据:
关闭 suricata 时,也可以看到总的收发包数和丢包数
capture mode 不同,显示的数目有可能有差别:
In AF_PACKET mode:
• kernel_packets is the number of packets correctly sent to userspace
• kernel_drops is the number of packets that have been discarded instead of being sent to userspace
In PF_RING mode:
• kernel_packets is the total number of packets seen by pf_ring
• kernel_drops is the number of packets that have been discarded instead of being sent to userspace
Ignoring Traffific
可通过配置 bpf 文件进行忽略某些类型的流量
echo "not host 1.2.3.4" > capture-filter.bpf
suricata -i ens5f0 -F capture-filter.bpf
语法类似于:“not (host IP1 or IP2 or IP3 or net NET/24)”或 “ tcp or udp”
或者也可根据 suricata 规则即可:
pass/drop ip 1.2.3.4 any <> any any (msg:"pass all traffic from/to 1.2.3.4"; sid:1;)
设置 tls 关键字,可以将 https 握手之后的流量全部放行,不去检测:
app-layer.protocols.tls.encryption-handling
版权声明: 本文为 InfoQ 作者【于顾而言】的原创文章。
原文链接:【http://xie.infoq.cn/article/523169779ebe2322f18149b97】。文章转载请联系作者。
评论