HDFS/Presto を使用した調査データの取得
概要
Sophos Linux Sensor (SLS) の非クラウド環境向けの推奨導入は、ストレージに HDFS (Hadoop 分散ファイルシステム) を使用し、クエリエンジンに Presto を使用することです。
設定
調査は、/etc/sophos/runtimedetections-rules.yaml
ファイルで設定します。デフォルトで、プロセスイベント、センサー、およびコンテナイベントが有効になっています。つまり、table
キーが指定されていない場合、そのようなテーブルは、メタイベントの種類ごとに一意のデフォルトの行サイズで自動的にオンになります。追加のテーブルを設定するには、直接指定する必要があります。
次の例では、メタイベントの種類すべてが、HDFS に書き込むように設定されています。
Investigations:
reporting_interval: 5m
sinks:
- name: >-
[The address of the name node here]:9000/[directory on hdfs to store
data, absolute path]
backend: hdfs
automated: true
credentials: null
blob_storage_hdfs_user:'[hadoop username that has write access]'
blob_storaee_create_buckets_enabled: true
flight_recorder:
enabled: true
Tables:
- name: shell_commands
enabled: true
- name: tty_data
enabled: true
- name: file_events
enabled: false
- name: connections
enabled: true
- name: sensor_metadata
enabled: true
- name: alerts
enabled: true
- name: sensors
enabled: true
- name: process_events
enabled: true
- name: container_events
enabled: true
ストレージソリューション
このセクションでは、SLS の調査データ用のストレージソリューションのインストールと設定に役立つガイドを提供します。
HDFS
認証情報
現在、セキュリティで保護されていない HDFS に対応しています。調査データを格納するディレクトリへの書き込みアクセス権のあるユーザーの名前のみが必要です。さらに、HDFS に書き込むすべてのセンサーは、ポート 8020/9000 の NameNode、およびポート 50010 と 50020 のすべての DataNode にアクセスできる必要があります。
SLS の設定
メタイベントを HDFS に書き込むには、ポートとユーザーのある名前ノードのアドレスを使用して設定できます。
次に例を示します。
investigations:
reporting_interval: 5m
sinks:
- name: '[The address of the name node here]:9000/[directory on hdfs to store data, absolute path]'
backend: hdfs
automated: true
credentials:
blob_storage_hdfs_user: '[hadoop username that has write access]'
blob_storage_create_buckets_enabled: true
バケットの作成
HDFS で、blob_storage_create_buckets_enabled: true
を設定することを強く推奨します。これは、HDFS が階層的であるのに対して、Blob ストレージはフラットであることによります。テーブルのサブディレクトリやパーティションフォルダが存在しない場合、書き込みに失敗します。
自動
次の設定は、HDFS でフォルダが存在しない場合は、作成されるようにします。/etc/sophos/runtimedetections-rules.yaml で、blob_storage_create_buckets_enabled
フィールドを有効にします。次の設定例を参照してください。
blob_storage_create_buckets_enabled: true blob_storage_hdfs_user:
クエリソリューション
このセクションでは、SLS の調査のクエリソリューションのインストール/セットアップに役立つガイドを提供します。
Presto: 手動
HDFS の設定
HDFS の詳細は、Presto ガイドを参照してください。
クエリの例
クエリは SQL 構文を使用して実行されます。このセクションでは、一般的なクエリの例を示します。クエリ可能なフィールドすべての詳細なリファレンスは、メタイベントフィルタの使用を参照してください。
誰が Sudo を使用してコマンドを実行したか?
SELECT from_unixtime(process_events.unix_nano_timestamp /
1000000000) as timestamp,
pid, path, username, login_username
FROM process_events where event_type = 0 and username !=
login_username;
どのプログラムとそのユーザーが特定の IP に接続したか?
SELECT DISTINCT from_unixtime(connections.unix_nano_timestamp
/ 1000000000) AS timestamp,
sensors.hostname,
process_events.path,
container_events.container_name,
container_events.image_name,
connections.dst_addr,
connections.dst_port
FROM connections, sensors, container_events, process_events
WHERE connections.process_uuid = process_events.process_uuid
AND container_events.process_uuid = ## Storage solutionsprocess_events.proce
ss_id
AND connections.dst_addr ='$DESTINATION_IP';
どのコンテナまたはイメージが、クラスタのどこで実行されたか?
SELECT sensors.hostname
container_events.image_name, from_unix_time(container_events.unix_nano_timestamp / 1000000000) as timestamp
FROM sensors, container_events;
特定のインシデントに関連する警告すべてを取得する
SELECT *
FROM alerts where incident_id ='$INCIDENT_ID';
特定のインシデントに関連するコマンドすべてを取得する
SELECT from_unixtime(shell_commands.unix_nano_timestamp /
1000000000) AS timestamp,
sensors.hostname,
array_join(shell_commands.program_arguments,' ') as args,
shell_commands.username
FROM shell_commands
JOIN sensors ON sensors.sensor_id = shell_commands.sensor_id
WHERE shell_commands.incident_id ='$INCIDENT_ID';