Translated message

A translation of this page exists in English.

Warning message

This translation is outdated. For the most up-to-date information, please refer to the English version.

audit を使用して特定の SYSCALL を監視する方法

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5

Issue

  • 特定の syscall がシステムで実行されたことを把握する必要はありますか?
  • たとえば、システムで実行した kill の痕跡をすべて把握する必要はありますか?

Resolution

  • 以下のように、audit ファイルを作成します。

    # vim /etc/audit/audit.rules
    -a entry,always -F arch=b64 -S kill -k teste_kill
    

  注意: arch は syscall の CPU アーキテクチャです。システムが 32 ビット OS であれば、"arch=b32" とする必要があります。詳細は adutctl の man ページ AUDITCTL(8) をご参照下さい。

  • audit サービスを再起動します。

    # service auditd restart
    
  • 一部のプロセスに kill を実行してルールをテストします。この例では、sleep プロセスを生成して終了させます。

    # vim /etc/audit/audit.rules
    -a entry,always -F arch=b64 -S kill -k teste_kill
    
    # service auditd restart
    
    # sleep 100
    
    # ps aux | grep sleep
    
    root      1968  0.0  0.0  58876   504 pts/3    S+   16:01   0:00 sleep 100
    root      1975  0.0  0.0  61136   736 pts/4    S+   16:01   0:00 grep sleep
    
    # kill 1968
    
    # tail -f /var/log/audit/audit.log
    type=SYSCALL msg=audit(1279134100.434:193): arch=c000003e syscall=62 success=yes exit=0 a0=7b0 a1=f a2=0 a3=0 items=0 ppid=1602 pid=1605 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=4294967295 comm="bash" exe="/bin/bash" key="teste_kill"
    type=OBJ_PID msg=audit(1279134100.434:193): opid=1968 oauid=-1 ouid=0 oses=-1 obj=<NULL> ocomm="sleep"
    
  • audit サーチを使用して、最初の手順で指定したキーをもとに kill コマンドに関連するログを見つけます。

    # ausearch -k teste_kill
    ----
    time->Wed Jul 14 16:00:17 2010
    type=CONFIG_CHANGE msg=audit(1279134017.731:186): auid=4294967295 op=add rule key="teste_kill" list=2 res=1
    ----
    time->Wed Jul 14 16:01:40 2010
    type=OBJ_PID msg=audit(1279134100.434:193): opid=1968 oauid=-1 ouid=0 oses=-1 obj=<NULL> ocomm="sleep"
    type=SYSCALL msg=audit(1279134100.434:193): arch=c000003e syscall=62 success=yes exit=0 a0=7b0 a1=f a2=0 a3=0 items=0 ppid=1602 pid=1605 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts4 ses=4294967295 comm="bash" exe="/bin/bash" key="teste_kill"
    

参照情報:
http://www.novell.com/documentation/sled10/pdfdoc/auditqs_sp2/auditqs_sp2.pdf
http://people.redhat.com/sgrubb/audit/audit-parse.txt

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments