ratproxyをインストールする on MacOS X
ratproxyをインストールする on MacOS X
0.改訂履歴
1.はじめに
このド
キュメントでは,Googleが公開した,クロスサイトスクリプティング(XSRF:Cross Site Request
Forgery)等,Webアプリケーションの脆弱性を検査するツールであるratproxyを,インストールして利用する手順を説明する.
このアプリケーションは,Googleが社内でWebアプリケーション試験用として使っていた物らしく,プロキシサーバとして動作する為,ブラウザに依存せずテストすることができる.
なお,インストールしたプラットフォームはMacOS X 10.5.4が稼働するPowerPC
G5システムであるが,デフォルトではLinuxに対応しているモジュールに,Action
ScriptのデコンパイラであるFlareをMacで動作するものに入れ替えて導入するため,その他の手順は同じ要領だと思われる.
2.モジュールの入手
- 以下のURLから入手する.
- 入手したモジュールを確認する.
iMac-G5:Downloads ujpadmin$ ls -lah ratproxy-1.51.tar.gz -rw-r--r--@ 1 ujpadmin staff 164K 7 7 12:46 ratproxy-1.51.tar.gz
iMac-G5:Downloads ujpadmin$
|
3.インストール
iMac-G5:Downloads ujpadmin$ tar xfz ratproxy-1.51.tar.gz iMac-G5:Downloads ujpadmin$
|
iMac-G5:Downloads ujpadmin$ cd ratproxy iMac-G5:ratproxy ujpadmin$ ls -la
total 544
drwxr-x---@ 23 ujpadmin staff 782 7 3 15:28 .
drwx------ 20 ujpadmin staff 680 7 7 12:51 ..
-rw-r-----@ 1 ujpadmin staff 1331 6 10 20:44 Makefile
lrwxr-xr-x 1 ujpadmin staff 10 7 7 12:51 README -> doc/README
-rw-r-----@ 1 ujpadmin staff 7144 7 3 15:27 config.h
-rw-r-----@ 1 ujpadmin staff 1209 6 9 04:11 debug.h
drwxr-x---@ 6 ujpadmin staff 204 7 3 15:28 doc
lrwxr-xr-x 1 ujpadmin staff 16 7 7 12:51 flare -> flare-dist/flare
drwxr-x---@ 5 ujpadmin staff 170 7 3 15:28 flare-dist
-rw-r-----@ 1 ujpadmin staff 35092 6 10 21:28 http.c
-rw-r-----@ 1 ujpadmin staff 3827 6 9 07:16 http.h
-rw-r-----@ 1 ujpadmin staff 1803 6 10 06:28 keyfile.pem
-rw-r-----@ 1 ujpadmin staff 10034 7 3 15:22 messages.list
-rw-r-----@ 1 ujpadmin staff 13411 6 10 21:23 mime.c
-rw-r-----@ 1 ujpadmin staff 941 6 9 07:31 mime.h
-rw-r-----@ 1 ujpadmin staff 6696 6 9 23:35 nlist.h
-rw-r-----@ 1 ujpadmin staff 74680 6 9 02:25 ratproxy-back.png
-rwxr-x---@ 1 ujpadmin staff 12976 6 10 06:16 ratproxy-report.sh
-rw-r-----@ 1 ujpadmin staff 52112 7 3 15:27 ratproxy.c
-rw-r-----@ 1 ujpadmin staff 5917 6 9 08:07 ssl.c
-rw-r-----@ 1 ujpadmin staff 930 6 10 01:04 ssl.h
-rw-r-----@ 1 ujpadmin staff 2924 6 10 20:38 string-inl.h
-rw-r-----@ 1 ujpadmin staff 1254 6 9 08:07 types.h
iMac-G5:ratproxy ujpadmin$
|
- configureタイプではなく,普通のMakefileだけのようである.
- Makefileの中身を確認すると.allをつけるようである.
- makeを行う.
iMac-G5:ratproxy ujpadmin$ make all
cc ratproxy.c -o ratproxy -Wall -O3 -Wno-pointer-sign -D_GNU_SOURCE http.c mime.
c ssl.c -lcrypto -lssl
*** WARNING: flare-dist/flare bianry is not operational. *** Please see flare-dist/README and update it for your OS.
iMac-G5:ratproxy ujpadmin$
|
- 警告が出ていて,flare-dist/READMEフォイルの確認が必要との事.
4.flareのインストール
iMac-G5:ratproxy ujpadmin$ cd flare-dist
iMac-G5:flare-dist ujpadmin$ ls -la total 128 drwxr-x---@ 5 ujpadmin staff 170 7 3 15:28 . drwxr-x---@ 30 ujpadmin staff 1020 7 7 15:47 .. -rw-r-----@ 1 ujpadmin staff 1767 6 9 20:52 LICENSE.TXT -rw-r-----@ 1 ujpadmin staff 724 6 9 20:53 README
-rwxr-x---@ 1 ujpadmin staff 56229 10 25 2005 flare
iMac-G5:flare-dist ujpadmin$ cat README This is a Linux binary of Flare ActionScript decompiler. If instructed to do so, ratproxy will invoke this tool to decompile SWF files on the fly.
If you intend to run ratroxy on a different operating system, you may need use the following binaries instead:
MacOS X: http://www.nowrap.de/download/flare06mac.tgz
Windows: http://www.nowrap.de/download/flare06doswin.zip
Unfortunately, there are no versions of Flare for *BSD or the like (but
binary emulation of Linux or Windows may come to the rescue). If Flare
is not found, ratproxy will simply not perform Flash analysis.
Note that this is a closed source application; please exercise common
sense, and do not use it on potentially malicious, external content.
iMac-G5:flare-dist ujpadmin$
|
- ratproxyをどうささせる為には,FlareというFlashのデコンパイラが必要との事.
- デコンパイラとは逆コンパイルの事で,一般的にはバイナリからソースコードを取り出す様な行為となるが,このFlareではAction Scriptを取り出すようである.
- このバイナリは,Linux用との事なので,今回ターゲットとなるMac用を取得する.
- READMEにあるとおりに,Mac版を取得する.
iMac-G5:flare-dist ujpadmin$ curl -O http://www.nowrap.de/download/flare06mac.tgz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 34608 100 34608 0 0 18304 0 0:00:01 0:00:01 --:--:-- 27034
iMac-G5:flare-dist ujpadmin$
|
iMac-G5:flare-dist ujpadmin$ ls -la total 200 drwxr-x---@ 6 ujpadmin staff 204 7 7 15:51 . drwxr-x---@ 30 ujpadmin staff 1020 7 7 15:47 .. -rw-r-----@ 1 ujpadmin staff 1767 6 9 20:52 LICENSE.TXT -rw-r-----@ 1 ujpadmin staff 724 6 9 20:53 README -rwxr-x---@ 1 ujpadmin staff 56229 10 25 2005 flare -rw-r--r-- 1 ujpadmin staff 34608 7 7 15:51 flare06mac.tgz
iMac-G5:flare-dist ujpadmin$
|
- 元から入っているLinux版をリネームして取っておく.
iMac-G5:flare-dist ujpadmin$ mv flare flare.linux
iMac-G5:flare-dist ujpadmin$ ls -la
total 200
drwxr-x---@ 6 ujpadmin staff 204 7 7 15:51 .
drwxr-x---@ 30 ujpadmin staff 1020 7 7 15:47 ..
-rw-r-----@ 1 ujpadmin staff 1767 6 9 20:52 LICENSE.TXT
-rw-r-----@ 1 ujpadmin staff 724 6 9 20:53 README
-rwxr-x---@ 1 ujpadmin staff 56229 10 25 2005 flare.linux
-rw-r--r-- 1 ujpadmin staff 34608 7 7 15:51 flare06mac.tgz
iMac-G5:flare-dist ujpadmin$
|
iMac-G5:ratproxy ujpadmin$ tar xfz flare06mac.tgz iMac-G5:ratproxy ujpadmin$
|
iMac-G5:flare-dist ujpadmin$ ls -la
total 368
drwxr-x---@ 10 ujpadmin staff 340 7 7 15:55 .
drwxr-x---@ 30 ujpadmin staff 1020 7 7 15:47 ..
-rw-r----- 1 ujpadmin staff 1751 10 25 2005 LICENSE.TXT
-rw-r-----@ 1 ujpadmin staff 724 6 9 20:53 README
-rw-r----- 1 ujpadmin staff 856 10 25 2005 classic.css -rwxr-xr-x 1 ujpadmin staff 64168 10 25 2005 flare -rw-r----- 1 ujpadmin staff 12233 10 25 2005 flare.html -rwxr-x---@ 1 ujpadmin staff 56229 10 25 2005 flare.linux -rw-r--r-- 1 ujpadmin staff 34608 7 7 15:51 flare06mac.tgz -rw-r----- 1 ujpadmin staff 282 10 15 2004 logo.gif iMac-G5:flare-dist ujpadmin$
|
iMac-G5:flare-dist ujpadmin$ cd ..
iMac-G5:ratproxy ujpadmin$ make clean
rm -f ratproxy *.exe *.o *~ a.out core core.[1-9][0-9]* *.stackdump
iMac-G5:ratproxy ujpadmin$ make all
cc ratproxy.c -o ratproxy -Wall -O3 -Wno-pointer-sign -D_GNU_SOURCE http.c mime.
c ssl.c -lcrypto -lssl
iMac-G5:ratproxy ujpadmin$
|
- 問題無く終了した模様.
- 作成されたファイルを確認する.
iMac-G5:ratproxy ujpadmin$ ls -lat|head -n 10 total 1024 drwxr-x---@ 30 ujpadmin staff 1020 7 7 15:58 . -rwxr-xr-x 1 ujpadmin staff 112644 7 7 15:58 ratproxy
drwxr-x---@ 10 ujpadmin staff 340 7 7 15:55 flare-dist
-rw-r-----@ 1 ujpadmin staff 6148 7 7 15:20 .DS_Store
-rw-r--r-- 1 ujpadmin staff 34608 7 7 12:58 flare06mac.tgz
lrwxr-xr-x 1 ujpadmin staff 10 7 7 12:51 README -> doc/README
drwx------ 20 ujpadmin staff 680 7 7 12:51 ..
drwxr-x---@ 6 ujpadmin staff 204 7 3 15:28 doc
-rw-r-----@ 1 ujpadmin staff 7144 7 3 15:27 config.h
iMac-G5:ratproxy ujpadmin$
|
5.ratproxyを実行する
iMac-G5:ratproxy ujpadmin$ ./ratproxy -h ratproxy version 1.51-beta by <lcamtuf@google.com> ./ratproxy: illegal option -- h Usage: ./ratproxy [ -w logfile ] [ -v logdir ] [ -p port ] [ -d domain ] [ -P host:port ] [ -xtifkgmjscael2XCr ] -w logfile - write results to a specified file (default: stdout)
-v logdir - write HTTP traces to a specified directory (default: none)
-p port - listen on a custom TCP port (default: 8080) -d domain - analyze requests to specified domains only (default: all)
-P host:port - use upstream proxy for all requests (format host:port)
-r - accept remote connections (default: 127.0.0.1 only)
-l - use response length, not checksum, for identity check
-2 - perform two, not one, page identity check
-e - perform pedantic caching headers checks
-x - log all XSS candidates
-t - log all directory traversal candidates
-i - log all PNG files served inline
-f - log all Flash applications for analysis (add -v to decompile)
-s - log all POST requests for analysis
-c - log all cookie setting URLs for analysis
-g - perform XSRF token checks on all GET requests
-j - report on risky Javascript constructions
-m - log all active content referenced across domains
-X - disruptively validate XSRF, XSS protections
-C - try to auto-correct persistent side effects of -X
-k - flag HTTP requests as bad (for HTTPS-only applications)
-a - indiscriminately report all visited URLs
Example settings suitable for most tests:
1) Low verbosity : -v <outdir> -w <outfile> -d <domain> -lfscm
2) High verbosity : -v <outdir> -w <outfile> -d <domain> -lextifscgjm
3) Active testing : -v <outdir> -w <outfile> -d <domain> -XClfscm
Multiple -d options are allowed. Consult the documentation for more.
iMac-G5:ratproxy ujpadmin$
|
- パラメータによってログファイルやポート番号,検証するドメイン名を指定することができる.
- 分析したログファイルを保存するオプションだけ設定して,実行してみる.
iMac-G5:ratproxy ujpadmin$ ./ratproxy -w /tmp/result.log ratproxy version 1.51-beta by <lcamtuf@google.com>
[!] WARNING: Running with no 'friendly' domains specified. Many cross-domain checks will not work. Please consult the documentation for advice.
[*] Proxy configured successfully. Have fun, and please do not be evil. [+] Accepting connections on port 8080/tcp (local only)...
|
- リッスン状態で起動している事が確認できる.
- FireFox3.0で,プロキシの設定を行う.
- ratproxyを起動した際に,ポートは指定してないので,デフォルトの8080ポートを設定する.
- これで終了.
- 適当なサイトにアクセスしてみる.
- アクセスした後に,ログファイルを確認する.
iMac-G5:tmp ujpadmin$ tail -f result.log
2|7|Cookie issuer with no XSRF protection|-|200|27070|text/html|text/html|UTF-8| -|GET|http://www.google.co.jp:80/search?q=Marc+Chagall|SS=Q0=TWFyYyBDaGFnYWxs|-| <html><head><meta http-equiv=content-type content=" ;text/html; charset=UTF-8"><title>Marc Chagall - Google  6;¤œç´¢</title><style>div,td,.n a,. n a:visited{color:#000}.ts td,.tc{padding:0}.ts,.tb{border-collapse:collapse}.ti, .bl{display:inline}.ti{display:inline-table}.f{color:#666}.flc,a.fl{color:#77c}a, .w,.q:visited,.q:active,.q,.b a,.b a:visited,.mblink:visited{color:#00c}a: visited{color:#551a8b}a:active{color:red}.t{background:#d5ddf3;color:#000; padding:5px 1px 4px}.bb{border-bottom:1px solid #36c}.bt{border-top:1px solid #3 6c}.j{width:34em}.h{color:#36c}.i{color:#a90a08}.a{color:green}.z{display:none} div.n{margin-top:1ex}.n a,.n .i{font-size:10pt}.n .i,.b a{font-weight:bold}.b a{ font-size:12pt}.std{font-size:82%}#np,#nn,.nr,#logo span,.ch{cursor:pointer; cursor:hand}.ta{padding:3px 3px 3px 5px}#tpa2,#tpa3{padding-top:9px}
|
1|1|Bad or no charset declared for renderable file|-|200|13774|tex
|
0|1|HTTP errors|-|404|205|text/html|text/html|iso-8859-1|-|GET|http://www.
|
6.レポートを作成する
- ratproxyで取得したログを利用して,HTML形式でレポートを作成することができる.
- まずは,レポート用ツールを確認する.
iMac-G5:ratproxy ujpadmin$ ls -la
total 1024
drwxr-x---@ 30 ujpadmin staff 1020 7 7 15:58 .
drwx------ 20 ujpadmin staff 680 7 7 12:51 ..
-rw-r-----@ 1 ujpadmin staff 6148 7 7 15:20 .DS_Store
-rw-r----- 1 ujpadmin staff 1751 10 25 2005 LICENSE.TXT
-rw-r-----@ 1 ujpadmin staff 1331 6 10 20:44 Makefile
lrwxr-xr-x 1 ujpadmin staff 10 7 7 12:51 README -> doc/README
-rw-r----- 1 ujpadmin staff 856 10 25 2005 classic.css
-rw-r-----@ 1 ujpadmin staff 7144 7 3 15:27 config.h
-rw-r-----@ 1 ujpadmin staff 1209 6 9 04:11 debug.h
drwxr-x---@ 6 ujpadmin staff 204 7 3 15:28 doc
-rwxr-xr-x 1 ujpadmin staff 64168 10 25 2005 flare
drwxr-x---@ 10 ujpadmin staff 340 7 7 15:55 flare-dist
-rw-r----- 1 ujpadmin staff 12233 10 25 2005 flare.html
-rw-r--r-- 1 ujpadmin staff 34608 7 7 12:58 flare06mac.tgz
-rw-r-----@ 1 ujpadmin staff 35092 6 10 21:28 http.c
-rw-r-----@ 1 ujpadmin staff 3827 6 9 07:16 http.h
-rw-r-----@ 1 ujpadmin staff 1803 6 10 06:28 keyfile.pem
-rw-r----- 1 ujpadmin staff 282 10 15 2004 logo.gif
-rw-r-----@ 1 ujpadmin staff 10034 7 3 15:22 messages.list
-rw-r-----@ 1 ujpadmin staff 13411 6 10 21:23 mime.c
-rw-r-----@ 1 ujpadmin staff 941 6 9 07:31 mime.h
-rw-r-----@ 1 ujpadmin staff 6696 6 9 23:35 nlist.h
-rwxr-xr-x 1 ujpadmin staff 112644 7 7 15:58 ratproxy
-rw-r-----@ 1 ujpadmin staff 74680 6 9 02:25 ratproxy-back.png
-rwxr-x---@ 1 ujpadmin staff 12976 6 10 06:16 ratproxy-report.sh
-rw-r-----@ 1 ujpadmin staff 52112 7 3 15:27 ratproxy.c
-rw-r-----@ 1 ujpadmin staff 5917 6 9 08:07 ssl.c
-rw-r-----@ 1 ujpadmin staff 930 6 10 01:04 ssl.h
-rw-r-----@ 1 ujpadmin staff 2924 6 10 20:38 string-inl.h
-rw-r-----@ 1 ujpadmin staff 1254 6 9 08:07 types.h
iMac-G5:ratproxy ujpadmin$
|
- レポートの作成を実行する.
- ratproxy-report.shコマンドに,ログファイル名を指定して,書き出すHTMLファイルを指定する.
iMac-G5:ratproxy ujpadmin$ ./ratproxy-report.sh /tmp/result.log > /tmp/report.html
iMac-G5:ratproxy ujpadmin$
|
- 無くても困らないが,ロゴ用の画像を,レポートを作成したディレクトリにコピーしておくと,見栄えが良い.
iMac-G5:ratproxy ujpadmin$ cp ratproxy-back.png /tmp/.
iMac-G5:ratproxy ujpadmin$
|
- 作成されたHTMLのレポートを,ブラウザで開いて確認すると,次の様な画面が表示される.
- toggleをクリックする事で,階層表示を開いたり閉じたりすることができる.
- Googleにアクセスしただけでも,セキュリティホールに限らず,いろいろと見つかります...