Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
linux:aide [14.03.2025 10:06. ] – [Datenbank erstellen] django | linux:aide [15.03.2025 09:08. ] (aktuell) – [Konfiguration] /etc/aide.conf aktualisiert django | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Host based Intrusion Detection System mit AIDE unter Arch ====== | + | ====== Host based Intrusion Detection System mit AIDE unter Arch Linux ====== |
===== HIDS - was ist das und wozu nutzt man es? ===== | ===== HIDS - was ist das und wozu nutzt man es? ===== | ||
Die Absicherung von Systemen ist eine der Grund- und Pflichtaufgaben eines jeden verantwortungsbewussten Systemadministrators und Administratorin. Dass dies ist kein einmaliger sondern stetig sich wiederholende Vorgang ist, versteht sich in aller Regel von selbst, so ist es unter anderem wichtig, dass regelmässig Systemüberprüfungen und Überwachung von Logmeldungen auf verdächtige und ungewöhnliche Ereignisse durchgeführt werden müssen. Zur Absicherung von Computersystem existieren unterschiedliche Ansätze. TLS-Transportverschlüsselung, | Die Absicherung von Systemen ist eine der Grund- und Pflichtaufgaben eines jeden verantwortungsbewussten Systemadministrators und Administratorin. Dass dies ist kein einmaliger sondern stetig sich wiederholende Vorgang ist, versteht sich in aller Regel von selbst, so ist es unter anderem wichtig, dass regelmässig Systemüberprüfungen und Überwachung von Logmeldungen auf verdächtige und ungewöhnliche Ereignisse durchgeführt werden müssen. Zur Absicherung von Computersystem existieren unterschiedliche Ansätze. TLS-Transportverschlüsselung, | ||
Zeile 1586: | Zeile 1586: | ||
# sudo vim / | # sudo vim / | ||
- | <file bash / | + | <file bash / |
- | # More information about configuration | + | # Ansible managed |
- | # Inspired from https:// | + | # |
- | + | # ┌──────────────────────────────────────────────────────────────────────┐ | |
- | # ┌───────────────────────────────────────────────────────────────┐ | + | # │ Contents of configuration file aide.conf |
- | # │ CONTENTS OF aide.conf | + | # ├──────────────────────────────────────────────────────────────────────┤ |
- | # ├───────────────────────────────────────────────────────────────┘ | + | # │ |
- | # │ | + | # ├──┬───── 1. |
- | # ├──┐VARIABLES | + | # │ ├───── 1.1 DATABASE |
- | # │ ├── DATABASE | + | # │ └───── 1.2 REPORT |
- | # │ └── REPORT | + | # │ │ |
- | # ├──┐RULES | + | # ├──┬───── 2. |
- | # │ ├── LIST OF ATTRIBUTES | + | # │ ├───── 2.1 LIST OF ATTRIBUTES |
- | # │ ├── LIST OF CHECKSUMS | + | # │ ├───── 2.2 LIST OF CHECKSUMS |
- | # │ └── AVAILABLE RULES | + | # │ └───── 2.3 AVAILABLE RULES │ |
- | # ├──┐PATHS | + | # │ │ |
- | # │ ├──┐EXCLUDED | + | # ├──┬───── 3. |
- | # │ │ ├── ETC | + | # │ ├──┬── 3.1 EXCLUDED |
- | # │ │ ├── USR | + | # │ │ ├── |
- | # │ │ | + | # │ │ ├── |
- | # │ └──┐INCLUDED | + | # │ │ |
- | # │ | + | # │ |
- | # │ | + | # │ └──┬── 3.2. |
- | # │ | + | # │ |
- | # │ | + | # │ |
- | # │ | + | # │ |
- | # └─────────────────────────────────────────────────────────────── | + | # │ |
- | + | # │ | |
- | # ################################################################ | + | # └──────────────────────────────────────────────────────────────────────┘ |
- | + | # | |
- | # ################################ | + | ## 1. |
+ | ## 1.1 DATABASE | ||
@@define DBDIR / | @@define DBDIR / | ||
Zeile 1622: | Zeile 1623: | ||
# The location of the database to be read. | # The location of the database to be read. | ||
- | database_in=file:@@{DBDIR}/aide.db.gz | + | database_in = http://10.0.0.40/ |
# The location of the database to be written. | # The location of the database to be written. | ||
- | # | + | database_out = file: |
- | # | + | |
- | database_out=file: | + | |
- | # Whether to gzip the output to database | + | # Whether to gzip the output to database. |
- | gzip_dbout=yes | + | gzip_dbout = no |
- | # ################################ | + | ## 1.2 REPORT |
- | # Default. | + | # Default |
log_level=warning | log_level=warning | ||
report_level=changed_attributes | report_level=changed_attributes | ||
- | |||
- | report_url=file: | ||
report_url=stdout | report_url=stdout | ||
- | # | + | report_url=syslog: |
- | #NOT IMPLEMENTED report_url=mailto: | + | |
- | #NOT IMPLEMENTED | + | |
- | # ################################################################ | + | ## 2. |
- | + | ## 2.1 LIST OF ATTRIBUTES | |
- | # ############################## | + | |
# These are the default parameters we can check against. | # These are the default parameters we can check against. | ||
- | #p: | + | # p: permissions |
- | #i: | + | # i: inode |
- | #n: | + | # n: number of links |
- | #u: | + | # u: user |
- | #g: | + | # g: group |
- | #s: | + | # s: size |
- | #b: | + | # b: block count |
- | #m: | + | # m: mtime |
- | #a: | + | # a: atime |
- | #c: | + | # c: ctime |
- | #S: | + | # S: check for growing size |
- | #acl: | + | # acl: Access Control Lists |
- | # | + | # selinux |
- | # | + | # (must be enabled at compilation time) |
+ | # xattrs: | ||
- | # ################################ | + | # 2.2 LIST OF CHECKSUMS |
- | #md5: | + | # md5: md5 checksum |
- | # | + | # sha1: |
- | # | + | # sha256: |
- | # | + | # sha512: |
- | # | + | # rmd160: |
- | # | + | # tiger: |
- | # | + | # haval: |
- | # | + | # gost: |
- | # | + | # crc32: |
- | # | + | # whirlpool: |
- | # ################################ | + | # 2.3 AVAILABLE RULES |
# These are the default rules | # These are the default rules | ||
- | #R: | + | # R: p+i+l+n+u+g+s+m+c+md5 |
- | #L: | + | # L: p+i+l+n+u+g |
- | #E: | + | # E: Empty group |
- | #>: | + | # >: Growing logfile p+l+u+g+i+n+S |
+ | |||
+ | # Default compound groups: | ||
+ | # R: l+p+u+g+s+c+m+i+n+md5+acl+xattrs+ftype+e2fsattrs | ||
+ | # L: l+p+u+g+i+n+acl+xattrs+ftype+e2fsattrs | ||
+ | # >: l+p+u+g+s+i+n+acl+xattrs+ftype+e2fsattrs+growing | ||
+ | # H: md5+sha1+rmd160+tiger+crc32+gost+sha256+sha512+whirlpool | ||
+ | # +stribog256+stribog512 | ||
+ | # X: acl+xattrs+e2fsattrs | ||
+ | |||
+ | # You can create custom rules - my home made rule definition goes like this | ||
+ | # ALLXTRAHASHES = sha1+rmd160+sha256+sha512+tiger | ||
- | # You can create custom rules - my home made rule definition goes like this | ||
- | ALLXTRAHASHES = sha1+rmd160+sha256+sha512+whirlpool+tiger+haval+gost+crc32 | ||
- | ALLXTRAHASHES = sha1+rmd160+sha256+sha512+tiger | ||
# Everything but access time (Ie. all changes) | # Everything but access time (Ie. all changes) | ||
- | EVERYTHING = R+ALLXTRAHASHES | + | EVERYTHING = R+sha256+sha512 |
# Sane, with multiple hashes | # Sane, with multiple hashes | ||
Zeile 1713: | Zeile 1716: | ||
DATAONLY = p+n+u+g+s+acl+xattrs+sha256 | DATAONLY = p+n+u+g+s+acl+xattrs+sha256 | ||
- | # ################################################################ | + | ## 3. PATHS |
+ | # | ||
+ | # Here we define which directories and files we want to view or not view | ||
+ | # when monitoring with AIDE. | ||
+ | # | ||
+ | ## 3.1 EXCLUDED | ||
+ | ## 3.1.1 ETC | ||
- | # Next decide what directories/files you want in the database. | + | # Ignore root cache files |
- | + | !/root/.* | |
- | # ################################ | + | |
- | + | ||
- | # ################ | + | |
# Ignore backup files | # Ignore backup files | ||
Zeile 1727: | Zeile 1733: | ||
!/etc/mtab | !/etc/mtab | ||
- | # ################ | + | ## 3.1.2 USR |
# These are too volatile | # These are too volatile | ||
Zeile 1733: | Zeile 1739: | ||
!/usr/tmp | !/usr/tmp | ||
- | # ################ | + | ## 3.1.3 VAR |
# Ignore logs | # Ignore logs | ||
!/ | !/ | ||
!/ | !/ | ||
- | !/ | + | !/ |
- | !/ | + | !/ |
- | !/ | + | |
!/ | !/ | ||
- | # ################################ | + | ## 3.1.4 OTHERS |
+ | # Ignore cups | ||
+ | !/etc/cups | ||
- | # ################ | + | # Ignore backup files |
+ | !/root/.* | ||
+ | |||
+ | |||
+ | ## 3.2 INCLUDED | ||
+ | ## 3.2.1 ETC | ||
- | # Check only permissions, | + | # Check only permissions, |
+ | # important files closely. | ||
/etc PERMS | /etc PERMS | ||
/ | / | ||
Zeile 1810: | Zeile 1823: | ||
/ | / | ||
- | # ################ | + | ## 3.2.2 USR |
/usr | /usr | ||
/ | / | ||
- | # ################ | + | ## 3.2.3 VAR |
/ | / | ||
Zeile 1822: | Zeile 1835: | ||
/ | / | ||
- | # ################ | + | ## 3.2.4 OTHERS |
/boot NORMAL | /boot NORMAL | ||
Zeile 1830: | Zeile 1843: | ||
/opt | /opt | ||
/root NORMAL | /root NORMAL | ||
- | </ | + | |
+ | |||
+ | # Host based OTHERS | ||
+ | # local user scripts | ||
+ | / | ||
+ | |||
+ | # local scripts with root rights | ||
+ | / | ||
+ | |||
+ | |||
+ | # | ||
+ | # END ANSIBLE MANAGED - DO NOT EDIT BLOCK</ | ||
Wie eigentlich immer bei der Konfiguration von neuen Programmen lohnt es sich die zugehörige Konfigurationsdatei - in unserem Falle von **AIDE** die **''/ | Wie eigentlich immer bei der Konfiguration von neuen Programmen lohnt es sich die zugehörige Konfigurationsdatei - in unserem Falle von **AIDE** die **''/ | ||
Zeile 1933: | Zeile 1957: | ||
</ | </ | ||
+ | === positive Prüfen des Filesystems gegen die Datenbank === | ||
+ | Mit der Option **'' | ||
+ | [django@pml010074 ~]$ sudo aide --check | ||
+ | < | ||
+ | AIDE found NO differences between database and filesystem. Looks okay!! | ||
+ | |||
+ | Number of entries: | ||
+ | |||
+ | --------------------------------------------------- | ||
+ | The attributes of the (uncompressed) database(s): | ||
+ | --------------------------------------------------- | ||
+ | |||
+ | / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | End timestamp: 2025-02-09 16:53:10 +0100 (run time: 5m 40s) | ||
+ | </ | ||
+ | |||
+ | Die Zeile: | ||
+ | AIDE found NO differences between database and filesystem. Looks okay!! | ||
+ | zeigt uns an, dass es keine Änderungen im und am System gab. | ||
+ | |||
+ | === negative Prüfen des Filesystems gegen die Datenbank === | ||
+ | Im nächsten Beispiel kompromittieren wir unser System, in dem wir von einem bestehenden Binary einen vermeintlichen bösen Klone erstellen: | ||
+ | # cp /usr/bin/sg / | ||
+ | |||
+ | Führen wir erneut eine Überprüfung unseres Systems aus, sollte die neue unbekannte Datei entsprechend detektiert werden. | ||
+ | [django@pml010074 ~]$ sudo aide --check | ||
+ | |||
+ | < | ||
+ | AIDE found differences between database and filesystem!! | ||
+ | |||
+ | Summary: | ||
+ | Total number of entries: | ||
+ | Added entries: 1 | ||
+ | Removed entries: 1 | ||
+ | Changed entries: 5 | ||
+ | |||
+ | --------------------------------------------------- | ||
+ | Added entries: | ||
+ | --------------------------------------------------- | ||
+ | |||
+ | f+++++++++++++++: | ||
+ | |||
+ | --------------------------------------------------- | ||
+ | Removed entries: | ||
+ | --------------------------------------------------- | ||
+ | |||
+ | f---------------: | ||
+ | |||
+ | --------------------------------------------------- | ||
+ | Changed entries: | ||
+ | --------------------------------------------------- | ||
+ | |||
+ | d = ... mc.. : /root | ||
+ | d < ... mc.. : / | ||
+ | f > ... mci.H : / | ||
+ | f < ... mci.H : / | ||
+ | d > ... mc.. : /usr/bin | ||
+ | |||
+ | --------------------------------------------------- | ||
+ | Detailed information about changes: | ||
+ | --------------------------------------------------- | ||
+ | |||
+ | Directory: /root | ||
+ | | ||
+ | | ||
+ | |||
+ | Directory: / | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | File: / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | File: / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Directory: /usr/bin | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | --------------------------------------------------- | ||
+ | The attributes of the (uncompressed) database(s): | ||
+ | --------------------------------------------------- | ||
+ | |||
+ | / | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | End timestamp: 2025-02-09 18:15:03 +0100 (run time: 5m 51s) | ||
+ | </ | ||
+ | |||
+ | In der Zusammenfassung sehen wir also in Summe 470.065 Datenbankeinträge, | ||
+ | Total number of entries: | ||
+ | Added entries: | ||
+ | Removed entries: 1 | ||
+ | Changed entries: 5 | ||
+ | |||
+ | Die Datei **''/ | ||
+ | |||
+ | Im Abschnitt **'' | ||
+ | < | ||
+ | d < ... mc.. : / | ||
+ | f > ... mci.H : / | ||
+ | f < ... mci.H : / | ||
+ | d > ... mc.. : / | ||
+ | * In der ersten Spalte kennzeichnet ein **'' | ||
+ | * In der zweiten Spalte wird eine Änderung angezeigt, ob sich die Grösse einer Datei bzw. des Verzeichnisses geändert hat. **'' | ||
+ | * Die mit jedem Buchstaben verbundenen Attribute sind wie folgt: | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * Die folgenden Buchstaben sind nur verfügbar, wenn sie explizit mit „configure“ aktiviert werden: | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | |||
+ | Im Abschnitt **'' | ||
+ | |||
+ | === Update Database === | ||
+ | Nach Änderungen am System, z.B. bei Konfigurationsänderungen, | ||
+ | $ sudo aide --update | ||
+ | |||
+ | Alternativ kann man auch direkt die Datenbank neu initialisieren: | ||
+ | $ sudo aide --init | ||
+ | |||
+ | **'' | ||
+ | |||
+ | Ein anderer Ansatz wäre dann ein **'' | ||
+ | |||
+ | === tägliche checks enablen === | ||
+ | Wiederkehrende | ||
+ | |||
+ | [django@pml010074 ~] $ sudo systemctl enable --now aidecheck.timer | ||
+ | |||
+ | Created symlink '/ | ||
+ | |||
+ | Den Status können wir wie gewohnt via **'' | ||
+ | [django@pml010074 ~] $ sudo systemctl status aidecheck.timer | ||
+ | < | ||
+ | <font style=" | ||
+ | | ||
+ | | ||
+ | | ||
+ | Trigger: Mon 2025-02-10 05:00:00 CET; 14h left | ||
+ | | ||
+ | |||
+ | Feb 09 13:47:17 pml010074 systemd[1]: Started Aide check every day at 5AM.</ | ||
+ | </ | ||
+ | |||
+ | === jounald (tägliche) logs === | ||
+ | In der Konfigurationsdatei **''/ | ||
+ | |||
+ | # vim / | ||
+ | < | ||
+ | |||
+ | # Default | ||
+ | log_level=warning | ||
+ | report_level=changed_attributes | ||
+ | report_url=stdout | ||
+ | report_url=syslog: | ||
+ | |||
+ | ...</ | ||
+ | |||
+ | Somit können wir einfach die Logeinträge von AIDE einfach ausgeben. | ||
+ | # journalctl -f / | ||
+ | ++++ Ausgabe der AIDE Logeinträge im Journal | | ||
+ | < | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Number of entries: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | | ||
+ | --------------------------------------------------- | ||
+ | The attributes of the (uncompressed) database(s): | ||
+ | --------------------------------------------------- | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | Mar 14 16:20:38 pml010070 aide[102360]: | ||
+ | | ||
+ | End timestamp: 2025-03-14 16:20:38 +0100 (run time: 1m 41s) | ||
+ | |||
+ | </ | ||
+ | ++++ | ||
+ | ===== Orchestrierung - Installation und Konfiguration von AIDE mit Hilfe von Ansible | ||
+ | ==== Aufgabenstellung ==== | ||
+ | Natürlich wird man im Jahr 2025 nicht mehr ernsthaft, manuell Server aufsetzen und betreiben wollen. Vielmehr wird man auf ein Orchestrierungswerkzeug wie z.B. **[[linux: | ||
+ | |||
+ | In diesem Konfigurationsbeispiel gehen wir davon aus, dass wir auf zwei Hosts im Intranet AIDE installieren und konfigurieren möchten. Ferner holen wir uns das AIDE-Installationspaket von einem internen Repository-/ | ||
+ | |||
+ | Wir werden uns nun nachfolgend die Server-Installation und -konfiguration genauer betrachten. | ||
+ | |||
+ | ==== Lösung ==== | ||
+ | |||
+ | <WRAP center round tip 80%> | ||
+ | Der ungeduldigen Leser kann auch direkt zur Tat schreiten und das manuelle Anlegen der Inventory-Hülle, | ||
+ | |||
+ | < | ||
+ | -O - | tar -xz --strip-components=1 -C ~/ | ||
+ | |||
+ | Nach Anpassung der Daten im Inventory kann man anschliessend direkt **[[# | ||
+ | </ | ||
+ | |||
+ | === Vorbereitung - Daten im Inventory === | ||
+ | Bei unserem Konfigurationsbeispiel hier gehen wir von folgenden Parametern aus: | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | |||
+ | Die Konfigurationsdatei unseres **inventory** in unsere, Ansible-Verzeichnis beinhaltet demnach unter anderem: | ||
+ | $ vim inventories/ | ||
+ | ++++ inventories/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | Für alle Host aus der Gruppe **'' | ||
+ | $ vim inventories/ | ||
+ | ++++ inventories/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | Die beiden Beispiel-Hosts aus der Gruppe|Zone **'' | ||
+ | * Der Host **'' | ||
+ | * Der Host **'' | ||
+ | |||
+ | Wir legen uns also nun die Definitionsdateien für die beiden Hosts im SOHO an. | ||
+ | $ vim inventories/ | ||
+ | ++++ inventories/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | $ vim inventories/ | ||
+ | ++++ inventories/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | Unser Beispiels-Inventory hat also nunmehr folgenden Aufbau: | ||
+ | < | ||
+ | ├── group_vars | ||
+ | │ └── arch | ||
+ | │ | ||
+ | ├── hosts | ||
+ | └── hosts_vars | ||
+ | ├── pml010070 | ||
+ | └── pml010074 | ||
+ | |||
+ | 4 directories, | ||
+ | |||
+ | === Rolle === | ||
+ | Für die Installation und Konfiguration von **aide** verwenden wir eine eigene Rolle **'' | ||
+ | $ cp -avr roles/ | ||
+ | ++++ Ausgabe von cp -avr roles/ | ||
+ | < | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | </ | ||
+ | ++++ | ||
+ | |||
+ | Bei Bedarf können wir uns später die Struktur, die somit angelegt wurde und die wir nun gleich mit Inhalten befüllen wollen, mit nachfolgendem Befehl anzeigen lassen. | ||
+ | $ tree roles/hids/ | ||
+ | ++++ Ausgabe von tree roles/hids/ | | ||
+ | < | ||
+ | ├── defaults | ||
+ | ├── files | ||
+ | ├── handlers | ||
+ | │ └── main.yml | ||
+ | ├── library | ||
+ | ├── lookup_plugins | ||
+ | ├── meta | ||
+ | ├── module_utils | ||
+ | ├── tasks | ||
+ | │ ├── config.yml | ||
+ | │ ├── install.yml | ||
+ | │ ├── main.yml | ||
+ | │ └── transfer.yml | ||
+ | ├── templates | ||
+ | │ ├── aide_config.j2 | ||
+ | │ └── systemd.j2 | ||
+ | └── vars | ||
+ | |||
+ | 11 directories, | ||
+ | </ | ||
+ | ++++ | ||
+ | == tasks == | ||
+ | Wie wir sehen ist die Rolle durchaus überschaubar, | ||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | Die Installation von AIDE wird in der ersten Task-Gruppe mit dem tag **'' | ||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | Die eigentliche Installation Konfiguration sowie das erstellen der initialen AIDE-Datenbank erfolgt im anschliessenden Task **'' | ||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | Was nun noch fehlt ist das Kopieren der erstellten AIDE-Datenbank auf unseren internen Repository-/ | ||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | == templates == | ||
+ | Für die Erstellung der AIDE-Konfigurationsdatei **''/ | ||
+ | |||
+ | <WRAP center round tip 80%> | ||
+ | Damit nicht nun später alle unsere 42 VMs zum selben Zeitpunkt mit dem Check des jeweiligen Systems beginnen und somit einen vermeidbaren Peak auf unserem Repository-/ | ||
+ | </ | ||
+ | |||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | == handlers == | ||
+ | Sollte bei der Abarbeitung des Playbook die individuelle systemd-timer Konfigurationsdatei **''/ | ||
+ | |||
+ | Zu guter Letzt brauchen wir noch eine Konfiguration der Aufgaben die bei einem **'' | ||
+ | $ vim roles/ | ||
+ | ++++ roles/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | |||
+ | === Playbook === | ||
+ | Unser Playbook zum Installieren und Konfigurieren unseres HIDS auf Basis AIDE, ist wie immer schlank, unscheinbar und unspektakulär, | ||
+ | $ vim playbooks/ | ||
+ | ++++ playbooks/ | ||
+ | {{gh> https:// | ||
+ | ++++ | ||
+ | |||
+ | |||
+ | |||
+ | === Ausführung - Playbooklauf === | ||
+ | Die orchestrierte Variante der Installation und Konfiguration unseres **AIDE**-Daemons gestaltet sich ab sofort sehr einfach, brauchen wir doch lediglich die Konfigurationswerte im Inventory zu hinterlegen und zu pflegen und letztendlich das Playbook entsprechend aufzurufen, wenn z.B. gewollte Änderungen an einem System durch einen Admin bzw. durch den Lauf eines der Ansible-Playbooks erfolgten. | ||
+ | |||
+ | In nachfolgendem Beispiel installieren wir nun unseren AIDE-Daemon auf dem Host **'' | ||
+ | $ ansible-playbook playbooks/ | ||
+ | |||
+ | < | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Ergebniskontrolle ==== | ||
+ | Bei einem Blick in unser System-Journal finden wir nun unter anderem zunächst einmal das Setzen des **'' | ||
+ | # journalctl -f / | ||
+ | < | ||
+ | Mar 14 14:40:36 pml010070 systemd[1]: Started Aide check every day at 05:51:00. | ||
+ | Mar 14 14:40:36 pml010070 systemd[1]: Started Aide Check.</ | ||
+ | |||
+ | Desweiteren finden wir auch Informationen zum initialen Erstellen der Aide-Datenbank. | ||
+ | # journalctl -f / | ||
+ | ++++ journal bei Erstellung der initialen Datenbank | | ||
+ | < | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | |||
+ | | ||
+ | The attributes of the (uncompressed) database(s): | ||
+ | | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | Mar 14 14:43:07 pml010070 aide[94384]: | ||
+ | |||
+ | End timestamp: 2025-03-14 14:43:07 +0100 (run time: 2m 31s) | ||
+ | Mar 14 14:43:07 pml010070 systemd[1]: aidecheck.service: | ||
+ | Mar 14 14:43:07 pml010070 systemd[1]: aidecheck.service: | ||
+ | ++++ | ||
+ | |||
+ | Täglich um **05:01** Uhr wird nun unser Host die aktuelle Datenbank gegen die bestehende AIDE-Datenbank auf unserem internen Repository-/ | ||
+ | # journalctl | ||
+ | ++++ journal beim täglichen check um 05:51 Uhr dieses Hosts | | ||
+ | < | ||
+ | Mar 15 05:51:27 pml010070 rtkit-daemon[1200]: | ||
+ | Mar 15 05:51:27 pml010070 rtkit-daemon[1200]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | | ||
+ | Total number of entries: | ||
+ | Added entries: | ||
+ | | ||
+ | | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | d = ... mc.. .. : /etc/cups | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | d = ... mc.. : /root | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | | ||
+ | The attributes of the (uncompressed) database(s): | ||
+ | | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | |||
+ | End timestamp: 2025-03-15 05:53:01 +0100 (run time: 1m 52s) | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 aide[57175]: | ||
+ | Mar 15 05:53:01 pml010070 systemd[1]: aidecheck.service: | ||
+ | Mar 15 05:53:01 pml010070 systemd[1]: aidecheck.service: | ||
+ | Mar 15 05:53:01 pml010070 systemd[1]: aidecheck.service: | ||
+ | </ | ||
+ | ++++ | ||
+ | |||
+ | ===== Fazit und Ausblick ===== | ||
+ | <WRAP center round tip 80%> | ||
+ | Mit **AIDE** haben wir nun ein Instrument an der Hand, mit der wir die Dateisysteme unserer Host einfach auf Anomalien hin überwachen kann. Mit Hilfe unseres Ansible-Playbooks können wir nun auch nicht nur die Installation und Konfiguration des Aide-Daemon erledigen, sondern auch einfach die jeweiligen AIDE-DAtenbanken der Hosts nach Änderungen durch den Admin bzw. bei Updates oder Ansible-Läufen, | ||
+ | |||
+ | In diesem Konfigurationsbeispiel wurde lediglich aufgezeigt, wie man einfach mit Hilfe von Ansible installieren, | ||
+ | noch im Detail ansehen! | ||
+ | </ | ||
+ | |||
+ | ====== Links ====== | ||
+ | * **[[linux: | ||
+ | * **=> [[linux: | ||
+ | * **[[linux: | ||
+ | * **[[wiki: | ||
+ | * **[[http:// | ||
- | FIXME! |