在 CentOS / Ubuntu / Debian 上設置和配置 Snort 以擴展入侵檢測和 DDoS 保護。
Snort 是一個免費、開源、輕量級的網絡入侵檢測系統 (NIDS),適用于 Linux 和 Windows專用服務器。Snort 執行協議分析、內容搜索和匹配。這些基本服務有許多用途,包括應用程序感知觸發的服務質量,在使用延遲敏感的應用程序時降低批量流量的優先級。
該程序還可用于檢測探測或?攻擊,包括但不限于操作系統指紋嘗試、通用網關接口、緩沖區溢出、服務器消息塊探測和隱形端口掃描。
本文將概述如何在您的CentOS 專用服務器上安裝和配置 Snort 。您可以修改這些說明以相應地在其他發行版上安裝 Snort。在本文的最后,我們將引導您完成一些基本的 Snort 命令以幫助您入門。
為 Linux 安裝 Snort
安裝 yum epel repo:
yum install -y epel-release
安裝所需的依賴項:
yum install -y wget gcc flex bison zlib zlib-devel libpcap libpcap-devel pcre pcre-devel tcpdump mysql mysql-server mysql-devel git libtool curl man libdnet libdnet-devel
安裝取證工具 repo:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.`uname -m`.rpm
rpm -Uhv rpmforge-release-0.5.3-1.el6.rf.`uname -m`.rpm
百勝安裝 centos-release-scl
rpm -Uvh https://forensics.cert.org/cert-forensics-tools-release-el6.rpm
安裝 Snort:
yum install –y snort
在 Snort.org 上創建一個帳戶并將規則下載到您的專用服務器。
將規則提取到 snort 配置文件夾:
tar -xvf community-rules.tar -C /etc/snort/rules
tar -xvf snortrules-snapshot-2962.tar.gz -C /etc/snort/rules
tar -xvf snortrules-snapshot-2975.tar.gz -C /etc/snort/rules
tar -xvf snortrules-snapshot-2976.tar.gz -C /etc/snort/rules
tar -xvf snortrules-snapshot-2980.tar.gz -C /etc/snort/rules
修復權限:
cd /etc/snort
觸摸 /etc/snort/rules/rules/white_list.rules
觸摸 /etc/snort/rules/rules/black_list.rules
chown -R 鼻息:鼻息 *
mkdir /usr/local/lib/snort_dynamicrules
編輯 snort 的配置:
因為 /etc/snort/rules/etc/snort.conf
ipvar HOME_NET YOUR_NETWORK_HERE
ipvar EXTERNAL_NET !$HOME_NET
使用以下命令測試配置:
snort -T -i eth0 -u snort -g snort -c /etc/snort/rules/etc/snort.conf
在 init.d 腳本中更改配置:
vim /etc/sysconfig/snort
接口=您的_INTERFACE_HERE
CONF=/etc/snort/rules/etc/snort.conf
開始打鼾:
/etc/init.d/snort 啟動
如何安裝和配置pullpork
Pulledpork 是一種與 Snort 結合使用的工具,可自動下載最新規則并使您的 Windows 專用服務器與 Snort 保持最新。
安裝必要的依賴項:
yum -y install perl-libwww-perl perl-Crypt-SSLeay perl-Archive-Tar
下載并安裝pullpork:
wget https://pulledpork.googlecode.com/files/pulledpork-0.7.0.tar.gz
tar -zxf pullpork-0.7.0.tar.gz
cd pullpork-0.7.0
cp pullpork.pl /usr/sbin ;?chmod 755 /usr/sbin/pulledpork.pl
cp etc/* /etc/snort/
如何配置pullpork
訪問 snort.org 并注冊一個帳戶以獲取您的 oinkcode。
編輯 pullpork 配置文件:
vim?/?etc?/snort/pullpork.conf?_
rule_url=?https://www.snort.org/reg-rules/|snortrules-snapshot.tar.gz|d30f456401a96924b902ea384d358fcf2290315e
rule_url=?https://www.snort.org/reg-rules/|opensource.gz|d30f456401a96924b902ea384d358fcf2290315e
rule_path?=?/?etc?/snort/rules/rules/snort.rules
out_path?=/?etc?/snort/rules/rules
local_rules?=?/?etc?/snort/rules/rules/local.rules
sid_msg?=/?etc?/snort/?sid-msg.map
config_path?=/?etc?/snort/rules/?etc?/?snort.conf
發行版=?Centos-5-4
snort_control?=/?usr?/bin/?snort_control
IPRVersion?=/?etc?/snort/rules/rules/?iplists
運行拉豬肉:
pullpork.pl –?vv?-c /?etc?/snort/pullpork.conf?-T?-l
將 pullpork 添加到 crontab 以每天運行:
01 04 * * * /usr/sbin/pulledpork.pl -c?/?etc?/snort/pulledpork.conf?-l
如何在 Linux 上使用 Snort?
Snort 可以配置為三種主要模式:嗅探器、數據包記錄器和網絡入侵檢測。在嗅探器模式下,程序將讀取網絡數據包并顯示在控制臺上。在數據包記錄器模式下,程序會將數據包記錄到磁盤。在入侵檢測模式下,程序將監控網絡流量并根據用戶定義的規則集對其進行分析。然后程序將根據已識別的內容執行特定操作。
Snort 相當容易使用,但有很多命令,而且并不總是清楚哪些選項可以很好地協同工作。以下是一些幫助您入門的示例。
嗅探器模式
將 TCP/IP 數據包頭打印到屏幕上:
./打鼾 -v
顯示傳輸中的應用程序數據:
./打鼾 -?vd
顯示數據鏈路層標頭:
./打鼾 -?vde
數據包記錄器模式
通過指定日志位置,Snort 將進入數據包記錄器模式:
./?snort -dev -l ./log
為了相對于家庭網絡進行日志記錄,您需要告訴 Snort 哪個網絡是家庭網絡:
./?snort -dev -l ./log -h 192.168.1.0/24
對于高速和流量網絡,建議以二進制模式登錄:
./snort?-l ./log –b
如果您想通過 Snort 以嗅探器模式運行二進制日志文件以將數據包轉儲到屏幕:
./?snort -dv -r packet.log
網絡入侵檢測模式
要啟用網絡入侵檢測 (NIDS) 模式并查看其工作方式:
./?snort -dev -l ./log -h 192.168.1.0/24 -c?snort規則.conf
對于長期使用 Snort,請刪除 v 和 e 標志以加快操作:
./snort -d -h 192.168.1.0/24 -l ./log -c snort.conf
這些是基本命令。Snort.org 提供了所有可用命令及其用法的詳盡匯編。