MAC下snort的安装与应用

一、snort简介

snort一个具有多平台(Multi-Platform)、实时(Real-Time)流量分析、网络IP数据包(Pocket)记录等特性的强大的网络入侵检测/防御系统(Network Intrusion Detection/Prevention System),即NIDS/NIPS。

如果还想更深入的了解,可以通过百度百科自查,Snort,不再赘述。

二、snort安装

因为安装snort版本和每个人的设备都不太一样,所以安装步骤我建议先看官方文档,在去查看相关的博客。

Snort官网

1、安装snort

官网给出的第一步如下:
在这里插入图片描述
MAC暂时只能通过源码安装,并且为了方便后期卸载清理,建议相关软件如非必要尽量安装在用户指定的路径下面。

1.1 安装daq

相关命令如下:

cd daq-2.0.6
./configure --prefix=/Users/schillerxu/daq
sudo make
sudo make install
#添加系统环境变量
vi ~/.bash_profile
export PATH=/Users/schillerxu/daq/bin:$PATH
source ~/.bash_profile

"export PATH=/Users/schillerxu/daq/bin:$PATH"是要在文件里面添加的内容,不是命令。

如果缺少一些依赖库,可以通过:
1、brew命令安装(类似于CentOS里面的yum,想了解可移步homebrew是个啥),brew命令安装的依赖库大部分会自己软连接到/usr/local/bin路径下面,但有一部分需要自己手动解决;
2、通过源码安装,再软连接到/usr/local/bin或者/usr/local/lib路径下面;
3、查看能否通过./configure命令指定依赖库的路径解决,实例如下:

./configure --prefix=/Users/schillerxu/daq --with-libpcap-includes=/usr/local/Cellar/libpcap/1.9.1/include --with-libpcap-libraries=/usr/local/Cellar/libpcap/1.9.1/lib
1.2 安装snort

安装snort的命令如下:

tar zxvf snort-2.9.15.1.tar.gz
cd snort-2.9.15.1
./configure --prefix=/Users/schillerxu/snort --with-daq-includes=/Users/schillerxu/daq/include --with-daq-libraries=/Users/schillerxu/daq/lib/
sudo make
sudo make install
#添加系统环境变量
vi ~/.bash_profile
export PATH=/Users/schillerxu/snort/bin:$PATH
source ~/.bash_profile

如果缺少依赖包,可以使用上面的方法解决。我在安装的时候还有一个问题没解决:

ERROR! LuaJIT library not found. Go get it from http://www.luajit.org/ (or) Try compiling without openAppId using '--disable-open-appid' configure: error: "Fatal!"

即使安装了luaJIT库,还是会出现这个错误,后来只能添加“–disable-open-appid”参数:

./configure --prefix=/Users/schillerxu/snort --with-daq-includes=/Users/schillerxu/daq/include --with-daq-libraries=/Users/schillerxu/daq/lib/ --disable-open-appid

三、snort配置与初步使用

在官网注册后即可获取相关配置:
在这里插入图片描述
配置命令如下:

cd ~/snort
tar zxvf snortrules-snapshot-29151.tar.gz 

解压之后差生四个文件夹

so_rules
rules
preproc_rules
etc

需要修改etc文件夹下面的snort.conf文件,主要是修改添加的过滤规则,如下:
在这里插入图片描述
可以根据自己的需要,使用部分规则。

snort一共有三种模式:

1、嗅探模式

执行命令以及部分结果如下:

#因为要监控网卡,所以必须得使用sudo权限
$ sudo snort -v
Running in packet dump mode

        --== Initializing Snort ==--
Initializing Output Plugins!
pcap DAQ configured to passive.
Acquiring network traffic from "en0".
Decoding Ethernet

        --== Initialization Complete ==--

   ,,_     -*> Snort! <*-
  o"  )~   Version 2.9.15.1 GRE (Build 15125) 
   ''''    By Martin Roesch & The Snort Team: http://www.snort.org/contact#team
           Copyright (C) 2014-2019 Cisco and/or its affiliates. All rights reserved.
           Copyright (C) 1998-2013 Sourcefire, Inc., et al.
           Using libpcap version 1.9.1
           Using PCRE version: 8.43 2019-02-23
           Using ZLIB version: 1.2.11
......
2、记录模式

执行命令如下:

#-l用于指定日志路径 默认目录是/var/log/snort
$ sudo snort -dev -l ./log
Running in packet logging mode

        --== Initializing Snort ==--
Initializing Output Plugins!
Log directory = ./log
pcap DAQ configured to passive.
Acquiring network traffic from "en0".
Decoding Ethernet

        --== Initialization Complete ==--

   ,,_     -*> Snort! <*-
  o"  )~   Version 2.9.15.1 GRE (Build 15125) 
   ''''    By Martin Roesch & The Snort Team: http://www.snort.org/contact#team
           Copyright (C) 2014-2019 Cisco and/or its affiliates. All rights reserved.
           Copyright (C) 1998-2013 Sourcefire, Inc., et al.
           Using libpcap version 1.9.1
           Using PCRE version: 8.43 2019-02-23
           Using ZLIB version: 1.2.11
......

最后会在log文件夹下生成如下类似文件:

$ ls -ltrh
total 24
-rw-------  1 root  staff   4.9K  2  6 11:27 snort.log.1580959621
-rw-r--r--  1 root  staff     0B  2  6 15:24 alert
-rw-------  1 root  staff   2.2K  3  2 22:12 snort.log.1583158357
#查看文件类型
$ sudo file snort.log.1583158357
snort.log.1583158357: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 1514)
3、网络入侵检测模式

命令如下:

$ sudo snort -l ./log/ -h 192.168.8.0/24 -c ./etc/snort.conf 
Running in IDS mode

        --== Initializing Snort ==--
Initializing Output Plugins!
Initializing Preprocessors!
Initializing Plug-ins!
Parsing Rules file "./etc/snort.conf"
......

结果会保存在log文件夹里的alert文件中。

四、snort网络入侵模式实验

我只说下思路,因为我在windows(192.168.8.7)上用nmap扫描MAC(192.168.8.3),MAC上用snort进行入侵检测,并没有在~/snort/log/alert文件里面找到想要的内容。

这里贴一张其他人实验的结果:
在这里插入图片描述

五、参考资料

snort的安装、配置和使用
day1:snort搭建
Snort 命令参数详解

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值