11-4. fwtk とワンタイム・パスワ−ド '96 (1) fwtk の概要と portscan * フリ−ソフトの fwtk と製品版の Gauntlet イ−サネットの口が2つある Apollo のマシンにインスト−ルして試してみた。 fwtk は BSD ベ−スで書かれていて、コンパイルは幾つかのワ−ニングは出たものの、数分であっ さり終わってしまった。ファイアウォ−ルのソフトなんていうのは、どんなにすごいプロ グラムかとテストするのも怖いような感じがしていたのだが。このソフト、イ−サネット の口が2つのゲ−トウェイとしてのホストに必ずしも載せる必要はない。 fwtk は Proxy サ−バの性質として、イ−サネットのポ−トが1個のホストでも問題なく機能する。ただ しこの場合は、経路制御に注意する必要がある。 fwtk の製品版の TIS Gauntlet 3.0 だ と下記のような二段構えの telnet でなく、透過的にできる。何か fwtk も Gauntlet も 基本部分は、ほとんど同じみたいである。 Gauntlet だと設定がWWWブラウザでできる のがミソぐらいなものか。 > telnet firewall Connet 192.9.200.1 << ファイアウォ−ルのホストに接続する。 tn-gw > c 外部ホスト << もう一度専用 telnet をかける。 login: * fwtk の認証 パスワ−ドによる認証には、プレ−ンテキスト、bellcore's S/Key、Security Dynamics' SecurID、Digital Pathways SNK、Enigma Logics' Silver Card の方法から選ぶことがで きる。デフォルトはプレ−ンテキストで、通常のロッグインと変わりない。 bellcore 社 の S/Key のみフリ−ソフトである。名称は fwtk のソ−スから抜粋した。 他の認証方法 を使うには再コンパイルが必要だが、コマンドとしては authsrv だけ使えれば、 どの方 法にも対応できる。パスワ−ドの登録作業は、 fwtk を入れたホストで行なうことが望ま しい。注意点は他のホストから fwtk のホストにロッグインを許さないことである。管理 者のみ内部のホストからロッグインできるようにすることはあるかも知れないが。 ・authsrv 認証サ−バはゲ−トウェイで稼働した方が安全性が高い。 ・authsrv の使用は、ゲ−トウェイだけでできる。 ・authmgr は authsrv を他のホストから使用するためのコマンドである。 ・authdump と authload は別に使う必要はない。 * ソフトの入手 以下の所から fwtk.tar.Z とドキュメントの fwtk-doc-only.tar.Z をとってくる。 この 時のバ−ジョンは v1.3、展開したファイルの README の日付けは October 20,1993 だっ た。小生がダウンロ−ドしたのは96年だった。それからしばらくして、 fwtk は商用利 用禁止になり、ダウンロ−ドも自由にできなくなった。iij のサイトにはもうソフトはな いし、TIS のサイトはアクセスできなくなっている。97年終わり頃の雑誌の記事によれ ば、TIS のWWWサイトにアクセスして、ダウンロ−ドのパスを教えてもらい、12時間 以内にダウンロ−ドするとか書いてあった。`02/06追記。この後の話でインタ−ネット接 続口で使うのはライセンス違反、内部での部門ファイアウォ−ルとして使う場合ならOK ということになった。 ftp://ftp.iij.ad.jp/pub/security/tis/toolkit/ ftp://ftp.tis.com/pub/firewalls/toolkit/ << 日本のTISではない。 $ ld /usr/local/source/fwtk README auth/ ftp-gw/ smap/ config/ tn-gw/ LICENSE auth.h http-gw/ smapd/ lib/ doc/ Makefile rlogin-gw/ netacl/ plug-gw/ x-gw tools/ Makefile.config CHANGES DISCLAIMER firewall.h ./doc admin_guide.ps manpages.ps presentation.ps user_guide.ps overview.ps sample-report.txt man/ <-- マニュアルが入っている ( README より抜粋 ) Makefile - toplevel Makefile README - this file auth - authentication server and libraries (optional) config - sample configuration/permissions tables doc - documentation firewall.h - compile-time configuration ftp-gw - sources for FTP proxy server http-gw - http/gopher proxy lib - sources for library routines netacl - sources for TCP/IP access control "wrapper" plug-gw - sources for plug-board proxy server rlogin-gw - sources for rlogin proxy server smap - sources for sendmail wrapper client smapd - sources for sendmail wrapper daemon tn-gw - sources for TELNET proxy server tools - miscellaneous/unsupported tools x-gw - X11 proxy ./tools/admin netscan - a tool to ping hosts on a network portscan - a tool to ping service ports on a host << どのポ−トが生きてい flog - follow log, tail -f /usr/adm/syslog るかリストするだけ。 reporting - fwtk のログからサマリ−を作成する。 progmail とう言うのもあり ディレクトリの中の README。 -------------------------------------------------------------------------- | This is a simple little hack I use to replace the shell in |sendmail.cf, where it invokes it for program mailing. Other approaches |for doing this are to use smrsh by Allman. On a firewall, though, I don't |want *any* program mailings done. | | Install this in /usr/local/etc and edit the line |in sendmail.cf that looks like: | |Mprog, P=/bin/sh, F=lsDFMeuP, S=10, R=20, A=sh -c $u | to look like: |Mprog, P=/usr/local/etc/progmail, F=lsDFMeuP, S=10, R=20, A=sh -c $u ./tools/server ftpd - a version of ftpd that uses the auth server login-sh - a login shell wrapper that uses the auth server syslog - a version of the 4.3bsd syslog that uses regexps README の上の所を抜粋。 ----------------------------------------------------------------------- | TIS Firewall Toolkit | | Trusted Information Systems, Inc. | October 20, 1993 | | |WHAT IS THE TIS FIREWALL TOOLKIT? | |Trusted Information Systems, Inc. (TIS) is pleased to provide the TIS |Firewall Toolkit, a software kit for building and maintaining |internetwork Firewalls. It is distributed in source code form, with |all modules written in the C programming language and runs on many |BSD UNIX derived platforms. The Toolkit is being made available for |use as specified in the license agreement (LICENSE). | | * コンパイル とりあえずコマンドなどは /usr/local/source/fwtk/bin に作成して、テストするときに、 /usr/local/etc にコピ−して使うことにする。 マニュアルをインスト−ルせず、見るに は $ /usr/bin/nrof -man plug-gw.8 このようにする。 Makefile.config --------------------------------------------------- |CC= cc |CP= cp |COPT= -g |MAKE= make |RANLIB= ranlib # touch |DEST=/usr/local/source/fwtk/bin # /usr/local/etc |AUXLIB= -lresolv # -lsocket |DBMLIB= # -lndbm | |LDFL= -g # -Bstatic or 空 |FWTKSRCDIR=/usr/local/source/fwtk Makefile ----------------------------------------------------------------- |include Makefile.config |LIB= lib auth |DIRS= smap smapd netacl plug-gw ftp-gw tn-gw rlogin-gw http-gw | | ↑ この下 make, clean, install がある。 使わないのは消せばいい。 * portscan を試してみる '99/05 追記 $ /usr/ucb/netstat -a << -an とすると番号で、例えば *.x11 が *.6000 と出る。 Active connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp 0 0 node_abcd.2420 indy1.telnet ESTABLISHED tcp 0 0 *.x11 *.* LISTEN tcp 0 0 *.time *.* LISTEN tcp 0 0 *.daytime *.* LISTEN tcp 0 0 *.exec *.* LISTEN tcp 0 0 *.shell *.* LISTEN tcp 0 0 *.login *.* LISTEN tcp 0 0 *.telnet *.* LISTEN tcp 0 0 *.sunrpc *.* LISTEN udp 0 0 *.time *.* udp 0 0 *.sunrpc *.* udp 0 0 *.1024 *.* /etc/inetd.conf ----------------------------------------------------- |telnet stream tcp nowait root /etc/telnetd telnetd |login stream tcp nowait root /etc/rlogind rlogind |shell stream tcp nowait root /etc/rshd rshd |exec stream tcp nowait root /etc/rexecd rexecd |daytime stream tcp nowait root internal |time stream tcp nowait root internal |time dgram udp wait root internal 上記のような環境で、自分自身のホストをポ−ト・スキャンしてみた。ホストはおなじみ Apollo コンピュ−タである。使い方は簡単。 portscan プログラムは TCP パケットだけ を対象にする。-l は開始ポ−ト番号、-h は終わりのポ−ト番号で、その範囲を1個ずつ なめていき、サ−ビスをしているか調べてる。 -v は調べたいホスト名かIPアドレスを 指定する。自分自身のホストなら localhost でもよい。portscan は fwtk をインスト− ルしたディレクトリ tools/admin に入り、make をかければ即できる。 $ portscan -l 1 -h 6000 -v node_abcd << root でなくても実行できた。 node_abcd: trying stream ports between 1 and 6000 ............. daytime ........ telnet .............. time ............................ sunrpc << Sun RPC の pormap デ−モン。 .................................. exec . login . shell << ここまではパッパとでる。次の x11 は 6000 番なので時間がかかる。 ........................................... x11 << xapollo。これは inetd 経由でなく直接稼働している。 この Apollo コンピュ−タでは inetd, portmap, xapollo が稼働している。それに INDY に telnet をかけているので、これらが $ pst コマンド(UNIXなら ps)で出てくる。 inetd を止めると inetd.conf にある telnet, login, shell, exec, daytime, time が、 $ netstat -a で出なくなる。portmap を止めると sunrpc が出なくなる。inetdを止めて も INDY への telnet は $ netstat -a で表示されるが、 portscan では出て来ないこと に注意したい。 $ portscan -l 1 -h 6000 -v 192.168.1.9 Cobalt Qube3をポ−トスキ 192.168.1.9: trying stream ports between 1 and 6000 ャンしてみた。やったのは ftp `2h/11/E で、 ちゃんと使 .. えた。これらはソ−スコ− telnet ドがあるので、勉強したけ .. ればやれます。 smtp ............................ domain ........................... 80 . 81 以下 110 auth 139 444 login shell 901 と出た。 [ ポ−ト・スキャンを tcpdump で見る ] $ portscan -l 19 -h 22 -v 192.9.10.1 ---------- --------- 192.9.10.1: trying stream ports between 19 and 22 | Apollo | | INDY | . ---------- --------- chargen | .2 | .1 .. -----*--------------*------ ftp << ftp-data 20/tcp は出てこない。 192.9.10.0 . INDY 側 netstat -a でも出てこない。 以下の tcpdump は Apollo から INDY に telnet して、root ユ−ザで INDY 側で実行し ている。-n でIPアドレスにポ−ト番号で表示するように指示している。src は Apollo からのパケットだけを見るようにしている。残りは telnet アクセスを表示しないように している。tcpdump の他、Solaris 2.x なら snoop が同様使える。 % tcpdump -n src 192.9.10.2 and not tcp port telnet tcpdump: listening on ec0 .. 192.9.10.2.4160 > 192.9.10.1.19: S 929056267:929056267(0) win 9116 .. 192.9.10.2.4160 > 192.9.10.1.19: . ack 1629376001 win 9116 .. 192.9.10.2.4160 > 192.9.10.1.19: F 0:0(0) ack 1495 win 7622 .. 192.9.10.2.4160 > 192.9.10.1.19: R 929056269:929056269(0) win 7622 .. 192.9.10.2.4160 > 192.9.10.1.19: R 929056269:929056269(0) win 61060 .. 192.9.10.2.4160 > 192.9.10.1.19: R 929056269:929056269(0) win 61060 .. 192.9.10.2.4161 > 192.9.10.1.20: S 929056332:929056332(0) win 9116 .. 192.9.10.2.4162 > 192.9.10.1.21: S 929056397:929056397(0) win 9116 .. 192.9.10.2.4162 > 192.9.10.1.21: . ack 1629504001 win 9116 .. 192.9.10.2.4162 > 192.9.10.1.21: F 0:0(0) ack 31 win 9086 .. 192.9.10.2.4162 > 192.9.10.1.21: R 929056399:929056399(0) win 9086 .. 192.9.10.2.4162 > 192.9.10.1.21: R 929056399:929056399(0) win 61060 .. 192.9.10.2.4163 > 192.9.10.1.22: S 929056462:929056462(0) win 9116 ↑ 16:25:17.708133 というように時刻である。スペ−スの都合省略。 (2) fwtk 組込み telnet のテスト * telnet でのテスト hostG はIPパケットの転送を禁止するとして、 hostA から hostB に telnet だけでき るようにする。hostB からは hostG へも hostA にもアクセスできないようにする。設定 は、/etc/inetd.conf と /usr/local/etc/netperm-table ファイルを少しいじるだけであ る。netperm-table ファイルは変更すると、直ちに有効になる。注意点としては fwtk コ マンドを /usr/local/etc に入れておくことである。 さて、先ず telnet と telnetd の 有りかを調べておく。Apollo では $ /usr/ucb/which telnet でみると /usr/ucb/telnet になっている。同様に /etc/telnetd になっている。 hostB □ 192.9.202.1 INDY | ---------------------- 192.9.202 | -------------------------- 192.9.201 | ↑------- 192.9.201.1 telnet ×|hostG| << hostG は Apollo です。 only ↓------- 192.9.200.1 ここに fwtk を入れる。 | ---------------------- 192.9.200 | hostA □ 192.9.200.2 INDY hostG /etc/inetd.conf -------------------------------------------------------------- |#telnet stream tcp nowait root /etc/telnetd telnetd |telnet stream tcp nowait root /usr/local/etc/netacl telnetd <--- 注目 hostG /usr/local/etc/netperm-table -------------------------------------------------------------------- | | |# どのホストからここにアクセスを許すのか。 |netacl-telnetd: permit-hosts 127.0.0.1 -exec /etc/telnetd |netacl-telnetd: permit-hosts 192.9.200.1 -exec /etc/telnetd |netacl-telnetd: permit-hosts 192.9.200.2 -exec /usr/local/etc/tn-gw | |# アクセスを許したホストで、アクセス時にパスワ−ドを要求するか。 |tn-gw: permit-hosts 192.9.200.2 -passok -xok << 要求しない場合。 $ /bin/ps -ax 1082 ? S 0:00 /etc/inetd << inetd デ−モンを初期化する。 $ /bin/kill -HUP 1082 [ hostA から hostB へアクセスする ] hostA % telnet hostG Trying 192.9.200.1... Connected to hostG. hostG telnet proxy (Version V1.3) ready: tn-gw-> c hostB Trying 192.9.202.1 port 23... IRIX System V.4 (hostB) << ロッグイン・セッションになって接続する。 | [ hostB から hostA にアクセスする ] hostB % telnet hostG Trying 192.9.200.1... Connected to hostG. << hostG にもアクセスできない。これでOK。 Connection closed by foreign host. * 設定の意味 ・netacl-telnetd: permit-hosts 127.0.0.1 -exec /etc/telnetd > 自分のホストで telnet localhost をやった場合は、 通常の telnetd を実行するこ とを意味する。tn-gw: の設定はここでは関係ない。 ・netacl-telnetd: permit-hosts 192.9.200.2 -exec /usr/local/etc/tn-gw tn-gw: permit-hosts 192.9.200.2 -passok -xok > fwtk の入ったホスト hostG へ Proxy 接続できるホストは 192.9.200.2 だけである。 -exec /usr/../tn-gw が Proxy 接続を意味する。 次の tn-gw: permit-hosts .. は、 192.9.200.2 がアクセスしてきた場合にパスワ−ドを要求するかどうかの指定になる。 ・netacl-telnetd: permit-hosts 127.0.0.1 192.9.200.* .. tn-gw: permit-hosts * -auth > IPアドレスの指定にワイルドカ−ドが使える。並べても構わない。 * plug-gw 汎用プロキシ−サ−バの特徴 `24/03 昔自分で書いたことだが、正しいかどうか分からなくなった、一応参考まで。plug-gw で は2つのホスト間で telnet する固定トンネルは設定できない。固定トンネルはクライア ント側のポ−ト番号が一意に決まるプロトコルである必要がある。よく NetNews の NNTP に使う話がある。電子メ−ルの SMTP も適用できない。本「ファイアウォ−ル」に載って いたAT&T作成の Relay プログラムと同じことが出来ないか考えてみたのだ。 確か動 作の確認もしたような気がするのだが。「UNIX MAGAZINE」'99/07, P.46〜53, "汎用 TCP プロキシ−" の記事を参照されたい。「UNIX MAGAZINE」'99/05, P.51〜58 にはファイア ウォ−ル越しに POP を中継する記事あり、"ファイアウォ−ルの作り方18、白崎博生"。 /usr/local/etc/netperm-table これはできない --------------------------------------------------------------------------- |plug-gw: port telnet 192.9.200.1 -plug-to telnet 192.9.202.1 -port telnet POP の 110 番ポ−トを受け付けるネットワ−クデ−モンとして機能する。 plug-gw がフ ァアウォ−ル内部のホストから接続要求を受けると、 外部メ−ルサ−バの POP ポ−トへ 接続し、両者間の通信を中継する。 /etc/rc.local ------------------------------------ |/usr/local/etc/plug-gw -daemon pop (3) fwtk のパスワ−ド設定 * authsrv の使用 上記で 192.9.200.2 ホストから hostG の fwtk Proxy Server へのアクセスには、 パス ワ−ドを要求するようにしてみる。平文によるパスワ−ドで、ロッグインのアカウントは katou でパスワ−ドは 333 とする。 /usr/local/etc/netperm-table -------------------------------------------------------------------- |netacl-telnetd: permit-hosts 127.0.0.1 -exec /etc/telnetd |netacl-telnetd: permit-hosts 192.9.200.1 -exec /etc/telnetd |netacl-telnetd: permit-hosts 192.9.200.2 -exec /usr/local/etc/tn-gw | |#tn-gw: permit-hosts 192.9.200.2 -passok -xok |tn-gw: permit-hosts 192.9.200.2 -auth -xok << パスワ−ドを要求する。 | | xok はあってもなくてもよい。 |# Example auth server and client rules |# ------------------------------------ |authsrv: hosts 127.0.0.1 << authsrv コマンドを使えるのは hostG だけ。 |authsrv: database /usr/local/etc/fw-authdb |authsrv: badsleep 1200 |authsrv: nobogus true |# clients using the auth server |*: authserver 127.0.0.1 7778 << 7777 は使っているのがあった。 /etc/services ------------------------------- |authsrv 7778/tcp # fwtk use << 7777 は使っているのがあったので変更した。 /etc/inetd.conf 追加する -------------------------------------------------------------- |authsrv stream tcp nowait root /usr/local/etc/authsrv authsrv 以上の編集をやって /etc/inetd デ−モンを再起動すると /usr/local/etc に fw-authdb ファイルなどができる。後は authsrv コマンドでアカウントを登録すれば、 パスワ−ド が効くようになる。ちなみに netperm-table の authsrv の部分をコメントを外さずにお くと $ authsrv コマンドを入れると "Cannot open database" と出て終わってしまう。 $ wd /usr/local/etc;ld authdump authload authmgr authsrv << 関係するコマンド。 fw-authdb fw-authdb.dir fw-authdb.pag << できたパスワ−ド・ファイル。 * アカウントの登録 $ wd /usr/local/etc $ authsrv authsrv# adduser katou 'katou ikken' << ユ−ザに katou を登録する。 ok - user added initially disabled authsrv# disp katou Report for user katou (katou ikken) Authentication protocol: password Flags: DISABLED authsrv# password << パスワ−ドを 333 とする。 Usage: password [username] passwordtext authsrv# password katou 333 Password for katou changed. authsrv# list << status が n だとアカウントは使えない。 Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- katou katou ikken n passw never authsrv# enable katou << アカウント katou を使えるようにする。 enabled authsrv# list Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- katou katou ikken y passw never ↑ authsrv# quit n から y に変わっている。 hostA % telnet hostG Trying 192.9.200.1... Connected to hostG. hostG telnet proxy (Version V1.3) ready: Username: katou << ユ−ザ名の入力。katou しか登録していない。 Password: ### << 平文によるパスワ−ド入力。 Login Accepted tn-gw-> c hostB Trying 192.9.202.1 port 23... IRIX System V.4 (hostB) login: katou hostB % * コマンド $ authdump user=katou << 登録したユ−ザ分だけ、だ−と表示してくれる。 特に使う longname=katou ikken 必要なし。 group= pass=pa1Ot5/6bGFtM << katou のパスワ−ド 333 とした。パスワ−ドを登録してな flags=1 いと pass=* と表示される。 bad_count=0 proto=p last=0 << last=0 はアクセスがまだ一度も無いことを示す。アクセス があると最後の日付けが last=837750663 などと出る。 $ authsrv authsrv# disp katou << ここで help を入れると使えるコマンドがリストされる。 Report for user katou (katou ikken) Last authenticated: Fri Jul 19 13:31:03 1996 Authentication protocol: password Flags:none authsrv# list Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- katou katou ikken y passw Fri Jul 19 13:31:03 1996 authsrv# del katou << 登録を消去する場合。 deleted authsrv# list Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- (4) fwtk 電子メ−ルへの対応 * fwtk の smap & smapd 制御 -------------------------------------------------------------------------------- fwtk の smap、smapd の働きは、ファイアウォ−ルの中でも最も複雑といってよい。いろ いろ雑誌にも smap を使うと書いてあるが、実際どうやって設定するかは見たことがない。 -------------------------------------------------------------------------------- hostG をメ−ルゲ−トウェイ兼メ−ルサ−バとする基本的な構成例で仕組みを見てみよう。 hostG のメ−ルサ−バに、内外の sendmail デ−モンからアクセスがくる。それを inetd 制御下にある SMTP クライアントの smap が受ける。 smap はメ−ルを受けてある適当な ディレクトリに落とす。それを smapd デ−モンが一定時間毎、 通常は1分毎にファイル をチェックする。smapd の中では sendmail デ−モンが起動され、メ−ルキュ−にファイ ルをキュ−の形で落とす。そして同時にメ−ルの配送を実施する。もし配送が失敗すれば キュ−に溜まったままになる。それを cron 運転で sendmail を時々稼働させ、キュ−を チェックし、メ−ルを配送する。 何でこんな処理をわざわざするのか。 sendmail はセキュリティ泣かせで有名なソフトと して通っている。即ち外部からのメ−ルを sendmail で直接受けようとするから危険なの である。そこでメ−ルサ−バは先ず、メ−ルを受けるだけにしましょう。これが smap で ある。受ける際に適当なユ−ザ設定ディレクトリに落とす。 このディレクトリには smap から chroot をかけて、よそのディレクトリに行けないようにしてしまう。 それに smap 自体メ−ルを受けるだけだから root 権限で実行せずに、 uucp などあまり権限のないユ −ザIDで稼働させておけばよい。さらにプログラミングをやるつもりなら、smapd.c は 500行ぐらいのソ−スだから、これをいじれば変なメ−ルを排除するとかできるわけだ。 一応下記の構成は smap の働きがわかるようにと、メ−ルサ−バをファイアウォ−ルのホ ストにおいた。これはあまりおすすめではない。メ−ルサ−バは内部ネットのホストに置 くか、バリアネットに置いた方がよい。バリアネットにおく例は幾つかのファイアウォ− ルの本に出ている。どうも安全面でも管理面でも、その方がいいような気がする。しかし この場合、hostA でメ−ルゲ−トウェイ、hostB でメ−ルサ−バとなる。hostA,B 間のメ −ルの受け渡しが必要になる。sendmail をリレ−として設定するか、 relay プログラム を使うかしなければならない。だいぶ設定がややこしい。この方が問題になったりして。 内外からのメ−ル inetd 制御 デ−モン cron 運転 sendmail -------> smap smapd sendmail -q ----> 失敗分の再配送 | / | / | / sendmail / ↓/ ↓ / ユ−ザ設定 Mail queue ディレクトリ /usr/spool/mqueue ---------> 配送完了 :どこかのホストからの sendmail WWW DNS : hostA □ MX hostG □ Router | | ----------*------------------- バリアネット INDY の場合 | ↓ ↑------- メ−ルサ−バ inetd /usr/etc/smap ×|hostG| deaemon /usr/etc/smapd ↓------- cron /usr/lib/sendmail -b | ----------*-------------------- 内部ネット | hostB □ sendmail * hostG の設定 INDY で fwtk でなく市販品の "Gauntlet 3.0 for IRIX" を使ってみた。WWWブラウザ で設定するようになっているが、それは使わずに手作業で設定してみた。ブラウザでやろ うとすると最初からうまくいかなかった。設定の際の予備知識なども挙げておく。 ・Gauntlet の一連のコマンドは /usr/etc/ にある。 ・netperm-table ファイルは /usr/gauntlet/config/ にあること。 ・電子メ−ルのキュ−・ディレクトリは /usr/spool/mqueue/ である。 /etc/inetd.conf -------------------------------------------------------------- |smtp stream tcp nowait root /usr/etc/smap smap /usr/gauntlet/config/netperm-table -------------------------------------------------------------- |# email wrapper control |smap, smapd: userid 3 << uucp uid。root でなければ結構。 |smap, smapd: directory /usr/spool/smap << これは作ること。オ−ナは uucp。 |smapd: executable /usr/etc/smapd |smap: timeout 3600 | |#smapd: baddir /usr/spool/smap << コメントでよし。 |#smapd: sendmail /usr/lib/sendmail << smapd 内部で定義された sendmail |#smap: maxrecip 4000 と違うのを使う場合。 |#smap: maxbytes 1048576 % ps -e | grep smapd << 本格運用の時はちゃんと rc2.d で起動しておくこと。 1863 ? 0:00 smapd /usr/spool/cron/crontab << いわば残務整理に使う。 -------------------------------------------------------------- |0,15,30,45 * * * * /usr/lib/sendmail -q > /dev/null 2>&1 % ps -e | grep cron << cron もちゃんと設定しておくこと。 320 ? 0:01 cron % netstat -a << smap の確認。 Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp 0 0 *.smtp *.* LISTEN % cat /etc/passwd uucp:*:3:5:UUCP Owner:/usr/lib/uucp:/bin/csh << uucp ユ−ザの確認。 * 等価テスト ユ−ザ katou jiro ------- ------- |hostB| |hostA| メ−ルサ−バ Apollo ------- INDY ------- | | ---------------------------------------------- nix.co.jj sendmail inetd による smap sendmail.cf クライアント sendmail.cf サ−バ $ /usr/ucb/mail -v jiro@nix.co.jj Subject: hello katou kun desuyo << メ−ルサ−バの hostA の smap と接続する。 . EOT jiro@nix.co.jj... Connecting to hostA.nix.co.jj (tcp)... 220 hostA SMTP/smap Ready. >>> HELO hostB.nix.co.jj 250 (hostB.nix.co.jj) pleased to meet you. >>> MAIL From: 250 ... Sender Ok >>> RCPT To: 250 OK >>> DATA 354 Enter mail, end with "." on a line by itself >>> . 250 Mail accepted >>> QUIT 221 Closing connection jiro@nix.co.jj... Sent % cd /usr/spool/smap;ls << hostB からのメ−ルを hostA の smap が受けて、 sma001857 ファイルに落としたところ。 sma001857 ------------------------------------------------------------- |FROM |RCPT |BODY |Received: from hostB(192.9.200.2) by hostA via smap (g3.0.1) | id sma001857; Tue, 3 Dec 96 15:21:57 +0900 |Received: by hostB.nix.co.jj (5.65c/nix.1.0) | id AA01642; Tue, 3 Dec 1996 15:05:52 +0900 |Date: Tue, 3 Dec 1996 15:05:52 +0900 |From: katou@nix.co.jj |Message-Id: <199612030605.AA01642@hostB.nix.co.jj> |To: jiro@nix.co.jj |Subject: hello | |katou kun desuyo % smapd をここで起動する << smapd を起動すると、 上の sma001857 は消えて、 メ−ルキュ−に入る。すぐに sendmail が smapd % cd /usr/spool/mqueue;ls の中で起動され、メ−ルは配送される。配送に失 dfPAA01865 qfPAA01865 敗するとキュ−にそのまま残る。 dfPAA01865 キュ−に残った状態を確かめるには、他のホスト ---------------- のユ−ザにメ−ルを送る。 一応 sendmail.cf や |katou kun desuyo named も設定し、そのホストで sendmail デ−モ ンだけ止めれば、配送できないのでキュ−に残る。 % /usr/lib/sendmail -q << キュ−に残っているメ−ルを吐き出す。 (5) ワンタイム・パスワ−ドを試す * fwtk による例 文字通り一回限り、毎回違うパスワ−ドである。外部からファイアウォ−ル内部のホスト にアクセスする場合に有効である。ワンタイム・パスワ−ドを使うようにするには、専用 のソフトで初期化をする必要がある。初期化をするには、ユ−ザ名、パスワ−ド、シ−ケ ンス番号、シ−ド(種)の4つのパラメ−タを与える。シ−ケンス番号は、パスワ−ドが 何回使えるか示す数である。ロッグインしてパスワ−ド入力するたびに、最初のシ−ケン ス番号の数から1ずつ減っていく。0になったら使えなくなってしまうので、再度パスワ −ドの初期化をすることになる。fwtk では authsrv コマンドがパスワ−ドの設定プログ ラム、ワンタイム・パスワ−ドを計算するのは別なソフトで donkey というのがある。 次の例は hostG に fwtk を入れて、hostA から telnet しているところである。 通常の telnet では login、Password を入力するが、ワンタイム・パスワ−ドの場合はユ−ザ名 を入れると、チャレンジ・コ−ド( 663 no21201 )を返してくる。 このコ−ドをもとに自 ホストでワンタイム・パスワ−ドを計算する。そしてこのパスワ−ドをレスポンス・コ− ドとして入力すると、めでたしロッグイン完了である。ここらあたりのやり取りでもって、 このパスワ−ド管理を Challenge & Response 方式と呼んでいる。チャレンジ・コ−ドの 663 はシ−ケンス番号であり、初期化の際は 664 だった。 663 はつまり2回目のロッグ インになる。no21201 はシ−ド(種)と呼ばれて固定である。 telnet パスワ−ドを初期化しておく <--------- ユ−ザ名 katou を送る katou authsrv# pass katou 333 <--------- % donkey 663 no21201 ID katou s/key is 664 no21201 Enter passphrase : 333 663 no21201 JIBE KNOB MILT BUN DRAB COG ----------> 664:シ−ケンス番号 S/Key 組込 no21201:シ−ド(種) ------------ JIBE .. ---------- | hostG | <---------- | | | | | hostA | |fwtk Proxy| ログインOK | | ------------ ----------> ---------- | | ------------------------------------------------- このテストを行なうためには、 S/Key のサ−バ側ソフトである logdaemon が必要である。 logdaemon にはパスワ−ドを計算するクライアント側のソフトも入っている。 donkey は クライアント側だけのソフトである。下記のところにちょうど2つ揃ってあった。 ftp://ftp.nic.ad.jp/src/donkey-0.3.tar md4,md5 サポ−ト ftp://ftp.nic.ad.jp/src/logdaemon-4.9.tar md4 のみサポ−ト 参考文献は「UNIX MAGAZINE」しかない。 何やらいろいろ訳の分からんことが一杯書いて ある。ワンタイム・パスワ−ドの数学的な意味など知る必要はない。S/Key は実績があり 安全であること。OTP( One Time Password ) は S/Key の今後の呼び方であること。 md4 とか md5 というのは、パスワ−ド生成の暗号化の度合で md5 の方が強力であること。こ れだけ知っておけば十分である。「UNIX MAGAZINE」'95/03, P.114〜 "転ばぬ先のセキュ リティ S/KEY"、'96/02, P.68〜 "転ばぬ先のセキュリティ OTP"。 * ワンタイム・パスワ−ドの運用 [ パスワ−ドの初期化 ] ワンタイム・パスワ−ド初期化の際のパスワ−ドは、管理者が勝手に決めてしまっていい のでないか。一般の人はそれ程セキュリティ意識が高いとは言えない。誕生日や免許証番 号の一部を使う可能性は高い。管理者が相手の誕生日などまで聞いて、パスワ−ドをチェ ックするわけにはいかない。手間もその度かかってしまう。ワンタイム・パスワ−ドとい えども、本当に隠されるのはパスフレ−ズと呼ばれるパスワ−ドだけである。シ−ケンス 番号やシ−ドはプレ−ン・テキストで流れる。よって簡単なパスワ−ドで初期化してしま ったら、見破られる可能性は大きい。もしそんなことで侵入されてしまったとしても、容 易なパスワ−ドをつけた人を責めることはできない。あくまでも管理者の責任でしかない。 [ 危険な設定 ] telnet にワンタイム・パスワ−ドを適用することを検討してみる。あるホストに telnet を掛けると、相手ホストでは telnetd デ−モンから、ロッグインのための /bin/loginが 起動される。この login はただのロッグイン手続きではなく、 ワンタイム・パスワ−ド 対応になっている必要がある。/bin/login は Sun や Apollo などの場合で、 INDY では /usr/bin/login である。つまりこの login プログラムをワンタイム・パスワ−ド用と置 き換えなければならない。これはテストするのも恐ろしい。login をへたに換えたらその 計算機に二度とロッグインできなくなってしまう。絶対やめた方がいい。そうしないため にもワンタイム・パスワ−ドは、fwtk や tcp_wrapper 等の制御下に組み込むべきである。 * ワンタイム・パスワ−ドの実装 [ fwtk に S/Key を組み込む ] $ wd /usr/local/source/logdaemon-4.9;ld Makefile README ftpd/ keysu/ lib/ login/ rexecd/ rlogind/ rshd/ skey/ skeysh/ telnetd/ fwtk は認証機能を使う場合、 デフォルトでプレ−ンテキストのただのパスワ−ド入力を するようになっている。これをソ−スプログラムの auth.h で bellcore's S/Key を使う ように修正する。そしてコンパイルし直すのだが、 ここで S/Key のライブラリが必要に なる。S/Key のソ−スである logdaemon をとってきて、libskey.aを作成しておく。fwtk はここでは Apollo コンピュ−タに設けるので、libskey.a も Apollo でコンパイルして 作成する。$ /bin/make sunos4 とやって、ともかく BSD 系を指示すると途中エラ−で止 まるが libskey.a はできる。テストはこれで問題ない。logdaemon のコンパイルは INDY でもやってみたが、難なく終わった。 [ fwtk の auth.h の修正とコンパイル ] /usr/local/source/fwtk/source/auth.h ---------------------------------------------------------------- |#define AUTHPROTO_PASSWORD /* builtin plaintext passwords */ |/* #define AUTHPROTO_SKEY bellcore's S/Key */ |/* #define AUTHPROTO_SECURID Security Dynamics' SecurID */ ↓ 変更する /usr/local/source/fwtk/source/auth.h ---------------------------------------------------------------- |/*#define AUTHPROTO_PASSWORD builtin plaintext passwords */ |#define AUTHPROTO_SKEY /* bellcore's S/Key */ /usr/local/source/fwtk/source/auth/Makefile ---------------------------------------------- |#SKEYDIR=../../skey |SKEYDIR= /usr/local/source/logdaemon-4.9/skey << libskey.a 必要。 |SKEYINC= -I$(SKEYDIR) |SKEYLIB= $(SKEYDIR)/libskey.a $ wd /usr/local/source/fwtk/source インスト−ルし直したら、authsrv だけがフ $ /bin/make ァイル・サイズが変わっていた。authsrv を $ /bin/make install /usr/local/etc にコピ−して入れ替える。 [ ワンタイム・パスワ−ドの初期化 ] 注意点として /etc/inetd デ−モンは、再起動して認証デ−タベ−スを初期化した方がい い。inetd を再起動しないとエラ−がでる。 もしこれでもダメなら /usr/local/etc/ に ある認証デ−タベ−スのファイル fw-authdb, fw-authdb.dir, fw-authdb.pag を消去し て、再度 inetd を起動してみる。初期化は S/Key の keyinitコマンドは使えない。fwtk の authsrv に組み込まれている。ユ−ザ名とパスワ−ドを入れると、 シ−ケンス番号と シ−ド(種)は authsrv が決める。 $ authsrv authsrv# passwd katou 333 Bad authentication protocol for user - abort $ wd /usr/local/etc $ authsrv authsrv# add katou 'katou ikken' << root で作業すること。 ok - user added initially disabled authsrv# list Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- katou katou ikken n unkno never authsrv# proto katou skey << skey を使う。 changed authsrv# list Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- katou katou ikken n Skey never authsrv# pass katou 333 ID katou s/key is 664 no21201 << 出たぞ。これがチャレンジ・コ−ドだ。 authsrv# enable katou << パスワ−ドを有効にする。 enabled authsrv# list Report for users in database user group longname status proto last ---- ----- -------- ------ ----- ---- katou katou ikken y Skey never [ いよいよトライ ] hostA % cd /usr/local/source/logdaemon-4.9/skey hostA % key 663 no21201 Reminder - Do not use this program while logged in via telnet or rlogin. Enter secret password: << パスワ−ド 333 をいれる JIBE KNOB MILT BUN DRAB COG << これがワンタイム・パスワ−ドだ hostA % telnet hostG hostG telnet proxy (Version V1.3) ready: Username: katou Skey Challenge: s/key 663 no21201 << ただ Return キ−を押してみた。ダメ。 Permission Denied. Username: katou ↓ここから後ろ入力する。小文字でもよい。 Skey Challenge: s/key 663 no21201JIBE KNOB MILT BUN DRAB COG Login Accepted << ロッグインに成功した。 tn-gw-> c localhost [ ワンタイム・パスワ−ドの計算 ] donkey というソフトでも S/Key の key と同じく、 ワンタイム・パスワ−ドを計算する ことができる。デフォルトは md4 で計算するが、md5 でも計算できる。 key の方は今の ところ md4 での計算だけである。以下全て katou でロッグインした状態での出力である。 donkey のコンパイルは IRIX 5.3 でやってみたが、特に問題なかった。各自やられたい。 % donkey 663 no21201 << デフォルトでは md4 で計算する。 Enter passphrase : JIBE KNOB MILT BUN DRAB COG % donkey -f md5 663 no21201 << md5 で出してみた。上記とは異なっている。 Enter passphrase : OUST WAIT WOK SAID COCO GRID % donkey -n 5 663 no21201 << 663 番から5個、ワンタイム・パスワ−ドを表示 Enter passphrase : した。プリントしておけば、計算機に donkey な 659: NAT THEM BEET JOB DEAL HOYT ど計算プログラムが無くても構わない。 660: MIKE FOUR AIDE CHAR HUM GLOM 661: TAKE FUME JOG BASH TIC AREA 662: ALP MALE BURY JACK EMMA ARE 663: JIBE KNOB MILT BUN DRAB COG % key -n 3 663 no21201 << S/Key でも同じ結果が得られる。 Reminder - Do not use this program while logged in via telnet or rlogin. Enter secret password: 661: TAKE FUME JOG BASH TIC AREA 662: ALP MALE BURY JACK EMMA ARE 663: JIBE KNOB MILT BUN DRAB COG % donkey -i << S/Key のための初期化用の書式を出力する。 Enter login name [default katou]: Enter sequence 1 to 999 [default 99]: 663 Enter new seed [default ic99863]: no21201 Enter passphrase : Enter passphrase : katou 0663 no21201 a174faee04a76616 Jul 22,1996 10:44:37 JIBE KNOB MILT BUN DRAB COG * donkey のコンパイル % donkey usage: donkey [-n num] [-f func] sequence seed donkey -i % tar -xvf donkey-0.3.tar << INDY IRIX 5.3 でコンパイルしてみた。なんの問 % ls -F 題も無く数十秒で終わった。 setup /obj /src 00changes 00install 00readme % ./setup Set up obj/IRIX.5.3 ... Done To make donkey for IRIX.5.3, type: cd obj/IRIX.5.3 << この順番で実行していけばよい。 ./configure make % cd obj/IRIX.5.3 % ./configure % make % make install cp donkey /usr/local/bin << /usr/local/bin/ に donkey がコピ−される。 ln -s donkey /usr/local/bin/key authsrv# help << これでだいたい使い方は分かる。 Command List: (Commands may be invoked with unique leading abbreviation) authorize username [comment] authenticate username response quit exit display username adduser username [fullname] deluser username enable username [onetime] disable username password [username] passwordtext passwd [username] passwordtext proto username protoname group username groupname rename username newname [fullname] wiz username unwiz username superwiz username operation group/user username command dest [tokens] list [group] ls [group] ? help ------------------------------------------------------------------------------------ [ 付録 ] いろいろ % ftp ftp.tis.com Connected to neptune.tis.com. 220 neptune FTP server (Version 5.60mjr). WARNING - some files are export controlled Name (ftp.tis.com:katou): anonymous 331 Guest login ok, send ident as password. Password: 230 Guest login ok, access restrictions apply. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls -rw-r--r-- 1 root daemon 92 Jul 13 1995 README -rw-r--r-- 1 root daemon 170 Sep 29 1994 README.html drwxr-xr-x 3 aldea aldea 512 May 23 1994 aldea drwxrwsr-x 4 root gauntlet 1024 Mar 6 14:19 gauntlet drwxrwx--x 5 root staff 512 Mar 7 16:47 private drwxr-xr-x 15 root daemon 512 Feb 16 16:41 pub drwxr-xr-x 2 root daemon 512 Jan 5 09:42 tmp drwxr-xr-x 9 root daemon 512 Sep 14 1995 users drwxr-xr-x 5 root daemon 512 May 17 1994 usr ftp> cd pub drwxr-xr-x 11 galvin staff 512 Jan 11 1994 386users drwxrwxr-x 3 feldman staff 512 Sep 27 17:08 DIGSIG drwxrwxr-x 4 feldman staff 512 Feb 29 18:19 DNSSEC drwxrwxr-x 6 feldman staff 512 Oct 4 10:23 MOSS drwxrwxr-x 2 feldman staff 512 Sep 13 1995 PEM drwxr-xr-x 3 balenson staff 512 Feb 16 16:26 PEM-DEV drwxr-xr-x 2 122 daemon 512 Jul 28 1994 TIS drwxrwxr-x 5 root staff 512 Feb 26 09:33 TMACH drwxrwxr-x 7 balenson staff 512 Jun 16 1995 crypto drwxrwxr-x 4 179 staff 1024 Dec 13 1994 firewalls lrwxrwxrwx 1 root daemon 11 Sep 1 1995 gauntlet -> ../gauntlet drwxrwxr-x 8 12 41 512 Feb 16 18:37 lists drwxr-xr-x 14 galvin staff 512 Dec 29 1993 pcip drwxr-xr-x 2 dave staff 512 Sep 29 1994 www ftp> cd firewalls -rw-r--r-- 1 179 staff 26606 Jun 6 1994 faq.current -rw-r--r-- 1 179 staff 1802340 Aug 2 1993 firewalls-slides.ps -rw-r--r-- 1 179 staff 706271 Jun 17 1994 firewalls-slides.ps.Z -rw-r--r-- 1 179 staff 197868 Aug 27 1993 firewalls.ps -rw-r--r-- 1 179 staff 74375 Jun 17 1994 firewalls.ps.Z -rw-r--r-- 1 179 staff 54494 Mar 4 1994 fw-brief.ps -rw-r--r-- 1 179 staff 24821 Jun 17 1994 fw-brief.ps.Z -rw-r--r-- 1 179 staff 39980 Mar 4 1994 fwtk.ps -rw-r--r-- 1 179 staff 18721 Jun 17 1994 fwtk.ps.Z drwxr-xr-x 2 root daemon 512 Mar 28 1995 gauntlet -rw-r--r-- 1 179 staff 692800 Dec 13 1994 handouts.ps -rw-r--r-- 1 179 staff 136979 Dec 13 1994 handouts.ps.Z -rw-r--r-- 1 179 staff 268510 Jan 25 1994 isoc94.ps -rw-r--r-- 1 179 staff 100467 Jun 17 1994 isoc94.ps.Z -rw-r--r-- 2 179 staff 31569 Mar 4 1994 netsec.ps -rw-r--r-- 1 179 staff 15426 Jun 17 1994 netsec.ps.Z -rw-r--r-- 1 179 staff 661215 Dec 13 1994 presentation.ps -rw-r--r-- 1 179 staff 136253 Dec 13 1994 presentation.ps.Z -rw-r--r-- 1 179 staff 374064 Aug 2 1993 sans-1-paper.ps -rw-r--r-- 1 179 staff 142934 Jun 17 1994 sans-1-paper.ps.Z -rw-r--r-- 1 179 staff 75415 Mar 4 1994 secacc.ps -rw-r--r-- 1 179 staff 30523 Jun 17 1994 secacc.ps.Z -rw-r--r-- 2 179 staff 65056 Jul 28 1994 tiscaps.ps drwxr-xr-x 7 179 staff 512 Dec 22 1994 toolkit -rw-r--r-- 1 179 staff 185431 Jun 6 1994 usenix-paper.ps -rw-r--r-- 1 179 staff 71593 Jun 17 1994 usenix-paper.ps.Z -rw-r--r-- 1 179 staff 137543 Jun 6 1994 usenix-slides.ps -rw-r--r-- 1 179 staff 31683 Jun 17 1994 usenix-slides.ps.Z ftp> cd toolkit ftp> ls -rw-r--r-- 1 179 staff 9078 Nov 4 1994 CHANGES -rw-r--r-- 1 179 staff 549 Nov 4 1994 CHECKSUMS -rw-r--r-- 1 179 staff 1465 Nov 4 1994 DISCLAIMER -rw-r--r-- 1 179 staff 4632 Feb 12 11:26 LICENSE -rw-r--r-- 1 179 staff 1366 Nov 4 1994 README drwxr-xr-x 2 179 staff 512 Nov 4 1994 US-only drwxr-xr-x 2 179 staff 512 Dec 30 1994 contrib drwxr-xr-x 2 120 daemon 1024 Mar 1 03:15 fwall-users-archive -rw-r--r-- 1 179 staff 418175 Nov 4 1994 fwtk-doc-only.tar.Z -rw-r--r-- 2 179 staff 444950 Feb 12 13:58 fwtk-v1.3.tar.Z -rw-r--r-- 2 179 staff 444950 Feb 12 13:58 fwtk.tar.Z drwxr-xr-x 2 179 staff 512 Nov 4 1994 old-versions drwxr-xr-x 2 179 staff 512 Mar 17 1995 patches ftp> ls contrib -rw-r--r-- 1 179 staff 482 Dec 30 1994 README -rw-r--r-- 1 179 staff 49152 Dec 22 1994 html-user-guide.tar -rw-r--r-- 1 179 staff 26110 Dec 30 1994 solaris.patch -rw-r--r-- 1 179 staff 4075 Dec 22 1994 tcl-fwtk-logwatcher toolkit/README だと思う。 --------------------------------------------------------------------- | TIS Firewall Toolkit | | Trusted Information Systems, Inc. | October 20, 1993 | | |WHAT IS THE TIS FIREWALL TOOLKIT? |--------------------------------- |Trusted Information Systems, Inc. (TIS) is pleased to provide the TIS |Firewall Toolkit, a software kit for building and maintaining |internetwork Firewalls. It is distributed in source code form, with |all modules written in the C programming language and runs on many |BSD UNIX derived platforms. The Toolkit is being made available for |use as specified in the license agreement (LICENSE). | | |USERS' GROUP |------------ |TIS maintains the electronic-mail users' group |for discussion of the toolkit. To join, send electronic mail to |. | |TIS Firewall Toolkit technical questions, license issues, bug reports, |etc. should be addressed to . | |Information about other TIS network security products or commercial |licensing requests should be sent to or by telephone to |(301) 854-6889. | | |WHAT IS HERE? |------------- |README - This file | |US-only - Directory containing US-only software. If you | are not accessing this from a site in the US or | Canada you will not be able to FTP these files. | |fwtk-doc-only.tar.Z - Toolkit documentation |fwtk.tar.Z - Toolkit sources and Makefiles (no documentation)