网络入侵检测--Snort软件运行模式及参数详解

这边介绍一下Snort的运行参数,这里主要根据使用的方式,来推荐一些常用的组合。Snort目前有常用的三种方式,

  • 数据包嗅探
  • 数据包记录
  • NIDS网络攻击检测

数据包嗅探

分析展示就是我们常用的嗅探模式,和我们用tcpdump,tshark命令一样。
就是让我来瞧瞧你们在说什么
在这里插入图片描述
大概效果如下
在这里插入图片描述
此处常用参数如下

参数含义
-v显示 IP 和 TCP / UDP / ICMP头信息
-e显示二层报文内容,即显示MAC地址以太网帧类型
-d显示应用层协议内容,即显示报文数据段
-C在-d模式下,不显示16进制数据,只显示字符串类型
-X显示链路层数据内容
-q安静模式,不显示启动信息,不显示统计信息

这些个参数可以自由组合。

数据包记录

这个功能就是将报文保存成pcap包,记录到某个路径下。大概就是把你们说的都记录下来,等以后算账
在这里插入图片描述

此处常用参数

参数含义
-l指定log存放目录
-L指定log记录名称,建议和-l配合使用,因为它只指定文件名称
-K <mode>记录日志模式 (pcap[默认],ascii,none),只有当使用ascii模式的时候, 才能存成人类可读格式,并且按照IP来源分开存储
-h指定哪个网络是家庭网络,存储以远端IP为名,如果都是本地,以端口号、IP为优先级,取大者,这个只有ascii模式才有效

NIDS网络攻击检测

这里是Snort最核心的用法,网络攻击检测,我倒是要看看你们有没有说什么不好的东西
在这里插入图片描述
这里的话,必备的参数就是 -c

参数含义
-c指定配置文件

因为配置文件中定义了各种变量,预处理器,模块,以及调用了哪些规则文件,只有都包含了这些内容之后,才能真正以NIDS的身份,监视各种网络报文的安全。
在NIDS模式下,通过-A参数可以控制输出报警到哪里。

参数含义
-A fast快速警报模式。以简单的格式写入警报,其中包含时间戳,警报消息,源 IP 地址和目标 IP / 端口
-A full完全警报模式。这是默认的警报模式,如果您未指定模式,它将自动使用
-A unsock将警报发送到另一个程序可以监听的 UNIX 套接字
-A none关闭警报
-A console将 “快速样式” 警报发送到控制台(屏幕)
-A cmg生成 “cmg 样式” 警报
-s将警报发送到 syslog,syslog 警报机制的默认功能是 LOG_AUTHPRIV 和 LOG_ALERT
-N关闭数据记录,只记录报警

如果想通过命令行配置规则和参数的话可以用这两个参数,不过通过配置文件更合适。

参数含义
-c <rules>使用 Rules文件
-S <n=v>设置rules文件中的变量 n 值为 v

!!!模式组合
前面这三种模式,我们常用的组合就是记录log与其他两种模式的组合,
我们可以既显示又存储

snort -i enp1s0 -dev -l ./log

log目录里存储的是二进制文件,也就是pcap包

我们也可以即进行攻击检测又存储

snort -l ./log -c /etc/snort/rules/etc/snort.conf 

log存储的是报警,和触发报警的那条数据的pcap包(安全报文不存储)

其他参数

读取文件

我们可以利用snort来分析已有的pcap报文,就像回放报文一样,正好和前面的报文记录呼应上了,我先记下来,再分析你有没有问题
在这里插入图片描述

参数就是-r

参数含义
-r指定读取的pcap报文

同理,这里我们可以配合前面的工作模式,分析已经发生的网络流量。

例如分析内容,甚至可以分析前面存储的log

snort  -dev -r ./log/snort.log.12453332

分析是否存在网络攻击

snort -c /etc/snort/rules/etc/snort.conf -r ./log/snort.log.12453332

接口配置参数

参数含义
-i指定监听报文接口
-I报警输出可以指定某个接口

运行软件相关

下面是一些运行软件可以用的参数

参数含义
-D守护进程方式运行
-u <uname>用户配置,Run snort uid as uname user (or uid) after initialization
-g <gname>组配置,Run snort gid as gname group (or gid) after initialization
-t <dir>运行根目录配置,Chroots process to <dir> after initialization
-G <0xid>如果多个Snort运行,可以为每个定义一个唯一标识
-M运行日志计入syslog
-T测试配置文件是否有效

退出软件相关

有些条件满足,会引发snort退出

参数含义
-x当配置出错时退出
-n <cnt>当收到cnt个包的时候退出

时间戳相关

参数含义
-y在alert和log中的时间中包含年
-U时间戳中的时间用UTC时间

打马赛克相关

如果想要在别的地方引用你的日志文件,又不想被人知道你的网络情况,那可以打马赛克
在这里插入图片描述

参数含义
-Olog中的IP地址打马赛克
-B <mask>带掩码的IP地址打马赛克

其他配置

参数含义
-V查看版本号
-p嗅探的时候不再开启混杂模式
-Q启用内联模式
-f在二进制log写入之后,不再调用fflush
-F <bpf>使用BPF过滤方法文件
-H使哈希表具有确定性.
-k <mode>校验码模式 (all,noip,notcp,noudp,noicmp,none)
-m <umask>设置掩码权限= <umask>
-P <snap>设置显式snaplen (默认 1514)
-R <id>在 snort_intf<id>.pid 文件名字中包含id
-Z <file>设置PerformMonitor预处理器文件路径和名称

这篇文章将

USAGE: snort [-options] <filter options>

所有的Options都解释了一下。
后面还有filter options,后续再翻译一下,可以先看看内容如下。

<Filter Options> are standard BPF options, as seen in TCPDump
Longname options and their corresponding single char version
   --logid <0xid>                  Same as -G
   --perfmon-file <file>           Same as -Z
   --pid-path <dir>                Specify the directory for the Snort PID file
   --snaplen <snap>                Same as -P
   --help                          Same as -?
   --version                       Same as -V
   --alert-before-pass             Process alert, drop, sdrop, or reject before pass, default is pass before alert, drop,...
   --treat-drop-as-alert           Converts drop, sdrop, and reject rules into alert rules during startup
   --treat-drop-as-ignore          Use drop, sdrop, and reject rules to ignore session traffic when not inline.
   --process-all-events            Process all queued events (drop, alert,...), default stops after 1st action group
   --enable-inline-test            Enable Inline-Test Mode Operation
   --dynamic-engine-lib <file>     Load a dynamic detection engine
   --dynamic-engine-lib-dir <path> Load all dynamic engines from directory
   --dynamic-detection-lib <file>  Load a dynamic rules library
   --dynamic-detection-lib-dir <path> Load all dynamic rules libraries from directory
   --dump-dynamic-rules <path>     Creates stub rule files of all loaded rules libraries
   --dynamic-preprocessor-lib <file>  Load a dynamic preprocessor library
   --dynamic-preprocessor-lib-dir <path> Load all dynamic preprocessor libraries from directory
   --dynamic-output-lib <file>  Load a dynamic output library
   --dynamic-output-lib-dir <path> Load all dynamic output libraries from directory
   --create-pidfile                Create PID file, even when not in Daemon mode
   --nolock-pidfile                Do not try to lock Snort PID file
   --no-interface-pidfile          Do not include the interface name in Snort PID file
   --disable-attribute-reload-thread Do not create a thread to reload the attribute table
   --pcap-single <tf>              Same as -r.
   --pcap-file <file>              file that contains a list of pcaps to read - read mode is implied.
   --pcap-list "<list>"            a space separated list of pcaps to read - read mode is implied.
   --pcap-dir <dir>                a directory to recurse to look for pcaps - read mode is implied.
   --pcap-filter <filter>          filter to apply when getting pcaps from file or directory.
   --pcap-no-filter                reset to use no filter when getting pcaps from file or directory.
   --pcap-loop <count>             this option will read the pcaps specified on command line continuously.
                                   for <count> times.  A value of 0 will read until Snort is terminated.
   --pcap-reset                    if reading multiple pcaps, reset snort to post-configuration state before reading next pcap.
   --pcap-reload                   if reading multiple pcaps, reload snort config between pcaps.
   --pcap-show                     print a line saying what pcap is currently being read.
   --exit-check <count>            Signal termination after <count> callbacks from DAQ_Acquire(), showing the time it
                                   takes from signaling until DAQ_Stop() is called.
   --conf-error-out                Same as -x
   --enable-mpls-multicast         Allow multicast MPLS
   --enable-mpls-overlapping-ip    Handle overlapping IPs within MPLS clouds
   --max-mpls-labelchain-len       Specify the max MPLS label chain
   --mpls-payload-type             Specify the protocol (ipv4, ipv6, ethernet) that is encapsulated by MPLS
   --require-rule-sid              Require that all snort rules have SID specified.
   --daq <type>                    Select packet acquisition module (default is pcap).
   --daq-mode <mode>               Select the DAQ operating mode.
   --daq-var <name=value>          Specify extra DAQ configuration variable.
   --daq-dir <dir>                 Tell snort where to find desired DAQ.
   --daq-list[=<dir>]              List packet acquisition modules available in dir.  Default is static modules only.
   --dirty-pig                     Don't flush packets and release memory on shutdown.
   --cs-dir <dir>                  Directory to use for control socket.
   --ha-peer                       Activate live high-availability state sharing with peer.
   --ha-out <file>                 Write high-availability events to this file.
   --ha-in <file>                  Read high-availability events from this file on startup (warm-start).
   --suppress-config-log           Suppress configuration information output.

下一篇会介绍一下snort.conf配置文件的参数,欢迎继续学习。
早晨看到了群里发的一段视频,汽车左转与一辆直行自行车相撞,从视频上看,自行车肯定是看到汽车左转了,他就是在赌汽车会减速,但是恰好,汽车司机感觉就没看到自行车,没有任何刹车就直接撞了。
在这里插入图片描述
这种事情,大家最好还是不要赌,看着就疼。
在这里插入图片描述
所以有时候不仅要遵守交通规则,更要懂得小心驶得万年船。

  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胖哥王老师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值