Lord of SQL injection – assassin
Level 15
Source Code
<?php include "../config.php"; login_chk(); dbconnect(); if(preg_match('/\'/i', $_GET[pw])) exit("No Hack ~_~"); $query = "select id from prob_assassin where pw like '{$_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>"; if($result['id'] == 'admin') solve("assassin"); highlight_file(__FILE__); ?>
Analyse
http://los.sandbox.cash/assassin-~~.php?pw=123
이라고 입력하게 되면
select 1234 from prob_assassin where pw like '123'
과 같이 MySQL 쿼리문이 입력된다.
9번째 줄에서 pw가 일치하는 id를 출력한다.
그리고 10번째 줄을 보면 &result['id']
가 admin이면 assassin문제가 풀린다.
즉, 쿼리문의 pw가 일치하는 id값을 가져온다.
Frist Hint is next page