The Will Will Web

記載著 Will 在網路世界的學習心得與技術分享

Google 推出 Open Source 的安全工具:RatProxy

最近 Google 推出一套免費的 Web 安全評估工具,叫做 ratproxy,這套工具可以檢測、分析您的網站是否有安全性漏洞或網頁是否有被入侵,目前可支援 Linux, FreeBSD, MacOS X, 與 Windows (Cygwin) 等執行環境(反正就是 Unix-like 的環境啦)。

RatProxy 可偵測到的漏洞包括 Cross-site Scripting (XSS, 跨網站指令碼)、指令碼惡意置入(script inclusion issues), 惡意網頁內容(content serving problems), insufficient XSRF 以及 XSS 防護(XSS defenses) 等。

若要在 Ubuntu 的環境下執行的話,必須要先安裝以下套件才能將 ratproxy 編譯成功:

apt-get install make gcc build-essential libssl-dev ca-certificates

下載、解壓縮、編譯:

wget http://ratproxy.googlecode.com/files/ratproxy-1.51.tar.gz
tar zxf ratproxy-1.51.tar.gz
cd ratproxy
make

編譯成功以後,就可以使用了,功能挺多的:

# ./ratproxy -h
ratproxy version 1.51-beta by <lcamtuf@google.com>
./ratproxy: invalid 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

由於 ratproxy 是屬「半自動」且「被動式」的偵測方法,使用 Proxy 的方式運作,並非主動連接到特定網站抓取所有網頁回來分析,所以啟動完該程式之後,會以 Proxy Server 的形式執行,你必須修改你瀏覽器的 Proxy 設定,將 Proxy 伺服器指定到 ratproxy 的 IP 與 Port(預設 ratproxy 啟動的 Port 埠號是 8080),才能讓 ratproxy 取得偵測的資訊,如下圖示:

修改你瀏覽器的 Proxy 設定,將 Proxy 伺服器指定到 ratproxy 的 IP 與 Port(預設 ratproxy 啟動的 Port 埠號是 8080)

若要啟動 ratproxy 伺服器,一段簡單的啟用指令如下:

./ratproxy -v /tmp/ratproxy -w ratproxy.log -d blog.miniasp.com -lextifscgjm -r

這代表你要將 ratproxy 服務啟動,預設監聽 Port 8080,並將偵測到的 Log 儲存在 /tmp/ratproxy/ratproxy.log 中,並且只分析連線到 blog.miniasp.com 網址的資料,並且將所有取得的網頁儲存成使用 -r 代表這個服務可以讓遠端主機使用(預設只會監聽 127.0.0.1 而已),如果你沒加上 -r 就無法用其他台機器連線。至於 lextifscgjm 這一串所代表的意義就請看 Help 說明吧。

最後,就是將取得的 ratproxy.log 產生報表網頁,並且查看你用 Browser 所逛過的網頁是否有潛在的安全風險或漏洞。你可以使用 ratproxy-report.sh 產生該網頁:

./ratproxy-report.sh ratproxy.log > report.html

產生的結果可以參考下圖:

ratproxy 分析結果報表預覽圖示

相關連結

留言評論