Jul 03, 2008
[Misc] ratproxy にチャレンジ
ratproxy とは
ratproxy は Google がオープンソースで公開した Web アプリケーションの脆弱性をチェックする HTTP proxy。
A semi-automated, largely passive web application security audit tool, optimized for an accurate and sensitive detection, and automatic annotation, of potential problems and security-relevant design patterns based on the observation of existing, user-initiated traffic in complex web 2.0 environments.Mac OS X でも動くということなので試してみた。
- ratproxy
- http://code.google.com/p/ratproxy/
ratproxy のインストール
Mac OS X 10.4 (Tiger) と 10.5 (Leopard) で試してみた。
というわけで、早速怒られた(といっても単なる警告だけれど)。 flare-dist/README を読めということなのでとりあえず見てみることに。$ tar zxvf ./ratproxy-1.51.tar.gz $ cd ./ratproxy $ make 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. $
ratproxy に同梱されている flare という SWF の逆コンパイラが Mac OS X 用ではないということらしい。 有り難いことに別途 Mac OS X 用のバイナリが用意されているらしいので、いそいそとダウンロード。 同梱の flare を Mac OS X 用のバイナリで上書きして、make をやり直してみる。$ vi ./flare-dist/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: http://www.nowrap.de/download/flare06mac.tgz
今度は警告も無くコンパイルが完了した。 とりあえず動かしてみたところ何事もなく動作した模様。$ cd .. $ tar zxvf ./flare06mac.tgz $ cp ./flare06mac/* ./ratproxy/flare-dist/ $ cd ./ratproxy $ make cc ratproxy.c -o ratproxy -Wall -O3 -Wno-pointer-sign -D_GNU_SOURCE http.c mime.c ssl.c -lcrypto -lssl $ chmod 755 ./ratproxy $ ./ratproxy ratproxy version 1.51-beta by[!] WARNING: Running with no command-line config options specified. This is almost certainly not what you want, as most checks are disabled. Please consult the documentation or use --help for more information. [*] Proxy configured successfully. Have fun, and please do not be evil. [+] Accepting connections on port 8080/tcp (local only)... ^C $
ratproxy で脆弱性をチェックしてみる
ratproxy が動くようになったところで、早速脆弱性をチェックしてみる。 まずは Web ブラウザの proxy 設定で localhost:8080 を proxy として登録する。 後は普通にチェックしたいサービスにアクセスするだけ。 すると下記の様なログが出力される。
というわけで、少し遊んだだけで中々興味深い結果を得ることができた。 真面目に使えばそれなりの効果を得られそうだ。$ ./ratproxy -lxtiscgjmXC ratproxy version 1.51-beta by[!] 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. WARNING: Disruptive tests enabled. use with care. [+] Accepting connections on port 8080/tcp (local only)... 1|3|Risky Javascript code|innerHTML|200|31742|text/html|application/xhtml+xml|UTF-8|-|GET| http://example.com:80/someservice/hoge|-|-|\r\n<?xml version= 1|1|Bad or no charset declared for renderable file|-|200|124136|application/x-javascript|a pplication/x-javascript|-|-|GET|http://example.com:80/someservice/script/prototype.js|-|-| 1|1|Markup in dynamic Javascript|-|200|124136|application/x-javascript|application/x-javas cript|-|-|GET|http://example.com:80/someservice/script/prototype.js|-|-| 1|1|Risky Javascript code|document.write|200|124136|application/x-javascript|application/x -javascript|-|-|GET|http://example.com:80/someservice/common/js/prototype.js|-|-| 3|3|Inline PNG image|-|200|21640|image/png|image/png|-|-|GET|http://example.com:80/someser vice/dummy.png|-|-|PNG\r\n\x1a\n 0|1|HTTP errors|-|404|209|text/html|text/html|iso-8859-1|-|GET|http://demo.beat.co.jp:80/f avicon.ico|-|-|<!DOCTYPE HTML PUBLIC " 1|1|Bad or no charset declared for renderable file|-|200|1010|text/javascript|text/javascr ipt|-|-|GET|http://example.com:80/someservice/scruot/selectbox.js|-|-|var 0|3|Dynamic Javascript for direct inclusion|-|200|844|text/javascript|text/javascript|UTF- 8|-|GET|http://example.com:80/someservice/script/baselistdisplay.js|-|-|\r\nvar 0|7|GET query with no XSRF protection|-|200|11074|text/javascript|text/javascript|utf-8|-| GET|http://www.google.com:80/uds/api? 1|7|File name in query parameters|uds.js|200|11074|text/javascript|text/javascript|utf-8|- |GET|http://www.google.com:80/uds/api?file=uds.js 1|7|XSS candidates (script)|key|200|11074|text/javascript|text/javascript|utf-8|-|GET|http: //www.google.com:80/uds/api?file=uds.js 2|3|MIME type set to text/plain|-|200|8847|text/plain|application/x-javascript|UTF-8|-|GET| http://example.com:80/someservice/dosomething|-|-|[{" 2|3|MIME type mismatch on renderable file|-|200|8847|text/plain|application/x-javascript|UT F-8|-|GET|http://example.com:80/someservice/dosomething|-|-|[{"