動かすPCのネットワーク状態は以下のとおり。
eden# ifconfig
sis0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
inet 192.168.0.8 netmask 0xffffff00 broadcast 192.168.0.255
inet6 fe80::207:40ff:fe24:2121%sis0 prefixlen 64 scopeid 0x1
ether 00:07:40:24:21:21
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
lp0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500
faith0: flags=8002<BROADCAST,MULTICAST> mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x4
inet 127.0.0.1 netmask 0xff000000
ppp0: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
eden#
ログディレクトリを作成します。
eden# pwd
/var/log
eden# mkdir snort
eden# ls -la snort
total 4
drwxr-xr-x 2 root wheel 512 Mar 21 00:28 .
drwxr-xr-x 3 root wheel 512 Mar 21 00:28 ..
eden#
snort.conf を設定します。初期値から変更した項目は、太字の個所。
各項目の説明は、@ITの記事が参考になります。
###################################################
# Step #1: Set the network variables:
var HOME_NET 192.168.0.0/24
var EXTERNAL_NET any
var DNS_SERVERS $HOME_NET
var SMTP_SERVERS $HOME_NET
var HTTP_SERVERS $HOME_NET
var SQL_SERVERS $HOME_NET
var TELNET_SERVERS $HOME_NET
var SNMP_SERVERS $HOME_NET
var HTTP_PORTS 80
var SHELLCODE_PORTS !80
var ORACLE_PORTS 1521
var AIM_SERVERS [64.12.24.0/24,64.12.25.0/24,64.12.26.14/24,64.12.28.0/24,64.12.29.0/24,64.12.161.0/24,64.12.163.0/24,205.188.5.0/24,205.188.9.0/24]
var RULE_PATH ../share/snort
###################################################
# Step #2: Configure preprocessors
preprocessor flow: stats_interval 0 hash 2
preprocessor frag2
preprocessor stream4: disable_evasion_alerts
preprocessor stream4_reassemble
preprocessor http_inspect: global iis_unicode_map unicode.map 1252
preprocessor http_inspect_server: server default profile all ports { 80 8080 8180 } oversize_dir_length 500
preprocessor rpc_decode: 111 32771
preprocessor bo
preprocessor telnet_decode
preprocessor flow-portscan
#preprocessor arpspoof
#preprocessor arpspoof_detect_host: 192.168.40.1 f0:0f:00:f0:0f:00
####################################################################
# Step #3: Configure output plugins
# output alert_syslog: LOG_AUTH LOG_ALERT
# output log_tcpdump: tcpdump.log
# output database: log, mysql, user=root password=test dbname=db host=localhost
# output alert_unified: filename snort.alert, limit 128
# output log_unified: filename snort.log, limit 128
include ../share/snort/classification.config
include ../share/snort/reference.config
####################################################################
# Step #4: Customize your rule set
include $RULE_PATH/local.rules
include $RULE_PATH/bad-traffic.rules
include $RULE_PATH/exploit.rules
include $RULE_PATH/scan.rules
include $RULE_PATH/finger.rules
include $RULE_PATH/ftp.rules
include $RULE_PATH/telnet.rules
include $RULE_PATH/rpc.rules
include $RULE_PATH/rservices.rules
include $RULE_PATH/dos.rules
include $RULE_PATH/ddos.rules
include $RULE_PATH/dns.rules
include $RULE_PATH/tftp.rules
include $RULE_PATH/web-cgi.rules
include $RULE_PATH/web-coldfusion.rules
include $RULE_PATH/web-iis.rules
include $RULE_PATH/web-frontpage.rules
include $RULE_PATH/web-misc.rules
include $RULE_PATH/web-client.rules
include $RULE_PATH/web-php.rules
include $RULE_PATH/sql.rules
include $RULE_PATH/x11.rules
include $RULE_PATH/icmp.rules
include $RULE_PATH/netbios.rules
include $RULE_PATH/misc.rules
include $RULE_PATH/attack-responses.rules
include $RULE_PATH/oracle.rules
include $RULE_PATH/mysql.rules
include $RULE_PATH/snmp.rules
include $RULE_PATH/smtp.rules
include $RULE_PATH/imap.rules
include $RULE_PATH/pop2.rules
include $RULE_PATH/pop3.rules
include $RULE_PATH/nntp.rules
include $RULE_PATH/other-ids.rules
# include $RULE_PATH/web-attacks.rules
# include $RULE_PATH/backdoor.rules
# include $RULE_PATH/shellcode.rules
# include $RULE_PATH/policy.rules
# include $RULE_PATH/porn.rules
# include $RULE_PATH/info.rules
# include $RULE_PATH/icmp-info.rules
include $RULE_PATH/virus.rules
# include $RULE_PATH/chat.rules
# include $RULE_PATH/multimedia.rules
# include $RULE_PATH/p2p.rules
include $RULE_PATH/experimental.rules
# include threshold.conf
では起動してみます。
Snort の起動オプションはたくさんありますが、こんな感じにしました。
| -D |
Daemonモード |
| -d |
アプリケーションレイヤーをダンプする |
| -e |
データリンク層のヘッダ情報を表示する |
| -c |
snort.conf のパス |
| -l |
ログのパス |
| -i |
使用するネットワークインターフェイス |
eden# /usr/local/bin/snort -Dde -c /usr/local/etc/snort.conf -l /var/log/snort -i sis0
eden#
eden# ps -ax | grep `cat /var/run/snort_sis0.pid `
4021 ?? Ss 0:02.91 /usr/local/bin/snort -Dde -c /usr/local/etc/snort.con
eden#
192.168.0.101 の MacOSX からポートスキャンをかけると、このように検出されます。
eden# pwd
/var/log/snort
eden#
eden# ls -la
total 8
drwxr-xr-x 3 root wheel 512 Mar 24 23:37 .
drwxr-xr-x 3 root wheel 1024 Mar 24 23:00 ..
drwx------ 2 root wheel 512 Mar 24 23:36 192.168.0.101
-rw------- 1 root wheel 1601 Mar 24 23:37 alert
eden#
eden# head alert
[**] [121:3:1] Portscan detected from 192.168.0.101 Talker(fixed: 15 sliding: 15) Scanner(fixed: 0 sliding: 0) [**]
03/24-23:36:58.435054
[**] [121:4:1] Portscan detected from 192.168.0.101 Talker(fixed: 30 sliding: 30) Scanner(fixed: 0 sliding: 0) [**]
03/24-23:36:58.842960
[**] [1:1418:11] SNMP request tcp [**]
[Classification: Attempted Information Leak] [Priority: 2]
03/24-23:36:58.747782 0:A:95:F6:13:82 -> 0:7:40:24:21:21 type:0x800 len:0x4A
192.168.0.101:49409 -> 192.168.0.8:161 TCP TTL:64 TOS:0x0 ID:3167 IpLen:20 DgmLen:60 DF
eden#
本当は、独自ルールを設定したり、ツールとしてACIDを入れたりするんでしょうが、今回はここまで。
ネットワーク構成も不正侵入を検知したいPCと Snort を動かしているPCをダムHUBで接続して監視するのが良いんでしょうね。
#でも最近ダムHUBって無くなっちゃったなー。
以下のファイルの中を確認します。
eden# pwd
/usr/local/etc/rc.d
eden# ls -la snort.sh
-rwxr-x--x 1 root wheel 895 Jan 4 14:27 snort.sh
eden#
/etc/rc.conf に追加するように指示されているので、追加します。
# Add the following lines to /etc/rc.conf to enable snort:
# snort_enable (bool): Set to YES to enable snort
# Default: NO
# snort_flags (str): Extra flags passed to snort
# Default: -Dq
# snort_interface (str): Network interface to sniff
# Default: ""
# snort_conf (str): Snort configuration file
# Default: ${PREFIX}/etc/snort.conf
こんな感じ。
eden# grep snort /etc/rc.conf
# --snort
snort_enable="YES"
snort_flags="-Dde"
snort_interface="sis0"
snort_conf="/usr/local/etc/snort.conf"
eden#
/var がログであふれないように定期的にご確認ください。