AIDE的使用规则配置

AIDE介绍

1.功能:高级入侵检测环境,用来检测文件的完整性,审计计算的那些文件被更改过
2.建议不检测的文件:日志文件、邮件、/proc文件系统、用户起始目录以及临时目录;因为这些文件的数据,总是在变动,没有必要放进AIDE的检测规则
3.工作原理:事先定义样板库(配置文件aide.conf)能够保存各种属性比如时间、节点、权限、用户和组等等,在更新所配置的文件数据库;文件数据库在于实际库所比较,生成一份监控报告

在这里插入图片描述

AIDE的配置规则文件(核心)

	这只是一个简单的案列,具体要监控什么的属性和文件,根据实际的生产需求来实现
[root@A ~]# cp /etc/aide.conf /etc/aide.conf.bak       #对配置文件修改前建议备份
[root@A ~]# vim /etc/aide.conf                 #编辑配置文件
#Example configuration file for AIDE.	#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      #数据库文件
 
#The location of the database to be written.	要写入的数据库的位置
#database_out=sql:host:port:database:login_name:passwd:table
#database_out=file:aide.db.new
database_out=file:@@{DBDIR}/aide.db.new.gz   	#数据库输出=文件:@@{DBDIR}/新助手数据库.gz点
 
#Whether to gzip the output to database	#是否将输出gzip到数据库
gzip_dbout=yes
 
#Default.
verbose=5
 
report_url=file:@@{LOGDIR}/aide.log		#日志文件
report_url=stdout
#report_url=stderr
#NOT IMPLEMENTED report_url=mailto:root@foo.com
#NOT IMPLEMENTED report_url=syslog:LOG_AUTH
 
#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		# 检查seliunx
#xattrs:        Extended file attributes			#扩展文件属性
#md5:    md5 checksum       #md5校验
#sha1:   sha1 checksum      # sha1校验
#sha256:        sha256 checksum     #sha256校验
#sha512:        sha512 checksum     #sha512校验
#rmd160: rmd160 checksum        #rmd160校验
#tiger:  tiger checksum     #tiger校验
#rmd160: rmd160 checksum        #rmd160校验
#tiger:  tiger checksum     #tiger校验
 
#haval:  haval checksum (MHASH only)    # haval校验   
#gost:   gost checksum (MHASH only) # gost校验
#crc32:  crc32 checksum (MHASH only)    # crc32校验
#whirlpool:     whirlpool checksum (MHASH only) 
 
#R:             p+i+n+u+g+s+m+c+acl+selinux+xattrs+md5
#L:             p+i+n+u+g+acl+selinux+xattrs
#E:             Empty group
#>:             Growing logfile p+u+g+i+n+S+acl+selinux+xattrs
 #####下面是系统配置的案列,仅供参考
#You can create custom rules like this.  #您可以创建这样的自定义规则
#With MHASH...
#ALLXTRAHASHES = sha1+rmd160+sha256+sha512+whirlpool+tiger+haval+gost+crc32
ALLXTRAHASHES = sha1+rmd160+sha256+sha512+tiger
#Everything but access time (Ie. all changes)
EVERYTHING = R+ALLXTRAHASHES
 
#Sane, with multiple hashes
#NORMAL = R+rmd160+sha256+whirlpool
NORMAL = R+rmd160+sha256
 
#For directories, don't bother doing hashes   
DIR = p+i+n+u+g+acl+selinux+xattrs
 
#Access control only
PERMS = p+i+u+g+acl+selinux
 
#Logfile are special, in that they often change
LOG = >
 
#Just do md5 and sha256 hashes
LSPP = R+sha256
 
#Some files get updated automatically, so the inode/ctime/mtime change
#but we want to know when the data inside them changes
DATAONLY =  p+n+u+g+s+acl+selinux+xattrs+md5+sha256+rmd160+tiger
 ######自己的定的规则
 
TEST = p+u+g+sha512+m+a+c        #自定义规则监控:权限+所有者+所属组+sha512+修改时间+访问时间+改变时间
/data/app TEST        #定义/app目录使用规则 mon
!/app/f3        #但是/app目录下的f3文件不监控,“!”表示忽略这个文件的检查

简单的案列

[root@localhost app]# ll
total 12
-rw-r----- 1 root root   2 Jul  9 12:39 f1
-rw-r--r-- 1 root root 692 Jul  9 12:23 f2
-rwxrwxrwx 1 root root   4 Jul  9 12:42 f3
[root@localhost app]# aide --init         #初始化默认的AIDE库

AIDE, version 0.15.1

### AIDE database at /var/lib/aide/aide.db.new.gz initialized.  # 所在成数据库的位置和名字

[root@localhost app]# cd /var/lib/aide
[root@localhost aide]# ls
aide.db.new.gz
[root@localhost aide]# mv aide.db.new.gz aide.db.gz    # 改名
[root@localhost aide]# ls
aide.db.gz 
[root@localhost aide]# aide --check   # 进去比较
AIDE, version 0.15.1
### All files match AIDE database. Looks okay!


##针对咋配置文件配置的逻辑规则,来修改f1,f2,f3 在比较 

[root@localhost aide]# aide --update   # 更新数据看
AIDE, version 0.15.1
### All files match AIDE database. Looks okay!
### New AIDE database written to /var/lib/aide/aide.db.new.gz

[root@localhost aide]# ls
aide.db.gz  (aide.db.new.gz)更新后新生成的数据库

## 对文件的权限和内容进行修改

[root@localhost aide]# cd /data/app
[root@localhost app]# chmod 300 f1
[root@localhost app]# ls
f1  f2  f3
[root@localhost app]# chmod 300 f2
[root@localhost app]# chmod 300 f3
[root@localhost app]# echo " " > f1
[root@localhost app]# echo " " > f3

## 开始对比,先把名字改了 

[root@localhost aide]# ls
aide.db.gz  aide.db.new.gz
[root@localhost aide]# mv aide.db.new.gz aide.db.gz
mv: overwrite ‘aide.db.gz’? y
[root@localhost aide]# aide --check   # 比对命令


所生成的数据报告
AIDE 0.15.1 found differences between database and filesystem!!
Start timestamp: 2020-07-09 15:45:15

Summary:
  Total number of files:	4
  Added files:			0
  Removed files:		0
  Changed files:		1


---------------------------------------------------
Changed files:
---------------------------------------------------

changed: /data/app/f3

---------------------------------------------------
Detailed information about changes:
---------------------------------------------------


File: /data/app/f3
 Size     : 4                                , 2
 Perm     : -rwxrwxrwx                       , --wx------   #(所修改的权限)
 MD5      : 5Cu4l9CvzbHxxG+14MGtIg==         , 14T6i22Y0naZeBvZp88Z8A==  (修改内容,不会显示具体修改了什么内容,只会显示hash值变了)

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值