linux - 如何在 OpenWRT 上启动 Snort?

标签 linux logging service openwrt snort

最近我用 OpenWRT 替换了我的路由器操作系统,并在上面安装了 snort(2.9):

opkg install snort

我在 /etc/snort/rules/local.rules 中唯一的规则:

alert icmp any any -> [My Router Private IP like : 192.168.0.1] any (msg: "NMAP ping sweep Scan"; dsize:0;sid:10000004; rev: 1;)

问题是当我运行时:

snort -A console -q -c /etc/snort/snort.conf -i br-lan --daq-dir /usr/lib/daq

在命令行上,它是好的,它检测到一些 Nmap 扫描攻击并在控制台中写入警报:

04/12-08:19:50.152690  [**] [1:10000005:2] NMAP TCP Scan [**] [Priority: 0] {TCP} 192.168.0.10:46287 -> 192.168.0.1:22

和日志文件,但是当我通过以下方式启动服务时:

/etc/init.d/snort start

当我使用相同的 Nmap 命令 (nmap -sX -p22 192.168.0.1) 时,没有任何反应,也没有创建日志文件。

我的问题是:

  1. 为什么服务器没有运行? 如果没有 Systemctl,则无法检测服务是否一切正常。

  2. 为什么我运行 snort 命令时创建的日志是无意义的? 例如,当我键入 cat/var/log/snort/snort.log.1523473976 时,我得到:

    ������Z��^8Mvv��n6(鈈����Ehu@@A3��<����

在控制台中。

附言: 1 -cat/etc/init.d/snort :

#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org

START=90
STOP=10

USE_PROCD=1
PROG=/usr/bin/snort

validate_snort_section() {
    uci_validate_section snort snort "${1}" \
        'config_file:string' \
        'interface:string'
}

start_service() {
    local config_file interface

    validate_snort_section snort || {
        echo "validation failed"
        return 1
    }

    procd_open_instance
    procd_set_param command $PROG "-c" "$config_file" "-q" "--daq-dir" "/usr/lib/daq/" "-i" "$interface" "-s" "-N"
    procd_set_param file $CONFIGFILE
    procd_set_param respawn
    procd_close_instance
}

stop_service()
{
    service_stop ${PROG}
}

service_triggers()
{
    procd_add_reload_trigger "snort"
    procd_add_validation validate_snort_section
}

2- 我实际上关注了 This link配置。但我取消注释并将 config logdir: 设置为 /var/log/snort/

(任何帮助将不胜感激)

最佳答案

默认设置为 localhost - lo 检查 uci show snort.snort.interface

的输出

你可以用 uci set snort.snort.interface=br-lan 改变它 重新启动 snort 以确认它确实采用了新参数 - /etc/init.d/snort restart

你可以在top/htop中查看整个命令行 如果一切正常,将更改保存到 UCI:uci commit 并且您的日志是该配置的二进制文件,而不是文本,我将我的日志记录到 syslog 并将它们发送到远程 rsyslog 服务器,在 snort.conf - output alert_syslog: LOG_AUTH LOG_ALERT

关于linux - 如何在 OpenWRT 上启动 Snort?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49791482/

相关文章:

linux - ext4 卷的根目录上的 fsync 会刷新所有子卷吗?

c++ - 如何将类似 iostream 的接口(interface)写入日志库?

grails - 将Grails日志记录配置与Config.groovy分开?

android - 如何在启动完成 android 时启动服务?

java - Kryonet RMI 抛出异常 => 循环 (StackOverflowError)

linux - 不支持 Xattrs

php - 为什么我的 .php 扩展文件不能在 cgi-bin 文件夹(linux 服务器)中作为 CGI 工作?

Python - 通过/SSH 使用远程主机的 env 变量

c# - MVC 6 中的 CorrelationID 在哪里

windows - 如何在安装时而不是每次启动时一劳永逸地将参数传递给 Windows 服务