なんだこれは

はてなダイアリーから移転しました。

ボクと契約(GPL)して、rkhunter/MacOSXを使ってよ。

えーっとPUELLA MAGI MADOKA MAGICAで頭がアレなfu7mu4が書いたsecurity scannerのメモです。これで、君のSnow leopardもマミられないぞ!もう何も怖くない!

Macは、UNIXの仲間だった、ような…

rkhunterってあったよね。あれ、UNIXで動いたよね。
ということで、コマンドラインからrkhunterを入れてみた。

内容はこんなかんじ。

  • それはとっても嬉しいなって(benefit)
  • もう何も恐くない(install)
  • hash登録もupdateも、あるんだよ。(short usage)
  • Dica-kitなんてあるわけない/こんなの絶対おかしいよ(false positive on Mac OSX)
  • 設定ファイルと向き合えますか?(fix configuration)

それはとっても嬉しいなって

rkhunterは Free SoftwareでRoot Kitを探したり(hunt)、Security上の問題を見つけたり、いろいろするものです。

もう何も恐くない

じゃあ、もう入れちゃいましょう。

The Rootkit Hunter projectからダウンロードしちゃいましょう。

で、ターミナルで/usr/local以下にいれてしまいましょう。ところで/usr/local/binはPATHにはいってますよね。

tar -zxvf rkhunter-1.3.8.tar.gz 
cd rkhunter-1.3.8
sudo ./install --help            #show help for installer
sudo ./installer.sh --layout /usr/local --install

Checking system for:
Rootkit Hunter installer files: found
A web file download command: wget found
Starting installation:
Checking installation directory "/usr/local": it exists and is writable.
Checking installation directories:
Directory /usr/local/share/doc/rkhunter-1.3.8: creating: OK
Directory /usr/local/share/man/man8: creating: OK
Directory /usr/local/etc: creating: OK
Directory /usr/local/bin: exists and is writable.
Directory /usr/local/lib: exists and is writable.
Directory /var/lib: exists and is writable.
Directory /usr/local/lib/rkhunter/scripts: creating: OK
Directory /var/lib/rkhunter/db: creating: OK
Directory /var/lib/rkhunter/tmp: creating: OK
Directory /var/lib/rkhunter/db/i18n: creating: OK
Installing check_modules.pl: OK
Installing filehashsha.pl: OK
Installing stat.pl: OK
Installing readlink.sh: OK
Installing backdoorports.dat: OK
Installing mirrors.dat: OK
Installing programs_bad.dat: OK
Installing suspscan.dat: OK
Installing rkhunter.8: OK
Installing ACKNOWLEDGMENTS: OK
Installing CHANGELOG: OK
Installing FAQ: OK
Installing LICENSE: OK
Installing README: OK
Installing language support files: OK
Installing rkhunter: OK
Installing rkhunter.conf: OK
Installation complete

hash登録もupdateも、あるんだよ。

rkhunterのコマンドラインの詳細はこんな感じでみてね。

sudo rkhunter --help

とりあえず、動かしてみよう。

sudo rkhunter --propupd          #hash registe
sudo rkhunter --update           #definition update
sudo rkhutner -c --skip-keypress #check without keypress

checkで --skip-keypressをつけない場合、一段落したら、リターンを打たないといけない。

Dica-Kitなんて、あるわけない!

System checks summaryの結果

File properties checks...
Required commands check failed
Files checked: 100
Suspect files: 4

Rootkit checks...
Rootkits checked : 160
Possible rootkits: 1
Rootkit names : Dica-Kit Rootkit

Applications checks...
Applications checked: 6
Suspect applications: 1

The system checks took: 3 minutes and 47 seconds

All results have been written to the log file (/var/log/rkhunter.log)

One or more warnings have been found while checking the system.
Please check the log file (/var/log/rkhunter.log)

えええー、魔女?Dica-kit Rootkit ????
ちょっとまって、冷静に素数を数えるんだ /var/log/rkhunter.log
を読もう。

こんなの絶対おかしいよ

Charles Martin Reidによると、false positiveつまるところ誤検出らしい。

Dica-kitはLinuxのTrojanでsshの設定ファイルを/etc/sshd_configや/etc/ssh_host_keyを置くらしい(Linuxの正しい位置は/etc/ssh/以下)。ただ、これがMacの正当な場所なのだそうです。

結局、他にも出ていたモノも結局設定ファイルをいじると治るらしい。

設定ファイルと向き合えますか?

とりあえず、/usr/local/etc/rkhuter.confの変更を出す。

--- rkhunter.conf.orig	2011-04-02 21:37:04.000000000 +0900
+++ rkhunter.conf	2011-04-02 22:01:38.000000000 +0900
@@ -431,6 +431,7 @@
 # for each new file, and rkhunter will report this.
 #
 #EXISTWHITELIST=""
+EXISTWHITELIST="/usr/share/man/man5/.rhosts.5.gz"
 
 #
 # Whitelist various attributes of the specified files.
@@ -466,6 +467,10 @@
 #
 #SCRIPTWHITELIST="/sbin/ifup /sbin/ifdown"
 #SCRIPTWHITELIST="/usr/bin/groups"
+SCRIPTWHITELIST="/opt/local/bin/whatis"
+SCRIPTWHITELIST="/usr/bin/fuser"
+SCRIPTWHITELIST="/usr/bin/whatis"
+SCRIPTWHITELIST="/usr/bin/shasum"
 
 #
 # Allow the specified commands to have the immutable attribute set.
@@ -519,6 +524,7 @@
 #ALLOWHIDDENFILE="/usr/lib/hmaccalc/sha384hmac.hmac"
 #ALLOWHIDDENFILE="/usr/lib/hmaccalc/sha512hmac.hmac"
 #ALLOWHIDDENFILE="/usr/sbin/.sshd.hmac"
+ALLOWHIDDENFILE="/usr/share/man/man5/.rhosts.5.gz"
 
 #
 # Allow the specified processes to use deleted files. The
@@ -645,6 +651,7 @@
 # wildcard characters.
 #
 #STARTUP_PATHS="/etc/rc.d /etc/rc.local"
+STARTUP_PATHS="none"
 
 #
 # This setting tells rkhunter the pathname to the file containing the
@@ -819,6 +826,8 @@
 #
 #RTKT_DIR_WHITELIST=""
 #RTKT_FILE_WHITELIST=""
+RTKT_FILE_WHITELIST="/etc/sshd_config"
+RTKT_FILE_WHITELIST="/etc/ssh_host_key"
 
 #
 # The following option can be used to whitelist shared library files that would

以下は設定の説明

EXISTWHITELIST

EXISTWHITELIST="/usr/share/man/man5/.rhosts.5.gz"

ドットからあるファイルは隠しファイルで、rootkitが置いたんじゃないの?
って聞かれるんだけど、これはマニュアルとしてあるものだからOKですよ、指摘しないでいいですよ。ということ。

SCRIPTWHITELIST

SCRIPTWHITELIST="/opt/local/bin/whatis"
SCRIPTWHITELIST="/usr/bin/fuser"
SCRIPTWHITELIST="/usr/bin/whatis"
SCRIPTWHITELIST="/usr/bin/shasum"

これはバイナリファイルのはずだけど、スクリプトファイルだよ、大丈夫?
って聞かれるんだけど、これは正当なスクリプトだから、OKですよということです。

ALLOWHIDDENFILE

ALLOWHIDDENFILE="/usr/share/man/man5/.rhosts.5.gz"

これも隠しファイルの件なので、(ry

RTKT_FILE_WHITELIST

RTKT_FILE_WHITELIST="/etc/sshd_config"
RTKT_FILE_WHITELIST="/etc/ssh_host_key"

ここに書いておけば、これはTrojanが置いたファイルじゃないよっていうことになります。
これが Dica-Kitの誤検出だ!

fu7mu4ってホント馬鹿

というわけで、もう一度、ハッシュを登録して

sudo rkhunter --propupd

以降はこれだけ、やればいいわけですね!

sudo rkhunter --update
sudo rkhunter -c --skip-keypress