snort入门

开源仓库: GitHub - snort3/snort3: Snort++

官网: https://snort.org/

使用ubuntu安装命令(当前ubuntu16-04默认安装snort2版本):

# apt install snort

安装完成后使用如下命令查看帮助:

# snort -?

snort分析流量是通过规则定义的, 社区规则下载地址:

https://snort.org/downloads#additional_downloads

还有官方安装源码,以及不同版本的规则下载集合包,还有规则说明文档等

这里简单说明一下流量规则如何定义:

snort规则简单示例如下:
# alert tcp any any  -> 192.168.0.5 :5000  [其他可选过滤参数]

alert代表匹配规则后的动作, 替换alert的操作有:
alert - generate an alert using the selected alert method, and then log the packet
log - log the packet
pass - ignore the packet
drop - block and log the packet
reject - block the packet, log it, and then send a TCP reset if the protocol is TCP or an ICMP port unreachable message if the protocol is UDP.
sdrop - block the packet but do not log it

tcp代表协议, 可以修改为 TCP、UDP、ICMP 和 IP 等

然后是ip范围 端口范围, 方向描述符, ip范围 端口范围  
(无论是ip范围还是端口范围前面都可以加叹号代表取反)
192.168.1.0/24 any  -> 192.168.0.5 8:5000   

三种方向
->  从左到右
<-  从右到左
<>  双向

 默认情况下安装后配置文件和默认规则会自动放到如下目录里面:

# /etc/snort/snort.conf
# /etc/snort/rules/

使用命令分析:

读取pcap格式的流量文件, 分析流量后将日志输出到/log目录下, 使用snort.conf配置的规则
# snort -r /path/one.pcap -l /path/log/ -c /etc/snort/snort.conf

添加 -N 参数不再输出默认普通流量日志
添加 -q 参数不再生成最终执行时长统计报告
# snort -N -q -r /path/one.pcap -l /path/log/ -c /etc/snort/snort.conf

日志生成:
/path/log/alert 文件是alert规则触发后才会记录的, 其他文件都是普通流量日志

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值