Lord of SQL injection – succubus
Level 17
Source Code
<?php include "../config.php"; login_chk(); dbconnect(); if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~"); if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); if(preg_match('/\'/i', $_GET[id])) exit("HeHe"); if(preg_match('/\'/i', $_GET[pw])) exit("HeHe"); $query = "select id from prob_succubus 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("succubus"); highlight_file(__FILE__); ?>
Analyse
http://los.sandbox.cash/succubus-~~.php?id=user&pw=123
이라고 입력하게 되면
select id from prob_succubus where id='user' and pw='123'
과 같이 MySQL 쿼리문이 입력된다.
이번엔 정규표현식을 통해 id와 pw의 입력에서 싱글 쿼터(‘)를 필터링 하고 있다.
그리고 11번째 줄을 보면 &result['id']
가 설정 되어있으면 succubus문제가 풀린다.
Frist Hint is next page