Lord of SQL injection – wolfman
Level 05
Source Code
<?php include "../config.php"; login_chk(); dbconnect(); if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); if(preg_match('/ /i', $_GET[pw])) exit("No whitespace ~_~"); $query = "select id from prob_wolfman 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>"; if($result['id'] == 'admin') solve("wolfman"); highlight_file(__FILE__); ?>
Analyse
http://los.sandbox.cash/wolfman-~~.php?pw=123
이라고 입력하게 되면
select id from prob_wolfman where id='guest' and pw='123'
과 같이 MySQL 쿼리문이 입력된다.
그리고 6번째 줄에서 whitespace를 필터링 하고 있다.
마지막으로 &result['id']
에 admin이 들어가야 wolfman 문제가 풀린다.
Frist Hint is next page