入侵检测:IDS-snort的安装配置及pcap规则编写思路

介绍windows环境下的snort安装和配置,主要是为了下面写snort规则和验证规则做铺垫

下载安装

官网下载:https://www.snort.org/

1553244073031.png

直接默认安装
1553244096478.png

进入安装目录: C:\Snort
1553244157433.png

配置文件

编辑C:\Snort\etc\snort.conf 修改成如下图

1553244303344.png
# Path to your rules files (this can be a relative path)
# Note for Windows users:  You are advised to make this an absolute path,
# such as:  c:\snort\rules
var RULE_PATH c:\snort\rules
var SO_RULE_PATH c:\snort\so_rules
var PREPROC_RULE_PATH c:\snort\preproc_rules

# If you are using reputation preprocessor set these
# Currently there is a bug with relative paths, they are relative to where snort is
# not relative to snort.conf like the above variables
# This is completely inconsistent with how other vars work, BUG 89986
# Set the absolute path appropriately
var WHITE_LIST_PATH c:\snort\rules
var BLACK_LIST_PATH c:\snort\rules

1553244347075.png
# path to dynamic preprocessor libraries

dynamicpreprocessor directory c:\snort\lib\snort_dynamicpreprocessor

# path to base preprocessor engine

dynamicengine c:\snort\lib\snort_dynamicengine\sf_engine.dll

1553244565985.png

1553244583273.png

此处安装参考:http://www.cnblogs.com/lasgalen/p/4512755.html

规则验证

进入C:\Snort\rules,新建三个文件

1553244641858.png

在文件 local.rules添加我们的snort规则进行验证测试,例如:
alert tcp any any -> any 1911 (msg:"IDS: fox-info"; content:"|66 6f 78|";  sid:1112515; rev:1;)

CMD进入目录C:\Snort\bin

注意:snort只能识别pcap后缀的包文件,用wireshark的pcapng后缀会报错 需要再另存为一下 修改文件格式 不是直接改后缀哦

1553245450470.png

1553823819727.png

然后运行:
PS C:\Snort\bin> .\snort.exe  -c c:\snort\etc\snort.conf -l c:\snort\log -r .\fox_info.pcap

没有报错就说明成功运行了,去看看log有没有输出信息

进入C:\Snort\log

1553245168969.png

1553245190700.png

成功按规则进行了信息输出,到此规则验证成功

pcap规则编写思路

IEC61850-MMS协议

1553825030436.png

先用wireshark打开对应的数据包文件,因为wireshark适配了mms协议的解析,所以可以很直观的分辨出哪个数据包对应什么功能

1553825113336.png

从上图可知,选中的数据包执行的是start操作

1553825178460.png

从上图可知,选中的数据包执行的是 stop操作

现在,我们把对应的数据包十六进制数据提取出来,做一下对比,就可以很轻松的写出对应的snort规则

1553826906976.png

提取出snort规则,在文件local.rules添加我们的snort规则进行验证测试,例如:

alert tcp any any -> any 102 (msg:"IDS: mms-START"; content:"|bf 28 1b|";  sid:1112727; rev:1;)
alert tcp any any -> any 102 (msg:"IDS: mms-STOP"; content:"|bf 29 19|";  sid:1112728; rev:1;)
alert tcp any any -> any 102 (msg:"IDS: mms-RESET"; content:"|bf 2b 19|";  sid:1112729; rev:1;)

尝试验证一下数据包的规则,查看日志:

1553827126774.png

可以发现日志里记录了规则命中的输出信息,到此就算规则编写完成了。
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值