歡迎您光臨本站 註冊首頁

RHS333-11 入侵檢測

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

Linux入侵檢測

一、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 #掃描網段

三、檢查文件是否修改

1md5sum通過檢查文件的

hash值變化

[root@station2 ~]# md5sum install.log

7d0c76c92baf8ec23714e38d99ad48f7 install.log

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

[root@station2 ~]# md5sum install.log

470d4cd0bbfe77613ecb614fd02e86e0 install.log

2tripwire

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檢測對系統管理文件的任何修改,

AIDETripware的替代品.它提供簡便的配置和詳細的報表.

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

#掛載備份鏡像

六、後面檢測

1lsof:檢查打開的文件

2fuser:檢查使用文件的進程,並對其處理

[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

本文出自 「netsword.blogchina.com」 博客,請務必保留此出處http://netsword.blog.51cto.com/13993/536091


[火星人 ] RHS333-11 入侵檢測已經有227次圍觀

http://coctec.com/docs/linux/show-post-49064.html