[LOS] SQL Injection 풀이 (giant)- 14

 

소스 코드

<?php 
  include "./config.php"; 
  login_chk(); 
  $db = 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 = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if($result[1234]) solve("giant"); 
  highlight_file(__FILE__); 
?>

필터링 된 문자

n

r

t

공백

shit을 get 방식으로 오는데 값이 1을 넘기면 필터링을 당하게 된다.

문제 접근

 

여기서 주된 풀이 관점은 '공백을 어떻게 넣어서 구분하냐' 이다.

SQL 문을 보게 되면 from 과 sql 데이터명이 분리가 되지 않아 값이 나오지 않게 된다.

그렇기 때문에 공백만 주게 된다면 문제는 쉽게 풀릴 것이다.

 

Solution

필터링 우회
공백 /**/, %0a, %0b, %0c, %0d, +, %20, %2b

그 중 필터링을 피한 우회 

Vertical Tab (%0b)

Form Feed (%0c)

 

저번에 정리해놓은 내용의 값을 집어넣으면 필터링이 거의 대부분되지만 안되는 것도 존재한다.

https://tyrell96.tistory.com/35

 

SQL Injection bypass(우회) 방법 정리

그간 Lord of SQLInjection 을 풀면서 사용했던 우회 기법들을 정리하고자 한다.  필터링 우회 공백 /**/, %0a, %0b, %0c, %0d, +, %20, %2b = Like, <, >, In, instr(string $str, string $substr) or || (%7..

tyrell96.tistory.com

 

+ Recent posts