[Level 16]Lord of SQL injection – zombie_assassin

Lord of SQL injection – zombie_assassin

Level 16


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(@ereg("'",$_GET[id])) exit("HeHe"); 
  if(@ereg("'",$_GET[pw])) exit("HeHe"); 
  $query = "select id from prob_zombie_assassin 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("zombie_assassin"); 
  highlight_file(__FILE__); 
?>

Analyse

http://los.sandbox.cash/zombie_assassin-~~.php?id=user&pw=123 이라고 입력하게 되면
select id from prob_zombie_assassin where id='user' and pw='123'과 같이 MySQL 쿼리문이 입력된다.
7번째 줄에서 ereg함수로 id와 pw의 입력에서 싱글 쿼터(‘)를 필터링 하고 있다.
그리고 11번째 줄을 보면 &result['id']가 설정 되어있으면 zombie_assassin문제가 풀린다.

Frist Hint is next page

카테고리LOS

글의 문제가 있다면 댓글을 달아 주세요.

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.