特別講座<パスワード編>


■はじめに(標準Physical_Security講座も参照せよ)

 ファイアウォールをいくつインストールしても、パスワードに弱点があれば、勝手口が開けっぱなしになっているようなものです。

 以下に、パスワード攻撃の種類を紹介します。パスワード攻撃といっても広いんですね。

 以下に、パスワード攻撃に対する対策を示します。

 

■パスワードクラック・TOOL

 パスワードを破るには、以下のようなパスワードクラッカーと呼ばれるものが使われます(詳しくは、基礎パスワードクラッカー講座を参照せよ)。

 

●Crackの説明

 ”Crack''”という名前のパスワードクラックソフトがあります。 Crack は、英単語、フィンランド人の姓、日本人の名前、 ``12345678'' などの単純な文字列...などなどを含む大きな辞書を持っていて、その辞書の中の語を順々に試していきます。それだけではなく、辞書の中の語を様々な方法で変換して、それも使います。例えば、まず ``orange'' を試したら、次は ``Orange''、次は ``egnaro'' (``orange'' の逆並び)、次は ``0range'' (``O'' [オー] ではなくて ``0'' [ゼロ]) などなど。

 Crack はインターネットで公開されていて無料で手にはいるので、誰でも手に入れることができ、従って、誰でもパスワード破りをしてみることができます。 Crack は、よそのシステムに侵入しようとする人がよく使います。実際、少し前、CCSR のユーザーのパスワードを盗んで (二人分)、ここのシステムに侵入していた人がいました。幸いその人は侵入して楽しんでいただけで実質的な被害はありませんでしたが、被害を与えようと思えば出来たのです。

 

■危険なパスワード

次のようなパスワードはよくありません。

 

■プログラムで自動的にパスワードを作ってみよう

 ISP(プロバイダ)から、あなたもアカウントのパスワードをもらっていると思います。しかし、そのパスワードはどのように作っているのでしょうか?あなたも、乱数パスワード作成プログラムで、パスワードもつくってみませんか?以下に、ソースを紹介します。

----- program of making of passwd -----

#! /usr/bin/perl

# passmake.perl

$max_generate = 20; # 生成するパスワードの数

$max_length = 8; # 生成するパスワードの長さ

$max_salt = 2; # サルト(味付け)

for(0..$max_generate)

{

$comp = ";

$salt = ";

for(0..%max_length)

{

$a = int(rand(94)) + 33;

$comp .=sprintf("%c", $a);

}

for(0..$max_salt)

{

$b = int(rand(94)) + 33;

#salt .= sprintf("%c",$b);

}

$crypt = crypt($comp, $salt);

printf qq|$comp >> $crypt\n|;

}

exit();

----- End -----

 

■辞書について(詳しくは、基礎辞書作成講座を参照せよ)

 パスワード破りに使われる「辞書」には、通常の辞書にある言葉に加えて、西洋や日本の人名 (Ayako, Taro, Tanaka, Satoh, ..., Mary, Andrei, Sophie, ..., Schmitt, Rousseau, Rodriguez, ...)、地名 (Beijing, Siberia, Alps, Nagasaki, ...)、規則的な文字の並び (abcdefgh, 12345678, aaaaaaaa, ...) などなどが含まれています。

 

■変換規則

 よく知られた変換規則としては、文字の順番を逆様にする (orange -> egnaro)、一部を大文字にする (Orange)、最後に数字を付ける (orange1)、最初に数字を付ける (1orange)、 ”e” を ”0'”に、 ”i'”を ”1”に、 ”e'”を ”3” に置き換える(orang3)、一部を繰り返す (oorangee)、反転する (orannaro)などなどがあります。

 

■安全なパスワードを考えるためのヒント

 パスワードには、アルファベット大文字、数字 (0, 1, 2, 3, ...)、句読点 (,.;:!?)、その他の記号 (#@$%^&*(){}[]_-=+/\|<>~)を自由に混ぜることが出来ます。例えば、``%s+AtoH*'' などというパスワードの方が ``satoh'' よりもずっと安全です。

 あるいは、自分にしか分からない情報を使うのも手です。例えば、「初めてディズニーランドに行ったのが8月9日で、次に行ったのが12月4日だ」ということをなぜか鮮明に憶えているのなら ``809D124L'' などというパスワードもいいかも知れません。 (``D'' と ``L'' は「ディスニー・ランド」の頭文字。)

 神経質になる必要はありません。例えば ``&N~%hW|^'' のようなパスワードは非常に安全でしょうが、とても憶えられるものではありません。一方 ``orange'' というような安易なパスワードは、全く危険です。その中間の適度な辺りを考えて下さい。

 

■パスワード文字数

 NCSC(National Computer Security Center)が定めたパスワード言い当ての確率は、以下のようになります。

P=(L×R)/S

ただし、Lはパスワードが変更されるまでの時間(有効期間)、Rは単位時間に行える探査の回数、Sはユニークなパスワードの件数(パスワード空間)である。Sは、Aをパスワードに使われるであろうアルファベットの文字列数、Mをパスワードの文字列数として、S=AMとなる。

 

■パスワードの制限

 パスワードとして使えるものに制限がある場合があります。コンピューター自体に制限が組み込まれていたり、システム管理者が制限をしていたりします。 CCSR では、次のような制限があります。

 

■パスワード・ファイルとは何か?

 パスワード・ファイルとはUNIX系OSにおけるユーザー情報やパスワードなどの情報が書かれたファイルのことである。 このファイルはログイン時の認証に使われたり、アプリケーションがユーザ情報を獲得するために使用される。以下のコマンドを実行して様様なパスワードファイルについて調べることができます。

$ man 5 passwd

PASSWD(5) File formats PASSWD(5)

 

NAME

passwd - password file

 

DESCRIPTION

Passwd is a text file, that contains a list of the sys-

tem's accounts, giving for each account some useful infor-

mation like user ID, group ID, home directory, shell, etc.

Often it also contains the encrypted passwords for each

account. It should have general read permission (many

utilities, like ls(1) use it to map user IDs to user

names), but write access only for the superuser.

 

In the good old days there was no great problem with this

general read permission. Everybody could read the

encrypted passwords, but the hardware was too slow to

crack a well-chosen password, and moreover, the basic

assumption used to be that of a friendly user-community.

These days many people run some version of the shadow

password suite, where /etc/passwd has *'s instead of

encrypted passwords, and the encrypted passwords are in

/etc/shadow which is readable by the superuser only.

 

Regardless of whether shadow passwords are used, many

sysadmins use a star in the encrypted password field to

make sure that this user can not authenticate him- or her-

self using a password. (But see the Notes below.)

 

If you create a new login, first put a star in the pass-

word field, then use passwd(1) to set it.

 

There is one entry per line, and each line has the format:

 

account:password:UID:GID:GECOS:directory:shell

 

The field descriptions are:

 

account the name of the user on the system. It

should not contain capital letters.

 

password the encrypted user password or a star.

 

UID the numerical user ID.

 

GID the numerical primary group ID for this

user.

 

GECOS This field is optional and only used for

informational purposes. Usually, it con-

tains the full user name. GECOS means

General Electric Comprehensive Operating

System, which has been renamed to GCOS

when GE's large systems division was sold

to Honeywell. Dennis Ritchie has

reported: "Sometimes we sent printer out-

The gcos field in the password file was a

place to stash the information for the

 

directory the user's $HOME directory.

 

shell the program to run at login (if empty,

use /bin/sh). If set to a non-existing

executable, the user will be unable to

login through login(1).

 

NOTE

If you want to create user groups, their GIDs must be

equal and there must be an entry in /etc/group, or no

group will exist.

 

If the encrypted password is set to a star, the user will

be unable to login using login(1), but may still login

using rlogin(1), run existing processes and initiate new

ones through rsh(1) or cron(1) or at(1) or mail filters

etc. Trying to lock an account by simply changing the

shell field yields the same result and additionally allows

the use of su(1).

 

FILES

/etc/passwd

 

SEE ALSO

passwd(1), login(1), su(1), group(5), shadow(5)

 

January 5, 1998 1

 古いシステムでのパスワード・ファイルは /etc/passwdにある。

例;hogehoge% ls -l etc/passwdでアクセス権限が分かります。

 

■どのようにパスワードファイルにアクセスするか?

 UNIXのパスワードファイルは /etc に有る passwd というテキストファイルだ。デフォルトでは設計上、このファイルはシステムのユーザなら誰でも読めるようになっている。 NIS/yp を使ったUNIXシステムや password shadowing が施されている場合は他の場所に有るだろう。

 

■パスワードファイルの見方

 nomad:HrLNrZ3VS3TF2:501:100:Simple Nomad:/home/nomad:/bin/bash

は以下に、対応してます。(フィールドは:で区切られてる)

 

●ユーザ名←左から1番目

 ユーザのユーザ名。8文字までで小文字しか使えない。 

 

●暗号化されたパスワードかパスワード・トークン

 特別講座<crypt編>を参照せよ。

 

●UID(ユーザID)←左から3番目

 UIDは、ユーザ名とは違い、16ビットの整数で示される。所有権を区別し、リソースへのアクセスを認めるために使われるのが、この数値です。UIDが0だった場合には、ルート権限を意味します。UIDの-1と-2は、NFS(詳しくは、基礎NFS講座を参照せよ)で使われる。UIDが-1の場合には、ユーザとして認められていないことを意味し、誰も参照されない。UIDが-の場合には、そのシステムのルートとしてアクセスすることが認められていない他のシステムのルートがファイルシステムにアクセスすることを意味する。

 ちなみに、UIDが0(ゼロ)のユーザはrootです。rootの情報が知りたいならば、コマンドfingerを使ってみましょう。以下のように、入力してみてください。

$ finger root

 

●GID(グループ名)←左から4番目

 4番目の領域は、GID領域で、16ビットの整数で示される。グループを使うと、同じグループのユーザでは特別な許可無しでファイルを共有できるのに、グループが違うユーザはアクセスできないといった設定が簡単にできます(詳しくは、特別講座<chmod編>を参照せよ)。

 

●GECOS←左から5番目

 GECOS領域は、コメントが書きこめれる領域で、しきたり(?)としてユーザの本名や住所、電話番号などが書きこまれるらしいです。私は見たこと無いなあ、本名が書かれているのは。本名かかれていたら、もうけもんですね(微笑)。この領域は、fingerコマンド(詳しくは、特別講座<finger編>を参照せよ)をはじめ、ユーザの本名をしめすたくさんのコマンドで使われます。

 しかし、このGECOS領域には情報が含まれるべきではない。管理者は注意しましょう。

 

●ホームディレクトリ←左から6番目

 ユーザのホームディレクトリで、64文字以内に制限されていることが多い。

 

●ログインシェル←左から7番目(右から1番目)

 一般に、44文字以内に制限されている。

 

■shadowパスワード(詳しくは、特別講座<シャドーシステム攻撃編>も参照せよ)

 現在のシステムでは、上のようなセキュリティ上問題がある古いパスワード・ファイルを使わないことが一般的になっています。 新しいパスワード・ファイルには、シャドウ・パスワードという仕組みが取り入れられています。 しかし一部のLinuxのディストリビューションでは、まだ新しいパスワードファイルが導入されていないものもあるみたいです。

 下のようにDES化したパスワードが「!」「*」「×」となっています。

root:!:10922:1000:Chris Carter:/root:/bin/csh

root:*:10922:1000:Chris Carter:/root:/bin/csh

root:x:10922:1000:Chris Carter:/root:/bin/csh

 例えば,次のようなところにシャドウ・パスワード・ファイルが保存されます。

 

 まず、シャドウ・パスワード・ファイルのアクセス権を確認してみましょう。

hogehoge% ls -l /etc/shadow

-rw------- 1 root whell xxx Sep xx xx:xx /etc/shadow

なるほど一般ユーザーにはシャドウ・パスワード・ファイルは読めないようになっていますね。これで安心というわけです。

 

実はこのこと以外に、シャドウ・パスワード・ファイルを使用するメリットがあります。

まずまずシャドウ・ファイルではパーミッションの変更以外にも変わったことがあります。 シャドウ・ファイルがどういう情報で構成されているかを見てみましょう。

gaku:hogehoge:10480:0:99999:7:::

それぞれ、

です。システムによって構成は違うと思います。

わからない場合は man shadow とするか shadow.h を見るとわかると思います

 

 古いタイプのパスワード・ファイルとずいぶん構成が違いますね、 ちなみにログインシェルなどの情報は従来のパスワード・ファイルを参照しています。 これは互換性を保つためだと思います。 しかし、Free BSD などのシャドウ・ファイルではユーザーID・グループID・ホームディレクトリなどの情報の 従来のパスワード・ファイルのエントリがすべて含まれています..が互換性のためか従来のパスワードファイルも残されています。

 

■brute force password cracking(力ずくパスワードクラック) はどのようにされるか?

 Brute force password cracking は単純に与えられたsaltでパスワード A を、同様に B C そして可能な限り全ての文字の組み合わせを次々に試していくことである。非常に時間がかかるが、十分な時間が有れば、brute force cracking はパスワードを得られる。

 UNIXのパスワード用の brute force cracker がいくつか有る。しかし、セキュリティを破るにはrootのパスワードの brute force crack を試みるより他に方法が有る。

 

■セキュリティの厳しいシステムのパスワードファイルから何が学べるか?

 システムのアクセスを手に入れてパスワードファイルが見れたが、shadowされていたとする。ここに例を挙げる:

root:!:0:0:root:/root:/bin/tcsh

bin:!:1:1:bin:/bin:

daemon:!:2:2:daemon:/sbin:

adm:!:3:4:adm:/var/adm:

lp:!:4:7:lp:/var/spool/lpd:

sync:!:5:0:sync:/sbin:/bin/sync

shutdown:!:6:0:shutdown:/sbin:/sbin/shutdown

halt:!:7:0:halt:/sbin:/sbin/halt

mail:!:8:12:mail:/var/spool/mail:

news:!:9:13:INN (NNTP Server) Admin ID, 525-2525:/usr/local/lib/inn:/bin/ksh

uucp:!:10:14:uucp login user:/var/spool/uucppublic:/usr/sbin/uucp/uucico

operator:!:0:0:operator:/root:/bin/tcsh

games:!:12:100:games:/usr/games:

man:!:13:15:man:/usr/man:

postmaster:!:14:12:postmaster:/var/spool/mail:/bin/tcsh

httpd:!:15:30:httpd:/usr/sbin:/usr/sbin/httpd:

nobody:!:65535:100:nobody:/dev/null:

ftp:!:404:100::/home/ftp:/bin/nologin

nomad:!:501:100:Simple Nomad, 525-5252:/home/nomad:/bin/bash

webadmin:!:502:100:Web Admin Group ID:/home/webadmin:/bin/bash

thegnome:!:503:100:Simple Nomad's Old Account:/home/thegnome:/bin/tcsh

dorkus:!:504:100:Alternate account for Fred:/home/dorkus:/bin/tcsh

 このパスワードファイルに関して興味を引かれる点は:ユーザ "operator" はユーザ番号ゼロ、つまりroot権限を持っている。8つのアカウントがinteractiveシェルを持っている、つまり直接のシェルアカウントを得る為のターゲットは8人ということだ。このマシンでは news、web、そして恐らく anonymous ftp が設定されている。ユーザ "nomad" は "thegnome" という古いアカウントを持っていて、恐らくこれは現在では使われていないだろうから、最初のターゲットにする。ユーザ "webadmin" は複数の者に共有されているアカウントのようだ。電話番号の局番は 525 だ。wardialerを起動してモデムを探せる。"dorkus" のアカウントが怪しい。Fred のアカウントが他のマシンに有るかも知れない ( .rhosts 等をチェックする)。

 ちなみに、管理者は、パスワードのいないユーザがいないようにしましょう。パスワードが無いユーザは、パスワードファイル中のパスワード領域が空白だろうから見つけるのが簡単である。また、次のスクリプトは、パスワード無しのアカウントを全て出力させます。

awk -F: 'length($2)<1 {print $1}' </etc/passwd

 

■パスワードを手に入れたら?

●rootを入手した場合

1、hogehoge% echo "myserver::0:0:Test User:/:/bin/csh" >> \etc\passwd

2、これによって、あなたはmyserverというIDでサーバーにログインする事ができるので、管理者達がrootとしてログインしている人々を見たとしても、彼らに疑問を抱かせる事は無いです。

 

●シェルを入手した場合(詳しくは、特別講座<finger編>を参照せよ)

1、ポート79にtelnetする。ちなみに、ポート79は、fingerポートです。

2、プロンプトに、クラックして手に入れたアカウントのユーザーネームを打ちこみます。

3、そうすると、そのユーザーの最後にログインした時刻が分かるので、それを全てのアカウントに対して実行するのです。

4、そしてアカウントを使う時には、それ程使われていないアカウント――1番良いのは"User Bever Logged On"と表示されるものですが――を使うのです(なぜならば、その場合、アカウントは基本的にあなたのものになるからです)。

 

■パスワードファイルにあるカンマに続く奇妙な文字列は何?

----- alt.2600 FAQ A06から引用 -----

A-06. What are those weird characters after the comma in my passwd file?

 

The characters are password aging data. Password aging forces the

user to change passwords after a system administrator-specified period

of time. Password aging can also force a user to keep a password for

a certain number of weeks before changing it.

 

]

] Sample entry from /etc/passwd with password aging installed:

]

] voyager:5fg63fhD3d,M.z8:9406:12:The Voyager:/home/voyager:/bin/bash

]

 

Note the comma in the encrypted password field. The characters after

the comma are used by the password aging mechanism.

 

]

] Password aging characters from above example:

]

] M.z8

]

 

The four characters are interpreted as follows:

 

1: Maximum number of weeks a password can be used without changing.

2: Minimum number of weeks a password must be used before changing.

3&4: Last time password was changed, in number of weeks since 1970.

 

Three special cases should be noted:

 

If the first and second characters are set to '..' the user will be

forced to change his/her passwd the next time he/she logs in. The

passwd program will then remove the passwd aging characters, and the

user will not be subjected to password aging requirements again.

 

If the third and fourth characters are set to '..' the user will be

forced to change his/her passwd the next time he/she logs in. Password

aging will then occur as defined by the first and second characters.

 

If the first character (MAX) is less than the second character (MIN),

the user is not allowed to change his/her password. Only root can

change that users password.

 

It should also be noted that the su command does not check the password

aging data. An account with an expired password can be su'd to

without being forced to change the password.

 

 

Password Aging Codes

+------------------------------------------------------------------------+

| |

| Character: . / 0 1 2 3 4 5 6 7 8 9 A B C D E F G H |

| Number: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |

| |

| Character: I J K L M N O P Q R S T U V W X Y Z a b |

| Number: 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |

| |

| Character: c d e f g h i j k l m n o p q r s t u v |

| Number: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |

| |

| Character: w x y z |

| Number: 60 61 62 63 |

| |

+------------------------------------------------------------------------+

----- End -----

上の引用を見れば分かるとおりその奇妙な文字列”M.z8”は、パスワード・エイジング(passordaging:パスワード劣化されたデータである。

 パスワード・エイジングとは、システム管理者がある時間を超えると、ユーザにパスワードの変更を要求する。また、パスワード・エイジングは、ユーザに対して一旦パスワードを変更したならば、次に変更するまでに数週間を置くように要求することも可能です。

 

■最後に

 /etc/passwdファイルは、テキストファイルで、どんなエディタでも編集でき、その形式も非常に平凡である。ただし、このファイルを複数の人間が平行して更新する危険性がある場合、何らかのロックアウトメカニズムを使うべきだろう。まさにそのために設計されたプログラムがvipwで、これはviを起動してパスワードファイルを読みこみ、処理が終了するまで他の人がそれを編集できないようにしている。

 このような単純な構成でも、非常に柔和なユーザ環境が実現可能である。ユーザをシステムに追加するのも簡単である。単に、ユーザについて書かれた行を追加して、そのユーザ用のホームディレクトリを作ればよいだけである(実際には、.cshrcと.loginまたは.profileのプロトタイプをホームディレクトリに入れておいてあげえば親切だが、これは絶対に必要だというわけではない)。

 シェルのフィールドは特に役に立ちます。ユーザごとに違うシェルの実力を許可すれば、どのような水準のユーザにも合うシステムにできるはずである。技術力の無いユーザにはメニュータイプなどの単純なシェルを遣わせれば良いし、制限つきのユーザには例えばゲームにしかアクセスできないような限定的なシェルを使わせればよいのである。また、コマンドをユーザとして登録してもよい。例えば、whoというユーザをログインシェルを/bin/whoとして登録すれば、whoとうしてログインするとwhoコマンドを実行できるのである(コマンド終了時にはログアウトすることになる)。

 アカウントの作成・管理については、特別講座<アカウント作成・管理編>を参照せよ。

 

■おまけ(1台のマシンを複数のユーザで使用している場合について)

●WinNT

 「administrator」権限で「ユーザマネージャー」からファイルへのアクセスを制限しましょう。

 

●Win9x

 Win95,98は、内部反抗に関しては穴だらけです。ですが、一応の制限はできます。

 「システム・ポリシー・エディタ(Win95,98のCD-ROM内の『J:\admin\apptools\poledit』にある)」で制限できます。

 


■参考文献


戻る

独自ドメインの取得をするなら 独自ドメインの取得をするなら 海外旅行保険の加入はコチラ!