# Intrusion detection on Gentoo with AIDE
Reading time: 2 minutes
Description: Local intrusion detection with AIDE (Advanced Intrusion Detection Environment) on Gentoo Linux
# AIDE Setup
Reference:
## 1. Installation
### 1.1 Available USE flags (as of 20.09.2023):
Flag | Description |
---|---|
acl | Add support for Access Control Lists |
audit | Enable support for Linux audit subsystem using sys-process/audit |
curl | Use curl for http,https and ftp backends |
e2fs | Enable support for checking file attributes on ext2/ext3/ext4 filesystems |
mhash | Add support for the mhash library |
xattrs | Add support for extended attributes (filesystem-stored metadata) |
### 1.2 emerge aide
|
|
## 2. Configuration
Reference: Gentoo Wiki (config section)
The best thing would be to read either the Gentoo Wiki, man page of aide or the actual documentation, since AIDE is heavily dependant of the individual system.
But the default config should be enough if you just want a quick setup to poke around.
### Adding custom rules
As a quick reference:
Short | Description |
---|---|
p | Permissions |
i | inode number |
n | Number of (hard)links |
u | User information |
g | Group information |
s | Size |
S | Size (only report when the size is suddenly smaller - growing is allowed) |
b | Block count |
m | Modification time |
sha256 | sha256 checksum |
rmd160 | rmd169 checksum |
<more available, check the man page and default config> |
The default ruleset on Gentoo is:
|
|
This weird p+i+...
string essentialy defines what options AIDE should check in each rule.
So for example, every folder tagged with the Logs
rule would be checked against it’s:
- file permissions (
p
) - inode number (
i
) - number of links (
n
) - user information (
u
) - group information (
g
) - size (
S
)
To add a new folder, simply append the following to the configuration file:
|
|
Again taking a log folder as example, which would check /var/log
against the Logs
rule:
|
|
# Hooking into the emerge process
Create/Edit the following file to automatically update AIDE’s database after each portage install, update or removal job.
/etc/portage/bashrc
|
|