Unix-commands-auditctl

提供:Dev Guides
移動先:案内検索

auditctl-Unix、Linuxコマンド

link:/unix_commands/index [previous] link:/unix_commands/index [next] [[1]] php [AddThis Social Bookmark Button]

NAME

概要

  • auditctl * options

説明

*auditctl*

オプション

Tag

説明

*-b* _backlog_

許可される未処理の監査バッファの最大数を設定します(カーネルのデフォルト= 64)。すべてのバッファがいっぱいの場合、アクションのためにカーネルによって失敗フラグが調べられます。

*-e* [ *0* .. *2* ]

有効フラグを設定します。 0 が渡されると、これを使用して一時的に監査を無効にすることができます。 1 が引数として渡されると、監査が有効になります。 変更できないように監査構成をロックするには、引数として 2 を渡します。 構成のロックは、この機能をアクティブにしたい人のためのaudit.rulesの最後のコマンドにすることを目的としています。 このモードで設定を変更しようとすると、監査されて拒否されます。 構成を変更するには、マシンを再起動する必要があります。

*-f* [ *0* .. *2* ]

障害フラグ* 0 = silent 1 = printk 2 * = panicを設定します。 このオプションにより、カーネルが重大なエラーを処理する方法を決定できます。 このフラグが参照される条件の例には、ユーザースペース監査デーモンへの送信エラー、バックログ制限超過、カーネルメモリ不足、レート制限超過が含まれます。 デフォルト値は 1 です。 安全な環境では、おそらくこれを 2 に設定する必要があります。

-h

Help

-i

ファイルからルールを読み取るときにエラーを無視する

-l

すべてのルールを1行ごとにリストします。 これには、キーオプション(-k)も使用できます。

*-k* _key_

監査ルールにフィルターキーを設定します。 フィルターキーは、最大31バイトの任意のテキスト文字列です。 ルールによって生成された監査レコードを一意に識別できます。 一般的な用途は、セキュリティ要件を満たす複数のルールがある場合です。 キー値はausearchで検索できるため、どのルールがイベントをトリガーしたとしても、その結果を見つけることができます。 このキーは、特定のキーを持つルールを選択するために、すべて削除(-D)およびリストルール(-l)にも使用できます。 ログに記録されたイベントを複数の方法で検索できるようにする場合、または分析を支援するためにキーを使用するaudispdプラグインがある場合は、ルールに複数のキーがある場合があります。

*-m* _text_

ユーザースペースメッセージを監査システムに送信します。 これは、rootユーザーのみが実行できます。

*-p* [* *r*  *|*  *w*  *|*  *x*  *|* a *]

ファイルシステム監視のアクセス許可フィルターを設定します。 * r * =読み取り、* w * =書き込み、* x * =実行、* a * =属性の変更。 これらの許可は、標準のファイル許可ではなく、この種のことを行う種類のシステムコールです。 読み取りと書き込みのシステムコールは、ログを圧倒するため、このセットから省略されます。 しかし、読み取りまたは書き込みではなく、オープンフラグを調べて、要求されたアクセス許可を確認します。

*-q* _mount-point、subtree_

既存のディレクトリ監視があり、監視サブツリー内の別のサブツリーをバインドまたは移動マウントする場合、監視対象ディレクトリと同等にマウントされるサブツリーを作成するようカーネルに指示する必要があります。 ディレクトリ監視の発行時にサブツリーがすでにマウントされている場合、サブツリーは監視用に自動的にタグ付けされます。 2つの値を区切るコンマに注意してください。 省略するとエラーが発生します。

*-r* _rate_

メッセージ/秒で制限を設定します(* 0 * =なし)。 この_rate_がゼロ以外であり、それを超えている場合、カーネルはアクションのために障害フラグを調べます。 デフォルト値は 0 です。

*-R* _file_

_file_からルールを読み取ります。 ルールは、1行に1つずつ、実行される順序である必要があります。 ルールファイルはルートが所有し、他のユーザーが読み取れないようにする必要があります。そうしないと拒否されます。 ルールファイルには、「#」文字で行を開始することでコメントを埋め込むことができます。 ファイルから読み取られるルールは、auditctlが優先されないことを除いて、コマンドラインで入力するルールと同じです(auditctlはファイルを実行するルールであるため)。

-s

ステータスを報告します。 pidが0の場合、監査デーモンが実行されていないことに注意してください。

-t

mountコマンドの後にサブツリーをトリミングします。

*-a* _list、action_

_action_を使用して、_list_の最後にルールを追加します。 2つの値を区切るコンマに注意してください。 省略するとエラーが発生します。 以下に、有効な_list_名について説明します。

Tag Description
task Add a rule to the per task list. This rule list is used only at the time a task is created — when fork() or clone() are called by the parent task. When using this list, you should only use fields that are known at task creation time, such as the uid, gid, etc.
entry Add a rule to the syscall entry list. This list is used upon entry to a system call to determine if an audit event should be created.
exit Add a rule to the syscall exit list. This list is used upon exit from a system call to determine if an audit event should be created.
user Add a rule to the user message filter list. This list is used by the kernel to filter events originating in user space before relaying them to the audit daemon. It should be noted that the only fields that are valid are: uid, auid, gid, and pid. All other fields will be treated as non-matching.
exclude Add a rule to the event type exclusion filter list. This list is used to filter events that you do not want to see. For example, if you do not want to see any avc messages, you would using this list to record that. The message type that you do not wish to see is given with the msgtype field.

以下は、ルールの有効な_actions_について説明しています。

Tag Description
never No audit records will be generated. This can be used to suppress event generation. In general, you want suppressions at the top of the list instead of the bottom. This is because the event triggers on the first matching rule.
always Allocate an audit context, always fill it in at syscall entry time, and always write out a record at syscall exit time.
*-A* __list __ **、** _ action_

_action_を使用してルールを先頭の_list_に追加します。

*-d* __list __ **、** _ action_

_action_を使用して_list_からルールを削除します。 ルールは、syscall名とフィールド名に完全に一致する場合にのみ削除されます。

-D

すべてのルールとウォッチを削除します。 これには、キーオプション(-k)も使用できます。

*-S* [__Syscall名または番号__ | *all* ]

任意の_syscall name_または_number_を使用できます。 「すべて」という言葉も使用できます。 このsyscallがプログラムによって作成された場合、監査レコードを開始します。 フィールドルールが指定され、syscallが指定されていない場合、すべてのsyscallがデフォルトになります。 同じルールで複数の-Sオプションを使用して、同じルールで複数のsyscallを指定することもできます。 これにより、評価する必要のあるルールが少なくなるため、パフォーマンスが向上します。 x86_64などのbi-archシステムを使用している場合、auditctlは単にテキストを取得し、ネイティブアーチ(この場合はb64)を検索し、そのルールをカーネルに送信することに注意する必要があります。 追加のarchディレクティブがない場合、32ビットと64ビットの両方のSYSCALLSに適用されます。 たとえば、オープンシステムコールが32ビットインターフェイスと64ビットインターフェイスの両方で同じ番号を持っているという保証がないため、これは望ましくない影響を与える可能性があります。 これを制御し、b32に等しいarchとb64に等しい2つのルールを作成して、カーネルが意図したイベントを確実に検出できるようにすることができます。

*-F* [__n __ * *=*  *_ v_ | __n __* *!= * *_ v_ | __n __* * <* *_ v_ | __n __* *> * *_ v_ | __n __*  *<=*  *_ v_ | __n __* *> = * *_ v_ | __n __* *&* *_ v_ | __n __* *&= ** _ v_]

ルールフィールドを作成します:名前、操作、値。 1つのコマンドラインで最大64個のフィールドを渡すことができます。 それぞれは -F で始まる必要があります。 各フィールド方程式は互いに監査されて監査レコードをトリガーします。 8つの演算子がサポートされています-等しい、等しくない、より小さい、より大きい、より小さい、または等しい、より大きい、等しい、ビットマスク、およびビットテスト。 ビットテストは値を「and」し、それらが等しいことを確認します。ビットマスクは値を「and」します。 ユーザーIDを取得するフィールドには、代わりにユーザー名が付いている場合があります。プログラムは名前をユーザーIDに変換します。 同じことがグループ名にも当てはまります。 有効なフィールドは次のとおりです。

Tag Description
a0, a1, a2, a3 Respectively, the first 4 arguments to a syscall. Note that string arguments are not supported. This is because the kernel is passed a pointer to the string. Triggering on a pointer address value is not likely to work. So, when using this, you should only use on numeric values. This is most likely to be used on platforms that multiplex socket or IPC operations.
*arch * The CPU architecture of the syscall. The arch can be found doing ’uname -m’. If you do not know the arch of your machine but you want to use the 32 bit syscall table and your machine supports 32 bit, you can also use* b32 for the arch. The same applies to the 64 bit syscall table, you can use b64.* In this way, you can write rules that are somewhat arch independent because the family type will be auto detected. However, syscalls can be arch specific and what is available on x86_64, may not be available on ppc. The arch directive should preceed the -S option so that auditctl knows which internal table to use to look up the syscall numbers.
auid The original ID the user logged in with. Its an abbreviation of audit uid. Sometimes its referred to as loginuid. Either the text or number may be used.
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. Should only be used on exit list. See "-w".
egid Effective Group ID
euid Effective User ID
exit Exit value from a syscall. If the exit code is an errno, you may use the text representation, too.
fsgid Filesystem Group ID
fsuid Filesystem User ID
filetype The target file’s type. Can be either file, dir, socket, symlink, char, block, or fifo.
gid Group ID
inode Inode Number
*key * This is another way of setting a filter key. See discussion above for* -k* option.
msgtype This is used to match the message type number. It should only be used on the exclude filter list.
obj_user Resource’s SE Linux User
obj_role Resource’s SE Linux Role
obj_type Resource’s SE Linux Type
obj_lev_low Resource’s SE Linux Low Level
obj_lev_high Resource’s SE Linux High Level
path Full Path of File to watch. Should only be used on exit list.
perm Permission filter for file operations. See "-p". Should only be used on exit list. You can use this without specifying a syscall and the kernel will select the syscalls that satisfy the permissions being requested.
pers OS Personality Number
pid Process ID
ppid Parent’s Process ID
subj_user Program’s SE Linux User
subj_role Program’s SE Linux Role
subj_type Program’s SE Linux Type
subj_sen Program’s SE Linux Sensitivity
subj_clr Program’s SE Linux Clearance
sgid Saved Group ID. See getresgid(2) man page.
success If the exit value is >= 0 this is true/yes otherwise its false/no. When writing a rule, use a 1 for true/yes and a 0 for false/no
suid Saved User ID. See getresuid(2) man page.
uid User ID
*-w* _path_

_path_でファイルシステムオブジェクトの監視を挿入します。 最上位ディレクトリにウォッチを挿入することはできません。 これはカーネルによって禁止されています。 ワイルドカードもサポートされていないため、警告が生成されます。 動作を監視する方法は、iノードを内部で追跡することです。 ファイルに監視を配置する場合、syscallルールで-F pathオプションを使用するのと同じです。 ディレクトリに監視を配置する場合、syscallルールで-F dirオプションを使用するのと同じです。 ウォッチを記述する-w形式は後方互換性のためであり、syscallベースの形式はより表現力豊かです。 ほとんどのsyscall監査ルールとは異なり、監視はカーネルに送信されるルールの数に基づいてパフォーマンスに影響を与えません。 ウォッチを使用する場合、有効なオプションは-pと-kのみです。 ファイルにアクセスする特定のユーザーを監査するなどの凝った作業が必要な場合は、パスまたはdirフィールドを指定したsyscall監査フォームを使用します。 あるフォームを別のフォームに変換する例については、使用例セクションを参照してください。

*-W* _path_

_path_にあるファイルシステムオブジェクトの監視を削除します。

パフォーマンスのヒント

auditctl -a exit,always -S open -F success=0
auditctl -a exit,always -S truncate -F success=0

1つのルールとして書き直すことができます。

auditctl -a exit,always -S open -S truncate -F success=0

また、実用的な場合は常にファイルシステム監査を使用してください。 これによりパフォーマンスが向上します。 たとえば、上記のように失敗したすべてのオープンと切り捨てをキャプチャしたいが、/etc内のファイルのみに関心があり、/usrまたは/sbinには関心がない場合、このルールを使用できます。

auditctl -a exit,always -S open -S truncate -F dir=/etc -F success=0

これは、カーネルがすべてのシステムコールを評価しないため、パフォーマンスが向上します。 ファイルシステム監査コードによって処理され、ファイルシステム関連のsyscallでのみチェックされます。

auditctl -a entry,always -S all -F pid=1005

特定のユーザーが開いたファイルを表示するには:

auditctl -a exit,always -S open -F auid=510

失敗したオープンコールを表示するには:

auditctl -a exit,always -S open -F success=0

ファイルの変更を監視するには(2つの表現方法):

auditctl -w/etc/shadow -p wa auditctl -a exit,always -F path=/etc/shadow -F perm=wa

ディレクトリの変更を再帰的に監視するには(2つの表現方法):

auditctl -w/etc/-p wa auditctl -a exit,always -F dir=/etc/-F perm=wa

ファイル

Tag

説明

/etc/audit/audit.rules

関連項目

  • リンク:/unix_commands/auditd [監査(8)]

著者

link:/unix_commands/index [previous] link:/unix_commands/index [next] link:/cgi-bin/printversion.cgi?tutorial = unix_commands&file = auditctl [Printer Friendly]

  
Advertisements