Snort3(設定)

設定

    [root]# ls /usr/local/snort/etc/snort/

      balanced.lua  file_magic.lua  max_detect.lua  snort.lua  talos.lua
     connectivity.lua  inline.lua  security.lua  snort_defaults.lua

    snort_defaults.lua はルールへのパス、AppID、インテリジェンスリスト、
   ネットワークなどのデフォルト値。

    snort.lua は Snort のメイン構成、Snort の実装と構成が可能。ルールファイル
   の組み込み、出力など。

    file_magic.lua には、事前定義されたファイル ID が記述され、snort.lua
   で利用される、変更の必要なし。

snort_defaults.lua

    [root]# vim /usr/local/snort/etc/snort/snort_defaults.lua

    ------------------------------------------------------------
    -- default paths
    ------------------------------------------------------------
    -- Path to your rules files (this can be a relative path)
    RULE_PATH = '../../rules'
    BUILTIN_RULE_PATH = '../../builtin_rules'
    PLUGIN_RULE_PATH = '../../so_rules'

    -- If you are using reputation preprocessor set these
    ALLOW_LIST_PATH = '../../intel'
    BLOCK_LIST_PATH = '../../intel'

    -- Path to AppID ODP - Optional
    APPID_PATH = '../../appid' or '/usr/local/snort/appid'

snort.lua

    [root]# vim /usr/local/snort/etc/snort/snort.lua

    ,(カンマ)の付け忘れ注意

    ------------------------------------------------------------
    -- 1. configure defaults
    ------------------------------------------------------------

    -- HOME_NET and EXTERNAL_NET must be set now
    -- setup the network addresses you are protecting
    -- HOME_NET = "any"
    HOME_NET = '[[グローバルIP/32,192.168.1.0/24]]'

    -- set up the external network addresses.
    -- (leave as "any" in most situations)
    -- EXTERNAL_NET = "any"
    EXTERNAL_NET = '[[!$HOME_NET]]'

    include 'snort_defaults.lua'
    include 'file_magic.lua'

    ------------------------------------------------------------
    -- 2. configure inspection
    ------------------------------------------------------------

    -- ネットワークを通過するファイルとファイルタイプを識別
    --[[
    file_id =
    {
        enable_type = true,
        enable_signature = true,
        file_rules = file_magic,
        file_policy =
        {
            { use = { verdict = 'log', enable_file_type = true, enable_file_signature = true } }
        }
    }
    --]]

    ※ 上記設定にて、エラー発生
    ERROR: /usr/local/snort/etc/snort/snort.lua: can't find file_id.file_policy
    ERROR: /usr/local/snort/etc/snort/snort.lua: can't find file_id.enable_signature
    ERROR: /usr/local/snort/etc/snort/snort.lua: can't find file_id.enable_type

    モジュールの説明
    [root]# /usr/local/snort/bin/snort --help-module file_id
    [root]# /usr/local/snort/bin/snort --help-module file_policy

    file_id = { rules_file = 'file_magic.rules' }
    file_policy =
    {
        enable_type = true,
        enable_signature = true,
        rules = {
            use = { verdict = "log" }
        },
    }
    
    -- 接続元アプリケーションの検出・識別(SnortSnarf 使用時は、コメントアウト)
    --[[
    appid =
    {
        -- appid requires this to use appids in rules
        app_detector_dir = APPID_PATH,
    }
    --]]

    reputation =
    {
        -- configure one or both of these, then uncomment reputation
        blocklist = BLOCK_LIST_PATH .. '/ip-blocklist',
        allowlist = ALLOW_LIST_PATH .. '/ip-allowlist',
    }

    ------------------------------------------------------------
    -- 5. configure detection
    ------------------------------------------------------------

    ips =
    {
        mode = tap,

        variables = default_variables,

        rules = [[
            include ../../rules/snort.rules  <-- PulledPork
                    or
            include /usr/local/snort/rules/snort.rules  <-- PulledPork
        ]],
    }

    ------------------------------------------------------------
    -- 7. configure outputs
    ------------------------------------------------------------

    -- Snort が検知したログ(/var/log/snort/alert_fast.txt)
    alert_fast =
    {
        file = true,
    }

    -- ファイルイベントのパケットとシステム時刻のログ(/var/log/snort/file.log)
    file_log =
    {
        log_pkt_time = true,
        log_sys_time = false,
    }