query : {$query}

"; $result = @mysqli_fetch_array(mysqli_query($db,$query)); if($result['id']) solve("gremlin"); highlight_file(__FILE__); ?>"> query : {$query}

"; $result = @mysqli_fetch_array(mysqli_query($db,$query)); if($result['id']) solve("gremlin"); highlight_file(__FILE__); ?>"> query : {$query}

"; $result = @mysqli_fetch_array(mysqli_query($db,$query)); if($result['id']) solve("gremlin"); highlight_file(__FILE__); ?>">
<?php
  include "./config.php";
  login_chk();
  $db = dbconnect();
  if(preg_match('/prob|_|\\.|\\(\\)/i', $_GET[id])) exit("No Hack ~_~"); // do not try to attack another table, database!
  if(preg_match('/prob|_|\\.|\\(\\)/i', $_GET[pw])) exit("No Hack ~_~");
  $query = "select id from prob_gremlin 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("gremlin");
  highlight_file(__FILE__);
?>

$_GET[] 을 통해 불러온 id와 pw값이 쿼리문에 그대로 들어가고 있습니다.

?id=1&pw=' or '1'='1 을 전송하면

select id from prob_gremlin where id='1' and pw='' or '1'='1' 가 실행됩니다.

pw 를 몰라도 ‘1’=’1’ 는 참이므로 pw 부분은 true 입니다.

Screenshot 2024-06-03 at 12.58.56 AM.png