| iplogで記録サルになる |
|
1.はじめに UNIXホスト動かして管理者なんかやってると〜 以下長い愚痴なので、省略 |
|
2.iplogとは iplogはTCP/IPのトラフィックを片っ端から記録してくれるツールで、Ryan McCabe あとは、詳細な記録を元にしてISPに抗議してアカウント停止に追い込むとか、踏台ホスト探し出して怠慢な管理者に喝を入れるなり好きにしてください。 iplogの主な機能は、iplog's documentにもありますように、 ・TCP、UDP、ICMPのトラフィックを記録する ・TCPのconnect、scan、FIN、SYN、XmasおよびUDPスキャンの検出 ・smurf、flagment攻撃の検出 ・OSの検出に使用されるbogus TCP flagの検出 などです。snortなどと比べると機能がずいぶんと少ない気がしないでもありませんが、トラフィックの検出機能はsnortに備わっていない機能ですから、ぜひ組合わせて使ってください。 動作確認が取れているプラットフォームは以下のとおりです。 ・FreeBSD (3.x, 4.0) ・OpenBSD (2.6 and up) ・BSDI (4.0, 4.01) ・Solaris (2.5.1, 7, 8) ・IRIX 6.5 Solaris2.6だとmake出来て動作しているように見えるのですが、何故かちゃんとトラフィックを検出してくれません。なんで? ではiplogをインストールしてみましょう。 *追加情報 Solaris2.6について おのづかさん より以下の情報をいただきました。ありがとうございます。 iplog2.2.3をsolaris2.6(sparc)で動くようにしてみました。 #gcc 2.95.2です。 configureスクリプト実行時に環境変数 CPPFLAGS を "-DBYTE_ORDER=1 -DLITTLE_ENDIAN=0 -DBIG_ENDIAN=1" と設定しておくとOKのようです。 # src/iplog_inet_header.h を直接いじってもOKです。 |
|
3.アーカイブの入手と展開 アーカイブはhttp://ojnk.sourceforge.net/から入手します。 2001.1.3日の時点では、iplog-2.2.3が最新です。 また例によってiplogもlibpcapを必要としますので注意してください。ちゃーんとドキュメントに従ってインストールまでしてくださいね。ねっ! libpcapの入手先 http://www.tcpdump.org/ # libpcap-0.6.1が出ましたので、こっちにしましょう。 # make installだけでOKですよん。便利になったね。ちなみにlibpcapが無い環境でconfigureすると > Error: libpcap is required to build this package. > Error: See the README file.のように、ちゃんとREADME読め!と怒られます。 アーカイブ取ってきたら適当なディレクトリで解凍してあげましょう。解凍したら例によって、ちゃんとREADMEとINSTALLくらいには目を通してください。 |
|
4.make & install makeとinstallは簡単です。./configure、make、make installとタイプするだけ。いちおうマニュアルから抜粋しときますので、ちゃんと読んでください。 > 1. `cd' to the directory containing the package's source code and type > `./configure' to configure the package for your system. If you're > using `csh' on an old version of System V, you might need to type > `sh ./configure' instead to prevent `csh' from trying to execute > `configure' itself. > > Running `configure' takes awhile. While running, it prints some > messages telling which features it is checking for. > > 2. Type `make' to compile the package. > > 3. Optionally, type `make check' to run any self-tests that come with > the package. > > 4. Type `make install' to install the programs and any data files and > documentation. > > 5. You can remove the program binaries and object files from the > source code directory by typing `make clean'. To also remove the > files that `configure' created (so you can compile the package for > a different kind of computer), type `make distclean'. There is > also a `make maintainer-clean' target, but that is intended mainly > for the package's developers. If you use it, you may have to get > all sorts of other programs in order to regenerate files that came > with the distribution. |
|
5.execute ちゃんとinstallできたら、ちょっと動かしてみましょうか。rootになってから root# /usr/local/sbin/iplog とタイプしてください。パスは違う場合もありますが、各自で適当に合わせてください。 あとはしばらく放っておけば何か記録してくれます。トラフィックの少ないネットワークにお住いだとか、気長に待てない「しし座」の貴方は、手近にあるコンピュータからnmapでもブッぱなしてください。 そうしますと、/var/log/messagesあたりに以下のようにログられます。 > Jan 16 13:27:56 matrix iplog[19621]: iplog started. > Jan 16 13:30:19 matrix iplog[19624]: > ICMP: echo from intruder.hoge.com (8 bytes) > Jan 16 13:30:19 matrix iplog[19624]: > UDP: dgram to port 1025 from ns.hoge.com:53 (245 data bytes) > Jan 16 13:30:19 matrix iplog[19624]: > UDP:dgram to port 1025 from ns.hoge.com:53 (238 data bytes) > Jan 16 13:30:19 matrix iplog[19624]: > TCP:port 3455 connection attempt from intruder.hoge.com:2925 > Jan 16 13:30:19 matrix iplog[19624]: > TCP:port 874 connection attempt from intruder.hoge.com:2926 > Jan 16 13:30:19 matrix iplog[19624]: > TCP:port 1664 connection attempt from intruder.hoge.com:2927 > Jan 16 13:30:19 matrix iplog[19624]: > TCP:port 621 connection attempt from intruder.hoge.com:2928 > Jan 16 13:30:19 matrix iplog[19624]: > TCP:port 1506 connection attempt from intruder.hoge.com:2929 > Jan 16 13:30:19 matrix iplog[19624]: > TCP:port 1532 connection attempt from intruder.hoge.com:2930 > Jan 16 13:30:19 matrix iplog[19624]: > TCP:re-mail-ck connection attempt from intruder.hoge.com:2931 > Jan 16 13:30:19 matrix iplog[19624]: > TCP: port 868 connection attempt from intruder.hoge.com:2932上のログで、例えば4行目は > Jan 16 13:30:19 matrix iplog[19624]: > UDP: dgram to port 1025 from ns.hoge.com:53 (245 data bytes)UDPでns.hoge.comの53番ポートよりmatrixの1025ポートにトラフィックがあった事を表します。 また、以下のような記録が残っている場合があります。 > Jan 16 13:30:19 matrix iplog[19624]: TCP: port scan detected > [ports 3455,874,1664,621,1506,1532,50,868,3306,1501,...] > from intruder.hoge.com [ports 2925,2926,2927,2928,2929,...]これはポートスキャンの可能性があるトラフィックを検出したものです。 ポートスキャンはFTPサーバ等のホスト上では、誤検知の可能性が非常に高くなりますので、検出記録の前後のログに目を通して、皆さん自身が判断してください。 このようにして、ホストへのコネクションを全て監視することにより、自分のホストがどのようなプロービングや攻撃を受けているのかを知ることが可能です。 |
|
5.もうひと味 iplogを運用しているとすぐに気づく問題があります。例えばmailを運用しているホストの場合ですと、tcp/25のsmtpやtcp/110のpop3へのトラフィックを全て記録しますから、ログの量が膨大になってしまいます。またDNSサーバへの問合せなども、UDP/53を対象としたトラフィックが大量に発生します。 このように大量のトラフィックが発生することが予め分かっていて、それらを記録したくない場合には/etc/iplog.confファイルで制御できます。(iplog 2.1.xまではiplog.rulesでした) コマンドオプションの --udp=false などで指定しても良いのですが、ここではもうちょっと詳しく制御してみましょう。 /etc/iplog.confファイルには、どのトラフィックをiplogが記録する/しないのかに関するパラメータを細かく与える事が可能です。 > ignore tcp sport 25 > ignore tcp dport 25 > ignore udp sport 53 > ignore udp dport 53 > ignore udp from xxx.xxx.0.0/16 > ignore icmp上記のように簡単な/etc/iplog.confファイルを作成してみましょう。 > ignore tcp sport 25 > ignore tcp dport 25このように記述するとsourceまたはdesitinationいづれかのtcp/25:smtpトラフィックを無視することができます。 > ignore udp sport 53 > ignore udp dport 53同様にudp/53:dnsトラフィックを無視します。 > ignore udp from xxx.xxx.0.0/16xxx.xxx.0.0/16のネットワークからのUDPトラフィックを全て無視します。 > ignore icmpicmpパケットを全て無視します。 以上のようにして細かく制御できますので、皆さんで工夫してみてください。/etc/iplog.confの詳しい内容については man iplog.conf を参照してください。(そのうち和訳するかも) ちなみに/etc/iplog.confファイルは作成しておくだけで、勝手にiplogが読み込んでくれますので、特にコマンドラインでオプションを与える必要はありません。 * /etc/iplog.confの位置はデフォルト設定ですので、make時のパラメータによっては変わる場合があります。 |