
FreeBSDのportsのSnort 3.0は暫くビルドできない状態で放置されていたが、3月20日に更新されてビルドできるようになったようなのでインストールして試してみた。(ただし題名のとおり今回は意図したようには動かなかった)
インストール
portsのビルドオプションは初期値+Hyperscanにチェックした。
# cd /usr/ports/security/snort3 # make install # which snort /usr/local/bin/snort # snort -V ,,_ -*> Snort++ <*- o" )~ Version 3.0.0 (Build 243) FreeBSD '''' By Martin Roesch & The Snort Team http://snort.org/contact#team Copyright (C) 2014-2018 Cisco and/or its affiliates. All rights reserved. Copyright (C) 1998-2013 Sourcefire, Inc., et al. Using DAQ version 2.2.2 Using LuaJIT version 2.0.5 Using OpenSSL 1.0.2o 27 Mar 2018 Using libpcap version 1.8.1 Using PCRE version 8.40 2017-01-11 Using ZLIB version 1.2.11 Using Hyperscan version 4.6.0 2018-04-06 Using LZMA version 5.2.3
ビルドできたし一応動いた。
動作準備
# bash #←以下はbshやbashで実施 # export LUA_PATH=/usr/local/include/snort/lua/\?.lua\;\; # export SNORT_LUA_PATH=/usr/local/etc/snort # env | grep LUA LUA_PATH=/usr/local/include/snort/lua/?.lua;; SNORT_LUA_PATH=/usr/local/etc/snort~/.profileや ~/.bashrcに2行追記
1 2 | export LUA_PATH=/usr/local/include/snort/lua/\?.lua\;\;
export SNORT_LUA_PATH=/usr/local/etc/snort
|
動作試験
# mv /usr/local/etc/snort/snort.lua /usr/local/etc/snort/snort_local.lua #portsを更新するとsnort.luaが強制的に上書きされるのでこうしておく(こちらを使う) # /usr/local/bin/snort -c /usr/local/etc/snort/snort_local.lua -------------------------------------------------- o")~ Snort++ 3.0.0-243 -------------------------------------------------- Loading /usr/local/etc/snort/snort_local.lua: FATAL: /usr/local/include/snort/lua/snort_config.lua:88: Undefined symbol "set_string" Fatal Error, Quitting..
早くもここでエラーになるとはイヤな予感。
/usr/local/include/snort/lua/snort_config.lua1 2 3 4 5 6 7 8 | -- elseif ( what == 'string' ) then
-- ffi.C.set_string(name, val)
-- elseif ( what == 'table' ) then
-- if ( ffi.C.open_table(name, idx) ) then
-- snort_traverse(val, name)
-- ffi.C.close_table(name, idx)
-- end
|
後のことは考えずにとりあえず、 88〜94行目の行頭に -- を付ける
再度実行
# /usr/local/bin/snort -c /usr/local/etc/snort/snort_local.lua
--------------------------------------------------
o")~ Snort++ 3.0.0-243
--------------------------------------------------
Loading /usr/local/etc/snort/snort_local.lua:
Finished /usr/local/etc/snort/snort_local.lua.
--------------------------------------------------
pcap DAQ configured to passive.
Snort successfully validated the configuration (with 0 warnings).
o")~ Snort exiting
警告が出たりエラーにならずに正常に終了した。
ルールファイルの使用
コミュニティ版のルールファイルを取得する。
# mkdir /usr/local/etc/snort/rules # cd ~ # fetch https://www.snort.org/downloads/community/snort3-community-rules.tar.gz # tar -zxvf snort3-community-rules.tar.gz # mv snort3-community-rules/snort3-community.rules /usr/local/etc/snort/rules/ # mv snort3-community-rules/sid-msg.map /usr/local/etc/snort/rules/
コミュニティルールのファイルは大きいけど中身は殆どの行がコメントになっているのでルールとして成立しているのは数行だけ。
必要に応じてコメントを外すみたい。動作試験の段階なのでコメントを外さずに試す。
# snort -c /usr/local/etc/snort/snort_local.lua -R /usr/local/etc/snort/rules/snort3-community.rules
--------------------------------------------------
o")~ Snort++ 3.0.0-243
--------------------------------------------------
Loading snort_local.lua:
Finished snort_local.lua.
Loading rules:
Loading snort3-community.rules:
ERROR: snort3-community.rules:389 Undefined variable in the string: $SQL_SERVERS.
ERROR: snort3-community.rules:389 undefined variable in the string: $EXTERNAL_NET.
ERROR: snort3-community.rules:389 invalid argument classtype: = unsuccessful-user
ERROR: snort3-community.rules:1777 Undefined variable in the string: $HOME_NET.
ERROR: snort3-community.rules:1777 undefined variable in the string: $EXTERNAL_NET.
FATAL: snort3-community.rules:1777 ***PortVar Lookup failed on '$HTTP_PORTS'.
Fatal Error, Quitting..
変数が全部取れてない。\(^o^)/オワタ
$SQL_SERVERS, $HOME_NET, $EXTERNAL_NET, $HTTP_PORTSはsnort_local.lua(snort.lua)またはsnort_defaults.luaで定義済みの筈なのでこれがダメだと何もできない。
snort_config.luaでエラーになってコメント化した部分を直さないとマズいのかしら。それか根本的なところが解ってなくて見当違いなことをしているか。