Sie können mit AUDITCTL auf Systemaufrufe überwachen bezogenen Aktivitäten des Dateisystems wie open
, stat
oder lstat
. Überwachung scheint read
oder write
scheint problematisch zu sein.
auditctl
ist ein Hilfsprogramm zur Unterstützung der Kontrolle des Prüfsystems des Kernels. Sie müssen root sein, um es verwenden zu können. Es unterstützt verschiedene Filter wie:
devmajor Device Major Number devminor Device Minor Number dir Full Path of Directory to watch. This will place a recursive watch on the directory and its whole subtree. It can only be used on exit list. See "-w". egid Effective Group ID. May be numeric or the groups name. euid Effective User ID. May be numeric or the user account name. filetype The target file's type. Can be either file, dir, socket, symlink, char, block, or fifo. path Full Path of File to watch. It can only be used on exit list. pid Process ID ppid Parent's Process ID
Beispiel (getestet mit Fedora 16 x86_64)
Um die Überwachungsregeln hinzuzufügen, führen Sie als root aus:
for syscall in open stat lstat read write; do auditctl -a exit,always -F arch=b64 -S $syscall \ -F euid=1000 \ -F dir=/tmp/superuser.com/questions/370070 done
Um sie später zu löschen, ersetzen Sie -a
mit -d
:
for syscall in open stat lstat read write; do auditctl -d exit,always -F arch=b64 -S $syscall \ -F euid=1000 \ -F dir=/tmp/superuser.com/questions/370070 done
Nachdem Sie die Regeln hinzugefügt haben, führen Sie als Benutzer mit der UID 1000 etwas in diesem Verzeichnis aus:
cd /tmp/superuser.com/questions/370070 echo foo > bar cat bar stat bar
ausearch --start 00:00:00 --uid-effective 1000
wird folgendes zurückgeben (das Protokoll ist /var/log/audit/audit.log
):
time->Thu Jun 14 00:02:32 2012 type=PATH msg=audit(1339621352.871:18529): item=0 name="/tmp/superuser.com/questions/370070" inode=178 dev=fd:03 mode=040775 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 type=CWD msg=audit(1339621352.871:18529): cwd="/home/ciupicri" type=SYSCALL msg=audit(1339621352.871:18529): arch=c000003e syscall=4 success=yes exit=0 a0=139bbf0 a1=7fff32d832d0 a2=7fff32d832d0 a3=24 items=1 ppid=2249 pid=3446 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts6 ses=1 comm="bash" exe="/bin/bash" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) [root@hermes ~]# ausearch --start 00:00:00 --uid-effective 1000 ---- time->Thu Jun 14 00:02:32 2012 type=PATH msg=audit(1339621352.871:18529): item=0 name="/tmp/superuser.com/questions/370070" inode=178 dev=fd:03 mode=040775 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 type=CWD msg=audit(1339621352.871:18529): cwd="/home/ciupicri" type=SYSCALL msg=audit(1339621352.871:18529): arch=c000003e syscall=4 success=yes exit=0 a0=139bbf0 a1=7fff32d832d0 a2=7fff32d832d0 a3=24 items=1 ppid=2249 pid=3446 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts6 ses=1 comm="bash" exe="/bin/bash" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) ---- time->Thu Jun 14 00:02:47 2012 type=PATH msg=audit(1339621367.175:18531): item=0 name="bar" inode=218 dev=fd:03 mode=0100664 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 type=CWD msg=audit(1339621367.175:18531): cwd="/tmp/superuser.com/questions/370070" type=SYSCALL msg=audit(1339621367.175:18531): arch=c000003e syscall=2 success=yes exit=3 a0=7fff5ed6b37f a1=0 a2=0 a3=7fff5ed69460 items=1 ppid=3446 pid=4735 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts6 ses=1 comm="cat" exe="/bin/cat" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) ---- time->Thu Jun 14 00:02:47 2012 type=PATH msg=audit(1339621367.172:18530): item=1 name="bar" inode=218 dev=fd:03 mode=0100664 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 type=PATH msg=audit(1339621367.172:18530): item=0 name="/tmp/superuser.com/questions/370070" inode=178 dev=fd:03 mode=040775 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 type=CWD msg=audit(1339621367.172:18530): cwd="/tmp/superuser.com/questions/370070" type=SYSCALL msg=audit(1339621367.172:18530): arch=c000003e syscall=2 success=yes exit=3 a0=1665500 a1=241 a2=1b6 a3=4 items=2 ppid=2249 pid=3446 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts6 ses=1 comm="bash" exe="/bin/bash" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) ---- time->Thu Jun 14 00:02:47 2012 type=PATH msg=audit(1339621367.971:18532): item=0 name="bar" inode=218 dev=fd:03 mode=0100664 ouid=1000 ogid=1000 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 type=CWD msg=audit(1339621367.971:18532): cwd="/tmp/superuser.com/questions/370070" type=SYSCALL msg=audit(1339621367.971:18532): arch=c000003e syscall=6 success=yes exit=0 a0=7fffdc713375 a1=7fffdc711580 a2=7fffdc711580 a3=7fffdc7112f0 items=1 ppid=3446 pid=4736 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=pts6 ses=1 comm="stat" exe="/usr/bin/stat" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
Die Systemrufnummern finden Sie in /usr/include/asm/unistd_64.h
.