Lord of SQL injection – skeleton
Level 10
Source Code
<?php include "../config.php"; login_chk(); dbconnect(); if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); $query = "select id from prob_skeleton where id='guest' and pw='{$_GET[pw]}' and 1=0"; echo "<hr>query : <strong>{$query}</strong><hr><br>"; $result = @mysql_fetch_array(mysql_query($query)); if($result['id'] == 'admin') solve("skeleton"); highlight_file(__FILE__); ?>
Analyse
http://los.sandbox.cash/skeleton-~~.php?pw=123
이라고 입력하게 되면
select id from prob_skeleton where id='guest' and pw='123' and 1=0
과 같이 MySQL 쿼리문이 입력된다.
쿼리문을 보면 알 수 있다 싶이 뒷부분에 “1=0″이 붙어 있어 이 쿼리는 항상 거짓이 된다.
그리고 입력된 id는 guset인데 &result['id']
에 admin이 들어가야만 skeleton문제가 풀린다.
Frist Hint is next page