Apparmor Handling: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
(Die Seite wurde neu angelegt: „ =Checken ob Apparmor installiert ist= *dpkg -l apparmor <pre> Gewünscht=Unbekannt/Installieren/R=Entfernen/P=Vollständig Löschen/Halten | Status=Nicht/Inst…“)
 
 
(4 dazwischenliegende Versionen von einem anderen Benutzer werden nicht angezeigt)
Zeile 23: Zeile 23:
 
       CPU: 0
 
       CPU: 0
 
</pre>
 
</pre>
 +
=Hilfsprogramme=
 +
*apt-get install apparmor-utils
 +
 
=AA Status=
 
=AA Status=
 
*aa-status  
 
*aa-status  
 
<pre>
 
<pre>
 
apparmor module is loaded.
 
apparmor module is loaded.
14 profiles are loaded.
+
7 profiles are loaded.
14 profiles are in enforce mode.
+
7 profiles are in enforce mode.
  /sbin/dhclient
+
   /usr/bin/man
   /usr/bin/lxc-start
+
   lsb_release
   /usr/bin/ubuntu-core-launcher
+
   man_filter
   /usr/lib/NetworkManager/nm-dhcp-client.action
+
   man_groff
   /usr/lib/NetworkManager/nm-dhcp-helper
+
   nvidia_modprobe
   /usr/lib/connman/scripts/dhclient-script
+
   nvidia_modprobe//kmod
   /usr/lib/ipsec/charon
+
   tcpdump
  /usr/lib/ipsec/stroke
 
   /usr/lib/lxd/lxd-bridge-proxy
 
  /usr/sbin/tcpdump
 
  lxc-container-default
 
  lxc-container-default-cgns
 
  lxc-container-default-with-mounting
 
  lxc-container-default-with-nesting
 
 
0 profiles are in complain mode.
 
0 profiles are in complain mode.
1 processes have profiles defined.
+
0 processes have profiles defined.
1 processes are in enforce mode.
+
0 processes are in enforce mode.
  /usr/lib/ipsec/charon (17017)
 
 
0 processes are in complain mode.
 
0 processes are in complain mode.
 
0 processes are unconfined but have a profile defined.
 
0 processes are unconfined but have a profile defined.
 
</pre>
 
</pre>
 +
 +
=Verzeichnisstruktur=
 +
*Globale und Systemeinstellungen sind in /etc/apparmor gespeichert.
 +
*Die Anwendungsprofile sowie mehrere vordefinierte Unterverzeichnisse befinden sich in /etc/apparmor.d/.
 +
==disable und force-complain==
 +
*Enthält /etc/apparmor.d/disable eine Verknüpfung zu einem Profil, so wird dieses nicht automatisch geladen.
 +
*Ähnlich sorgen Verknüpfungen unter /etc/apparmor.d/force-complain dafür, dass Profile nur im complain-Modus geladen werden (siehe unten).
 
=Apparmor Modi=
 
=Apparmor Modi=
 
*Enforce-Modus
 
*Enforce-Modus
Zeile 58: Zeile 60:
 
**Checken potentieller Regelverstösse
 
**Checken potentieller Regelverstösse
  
=Apparmor Utils=
 
*apt install apparmor-utils
 
 
==aa-audit==
 
==aa-audit==
 
Setzen einen Anwendung in den Auditmodus
 
Setzen einen Anwendung in den Auditmodus
Zeile 76: Zeile 76:
 
=disable service from apparmor permanently=
 
=disable service from apparmor permanently=
 
*ln -s /etc/apparmor.d/usr.sbin.tcpdump /etc/apparmor.d/disable/
 
*ln -s /etc/apparmor.d/usr.sbin.tcpdump /etc/apparmor.d/disable/
 +
*aa-disable /etc/apparmor.d/<profile-name>
 
*systemctl restart apparmor
 
*systemctl restart apparmor
  

Aktuelle Version vom 2. Juli 2024, 07:05 Uhr

Checken ob Apparmor installiert ist

  • dpkg -l apparmor
Gewünscht=Unbekannt/Installieren/R=Entfernen/P=Vollständig Löschen/Halten
| Status=Nicht/Installiert/Config/U=Entpackt/halb konFiguriert/
         Halb installiert/Trigger erWartet/Trigger anhängig
|/ Fehler?=(kein)/R=Neuinstallation notwendig (Status, Fehler: GROSS=schlecht)
||/ Name                                      Version                   Architektur               Beschreibung
+++-=========================================-=========================-=========================-=======================================================================================
ii  apparmor                                  2.10.95-0ubuntu2.6        amd64                     user-space parser utility for AppArmor

Läuft Apparmor

  • systemctl status apparmor
● apparmor.service - LSB: AppArmor initialization
   Loaded: loaded (/etc/init.d/apparmor; bad; vendor preset: enabled)
   Active: active (exited) since Di 2017-10-24 11:55:53 CEST; 2 weeks 3 days ago
     Docs: man:systemd-sysv-generator(8)
  Process: 591 ExecStart=/etc/init.d/apparmor start (code=exited, status=0/SUCCESS)
    Tasks: 0
   Memory: 0B
      CPU: 0

Hilfsprogramme

  • apt-get install apparmor-utils

AA Status

  • aa-status
apparmor module is loaded.
7 profiles are loaded.
7 profiles are in enforce mode.
   /usr/bin/man
   lsb_release
   man_filter
   man_groff
   nvidia_modprobe
   nvidia_modprobe//kmod
   tcpdump
0 profiles are in complain mode.
0 processes have profiles defined.
0 processes are in enforce mode.
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.

Verzeichnisstruktur

  • Globale und Systemeinstellungen sind in /etc/apparmor gespeichert.
  • Die Anwendungsprofile sowie mehrere vordefinierte Unterverzeichnisse befinden sich in /etc/apparmor.d/.

disable und force-complain

  • Enthält /etc/apparmor.d/disable eine Verknüpfung zu einem Profil, so wird dieses nicht automatisch geladen.
  • Ähnlich sorgen Verknüpfungen unter /etc/apparmor.d/force-complain dafür, dass Profile nur im complain-Modus geladen werden (siehe unten).

Apparmor Modi

  • Enforce-Modus
    • Unterbindet alle Regelverstösse
  • Complain-Modus
    • Protokolliert alle Regelverstösse
  • Audit-Modus
    • Checken potentieller Regelverstösse

aa-audit

Setzen einen Anwendung in den Auditmodus

  • aa-audit /etc/apparmor.d/usr.lib.ipsec.charon
Setting /etc/apparmor.d/usr.lib.ipsec.charon to audit mode.

aa-unconfined

Checken welche Netzwerkdienste nicht überwacht werden

  • aa-unconfined
1034 /usr/sbin/sshd not confined
17017 /usr/lib/ipsec/charon confined by '/usr/lib/ipsec/charon (enforce)'

disable service from apparmor temporarily

  • apparmor_parser -R /etc/apparmor.d/usr.sbin.tcpdump

enable to apparmor

  • apparmor_parser /etc/apparmor.d/usr.sbin.tcpdump

disable service from apparmor permanently

  • ln -s /etc/apparmor.d/usr.sbin.tcpdump /etc/apparmor.d/disable/
  • aa-disable /etc/apparmor.d/<profile-name>
  • systemctl restart apparmor

undo and enable the service

  • rm /etc/apparmor.d/disable/usr.sbin.tcpdump
  • systemctl restart apparmor

Links