AIDE 概念:
AIDE:Advanced Intrusion Detection Environment,是一款入侵检测工具,主要用途是检查文档的完整性。AIDE在本地构造了一个基准的数据库,一旦操做系统被入侵,能够经过对比基准数据库而获取文件变动记录,使用aide.conf做为其配置文档。AIDE数据库可以保存文档的各类属性,包括:权限(permission)、索引节点序号(inode number)、所属用户(user)、所属用户组(group)、文档大小、最后修改时间(mtime)、建立时间(ctime)、最后访问时间(atime)、增长的大小连同链接数。AIDE还可以使用下列算法:sha一、md五、rmd160、tiger,以密文形式创建每一个文档的校验码或散列号。 node
安装:
[root@ecs-proxy ~]# yum -y install aidelinux
能够根据需求修改配置文件对指定的文件进行检测算法
[root@ecs-proxy ~]# vim /etc/aide.conf数据库
# Example configuration file for AIDE. @@define DBDIR /var/lib/aide //数据库目录 @@define LOGDIR /var/log/aide //日志目录 # The location of the database to be read. database=file:@@{DBDIR}/aide.db.gz //数据文件 ... # These are the default rules. //默认规则 # #p: permissions #i: inode: #n: number of links #u: user #g: group #s: size #b: block count #m: mtime #a: atime #c: ctime #S: check for growing size #acl: Access Control Lists #selinux SELinux security context #xattrs: Extended file attributes #md5: md5 checksum #sha1: sha1 checksum #sha256: sha256 checksum #sha512: sha512 checksum #rmd160: rmd160 checksum #tiger: tiger checksum #haval: haval checksum (MHASH only) #gost: gost checksum (MHASH only) #crc32: crc32 checksum (MHASH only) #whirlpool: whirlpool checksum (MHASH only) FIPSR = p+i+n+u+g+s+m+c+acl+selinux+xattrs+sha256 //对多个规则进行定义 方便使用 ... # matches. e.g. Put file matches before directories. /boot/ CONTENT_EX //目录 校验规则 /bin/ CONTENT_EX /sbin/ CONTENT_EX /lib/ CONTENT_EX /lib64/ CONTENT_EX /opt/ CONTENT # Admin's dot files constantly change, just check perms. /root/\..* PERMS # Otherwise get all of /root. /root/ CONTENT_EX # These are too volatile. !/usr/src/ //使用!表示不校验的目录 !/usr/tmp/ # Otherwise get all of /usr. /usr/ CONTENT_EX
初始化数据库
[root@ecs-proxy ~]# aide -i //初始化vim
AIDE, version 0.15.1安全
### AIDE database at /var/lib/aide/aide.db.new.gz initialized.ide
注:为了节约实验时间 配置文件只对/etc/passwd文件进行验证工具
[root@ecs-proxy ~]# cd /var/lib/aide/
[root@ecs-proxy aide]# ls
aide.db.new.gz
[root@ecs-proxy aide]# cp aide.db.new.gz aide.db.gz //生产环境确定要拷贝到U盘或其余安全地方 这里为方便测试
[root@ecs-proxy aide]# ls
aide.db.gz aide.db.new.gz
[root@ecs-proxy aide]# aide --check //进行校验 (此时文件没有进行任何改动)测试
AIDE, version 0.15.1spa
### All files match AIDE database. Looks okay! //验证OK
[root@ecs-proxy aide]# useradd oschina //添加用户 模拟异常
[root@ecs-proxy aide]# aide --check //检测
AIDE 0.15.1 found differences between database and filesystem!! //检测到异常
Start timestamp: 2020-04-23 21:57:08
Summary:
Total number of files: 7
Added files: 0
Removed files: 0
Changed files: 2
---------------------------------------------------
Changed files:
---------------------------------------------------
changed: /etc/passwd
changed: /etc/passwd-
---------------------------------------------------
Detailed information about changes:
---------------------------------------------------
File: /etc/passwd
SHA256 : I8k7bYNV4NC/tmL973Wd3V2l5DxgQ+1g , zvNQgkGiCAAiOJRH+8/UObOvxbcwm57S
File: /etc/passwd-
SHA256 : h44uH2sHDZCK7hhesyU0yW2msG3U05Lq , I8k7bYNV4NC/tmL973Wd3V2l5DxgQ+1g
[root@ecs-proxy aide]#
若是文件修改,对AIDE数据库进行更新
aide --update 或 aide -u