1. AIDE AIDE (Advanced Intrusion Detection Environment) is a program that performs integrity checks on files and directories. It was developed as a replacement for Tripwire. How AIDE works AIDE constructs an integrity sample library (snapshot) of specified files as a comparison standard. When these files are changed, their corresponding checksum values will inevitably change accordingly. AIDE can identify these changes and alert the administrator. The attribute changes monitored by AIDE mainly include: permissions, owner, group, file size, creation time, last modification time, last access time, increased size and number of links, and can use algorithms such as SHA1 and MD5 to generate verification codes for each file. This tool is quite old, and compared to similar tools like Tripwire, it is also simpler to operate. It needs to take a snapshot of the system, record the HASH value, modification time, and the administrator's preprocessing of the file. This snapshot allows administrators to build a database and then store it on an external device for safekeeping. Features of AIDE
[root@centos7 ~]$ yuminstall-y aide Install AIDE Download: http://sourceforge.net/projects/aide yum install aide vi /etc/aide.conf database=file:@@{DBDIR}/aide.db.gz #System image library location database_out=file:@@{DBDIR}/aide.db.new.gz #Newly generate system image library, by default in /var/lib/aide/# Next decide what directories/files you want in the database. /boot NORMAL /bin NORMAL /sbin NORMAL /lib NORMAL /lib64 NORMAL #/opt NORMAL #Comment not to check directory /usr NORMAL /root NORMAL # These are too volatile, exclude individual directories that are not checked!/usr/src !/usr/tmp #Add a new detection directory /etc/exports NORMAL below according to requirements /etc/fstab NORMAL /etc/passwd NORMA Detailed explanation of the configuration file#Defines the variables of the database path and the log path
# Enable compression gzip_dbout=yes # Define multiple permissions as rules and assign them to variables for later reference
# Which rules are used to monitor which files
# Files not to be monitored !/etc/.*~ #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 Defining Rules Edit the configuration file /etc/adie.conf, define a rule variable mon, monitor all files in the /app directory, and do not monitor /app/saomiao.log. [root@centos7 aide]$ vim /etc/aide.conf mon = p+u+g+sha512+m+a+c /appmon !/app/juli.sh Create a database Generate a database file, define the checksums for each file in the configuration file, and put them into the database for later comparison. From the prompt, we can see that a /var/lib/aide/aide.db.new.gz database file is generated. This database file is the initial database. If intrusion detection is performed, it will be compared with the /var/lib/aide/aide.db.gz database file. If the two databases are inconsistent, it will be prompted that there is an intrusion. [root@centos7 aide]$aide --init AIDE, version 0.15.1 ### AIDE database at /var/lib/aide/aide.db.new.gz initialized. Simulate files being hacked and changed Simulation files are modified: Add newlines to saomiao.sh file, prompting changes to checksum, Mtime, Ctime [root@centos7 aide]$ echo >> /app/saomiao.sh Detection: AIDE's detection mechanism is to calculate the current database and compare it with aide.db.gz. aide.db.gz does not exist by default, so you need to rename the previously created initialization database aide.db.new.gz to aide.db.gz. [root@centos7 aide]$mv aide.db.new.gz aide.db.gz Intrusion Detection Finally, use aide -C, note that it is capitalized, to compare the calculated data with aide.db.new.gz, and check whether the Mtime and Ctime SHA512 of the saomiao.sh file have been changed. Set up task schedule and conduct regular inspections
You can also send information to email: 30 08 * * * /usr/sbin/aide --check| mail –s “AIDE report“ [email protected] 2. RKHunter RKHunter is a tool that is specifically designed to detect whether a system is infected with rootkits. It automatically executes a series of scripts to comprehensively detect whether the server is infected with rootkits. Features of RKHunter
Install [root@centos7 aide]$yum install rkhunter Detection Run the rkhunker -c command to test the system. RKHunter detection is divided into several parts. The first part mainly detects binary tools of the system, because these tools are the primary infection targets of rootkits. After each test, you need to press Enter to confirm. [ ok ] means no abnormality [ no found ] means the tool was not found, ignore it [ warning ] If it is a red warning, you need to further confirm whether these tools are infected or replaced. Set up task schedule and conduct regular inspections
You can also send information to email: 2. RKHunter RKHunter is a tool that is specifically designed to detect whether a system is infected with rootkits. It automatically executes a series of scripts to comprehensively detect whether the server is infected with rootkits. Features of RKHunter
Install [root@centos7 aide]$yum install rkhunter Detection Run the rkhunker -c command to test the system. RKHunter detection is divided into several parts. The first part mainly detects binary tools of the system, because these tools are the primary infection targets of rootkits. After each test, you need to press Enter to confirm.
If you want the program to detect automatically instead of asking the user to confirm after each detection, you can use rkhunter --check --skip-keypress At the same time, if you want to achieve weekly or monthly automatic detection, you can add it to the scheduled task for automatic execution
The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: What are the advantages of MySQL MGR?
>>: Detailed explanation of the use of Vue.js render function
This article example shares the specific code of ...
Table of contents 1. Installation 2. Import into ...
Phrase elements such as <em></em> can ...
1. Always close HTML tags In the source code of p...
Table of contents 1. parse 1.1 Rules for intercep...
This article uses examples to illustrate the diff...
Open Source Database Architecture Design Principl...
CSS adds scrolling to div and hides the scroll ba...
Have you ever had the need to compute a very larg...
Forwarding between two different servers Enable p...
Problem Description As we all know, when writing ...
<br />The header refers to the first row of ...
The code looks like this: SELECT @i:=@i+1 rowNum,...
Nowadays we often talk about Web2.0, so what is W...
1. Introduction The requirement is to obtain the ...