AIDE

AIDE

	当一个入侵者进入了你的系统并且种植了木马,通常会想办法来隐蔽这个木马(除了木马自身的一些隐蔽特性外,他会尽量给你检查系统的过程设置障碍)。
	通常入侵者会修改一些文件,比如管理员通常用ps -aux 来查看系统进程,那么入侵者很可能用自己经过修改的ps 程序来替换掉你系统上的ps 程序,以使用ps 命令查不到正在运行的木马程序。如果入侵者发现管理员正在运行crontab 作业,也有可能替换掉crontab程序等等。
	所以由此可以看出对于系统文件或是关键文件的检查是很必要的。
	目前就系统完整性检查的工具用的比较多的有两款:Tripwire 和AIDE,前者是一款商业软件,后者是一款免费的但功能也很强大的工具。
	
	AIDE(Adevanced Intrusion Detection Environment),高级入侵检测环境,是一个入侵检测工具,主要用途是检查文件的完整性,审计计算机上的那些文件被更改过了。
	AIDE 能够构造一个指定文件的数据库,它使用aide.conf 作为其配置文件。
	AIDE 数据库能够保存文件的各种属性,包括:权限(permission) 、索引节点序号(inode number) 、所属用户(user)、 所属用户组(group) 、文件大小、最后修改时间(mtime) 、创建时间(ctime) 、最后访问时间(atime) 、增加的大小以及连接数。
	AIDE还能够使用下列算法:sha1 、md5 、rmd160 、tiger ,以密文形式建立每个文件的校验码或散列号。
	这个数据库不应该保存那些经常变动的文件信息,例如:日志文件、邮件、/proc 文件系统、用户起始目录以及临时目录.
	
	安装
		yum install aide
	
	aide
		aide - Advanced Intrusion Detection Environment
		aide [parameters] command
		Commands:
			-i, --init			Initialize the database
			-C, --check			Check the database
			-u, --update			Check and update the database non-interactively
			--compare			Compare two databases
		Miscellaneous:
			-D, --config-check		Test the configuration file
			-v, --version			Show version of AIDE and compilation options
			-h, --help			Show this help message
		Options:
			-c [cfgfile]	--config=[cfgfile]		Get config options from [cfgfile]
			-B "OPTION"	--before="OPTION"		Before configuration file is read define OPTION
			-A "OPTION"	--after="OPTION"		After configuration file is read define OPTION
			-r [reporter]	--report=[reporter]		Write report output to [reporter] url
			-V[level]	--verbose=[level]		Set debug message level to [level]
			
	
	修改配置文件
		vim /etc/aide.conf ( 指定对哪些文件进行检测)
			/test/chameleon 	R
			/bin/ps 	R+a
			/usr/bin/crontab 	R+a
			/etc 	PERMS
			!/etc/mtab 	# “!” 表示忽略这个文件的检查
			R=p+i+n+u+g+s+m+c+md5  	权限+ 索引节点+ 链接数+用户+ 组+ 大小+ 最后一次修改时间+ 创建时间+md5 校验值
			NORMAL = R+rmd60+sha256	
	初始化默认的AIDE 的库:
		/usr/local/bin/aide --init
	生成检查数据库(建议初始数据库存放到安全的地方)
		cd /var/lib/aide
		mv aide.db.new.gz aide.db.gz
	检测:
		/usr/local/bin/aide --check
	更新数据库
		aide --update
原文地址:https://www.cnblogs.com/shenxm/p/8451509.html