Communitygithub.com

Linux監査ログ解析による侵入検知

Linux Auditフレームワーク(auditd)とausearch、aureportを活用して、侵入兆候の調査や証拠保全を行います。

Linux監査ログ解析による侵入検知 とは?

このスキルは、Linux Auditフレームワーク(auditd)を使用して、ホストへの不正アクセスや特権昇格、持続化機構などの侵入兆候を検出・分析する方法を提供します。ausearch と aureport ユーティリティを用いた詳細なログ検索とサマリレポート生成、攻撃タイムラインの再構築手順をカバーしています。さらに、侵入検知に特化した監査ルールのデプロイ例や、監査ログをSIEMに転送する設定方法も含まれています。このスキルは、セキュリティインシデント対応やコンプライアンス監査(CIS、STIG、PCI-DSS)でシステムコールレベルでの監視が必要なシナリオで特に有用です。カーネルレベルで動作するため、個々のホストにおけるきめ細かいアクティビティ追跡が可能で、SuricataやZeekのようなネットワークレベルの侵入検知とは異なる補完的な役割を果たします。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-linux-audit-logs-for-intrusion

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Linux監査ログ解析による侵入検知 は何をしますか?

使用するタイミング

  • Linuxホストにおける不正アクセスまたは特権昇格の疑いを調査する場合
  • エクスプロイト、バックドアインストール、持続化メカニズムの証拠を探す場合
  • システムコール監視を必要とするセキュリティベースライン(CIS、STIG、PCI-DSS)への準拠を監査する場合
  • インシデント対応において攻撃者の行動の時系列を再構築する場合
  • /etc/passwd、/etc/shadow、SSH鍵などの重要なシステムファイルの改ざんを検出する場合

使用しない場合: ネットワークレベルの侵入検知には使わないでください。ネットワークトラフィック分析にはSuricataやZeekを使用してください。Auditdは個々のホストのカーネルレベルで動作します。

前提条件

  • auditdパッケージがインストールされ、監査デーモンが動作しているLinuxシステム(systemctl status auditd)
  • 監査ルールの設定とログの照会に必要なrootまたはsudoアクセス権
  • /etc/audit/rules.d/*.rules に配置、または auditctl でロードされた監査ルール
  • 推奨: 包括的なベースラインカバレッジのための Neo23x0/auditd ルールセット(GitHub)
  • Linuxシステムコール(execve、open、connect、ptrace など)に関する知識
  • 十分な保持期間を持つログストレージ(デフォルトの場所: /var/log/audit/audit.log)

ワークフロー

ステップ1: 監査デーモンの状態と設定を確認する

監査システムが動作していることを確認し、現在のルールセットを確認します:

# auditdサービスの状態を確認
systemctl status auditd

# 現在カーネルにロードされている監査ルールを表示
auditctl -l

# 監査デーモンの設定を表示
cat /etc/audit/auditd.conf | grep -E "log_file|max_log_file|num_logs|space_left_action"

# 監査バックログが超過していないか確認(ドロップされたイベント)
auditctl -s

バックログ制限に達している場合は、増やします:

auditctl -b 8192

ステップ2: 侵入検知に特化した監査ルールをデプロイする

一般的な侵入兆候を対象とするルールを追加します。/etc/audit/rules.d/intrusion.rules に配置します:

# 認証情報ファイルの不正な読み取りや変更を監視
-w /etc/passwd -p wa -k credential_access
-w /etc/shadow -p rwa -k credential_access
-w /etc/gshadow -p rwa -k credential_access
-w /etc/sudoers -p wa -k privilege_escalation
-w /etc/sudoers.d/ -p wa -k privilege_escalation

# SSH設定と認証鍵を監視
-w /etc/ssh/sshd_config -p wa -k sshd_config_change
-w /root/.ssh/authorized_keys -p wa -k ssh_key_tampering

# ユーザーおよびグループ管理コマンドを監視
-w /usr/sbin/useradd -p x -k user_management
-w /usr/sbin/usermod -p x -k user_management
-w /usr/sbin/groupadd -p x -k user_management

# ptraceによるプロセスインジェクションを検出
-a always,exit -F arch=b64 -S ptrace -F a0=0x4 -k process_injection
-a always,exit -F arch=b64 -S ptrace -F a0=0x5 -k process_injection
-a always,exit -F arch=b64 -S ptrace -F a0=0x6 -k process_injection

# 異常なディレクトリからのプログラム実行を監視
-a always,exit -F arch=b64 -S execve -F exe=/tmp -k exec_from_tmp
-a always,exit -F arch=b64 -S execve -F exe=/dev/shm -k exec_from_shm

# カーネルモジュールのロードを検出(ルートキットのインストール)
-a always,exit -F arch=b64 -S init_module -S finit_module -k kernel_module_load
-a always,exit -F arch=b64 -S delete_module -k kernel_module_remove
-w /sbin/insmod -p x -k kernel_module_tool
-w /sbin/modprobe -p x -k kernel_module_tool

# リバースシェルのためのネットワークソケット作成を監視
-a always,exit -F arch=b64 -S socket -F a0=2 -k network_socket_created
-a always,exit -F arch=b64 -S connect -F a0=2 -k network_connection

# cronジョブの変更を検出(持続化)
-w /etc/crontab -p wa -k cron_persistence
-w /etc/cron.d/ -p wa -k cron_persistence
-w /var/spool/cron/ -p wa -k cron_persistence

# ログの削除や改ざんを監視
-w /var/log/ -p wa -k log_tampering

編集後、ルールを再ロードします:

augenrules --load
auditctl -l | wc -l   # ルール数を確認

ステップ3: ausearch で侵入兆候を検索する

ausearch を使用して監査ログから特定のイベントを検索します:

# 過去24時間のすべての失敗したログイン試行を検索
ausearch -m USER_LOGIN --success no -ts recent

# 特定のユーザーによって実行されたコマンドを検索
ausearch -ua 1001 -m EXECVE -ts today

# /etc/shadow へのすべてのファイルアクセスイベントを検索
ausearch -f /etc/shadow -ts this-week

# sudoによる特権昇格を検索
ausearch -m USER_CMD -ts today

# カーネルモジュールロードイベントを検索
ausearch -k kernel_module_load -ts this-month

# /tmp から実行されたプロセスを検索(一般的な攻撃ステージング)
ausearch -k exec_from_tmp -ts this-week

# SSH鍵の変更を検索
ausearch -k ssh_key_tampering -ts this-month

# 監査イベントIDで特定のイベントを検索
ausearch -a 12345

# 特定の時間範囲のイベントを検索
ausearch -ts 03/15/2026 08:00:00 -te 03/15/2026 18:00:00

# システムコール番号を解釈し、出力を読みやすく整形
ausearch -k credential_access -i -ts today

ステップ4: aureport でサマリレポートを生成する

aureport を使用して、トリアージのための集計サマリを生成します:

# すべての認証イベントのサマリ
aureport -au -ts this-week --summary

# すべての失敗イベントのレポート(ログイン、アクセスなど)
aureport --failed --summary -ts today

# 実行可能ファイルの実行レポート
aureport -x --summary -ts today

# すべての異常イベントのレポート(セグフォルト、プロミスキャスモードなど)
aureport --anomaly -ts this-week

# ファイルアクセスイベントのレポート
aureport -f --summary -ts today

# キー別の全イベントレポート(カスタムルールキーにマッピング)
aureport -k --summary -ts this-month

# すべてのシステムコールのレポート
aureport -s --summary -ts today

# ユーザー別にグループ化されたイベントのレポート
aureport -u --summary -ts this-week

# タイムライン構築のための詳細な時間ベースのイベントレポート
aureport -ts 03/15/2026 08:00:00 -te 03/15/2026 18:00:00 --summary

ステップ5: 攻撃タイムラインを再構築する

ausearchクエリを組み合わせて時系列のストーリーを構築します:

# ステップ5a: 初期アクセスのタイムスタンプを特定
ausearch -m USER_LOGIN -ua 0 --success yes -ts this-week -i | head -50

# ステップ5b: 攻撃者がアクセス後に何をしたかを追跡
# インシデント期間内の侵害アカウントからのすべてのイベントを取得
ausearch -ua <UID> -ts "03/15/2026 14:00:00" -te "03/15/2026 18:00:00" -i \
  | aureport -f -i

# ステップ5c: インシデント期間中に実行されたすべてのコマンドを抽出
ausearch -m EXECVE -ts "03/15/2026 14:00:00" -te "03/15/2026 18:00:00" -i

# ステップ5d: インストールされた持続化メカニズムを確認
ausearch -k cron_persistence -ts "03/15/2026 14:00:00" -i
ausearch -k ssh_key_tampering -ts "03/15/2026 14:00:00" -i

# ステップ5e: 横展開(アウトバウンド接続)を確認
ausearch -k network_connection -ts "03/15/2026 14:00:00" -i

ステップ6: 監査ログをSIEMに転送する

audisp-remote または auditbeat を設定して、ログを集中SIEMに転送し、相関分析を行います:

# オプションA: audisp-remote プラグインを使用
# /etc/audit/plugins.d/au-remote.conf を編集
active = yes
direction = out
path = /sbin/audisp-remote
type = always

# /etc/audit/audisp-remote.conf でリモートターゲットを設定
remote_server = siem.internal.corp
port = 6514
transport = tcp

# オプションB: Elastic Auditbeat を使用
# auditbeat をインストールし、/etc/auditbeat/auditbeat.yml を設定
# Auditbeat はカーネル監査フレームワークから直接読み取ります

主要な概念

用語定義
auditdカーネルから監査イベントを受け取り、/var/log/audit/audit.log に書き込むLinux監査デーモン
auditctl監査システムを制御するコマンドラインユーティリティ: ルールの追加/削除、状態確認、バックログサイズ設定
ausearchメッセージタイプ、ユーザー、ファイル、キー、時間範囲、イベントIDで監査ログを検索するクエリツール
aureportトリアージやコンプライアンスのために監査イベントの集計サマリを生成するレポートツール
監査ルールキー (-k)監査ルールに付与するユーザー定義のラベル。ausearch と aureport で関連イベントを高速フィルタリングできる
システムコール監査システムコール(execve, open, connect, ptrace)のカーネルレベルでの監視。プロセスとファイルのアクティビティを捕捉する
augenrules/etc/audit/rules.d/ 内のすべてのファイルを /etc/audit/audit.rules にマージし、カーネルにロードするユーティリティ

確認項目

  • auditd が動作しており、ルールがロードされている(auditctl -l で期待されるルール数が返る)
  • 監査バックログのオーバーフローがない(auditctl -s で backlog: 0 または低い値、lost: 0)
  • ausearch が各カスタムキーに対してイベントを返す(ausearch -k <key> -ts today で結果が返る)
  • aureport が認証、実行可能ファイル、ファイルイベントに対して空でないサマリを生成する
  • タイムライン再構築により、攻撃者の行動の一貫した時系列が得られる
  • 重要なファイル監視がテスト操作(touch /etc/shadow)でアラートをトリガーする
  • ログが中央SIEMに転送されている(テストイベントで受信を確認)
  • 監査ルールが再起動後も持続する(ルールが /etc/audit/rules.d/ にあり、auditctl 経由のみではない)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

関連スキル