基于主机的IDS--AIDE基础使用

snow chuai汇总、整理、撰写—2020/2/28


1. 安装与配置AIDE
1) 安装AIDE工具
[root@srv1 ~]# yum install aide -y
2) AIDE检测权限说明 p:权限 i:i节点 n:连接数量 u:用户 g:用户组 s:大小 xattrs:扩展属性
m:最后一次修改时间 a:最后一次访问时间 c:创建时间 S:检查增加的大小
l:链接名 b:块计算 I:忽略改变的文件 sha1:sha1校验 sha256:sha256校验
sha512:sha512校验 md5:md5校验 crc32:crc32校验 rmd160:rmd160校验
tiger:tiger校验 haval:haval校验 acl:acl检测 selinux:selinux检测
3) 查看/配置AIDE [root@srv1 ~]# vim /etc/aide.conf ...... ...... ...... ...... ...... ......
# 于文档最后添加如下内容 /var/log p+u+g+i+n+acl+selinux+xattrs
4) 初始化AIDE数据库 [root@srv1 ~]# aide --init AIDE, version 0.15.1
### AIDE database at /var/lib/aide/aide.db.new.gz initialized.
6) 将新的数据库作为AIDE数据库 [root@srv1 ~]# cp -p /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
2. 使用AIDE
1) 检测系统环境
[root@srv1 ~]# aide --check
AIDE, version 0.15.1
### All files match AIDE database. Looks okay!# 当前系统环境与数据库记录一致
2) 更改一个文件属性/权限做aide测试 [root@srv1 ~]# ll anaconda-ks.cfg -rw-------. 1 root root 1838 Feb 22 17:40 anaconda-ks.cfg
[root@srv1 ~]# chmod 644 anaconda-ks.cfg [root@srv1 ~]# ll anaconda-ks.cfg -rw-r--r--. 1 root root 1838 Feb 22 17:40 anaconda-ks.cfg
[root@srv1 ~]# aide -C # -C就是--check参数 AIDE 0.15.1 found differences between database and filesystem!! Start timestamp: 2020-02-28 01:14:24
Summary: Total number of files: 57282 Added files: 0 Removed files: 0 Changed files: 1 # 检测到有1个修改的文件

--------------------------------------------------- Changed files: ---------------------------------------------------
changed: /root/anaconda-ks.cfg # 修改的文件名
--------------------------------------------------- Detailed information about changes: ---------------------------------------------------

File: /root/anaconda-ks.cfg Perm : -rw------- , -rw-r--r-- # 修改的信息 ACL : old = A: ---- user::rw- group::--- other::--- ---- D: <NONE> new = A: ---- user::rw- group::r-- other::r-- ---- D: <NONE>
3) 如果确认检测出来的差异是合法的,需要重新生成新的aide数据库 [root@srv1 ~]# aide --update [4/501] AIDE 0.15.1 found differences between database and filesystem!! Start timestamp: 2020-02-28 01:20:56
Summary: Total number of files: 57282 Added files: 0 Removed files: 0 Changed files: 1

--------------------------------------------------- Changed files: ---------------------------------------------------
changed: /root/anaconda-ks.cfg
--------------------------------------------------- Detailed information about changes: ---------------------------------------------------

File: /root/anaconda-ks.cfg Perm : -rw------- , -rw-r--r-- ACL : old = A: ---- user::rw- group::--- other::--- ---- D:<NONE> new = A: ---- user::rw- group::r-- other::r-- ---- D: <NONE>
[root@srv1 ~]# cp -p /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
4) 定期检测并发送检测通知 [root@srv1 ~]# vim /etc/cron.d/aide 00 00 * * * /usr/sbin/aide --update | mail -s 'Daily Check by AIDE' root

 

如对您有帮助,请随缘打个赏。^-^

gold