The Will Will Web

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

介紹幾款好用的 SQL Injection 偵測與防禦工具

微軟最近推出了兩套 SQL Injection 偵測與防禦工具,分別是 Microsoft Source Code Analyzer for SQL Injection (MSCASI) 與 URLScan 3.0

其中 Microsoft Source Code Analyzer for SQL Injection (MSCASI) 是專門用來分析早期 Active Server Pages (ASP) 程式中的 SQL Injection 漏洞,他會直接分析你的 ASP 原始碼並明確點出你的程式中潛在的 SQL Injection 漏洞在哪裡、潛在的風險、第幾行有問題等(如下圖)。如果你曾經寫過的 ASP 網站年久失修,建議你用這套工具執行看看是否有哪一段程式是有 SQL Injection 漏洞的。另外,微軟在前幾週也發表了一篇關於如何在 ASP 程式中防禦 SQL Injection 的建議( Preventing SQL Injections in ASP),而這套工具就是依據這篇文章中所寫的幾個規則進行 ASP 原始碼分析的。

Microsoft Source Code Analyzer for SQL Injection 執行畫面

由於 Microsoft Source Code Analyzer for SQL Injection 是指令列程式,你下載後只要解壓縮就能用了,用法很簡單,你只要執行 msscasi_asp.exe 就會出現使用說明了。

G:\asp>msscasi_asp.exe
Microsoft (R) Source Code Analyzer for SQL Injection Version 1.3.30601.30622
Copyright (C) Microsoft Corporation. All rights reserved.

Usage: msscasi_asp.exe [/nologo] [/quiet] [/suppress=num;..;num] [/GlobalAsaPath=
path] [/IncludePaths=path;..;path] /Input=file.asp

** msscasi_asp failure: no input file specified.

一次只能掃瞄一個檔案,底下是一個範例的用法:

msscasi_asp.exe /nologo /Input="c:\web1\test.asp"

你如果要掃瞄整個網站的 asp 程式你可以寫個批次檔來處理。

另一套軟體 URLScan 3.0 有別於已經推出五年之久的 UrlScan 2.5 版,功能多出了許多,他比較能夠主動偵測 SQL Injection 的攻擊,且目前也完整支援 IIS 7.0,不過未來這些掃瞄功能應該會直接整合進 IIS 7.0 中。

URLScan 3.0 版新增的功能有:

  • Support for query string scanning, including an option to scan an unescaped version of the query string.
  • Change notification for configuration (no more restarts for most settings.)
  • UrlScan can be installed as a site filter.  Different sites can have their own copy, with their own configuration.
  • Escape sequences can be used in the configuration file to express CRLF, a semicolon (normally a comment delimiter) or unprintable characters in rules.
  • Custom rules can be created to scan the URL, query string, a particular header, all headers or combination of these.  The rules can be applied based on the type of file requested.
  • Support for 64 bit IIS worker processes.

另外還有一套由 HP Web Security Research Group 發展出來的一個 SQL injection 偵測工具,叫做 Scrawlr 1.0,我覺得還挺酷的,用一個比較視覺化的方式偵測你的網站是否包含 SQL Injection 漏洞,只要輸入要檢測的網址,再按下 Start 按鈕就會開始跑了,非常的直覺、好用。如果你的網站被他抓到有漏洞的話,他還可以猜出你的資料庫名稱與相關資訊。

Scrawlr 1.0

相關連結

留言評論