方法1:下载libdnet进行源码编译安装,文件上面网盘有下载,下面为操作步骤:
cd /usr/local/src/libdnet-1.xx
./configure –with-pic
make
make install
cd /usr/local/lib
ldconfig –v /usr/local/lib 别忘了,容易忽略
可能会出以下错误:
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
解决办法:
yum install glibc-headers gcc-c++
修改/etc/snort/snort.conf配置文件,参考如下:
# such as: c:\snort\rules
var RULE_PATH /etc/snort/rules
var SO_RULE_PATH /etc/snort/so_rules
var PREPROC_RULE_PATH /etc/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 /etc/snort/rules
var BLACK_LIST_PATH /etc/snort/rules
尝试启动snort –c /etc/snort/snort.conf,会报如下错误:
ERROR: snort.conf(253) Could not stat dynamic module path "/usr/local/lib/snort_dynamicrules": No such file or directory. Fatal Error, Quitting.
解决办法:
mkdir -p /usr/local/lib/snort_dynamicrules
chown -R snort:snort /usr/local/lib/snort_dynamicrules
chmod -R 700 /usr/local/lib/snort_dynamicrules
规则添加:(很重要)
发现2.9.8这个版本下载后,rules目录下有些策略默认是空的,比如/etc/snort/rules/scan.rules
# to the VRT Certified Rules License Agreement (v2.0).
#
#------------
# SCAN RULES
#------------
需要我们自己完善,这些规则可以参考其他人写的,完善到自己的snort rules中
https://github.com/eldondev/Snort/blob/master/rules/scan.rules
2、检测nmap类扫描规则: -> /etc/snort/rules/scan.rules
alert tcp any any -> any any (msg:"SYN FIN Scan"; flags: S;sid:9000000;)
alert tcp any any -> any any (msg:"FIN Scan"; flags: F;sid:9000001;)
alert tcp any any -> any any (msg:"NULL Scan"; flags: 0;sid:9000002;)
alert tcp any any -> any any (msg:"XMAS Scan"; flags: FPU;sid:9000003;)
alert tcp any any -> any any (msg:"Full XMAS Scan"; flags: SRAFPU;sid:9000004;)
alert tcp any any -> any any (msg:"URG Scan"; flags: U;sid:9000005;)
alert tcp any any -> any any (msg:"URG FIN Scan"; flags: FU;sid:9000006;)
alert tcp any any -> any any (msg:"PUSH FIN Scan"; flags: FP;sid:9000007;)
alert tcp any any -> any any (msg:"URG PUSH Scan"; flags: PU;sid:9000008;)
alert tcp any any -> any any (flags: A; ack: 0; msg:"NMAP TCP ping!";sid:9000009;)
3、检测一句话(中国菜刀webshell)规则:-> /etc/snort/rules/local.rules
alert tcp any any -> any 80 (msg:"China Chopper PHP/Backdoor Detected"; content:"|62 61 73 65 36 34 5f 64 65 63 6f 64 65|"; rawbytes;reference:url,http://www.fireeye.com/blog/technical/botnet-activities-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html; classtype:trojan-activity; sid:500007; rev:1;)
alert tcp any any -> any 80 ( sid:900001; content:"base64_decode";http_client_body;flow:to_server,established; content:"POST"; nocase;http_method;msg:"Webshell Detected Apache";)
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg: "China Chopper with first Command Detected";flow:to_server,established; content: "FromBase64String";content: "z1"; content:"POST"; nocase;http_method;reference:url,http://www.fireeye.com/blog/technical/botnet-activities-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html;classtype:web-application-attack; sid: 900000101;)
一般攻击日志,导出csv格式就可以了,纪录的也不是很详细,丢数据库个人觉得意义不是特大,自己结合实际情况吧。
导出csv方法:
vim /etc/snort/snort.conf
output alert_csv: /var/log/snort/alert.csv msg,proto,timestamp,src,srcport,dst,dstport
0x3、snort与iptables联动,升级为IPS
Step 1 :
Go to http://www.chaotic.org/guardian/ to download Guardian. The current version as at this writing is version 1.7.
wget http://www.chaotic.org/guardian/guardian-1.7.tar.gz
Step 2 :
Untar the package.
tar -xzvf guardian-1.7.tar.gz
Step 3 :
cd guardian-1.7
cp guardian.pl /usr/local/bin/
cp scripts/iptables_block.sh /usr/local/bin/guardian_block.sh
cp scripts/iptables_unblock.sh /usr/local/bin/guardian_unblock.sh
cp guardian.conf /etc/snort/
touch /etc/snort/guardian.ignore
touch /etc/snort/guardian.target
touch /var/log/snort/guardian.log
Step 4 :
vi /etc/snort/guardian.conf
Make the file looks like this (the IP address of HostIpAddr may be different from yours).
HostIpAddr取消注释,写自己eth0 ip地址
Step 5:
Vim /etc/snort/guardian.target
将步骤4中监听的eth0 ip地址写进来,这里别落下了,网上已有文章,这里是个坑,导致关联有问题
Step 6:
Vim /etc/snort/snort.conf注释掉output alert_syslog:LOG_AUTH LOG_ALERT,至于下一行的需不需要output alert_csv结合自己需要。