Snort Configuration Manulal

Snort最新バージョン
2005/2/5現在
Snort 2.3.0
pcre 5.0
ACID 0.9.6b23
BASE 1.0.1
SnortCenter 1.0-RC1

目次

Snortの情報はネット上にいくつもあるので別のページを参考にしてください。 SnortCenterは情報こそ少ないですが、もう更新もされていないので今後には期待できません。 ということでこのページは参考になりません。 あしからず・・・

※Snortcenter2って言うのが2004年の年末に出たんですね。 http://sourceforge.net/projects/snortcenter2 後日入れてみます。 結果はもうしばらくお待ちください。 場合によってはSnortcenter2の部分だけ切り離して書く可能性もあります。

※Snort.orgでのルールセット(シグネチャ)の配布の形式が変わりました。詳細に関しましてはこちらをご参照ください。 一応簡単に説明しておきますが、ルールが3種類に分かれたようです。

1.Sourcefire VRT certified Rule:Subscriber
有償のルールセットのようです。主に商用で使用する場合には、ライセンスの購入が必要なようです。
2.Sourcefire VRT certified Rule:Register
登録するだけで使用できるルールセットです。2.0・2.1のルールを入手は、このRegisterからのみ入手できるようです。
3.Community Rules
登録もする必要なく、すぐに手に入るルールセットです。今までどおり、普通に使えます。

PHPのリコンパイル

PHPコンパイルオプション

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-gd --enable-bcmath --enable-sockets
--enable-mbstring --with-zlib --enable-mbregex --enable-zend-multibyte --with-curl
make
make install

コンフィグレーションでエラーが出たら、対策をして再度チャレンジ こればかりはがんばるしかないね。 ちなみにCURLはRPMで入れてあってもエラーが出たので、私はソースから再度インストールした。

MySQLのインストール

rpmのインストール

ACIDやBASEを使うにはSQLサーバをインストールする必要がある。 今回はMySQLを用いて構築する。 MySQLはRPMを配布しているので、普通にRPMをインストールすればよい。 ちなみにRPMでインストールする必要のあるファイルは

MySQL-server
MySQL-client
MySQL-shard
MySQL-shard-compact  <==必須ではない
MySQL-devel

以上の5種類である。 mysqlのrootユーザの設定する。

/usr/bin/mysqladmin -u root password "newpassword"

これでmysqlのルートユーザのパスワードが”newpassword”に設定された。

不要なデータベースの削除

デフォルトで不必要なデータベースが登録されているのでそれを削除する。 とりあえず今作られているデータベース一覧の表示

mysqlshow -p
+-----------+
| Databases |
+-----------+
| mysql     |
| test      |
+-----------+

mysqlとtestというデータベースが存在していることがわかる。 そしてmysqlデータベースの中を見て不必要な部分を削除する。

mysql> connect mysql;
mysql> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
|      | myhost    |
| root | myhost    |
|      | localhost |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)

上記のように表示されるはずなので、以下のように入力し、削除を行う。

mysql> delete from user where user="";
mysql> delete from db where user="";
mysql> select user,host from user;
+------+-----------+
| user | host      |
+------+-----------+
| root | myhost    |
| root | localhost |
+------+-----------+
2 rows in set (0.00 sec)

こうなればOK。

Snortデータベースの作成・設定

Snortのデータベースを作る。

mysql -u root -p
mysql> create database snort;
mysql> exit

Snortで使うテーブルの作成

mysql -D snort -u root -p < snort-2.2.0/contrib/create_mysql

テーブルが出来たかどうか確認

mysql -u root -p
mysql> connect snort;
mysql> show tables;
+------------------+
| Tables_in_snort  |
+------------------+
| data             |
| detail           |
| encoding         |
| event            |
| icmphdr          |
| iphdr            |
| opt              |
| reference        |
| reference_system |
| schema           |
| sensor           |
| sig_class        |
| sig_reference    |
| signature        |
| tcphdr           |
| udphdr           |
+------------------+
16 rows in set (0.00 sec)

テーブルが作成されたことが確認できた。

mysql> grant INSERT,SELECT on snort.* to snort@localhost;
mysql> grant CREATE,INSERT,SELECT,UPDATE,DELETE on snort.* to acid@localhost;
mysql> set password for 'snort'@'localhost' = password('snortpassword');
mysql> set password for 'acid'@'localhost' = password('acidpassword');
mysql> flush privileges;

一応これでうまくいくはずなんだけど、上手くいく時と上手くいかない時がある。 なぜかはよくわからないんだよねぇ~?? たぶん、私の環境でのみ起こる問題だと思う。

Snortのインストール

pcreのインストール

Snortをインストールする前にpcreをインストールしておく必要がある。 いつもの手順でインストール。

tar zxvf pcre-5.0.tar.gz
cd pcre-5.0
./configure
make
make install

特に問題なくインストールできるはずである。

Snortのインストール

で・・・いよいよメインプログラムのインストール。 DBとしてMySQLを使うので、指定は忘れずに・・・

tar zxvf snort-2.2.0.tar.gz
cd snort-2.2.0
./configure --with-mysql
make
make install

終了したらSnortの設定を格納するディレクトリを作成。 Snortのコンフィグファイルをコピー。 おまけにプリプロセッサのコンフィグファイルもコピー。

mkdir /etc/snort
cp etc/snort.conf /etc/snort
cp etc/classification.config /etc/snort
cp etc/reference.config /etc/snort
cp etc/threshold.conf /etc/snort
cp etc/unicode.map /etc/snort

snort.confの設定は省略。ほかのページを参考にしてね♪

最新版のシグネチャを入手

Snort.orgから最新版のシグネチャを入手する。

wget http://www.snort.org/dl/rules/snortrules-snapshot-2_2.tar.gz
tar zxvf snortrules-snapshot-2_2.tar.gz
mv rules/ /etc/snort

Snortを動かす

snort.confをを編集した後で、以下のコマンドを実行。

snort -D -c /etc/snort/snort.conf

デーモンとして動いていればOK。 次いってみよう。

ACIDのインストール

gdをインストール。

tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure
make
make install

adodbjpgraphの展開

tar zxvf adodb454.tgz -C /usr/local/apache2/htdocs
tar zxvf jpgraph-1.16.tar.gz -C /usr/local/apache2/htdocs
mv /usr/local/apache2/htdocs/jpgraph11.16 /usr/local/apache2/htdocs/jpgraph

ACIDの導入

tar zxvf acid-0.9.6b23.tar.gz -C /usr/local/apache2/htdocs
cd /usr/local/apache2/htdocs/acid
vi acid_conf.php
--------------------------------------------------
$DBlib_path = "../adodb";
$DBtype = "mysql";
$alert_dbname   = "snort";
$alert_host     = "localhost";
$alert_port     = "3306";
$alert_user     = "acid";
$alert_password = "acidpassword";
$ChartLib_path = "../jpgraph/src";
--------------------------------------------------

以上の設定をして、ACIDを設置したディレクトリにアクセス。 上手く動くはず・・・。

SnortCenterのインストール

SnortCenter Agentのインストール

SnortCenter Agentを、まずはインストール

mkdir /opt/snortagent
tar xvfz snortcenter-agent-v1.0-RC1.tar.gz -C /opt/snortagent
cd /opt/snortagent/sensor/
./setup.sh
Config file directory [/opt/snortagent/sensor/conf]:
Log file directory [/opt/snortagent/sensor/log]:
Full path to perl (default /usr/bin/perl):
Full path to snort (default /usr/local/bin/):
Snort Rule config file directory [/opt/snortagent/sensor/rules/]:
***********************************************************************
For Webmin to work properly, it needs to know which operating system
type and version you are running. Please select your system type by
entering the number next to it from the list below
---------------------------------------------------------------------------
  1) Sun Solaris            2) Caldera OpenLinux eS   3) Caldera OpenLinux
  4) Redhat Linux           5) Slackware Linux        6) Debian Linux
  7) SuSE Linux             8) United Linux           9) Corel Linux
 10) TurboLinux            11) Cobalt Linux          12) Mandrake Linux
 13) Mandrake Linux Corpo  14) Delix DLD Linux       15) Conectiva Linux
 16) ThizLinux Desktop     17) ThizServer            18) MSC Linux
 19) MkLinux               20) LinuxPPC              21) XLinux
 22) LinuxPL               23) Trustix               24) Cendio LBS Linux
 25) Ute Linux             26) Lanthan Linux         27) Yellow Dog Linux
 28) Corvus Latinux        29) Immunix Linux         30) Gentoo Linux
 31) Lycoris Desktop/LX    32) Secure Linux          33) Generic Linux
 34) FreeBSD               35) OpenBSD               36) NetBSD
 37) BSDI                  38) HP/UX                 39) SGI Irix
 40) DEC/Compaq OSF/1      41) IBM AIX               42) SCO UnixWare
 43) SCO OpenServer        44) Darwin                45) Mac OS X
 46) Mac OS X / OS X Serv  47) Cygwin
---------------------------------------------------------------------------
Operating system: 4
---------------------------------------------------------------------------
  1) Redhat Linux 4.0                     2) Redhat Linux 4.1
  3) Redhat Linux 4.2                     4) Redhat Linux 5.0
  5) Redhat Linux 5.1                     6) Redhat Linux 5.2
  7) Redhat Linux 6.0                     8) Redhat Linux 6.1
  9) Redhat Linux 6.2                    10) Redhat Linux 7.0
 11) Redhat Linux 7.1                    12) Redhat Linux 7.2
 13) Redhat Linux 7.3                    14) Redhat Linux 2.1AS
 15) Redhat Linux 2.1ES                  16) Redhat Linux 2.1WS
 17) Redhat Linux 8.0                    18) Redhat Linux 8.1
 19) Redhat Linux 9.0
---------------------------------------------------------------------------
Version: 19
Sensor port (default 2525):
only one address (default any):
Login name (default admin):
Login password:
Password again:
Sensor host name (default FC3):
Allowed IP addresses (default localhost):
Start Sensor at boot time (y/n):

OSの選択ってWebmin使っている人しか意味がないのね・・・ それなら何を選んでもいいか! 笑

/etc/rc.d/init.d/sensor が追加されているはず conf/miniserv.conf がAgentのコンフィグファイル

port=2525
bind=127.0.0.1
ssl=0
userfile=/opt/snortagent/sensor/conf/sensor.users
keyfile=/opt/snortagent/sensor/conf/sensor.pem

bindの指定はAgentがListenするIPを指定する。127.0.0.1にすると、ローカルホスト接続以外は受け付けられない。 外部へログを飛ばすような場合にはNICに割り当てられているIPを書くとよい。 残りはSSL関係の指定。必要に応じて書き換えればよい。

ちなみにuninstall.shを実行するとAgentファイルがすべて削除される。

SnortCenterのインストール

Snortcenter用のデータベースをMySQLに作成する。 そのためのユーザの作成

mysql -u root -p
mysql> create database snortcenter;
mysql> grant CREATE,INSERT,SELECT,UPDATE,DELETE on snortcenter.* to snortcenter@localhost;
mysql> set password for 'snortcenter'@'localhost' = password('snortcenterpassword');
mysql> flush privileges;
mysql> exit

Snortcenter本体のインストール

tar xvfz snortcenter-v1.0-RC1.tar.gz -C /usr/local/apache2/htdocs/
cd /usr/local/apache2/htdocs
mv www/ snortcenter/
cd snortcenter/
vi config.php
--------------------------------------------------
$DBlib_path = "/usr/local/apache2/htdocs/adodb/";
$curl_path = "/usr/local/bin"; <==ソースでインストールしたのでこの指定になる。
$DBtype = "mysql";
$DB_dbname   = "snortcenter";
$DB_host     = "localhost";
$DB_user     = "snortcenter";
$DB_password = "snortcenterpassword";
$DB_port     = "3306";
$alert_console = "http://Server_IP/base/";
$snortrules_url = "http://www.snort.org/dl/rules/snortrules-snapshot-2_0.tar.gz";
--------------------------------------------------

このコンフィグで注意すべき点は二つ。alert_consoleはACIDまたはBASEのURLを指定する。 ACIDまたはBASEがインストールされていない場合は指定しなくてもよい。 またSnortのルールファイルの指定だが、SnortcenterはSnort2.0のシグネチャ以外をインポートすることが出来ない。 2.1や2.2のシグネチャをインポートした場合、エラーが表示され、テーブルを作り直さなければならなくなるので注意が必要。 (※最新のシグネチャのインポートでは、一つだけインポートできないエラーが出るが、気にしなくていい)

その後Snortcenterにログインする。 1度目のアクセスで自動的にsnortcenter用のテーブルを作成してくれる。 2度目のアクセスで、ログイン画面が表示されるようになる。

デフォルトのIDとパスワード(必ず変更すること。)
ID = admin
Pass = change

ログイン画面
snortcenter-01.gif

センサーサーバの設定画面
snortcenter-02.gif

管理画面
snortcenter-03.gif

参考リンク

Snort.org

Japan Snort Users Group

ACID

BASE


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2017-01-01 (日) 20:59:30 (2673d)