RockyLinuxにSnort3をインストールして構成する
[**]この記事の執筆時点では、RockyLinuxのデフォルトリポジトリはSnortパッケージを提供していません。 そのため、RockyLinuxにSnort3をインストールして構成するには、ソースからビルドする必要があります。
ソースコードからRockyLinuxにSnort3をビルドしてインストールする
[**]RockyLinuxでのSnort3のビルドとインストールを成功させるには、ビルドプロセスの前にインストールする必要のあるビルドツールと依存関係がいくつかあります。
[**]EPELをインストールし、Powertoolsリポジトリを有効にします。
dnf install epel-release
dnf config-manager --set-enabled powertools
[**]次に、必要なビルドツールとライブラリをインストールします。
dnf -y install bison flex libtool nghttp2 libnghttp2-devel
libpcap-devel pcre-devel openssl-devel libdnet-devel
libtirpc-devel git gcc-c++ libunwind-devel cmake hwloc-devel
luajit-devel xz-devel libnfnetlink-devel libmnl-devel
libnetfilter_queue-devel uuid-devel libsafec-devel
[**]Snort DAQの最新バージョンをダウンロードしてインストールします(データ収集 図書館)。 DAQはデフォルトのUbuntuリポジトリでは利用できないため、ソースからビルドしてインストールする必要があります。
mkdir snort-source-files && cd snort-source-files
git clone https://github.com/snort3/libdaq.git cd libdaq ./bootstrap ./configure make make install
[**]ダウンロードとインストール グーグルのスレッドキャッシングmalloc、Tcmalloc、メモリアロケータ 同時実行性の高い状況向けに最適化されており、メモリ使用量の増加とのトレードオフの速度が向上します。 これはオプションの依存関係ですが、強くお勧めします。
cd ../ wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.9.1/gperftools-2.9.1.tar.gz tar xzf gperftools-2.9.1.tar.gz cd gperftools-2.9.1/ ./configure make make install
ソースコードからRockyLinuxにSnort3をインストールする
[**]必要な依存関係がすべて整ったので、RockyLinuxにSnort3をダウンロードしてインストールします。
[**]から リリースページ、Snort tarballの最新リリースバージョンを入手して、ダウンロードしてください。 以下のコマンドは、この記事の執筆時点での最新リリースであるSnort3.1.28.0をダウンロードします。
cd ../
wget https://github.com/snort3/snort3/archive/refs/tags/3.1.28.0.tar.gz
[**]Snort 3ソースディレクトリを抽出して移動し、コンパイルしてインストールします。
tar xzf 3.1.28.0.tar.gz
cd snort3-3.1.28.0
./configure_cmake.sh --prefix=/usr/local --enable-tcmalloc
[**]サンプルビルドの概要。
...
-------------------------------------------------------
snort version 3.1.28.0
Install options:
prefix: /usr/local
includes: /usr/local/include/snort
plugins: /usr/local/lib64/snort
Compiler options:
CC: /usr/bin/cc
CXX: /usr/bin/c++
CFLAGS: -fvisibility=hidden -DNDEBUG -g -ggdb -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -O2 -g -DNDEBUG
CXXFLAGS: -fvisibility=hidden -DNDEBUG -g -ggdb -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -O2 -g -DNDEBUG
EXE_LDFLAGS:
MODULE_LDFLAGS:
Feature options:
DAQ Modules: Static ()
libatomic: System-provided
Flatbuffers: OFF
Hyperscan: OFF
ICONV: ON
Libunwind: ON
LZMA: ON
RPC DB: Built-in
SafeC: OFF
TCMalloc: ON
JEMalloc: OFF
UUID: OFF
-------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /root/snort-source-files/snort3-3.1.28.0/build
[**]ビルドディレクトリに移動し、Snort3をコンパイルしてRockyLinuxにインストールします。
cd build
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig
make
make install
[**]インストールが完了したら、共有ライブラリを更新します。
ln -s /usr/local/lib/libtcmalloc.so.4 /lib/
ln -s /usr/local/lib/libdaq.so.3 /lib/
ldconfig
[**]バージョンを確認して、Snort3のインストールを確認します。
snort -V
,,_ -*> Snort++ <*-
o" )~ Version 3.1.28.0
'''' By Martin Roesch & The Snort Team
http://snort.org/contact#team
Copyright (C) 2014-2022 Cisco and/or its affiliates. All rights reserved.
Copyright (C) 1998-2013 Sourcefire, Inc., et al.
Using DAQ version 3.0.7
Using LuaJIT version 2.1.0-beta3
Using OpenSSL 1.1.1k FIPS 25 Mar 2021
Using libpcap version 1.9.1 (with TPACKET_V3)
Using PCRE version 8.42 2018-03-20
Using ZLIB version 1.2.11
Using LZMA version 5.2.4
[**]上記は、Snort 3のインストールが成功し、正常に機能していることを確認します。
Snortコマンドラインヘルプの取得
[**]Snortコマンドラインヘルプを取得するには、以下のコマンドのいずれかを実行して、違いを確認してください。
snort --help
snort -?
Snort has several options to get more help: -? list command line options (same as --help) --help this overview of help --help-commands [<module prefix>] output matching commands --help-config [<module prefix>] output matching config options --help-counts [<module prefix>] output matching peg counts --help-limits print the int upper bounds denoted by max* --help-module <module> output description of given module --help-modules list all available modules with brief help --help-modules-json dump description of all available modules in JSON format --help-plugins list all available plugins with brief help --help-options [<option prefix>] output matching command line options --help-signals dump available control signals --list-buffers output available inspection buffers --list-builtin [<module prefix>] output matching builtin rules --list-gids [<module prefix>] output matching generators --list-modules [<module type>] list all known modules --list-plugins list all known modules --show-plugins list module and plugin versions --help* and --list* options preempt other processing so should be last on the command line since any following options are ignored. To ensure options like --markup and --plugin-path take effect, place them ahead of the help or list options. Options that filter output based on a matching prefix, such as --help-config won't output anything if there is no match. If no prefix is given, everything matches. Report bugs to [email protected]
RockyLinuxでのSnort3の構成
ネットワークインターフェイスカードを構成する
[**]まず、Snortがネットワークトラフィックをリッスンしているインターフェイスをオンにします promiscuous モードを使用すると、Snort 3サーバー内から発信されたトラフィックだけを表示するのではなく、送信されたすべてのネットワークトラフィックを表示できます。
ip link set dev enp0s8 promisc on
[**]確認;
ip add sh enp0s8
3: enp0s8: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:84:be:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.60.22/24 metric 100 brd 192.168.56.255 scope global dynamic enp0s8
valid_lft 377sec preferred_lft 377sec
inet6 fe80::a00:27ff:fe84:be8b/64 scope link
valid_lft forever preferred_lft forever
[**]Snortが1518バイトを超える大きなパケットを切り捨てないようにするには、インターフェイスオフロードを無効にします。 この機能が有効になっているかどうかを確認できます。
ethtool -k enp0s8 | grep receive-offload
generic-receive-offload: on
large-receive-offload: off [fixed]
[**]GROは、LROが固定されている間は有効になっているため、変更できません。
[**]次に無効にします。
ethtool -K enp0s8 gro off lro off
[**]2つのNICの変更は一時的なものです。 システムの再起動後も変更が持続するようにするには、systemdサービスユニットを作成して有効にし、変更を実装します。
cat > /etc/systemd/system/snort3-nic.service << 'EOL' [Unit] Description=Set Snort 3 NIC in promiscuous mode and Disable GRO, LRO on boot After=network.target [Service] Type=oneshot ExecStart=/usr/sbin/ip link set dev enp0s8 promisc on ExecStart=/usr/sbin/ethtool -K enp0s8 gro off lro off TimeoutStartSec=0 RemainAfterExit=yes [Install] WantedBy=default.target EOL
[**]systemd構成設定をリロードします。
systemctl daemon-reload
[**]起動時にサービスを開始して有効にします。
systemctl enable --now snort3-nic.service
RockyLinuxにSnort3ルールセットをインストールする
[**]ルールセットは、Snorts侵入検知エンジンの主要な動脈です。 Snortルールには次の3つのタイプがあります。
- コミュニティルール
- 登録規則
- サブスクライバールール
[**]このチュートリアルでは、コミュニティのSnortルールをインストールします。
[**]Snortルールディレクトリを作成します。 の中に /usr/local/etc/snort/snort_defaults.lua デフォルトのルールパス(RULE_PATH)である設定ファイルは次のように定義されます。 /usr/local/etc/rules。
mkdir /usr/local/etc/rules
[**]Snort3コミュニティルールをからダウンロード Snort3ダウンロードページ;
wget -qO-
https://www.snort.org/downloads/community/snort3-community-rules.tar.gz
| tar xz -C /usr/local/etc/rules/
ls -1 /usr/local/etc/rules/snort3-community-rules/
AUTHORS
LICENSE
sid-msg.map
snort3-community.rules
VRT-License.txt
[**]開始するためのルールができたので、Snort3を構成する必要があります。
[**]編集のためにメイン構成ファイルを開きます。
vim /usr/local/etc/snort/snort.lua
[**]の値として、攻撃から保護するようにネットワークを設定します HOME_NET 変数。 これは、単一のIPアドレス、サブネットにすることができます…簡単にするために、これをSnort3インターフェイスのサブネットに設定します。 The EXTERNAL_NET HOME_NET以外のものです。
... -- HOME_NET and EXTERNAL_NET must be set now -- setup the network addresses you are protecting HOME_NET = '192.168.60.22/32' -- set up the external network addresses. -- (leave as "any" in most situations) -- EXTERNAL_NET = 'any' EXTERNAL_NET = '!$HOME_NET' ...
[**]変更を保存してファイルを終了します。
[**]次に、ルールへのパスを更新します /usr/local/etc/snort/snort.lua 構成ファイル。
ips =
{
-- use this to enable decoder and inspector alerts
--enable_builtin_rules = true,
-- use include for rules files; be sure to set your path
-- note that rules files can include other rules files
-- (see also related path vars at the top of snort_defaults.lua)
variables = default_variables,
rules = [[
include $RULE_PATH/snort3-community-rules/snort3-community.rules
]]
}
[**]構成ファイルを保存して終了します。
SnortOpenAppIDのインストール
[**]OpenAppIDは、Snortがネットワークで使用されているさまざまなアプリケーション(Facebook、Netflix、Twitter、Reddit)を検出できるようにするアプリケーション層プラグインです。 以下のコマンドを実行します。 Snort3ダウンロードページ SnortOpenAppIDをインストールします。
wget https://www.snort.org/downloads/openappid/23020 -O OpenAppId-23020.tgz
tar -xzvf OpenAppId-23020.tgz
cp -R odp /usr/local/lib/
[**]次に、Snort 3構成ファイルを編集し、OpenAppIDライブラリの場所を定義します。
vim /usr/local/etc/snort/snort.lua
appid =
{
-- appid requires this to use appids in rules
--app_detector_dir = 'directory to load appid detectors from'
app_detector_dir = '/usr/local/lib',
log_stats = true,
}
[**]構成ファイルを保存して終了します。
[**]SnortsLogディレクトリを作成します。
mkdir /var/log/snort
[**]次に、構文チェックを実行します。
snort -c /usr/local/etc/snort/snort.lua
-------------------------------------------------- o")~ Snort++ 3.1.28.0 -------------------------------------------------- Loading /usr/local/etc/snort/snort.lua: Loading snort_defaults.lua: Finished snort_defaults.lua: Loading file_magic.lua: Finished file_magic.lua: ssh host_cache pop so_proxy stream_tcp mms smtp gtp_inspect packets dce_http_proxy stream_icmp normalizer ips binder wizard appid file_id stream_udp http2_inspect http_inspect ftp_data search_engine ftp_server port_scan dce_http_server dce_smb dce_tcp netflow iec104 cip telnet ssl sip rpc_decode modbus host_tracker stream_user stream_ip back_orifice trace classifications dnp3 active process ftp_client decode daq alerts stream network references arp_spoof output hosts dns dce_udp imap file_policy s7commplus stream_file Finished /usr/local/etc/snort/snort.lua: -------------------------------------------------- pcap DAQ configured to passive. Snort successfully validated the configuration (with 0 warnings). o")~ Snort exiting
[**]Snortセットアップをテストする目的で、カスタムローカルルールを作成します。
vim /usr/local/etc/rules/local.rules
[**]pingテストを検出するためのルールを作成します。
alert icmp any any -> $HOME_NET any (msg:"ICMP connection test"; sid:1000001; rev:1;)
[**]ローカルルールファイルを保存して終了します。 構文を確認してください。
snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/rules/local.rules
[**]次に、以下のコマンドを実行してテストを実行します。
snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/rules/local.rules -i enp0s8 -A alert_fast -s 65535 -k none
[**]別の端末で、Snortサーバーにpingを実行します。
[**]pingの実行中、標準出力に書き込まれたアラート行が表示されます。
...
05/03-11:24:01.979485 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:03.006407 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:04.026118 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:05.053991 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:06.074083 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:07.097995 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:08.122173 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:09.145955 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:10.169989 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:11.194106 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:12.218152 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:13.241983 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:14.266063 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:15.289931 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:16.314112 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:17.337879 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:18.362716 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:19.364461 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:20.365276 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:21.370316 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:22.371367 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:23.386220 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:24.410267 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:25.410309 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:26.426397 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:27.427366 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:28.442598 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
05/03-11:24:29.443398 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.56.1 -> 192.168.56.124
...
[**]キャンセルすると、パケット統計が表示されます。
Packet Statistics
--------------------------------------------------
daq
received: 129
analyzed: 119
dropped: 6
outstanding: 10
allow: 119
rx_bytes: 15783
--------------------------------------------------
codec
total: 119 (100.000%)
arp: 4 ( 3.361%)
eth: 119 (100.000%)
icmp4: 68 ( 57.143%)
ipv4: 115 ( 96.639%)
tcp: 41 ( 34.454%)
udp: 6 ( 5.042%)
--------------------------------------------------
Module Statistics
--------------------------------------------------
appid
packets: 115
processed_packets: 115
total_sessions: 5
service_cache_adds: 4
bytes_in_use: 608
items_in_use: 4
--------------------------------------------------
arp_spoof
packets: 4
--------------------------------------------------
back_orifice
packets: 6
--------------------------------------------------
binder
raw_packets: 4
new_flows: 5
inspects: 9
--------------------------------------------------
detection
analyzed: 119
hard_evals: 68
raw_searches: 24
cooked_searches: 2
pkt_searches: 26
alerts: 34
total_alerts: 34
logged: 34
--------------------------------------------------
normalizer
test_tcp_ts_nop: 1
--------------------------------------------------
pcre
pcre_rules: 178
pcre_native: 178
--------------------------------------------------
port_scan
packets: 115
trackers: 8
--------------------------------------------------
search_engine
non_qualified_events: 34
qualified_events: 34
searched_bytes: 5452
--------------------------------------------------
stream
flows: 5
--------------------------------------------------
stream_icmp
sessions: 1
max: 1
created: 1
released: 1
--------------------------------------------------
stream_tcp
sessions: 1
max: 1
created: 1
released: 1
instantiated: 1
setups: 1
data_trackers: 1
segs_queued: 21
segs_released: 21
segs_used: 21
rebuilt_packets: 2
rebuilt_bytes: 392
client_cleanups: 1
server_cleanups: 1
partial_fallbacks: 1
max_segs: 17
max_bytes: 3196
--------------------------------------------------
stream_udp
sessions: 3
max: 3
created: 3
released: 3
total_bytes: 2541
--------------------------------------------------
wizard
tcp_scans: 17
udp_scans: 3
udp_misses: 3
--------------------------------------------------
Appid Statistics
--------------------------------------------------
detected apps and services
Application: Services Clients Users Payloads Misc Referred
dhcp: 2 0 0 0 0 0
icmp: 1 0 0 0 0 0
unknown: 1 0 0 0 0 0
--------------------------------------------------
Summary Statistics
--------------------------------------------------
process
signals: 1
--------------------------------------------------
timing
runtime: 00:00:50
seconds: 50.745225
pkts/sec: 2
o")~ Snort exiting
Snort3ロギングを構成する
[**]Snort 3イベントをログファイルに書き込むには、アラート設定を構成する必要があります。 でよく説明されているさまざまなSnortロギングオプションがあります Snort 3マニュアル、ロガーモジュールセクション。 イベントデータを簡単な形式でファイルに出力するには(上記のコマンドラインでオプションで定義されているように) -A alert_type)、を開きます snort.lua 構成を行い、出力セクションに進みます。
vim /usr/local/etc/snort/snort.lua
--------------------------------------------------------------------------- -- 7. configure outputs --------------------------------------------------------------------------- -- event logging -- you can enable with defaults from the command line with -A-- uncomment below to set non-default configs --alert_csv = { } alert_fast = { file = true, packet = false, limit = 10, } --alert_full = { } --alert_sfsocket = { } --alert_syslog = { } --unified2 = { }
[**]この設定により、snortはログを書き込みます alert_fast.txt ファイル。
[**]構成を保存して終了し、構文チェックを実行します。
snort -c /usr/local/etc/snort/snort.lua
[**]今度はオプションなしでコマンドを再実行します。 -A alert_fast、ただし、ログディレクトリを指定するオプションがあります。 -l /var/log/snort。
snort -c /usr/local/etc/snort/snort.lua -R /usr/local/etc/rules/local.rules -i enp0s8 -s 65535 -k none -l /var/log/snort/
[**]pingテストを再度実行します。
[**]ログディレクトリを確認すると、 alert_fast.txt ファイルが作成されました。 このファイルを調整できます。
tail -f /var/log/snort/alert_fast.txt
05/05-14:01:33.468399 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:34.492480 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:35.516336 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:36.544332 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:37.564282 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:38.588384 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:39.612393 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:40.636332 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:41.664373 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:42.684480 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:43.708500 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:44.732387 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
05/05-14:01:45.756329 [**] [1:1000001:1] "ICMP connection test" [**] [Priority: 0] [AppID: ICMP] {ICMP} 192.168.60.1 -> 192.168.60.22
[**]ローカルルールをsnort.luaに含めることができます。
vim /usr/local/etc/snort/snort.lua
ips =
{
-- use this to enable decoder and inspector alerts
--enable_builtin_rules = true,
-- use include for rules files; be sure to set your path
-- note that rules files can include other rules files
-- (see also related path vars at the top of snort_defaults.lua)
variables = default_variables,
rules = [[
include $RULE_PATH/snort3-community-rules/snort3-community.rules
include $RULE_PATH/local.rules
]]
}
Snortをサービスとして実行する
[**]コマンドラインオプションを使用して、バックグラウンドでデーモンとしてSnortを実行することは可能ですが -D、Snortのsystemdサービスユニットを作成することもできます。
[**]Snortをサービスとして実行する場合は、特権のないシステムユーザーで実行することをお勧めします。 したがって、Snortの非ログインシステムユーザーアカウントを作成します。
useradd -r -s /usr/sbin/nologin -M -c SNORT_IDS snort
[**]Snortがsnortユーザーとして実行されるsystemdサービスユニットを作成します。 それに応じてインターフェイスを調整します。
cat > /etc/systemd/system/snort3.service << EOL [Unit] Description=Snort Daemon After=syslog.target network.target [Service] Type=simple ExecStart=/usr/local/bin/snort -c /usr/local/etc/snort/snort.lua -s 65535 -k none -l /var/log/snort -D -i enp0s8 -m 0x1b -u snort -g snort ExecStop=/bin/kill -9 $MAINPID [Install] WantedBy=multi-user.target EOL
[**]systemd構成をリロードします。
systemctl daemon-reload
[**]ログファイルの所有権と権限を設定します。
chmod -R 5775 /var/log/snort
chown -R snort:snort /var/log/snort
[**]Snortを起動し、システム起動時に実行できるようにします。 サービスはrootとして実行され、作成されたSnortユーザーに特権をドロップします。
systemctl enable --now snort3
[**]サービスをチェックして、実行されているかどうかを確認します。
systemctl status snort3
● snort3.service - Snort Daemon
Loaded: loaded (/etc/systemd/system/snort3.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2022-05-05 14:00:22 EDT; 4s ago
Main PID: 60655 (snort)
Tasks: 2 (limit: 11256)
Memory: 218.3M
CGroup: /system.slice/snort3.service
└─60655 /usr/local/bin/snort -c /usr/local/etc/snort/snort.lua -s 65535 -k none -l /var/log/snort -D -i enp0s8 -m 0x1b -u snort -g snort
May 05 14:00:22 localhost.localdomain systemd[1]: Started Snort Daemon.
[**]これで、RockyLinuxにSnort3をインストールして構成する方法に関するチュートリアルは終了です。
参照
[**]Snort3のインストール
参考文献
[**]Snort3ユーザーマニュアル
関連チュートリアル
[**]Ubuntu22.04にSnort3をインストールして構成する
[**]RockyLinuxにSuricataをインストールしてセットアップする
The post RockyLinuxにSnort3をインストールして構成する appeared first on Gamingsym Japan.