最新のSnort 2.9.2をMac OS X Lion上でソースからインストールして動作させる。

ソースファイルダウンロード


Snortのオフィシャルページ(http://www.snort.org/snort-downloads)より、ソースファイルをダウンロードする。

前提ライブラリ


MAC PortでSnortが依存する以下のライブラリをインストールする。Homebrewの場合は、libpcapはApple製を使うためインストールの必要はない。
libdnet, libpcap, libpcre

wchichコマンドを使用して、以下のコマンドが存在するかチェックする。
$ which dnet-config
$ which pcre-config
$ which daq-modules-config

ビルド


テキトウなディレクトリで以下のようなコマンドを実行し、ソースファイルを解凍する。
$ tar xzvf snort-2.9.2.2.tar.gz

doc/INSTALLを見て、MAC用の設定を行ってからビルドする。
Homebrewの環境では、通常/opt/localではなく/usr/localを使用するので適宜変更する。
MySQLへのデータの格納を行うには --with-mysql を付ける必要があるが、オプションを負荷すると2.2.3からは削除されるという警告が表示される。Barnyard2形式で出力してからMySQLに格納することが推奨されているようだ。

Mac Portsの場合

$ glibtoolize --force
$ aclocal -I m4
$ autoheader
$ automake --add-missing --copy
$ autoconf

$ export LD_TWOLEVEL_NAMESPACE=1
$ ./configure prefix=/opt/local --disable-static-daq
$ make
$ make check

Homebrewの場合

$ glibtoolize --force
$ aclocal -I /usr/local/share/aclocal -I m4

$ autoheader
$ automake --add-missing --copy
$ autoconf

$ export LD_TWOLEVEL_NAMESPACE=1
$ ./configure prefix=/usr/local --disable-static-daq
$ make
$ make check

問題なかったらルート権限でインストールする。
# make install

起動


パケットスニファとして起動する。
sudo snort -de -i en0 --daq-dir /opt/local/lib/daq/

後述の設定ファイルで起動する。
sudo snort -de -i en0 --daq-dir /opt/local/lib/daq/ -c /etc/snort/conf.d/snort.conf

起動スクリプト


Mac OS X Lionでは、自動起動にlaunchdを利用する。
ディレクトリ用途
〜/Library/ユーザ毎の設定
/Library/ローカル用の設定
/Library/LaunchAgents管理者によるユーザ毎の設定
/Library/LaunchDeamons管理者による全体の設定
/Systemシステムによる設定
/System/LaunchAgentsシステムによる設定
/System/LaunchDeamonsシステムによる全体の設定

/Library/LaunchDaemons/org.snort.snort.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://
www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>org.snort.snort</string>
 <key>KeepAlive</key>
 <true/>
 <key>RunAtLoad</key>
 <true/>
 <key>ProgramArguments</key>
 <array>
  <string>/opt/local/bin/snort</string>
  <string>-D</string>
  <string>-d</string>
  <string>-e</string>
  <string>-i</string>
  <string>en0</string>
  <string>-c</string>
  <string>/etc/snort/snort.conf</string>
 </array>
 <key>ServiceDescription</key>
 <string>Snort 2.9.2.2</string>
</dict>
</plist>

設定ファイル

ディレクトリは任意だが、/etc/snort以下に配置することとする。構成は以下のとおり。snort-2.9.2.2/etcにあるファイルを/etc/snort以下にコピーする。
  • /etc
    • snort
      • conf.d : 設定ファイルを配置するディレクトリ
      • rules.d : ルールやリストを配置するディレクトリ
      • backup : ルールのバックアップを格納するディレクトリ

snort.conf

/etc/snort/conf.d/snort.conf
Step 1 Set the network variables
ネットワーク設定とパスの設定。
項目デフォルト値設定値
HOME_NETany
ETERNAL_NETany
_SERVERS
_PORTS
RULE_PATH../rules../rules.d
SO_RULE_PATH../so_rules
PREPROC_RULE_PATH../preproc_rules
WHITE_LIST_PATH../rules../rules.d
BLACK_LIST_PATH../rules../rules.d
Step 2 Configure the decoder
Step 3 Configure the base detection engine
Step 4 Configure dynamic loaded libraries
Step 5 Configure preprocessors
プリプロセッサの設定。
Step 6 Configure output plugins
アウトプットプラグインの設定。デフォルトでは、unified2は有効化されていない。
Step 7 Customize your rule set
Step 8 Customize preprocessor and decoder rule set
Step 9 Customize shared object rule set



sid-msg.map

threshold.conf

gen-msg.map

classification.config

white_list.rules

black_list.rules

バイナリの配布

HenWen(http://seiryu.home.comcast.net/~seiryu/henwen.html...というMac向けバイナリのプロジェクトがあったようですが、Snort2.3.3に対応ということでどうやらメンテナンスは終了しているようです。

メンバーのみ編集できます