문제풀이/los.rubiya.kr

[LOS] 10번 skeleton 풀이

여 니 2019. 7. 31. 18:46
<?php 
  include "./config.php"; 
  login_chk(); 
  $db = 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 = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if($result['id'] == 'admin') solve("skeleton"); 
  highlight_file(__FILE__); 
?>

금지문자열은 prob _ . () 이다.

이 문제는 3번 goblin 문제와 같은 방법으로 풀 수 있다. 좀 더 응용한정도?

3번을 풀었던 것처럼 and와 or의 우선순위만 기억하자!

주어진 문제의 쿼리의 조건문(where)은

where 0 and [ ] and 0

과 같은 형식을 취하고 있다. 그러면 이 때 [ ]에 뭐가 들어가면 전체 값이 참(id:admin)이 될까?

 

바로

where 0 and [ 아무값 or 1 or 아무값 ] and 0

이런 형식으로 만들어주면 된다!

 

and가 or보다 우선순위가 높으므로 저러면 where 0 or 1 or 0이 되고, 최종적으로 우리가 원하는 내용을 얻을 수 있다.

따라서 parameter로 ' or id='admin' or '을 입력해주면 되겠다.