2025年AIDE的使用规则配置

AIDE的使用规则配置AIDE 介绍 1 功能 高级入侵检测环境 用来检测文件的完整性 审计计算的那些文件被更改过 2 建议不检测的文件 日志文件 邮件 proc 文件系统 用户起始目录以及临时目录 因为这些文件的数据 总是在变动 没有必要放进 AIDE 的检测规则 3 工作原理

大家好,我是讯享网,很高兴认识大家。

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值变了) 
小讯
上一篇 2025-01-11 10:24
下一篇 2025-01-15 08:05

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/82670.html