■snortの起動チェック
$ sudo /etc/init.d/snort status
Status of snort daemon(s): eth0 OK.
■全体のフィルタルールチェック(local.rulesを追加、ルール全体を更新した時など)
「-T」はテストオプション、「-n1」は1パケットを受信したら終了する。
$ sudo snort -T -c /etc/snort/snort.conf 2>&1 | grep -i "warn\|error\|exit"
ERROR: /etc/snort/rules/bad-traffic.rules(27): Couldnt resolve hostname DEBIAN_SNORT_HOME_NET
Fatal Error, Quitting..
■DEBIAN_SNORT_HOME_NETが原因の様子なので、修正。
$ sudo grep DEBIAN /etc/snort/snort.conf
var HOME_NET DEBIAN_SNORT_HOME_NET
$ sudo grep "DEBIAN_SNORT_HOME_NET" /etc/snort/snort.debian.conf
DEBIAN_SNORT_HOME_NET="192.168.72.0/24"
$ sudo grep DEBIAN /etc/snort/snort.conf
var HOME_NET 192.168.72.0/24
$ sudo snort -n1 -c /etc/snort/snort.conf 2>&1 | grep -i "warn\|error\|exit"
Warning: /etc/snort/rules/dos.rules(42) => threshold (in rule) is deprecated; use detection_filter instead.
Warning: flowbits key 'smb.tree.create.llsrpc' is set but not ever checked.
Warning: flowbits key 'ms_sql_seen_dns' is checked but not ever set.
Warning: flowbits key 'community_uri.size.1050' is set but not ever checked.
Warning: flowbits key 'realplayer.playlist' is checked but not ever set.
Snort exiting
$ sudo snort -T -c /etc/snort/snort.conf 2>&1 | grep -i "warn\|error\|exit"
Warning: /etc/snort/rules/dos.rules(42) => threshold (in rule) is deprecated; use detection_filter instead.
Warning: flowbits key 'smb.tree.create.llsrpc' is set but not ever checked.
Warning: flowbits key 'realplayer.playlist' is checked but not ever set.
Warning: flowbits key 'ms_sql_seen_dns' is checked but not ever set.
Warning: flowbits key 'community_uri.size.1050' is set but not ever checked.
Snort exiting
※2012/08/13追記
「local.rules」の作成については以下に追記。
Tポイントツールバーのブロック色々
http://labunix.hateblo.jp/entry/2012/08/11/175214
また、変数はテスト時に直接渡せました。
$ sudo snort -S DEBIAN_SNORT_HOME_NET="192.168.72.0/24" -T -c /etc/snort/snort.conf 2>&1 | \
grep -i "warn\|error\|exit"
Warning: /etc/snort/rules/dos.rules(42) => threshold (in rule) is deprecated; use detection_filter instead.
Warning: flowbits key 'smb.tree.create.llsrpc' is set but not ever checked.
Warning: flowbits key 'realplayer.playlist' is checked but not ever set.
Warning: flowbits key 'ms_sql_seen_dns' is checked but not ever set.
Warning: flowbits key 'community_uri.size.1050' is set but not ever checked.
Snort exiting
■snortの動作中に統計を見たい。
※killallは使えなかった。
■PIDをファイルから取得(eth0とは限らないところが難点)
$ THISTIME=`env LANG=C date '+%b *%-d %H:%M:'`;sudo cat /var/run/snort_eth0.pid | \
sudo kill -USR1 `xargs`
■psコマンドから取得(長くなるけどpkillが無い環境でも使える)
$ THISTIME=`env LANG=C date '+%b *%-d %H:%M:'`;ps -ef | \
grep snort | grep -v grep | awk '{print $2}' | sudo kill -USR1 `xargs`
■pkillから取得
$ THISTIME=`env LANG=C date '+%b *%-d %H:%M:'`; sudo pkill -USR1 snort
■上記、3つのいずれの方法でも出力は同じ。
$ sudo grep "^${THISTIME}.*snort" /var/log/syslog | sed s/".*snort\[[0-9]*\]\: "//g | grep -v "0.000%\|\: *0"
*** Caught Usr-Signal
===============================================================================
Packet Wire Totals:
Received: 162008
Analyzed: 106131 (65.510%)
Dropped: 55871 (34.487%)
Outstanding: 6 (0.004%)
===============================================================================
Breakdown by protocol (includes rebuilt packets):
IP4: 105011 (98.911%)
IP4disc: 106 (0.100%)
TCP: 104131 (98.082%)
UDP: 749 (0.705%)
ICMP: 25 (0.024%)
ARP: 1156 (1.089%)
DISCARD: 106 (0.100%)
InvChkSum: 10816 (10.188%)
S5 G 2: 36 (0.034%)
Total: 106167
===============================================================================
Action Stats:
ALERTS: 1916
LOGGED: 1935
===============================================================================
Frag3 statistics:
===============================================================================
Stream5 statistics:
Total sessions: 776
TCP sessions: 776
TCP StreamTrackers Created: 862
TCP StreamTrackers Deleted: 140
TCP Timeouts: 50
TCP Segments Queued: 90
TCP Segments Released: 87
TCP Rebuilt Packets: 38
TCP Segments Used: 87
TCP Discards: 3742
TCP Port Filter
Tracked: 93443
UDP Port Filter
===============================================================================
HTTP Inspect - encodings (Note: stream-reassembled packets included):
GET methods: 26
Headers extracted: 10
Directory traversals: 16
Self-referencing paths ("./"): 16
Total packets processed: 9646
===============================================================================
dcerpc2 Preprocessor Statistics
===============================================================================
===============================================================================
■他のツールの力を借りる。
一言で言うと、自分でスクリプトを書いた方が早いのではないかと。。。
また、メンテナンスにおいても余計な脆弱性を増やすようにしか見えないw。
まあ、自宅用なので、以下は保留にします。
Swatchは適切な設定「swatchrc」が必要。
ACIDはグラフィック関連ツール等デフォルトには無いツール群もある。
また、デフォルトでも「php.ini」の修正、acidbase用のユーザの作成や、
sql文の実行が必要になる。
■Swatch
説明にあるようにログビューアとして、auth.logから正規表現のマッチングとフック機能を利用し、
リアルタイム監視とアラートを生成を行う。
依存関係はPerlモジュール。
$ apt-cache search ^swatch\$
swatch - 正規表現マッチング、構文強調やフック機能を持つログファイルビューア
$ apt-cache show swatch | grep ^Description -A 10
Description-ja: 正規表現マッチング、構文強調やフック機能を持つログファイルビューア
Swatch は、システムの活動を監視するために設計されています。検索するパターン
および各パターンを発見した時に実行するアクションを含む設定ファイルを読み込
みます。
.
典型的なアクションとしては、マッチした行を様々な色や、ビデオ反転、太字、下
線、そして通常表示を含むフォーマットによるエコー表示があります。このフォー
マットには swatch が内部的に出力方法を理解するものが使えます。他のアクショ
ンとしては、メール送信や、その行での任意のファイルの実行が含まれます。
.
Swatch は Perl で書かれており、行マッチングの際に Perl 正規表現を利用します。
$ apt-cache show swatch | grep ^Depends | sed s/"\,"/"&\n"/g
Depends: perl (>= 5.6.1),
libtimedate-perl,
libtime-hires-perl,
libdate-calc-perl,
libfile-tail-perl,
libdate-manip-perl
■ACID
説明にあるように、SnortIDSのDBログからWebブラウジングでの閲覧、
分析を行うインターフェイスを提供する。
依存関係のパッケージの他、Apache等のWebブラウザが必要
postgres用、mysql用の各設定が必要。
$ apt-cache search ^acid
acidbase - Basic Analysis and Security Engine
$ apt-cache show acidbase | grep ^Description -A 8
Description: Basic Analysis and Security Engine
BASE is based on the code from the Analysis Console for Intrusion Databases
(ACID) project. This application provides a web front-end to query and analyze
the alerts coming from a SNORT IDS system.
.
BASE is a web interface to perform analysis of intrusions that snort has
detected on your network. It uses a user authentication and role-base system,
so that you as the security admin can decide what and how much information
each user can see.
$ apt-cache show acidbase | grep ^Depends | sed s/"|"/"&\n"/g
Depends: debconf (>= 0.5) |
debconf-2.0, dbconfig-common, mysql-client |
virtual-mysql-client |
postgresql-client, php5, libphp-adodb (>= 4.62), php5-mysql |
php5-pgsql, libwww-perl, php-mail, php-mail-mime