外部用ネットワークトラフィック - IPv4 - 許可リストの例外あり
Sophos Linux Sensor の調査の接続イベントをクエリすることで、パブリックインターネットへの接続が想定されていないサーバーを監査できます。クエリの結果は、宛先アドレスの一覧です。このような宛先アドレスを使用して、現在の外部接続が既知で、安全または悪意があるとして検出されることを確認できます。
このクエリでは、許可リストを適用できます。
必要なテーブル
- connections
入力フィールド
許可リストは、allowlist
フィールドに IP を追加することで更新できます。各 IP には、SELECT '<IP ADDRESS>' as addr
形式を使用してください。複数の SELECT ステートメントは、UNION ALL
ステートメントで結合してください。
戻りフィールド
フィールド | 説明 |
---|---|
ipint dst_addr | ホワイトリストにない、外部リクエストの ipint および dst_addr |
クエリ
WITH
ipranges as (
SELECT '10.0.0.0' as low, '10.255.255.255' as high
UNION ALL
SELECT '172.16.0.0' as low, '172.31.255.255' as high
UNION ALL
SELECT '192.168.0.0' as low, '192.168.255.255' as high
UNION ALL
SELECT '127.0.0.0' as low, '127.255.255.255' as high
),
allowlist as (
SELECT '100.24.246.89' as addr UNION ALL SELECT '104.16.171.99' as addr
),
ipint as (SELECT dst_addr, (
cast(split_part(dst_addr, '.', 1) AS bigint) * (256 * 256 * 256) +
cast(split_part(dst_addr, '.', 2) AS bigint) * (256 * 256 ) +
cast(split_part(dst_addr, '.', 3) AS bigint) * (256 ) +
cast(split_part(dst_addr, '.', 4) AS bigint)) AS ipint
FROM connections),
iprangesint as (
SELECT CONCAT(ipranges.low, ' - ', ipranges.high) as str,
(cast(split_part(ipranges.low, '.', 1) AS bigint) * (256 * 256 * 256) +
cast(split_part(ipranges.low, '.', 2) AS bigint) * (256 * 256 ) +
cast(split_part(ipranges.low, '.', 3) AS bigint) * (256 ) +
cast(split_part(ipranges.low, '.', 4) AS bigint)) AS low,
(cast(split_part(ipranges.high, '.', 1) AS bigint) * (256 * 256 * 256) +
cast(split_part(ipranges.high, '.', 2) AS bigint) * (256 * 256 ) +
cast(split_part(ipranges.high, '.', 3) AS bigint) * (256 ) +
cast(split_part(ipranges.high, '.', 4) AS bigint)) AS high
FROM ipranges)
SELECT ipint.ipint, ipint.dst_addr
FROM ipint
WHERE NOT EXISTS (SELECT iprangesint.str FROM iprangesint WHERE iprangesint.low <= ipint.ipint AND iprangesint.high >= ipint.ipint) AND dst_addr NOT IN (SELECT addr from allowlist)
ORDER BY dst_addr