RHS333-11 入侵检测推荐

一、iptables实现日志记录网络流量

[root@station2 aide]# iptables -A INPUT -p tcp –dport 80 -j LOG –log-prefix= 80

[root@station2 aide]# tail /var/log/messages

Apr 5 23:23:35 station2 kernel: 80IN=eth0 OUT= MAC=54:52:00:67:6f:33:00:18:8b:7c:67:87:08:00 SRC=192.168.32.221 DST=192.168.32.32 LEN=353 TOS=0x00 PREC=0x00 TTL=127 ID=3155 DF PROTO=TCP SPT=56663 DPT=80 WINDOW=4420 RES=0x00 ACK PSH URGP=0

Apr 5 23:23:35 station2 kernel: 80IN=eth0 OUT= MAC=54:52:00:67:6f:33:00:18:8b:7c:67:87:08:00 SRC=192.168.32.221 DST=192.168.32.32 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=3156 DF PROTO=TCP SPT=56663 DPT=80 WINDOW=4302 RES=0x00 ACK URGP=0

Apr 5 23:23:35 station2 kernel: 80IN=eth0 OUT= MAC=54:52:00:67:6f:33:00:18:8b:7c:67:87:08:00 SRC=192.168.32.221 DST=192.168.32.32 LEN=40 TOS=0x00 PREC=0x00 TTL=127 ID=3157 DF PROTO=TCP SPT=56663 DPT=80 WINDOW=4302 RES=0x00 ACK FIN URGP=0

二、开发端口监控

1、本地监控:netstat

[root@station2 ~]# netstat -tulpn #监控端口开放

[root@station2 ~]# netstat -tupn #监控活动链接

2、远程监控:nmap (gui工具:nmapfe)

[root@station2 ~]#nmap -P0 station3.example.com #扫描主机

[root@station2 ~]#nmap -sV 192.168.32.0/24 #扫描网段

三、检查文件是否修改

1、md5sum(通过检查文件的hash值变化)

[root@station2 ~]# md5sum install.log

7d0c76c92baf8ec23714e38d99ad48f7 install.log

[root@station2 ~]# echo 1111 install.log

[root@station2 ~]# md5sum install.log

470d4cd0bbfe77613ecb614fd02e86e0 install.log

2、tripwire

3、rpm

[root@station2 ~]# rpm -Vf /etc/hosts.allow

S.5….T c /etc/aliases

S.5….T c /etc/printcap

# S :file Size differs

M :Mode differs (includes permissions and file type)

5 :MD5 sum differs

D :Device major/minor number mismatch

L :readLink(2) path mismatch

U :User ownership differs

G :Group ownership differs

四、aide(高级入侵检测环境)

AIDE检测对系统管理文件的任何修改,AIDE是Tripware的替代品。它提供简便的配置和详细的报表。

1、安装

[root@station2 ~]# yum install aide

2、修改配置文件/etc/aide.conf,指定要求检查的系统文件

[root@station2 ~]# vi /etc/aide.conf

3、生成检查数据库

[root@station2 ~]# aide -i

AIDE, version 0.13.1

### AIDE database at /var/lib/aide/aide.db.new.gz initialized.

[root@station2 ~]# cp /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

#生成入侵检测数据库/var/lib/aide/aide.new.db.gz,必须修改成aide.db.gz。aide的数据库是aide.db.gz,默认生成aide.new.db.gz是为了避免更新时覆盖原数据库。

4、测试

[root@station2 ~]# echo vsftpd: All: 192.168.32.33 /etc/hosts.allow

[root@station2 ~]# aide –check

File: /etc/hosts.allow

Mtime : 2011-04-05 22:31:05 , 2011-04-05 23:47:00

Ctime : 2011-04-05 22:31:05 , 2011-04-05 23:47:00

Inode : 7458581 , 7458490

MD5 : cX97u2rExsuNyiOLdj/8vw== , yq5XmgvQaEMfuR6STPPKVw==

RMD160 : bX8Xnn90YGotaxpN/nsHQTBM+W0= , r3Sb2RlBnZI38i4IyuWaVpurHk4=

SHA256 : BD7vdNOGmxiFuhEvG87Y3ysbdJeHnIUU , vYwvU0mVeqI6ynTu2t8zqto9z5d6iE2q

#检测显示/etc/hosts.allow被修改

五、磁盘备份镜像

[root@station2 ~]#dd if=/dev/hdd of=/home/image-hdd.img bs=1k conv=noerror,sync

#conv=noerror:出现磁盘错误不停止备份,sync不同内存直接备份,加快备份速度

[root@station2 ~]#$mount -o loop /home/image-hadd.img /mnt

#挂载备份镜像

六、后面检测

1、lsof:检查打开的文件

2、fuser:检查使用文件的进程,并对其处理

[root@station2 ~]# fuser /usr/sbin/saslauthd #查看运行文件的进程

/usr/sbin/saslauthd: 26360e 26361e 26362e 26363e 26365e

[root@station2 ~]# fuser -k /usr/sbin/saslauthd #关闭运行文件的进程

/usr/sbin/saslauthd: 26360e 26361e 26362e 26363e 26365e

[root@station2 ~]# fuser /usr/sbin/saslauthd

君子无故,玉不去身。

RHS333-11 入侵检测推荐

相关文章:

你感兴趣的文章:

标签云: