들어가기 전에
$_GET을 이용한 파라미터 전달 방법에 대한 글을 보고 오자.
Lord of SQL injection – gremlin
Level 01
Source Code
<?php include "../config.php"; login_chk(); dbconnect(); if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~"); // do not try to attack another table, database! if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); $query = "select id from prob_gremlin where id='{$_GET[id]}' and pw='{$_GET[pw]}'"; echo "<hr>query : <strong>{$query}</strong><hr><br>"; $result = @mysql_fetch_array(mysql_query($query)); if($result['id']) solve("gremlin"); highlight_file(__FILE__); ?>
Analyse
http://los.sandbox.cash/~~.php?id=abc&pw=123
이라고 입력하게 되면
select id from prob_gremlin where id='abc' and pw='123'
와 같이 MySQL 쿼리문이 입력된다.
그리고 133번째 줄을 보면 &result['id']
에 값이 들어있으면 gremlin문제를 풀리게 된다.
Frist Hint is next page