본문 바로가기
[웹해킹]/[LOS]

[LOS] GOBLIN

by Hevton 2020. 12. 11.
반응형
<?php 
  include "./config.php"; 
  login_chk(); 
  $db = 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 = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if($result['id']) echo "<h2>Hello {$result[id]}</h2>"; 
  if($result['id'] == 'admin') solve("goblin");
  highlight_file(__FILE__); 
?>

 

1. and 연산과 no 연산이 있을 때, 위치에 상관없이 and 연산이 우선 처리되고 no 연산이 늦게 처리되는 점을 이용한다.

(만약 no를 먼저 처리시키고 싶으면 연산할 구간을 괄호로 감싼다)

 

2. 싱글쿼터가 필터링중이므로 'admin'의 16진수값인 0x61646D696E를 이용해준다.

 

 

 

query : select id from prob_goblin where id='guest' and no=2 or id=0x61646D696E

 

이렇게 되면 id='guest' and no=2 인 없는 경우가 생기고, or id=0x61646D696E 가 되어 admin으로 로그인된다.

 

 

 

반응형

'[웹해킹] > [LOS]' 카테고리의 다른 글

[LOS] DARKELF  (0) 2020.12.13
[LOS] WOLFMAN  (0) 2020.12.12
[LOS] ORC  (0) 2020.12.11
[LOS] COBOLT  (0) 2020.12.10
[LOS] GREMLIN  (0) 2020.12.09