웹해킹/sql injection

SQL Injection 필터링 우회 방법 - 대표 함수편

정보보호학과 새내기 2021. 7. 8. 17:04
반응형
SMALL
<?php
	$_GET[id] = str_replace("admin","",$_GET[id]);
	if(preg_match('/substr\(/i', $_GET[pw]))
	if(preg_match('/ascii\(/i', $_GET[pw]))
?>

위와 같이 특정 함수들을 필터링하거나 또는 어떤 함수를 통해 필터링되는 것을 우회하는 방법

 

첫 번째 - str_replace(string $search, string $replace, string $subject)

(이 함수는 특정 문자열을 아예 다른 문자열로 바꿔버리는 함수로 필터링 함수와 같이 사용된다.)

1) 필터링 되는 문자열 사이에 문자열을 넣는다.

- ex) str_replace("admin","",$_GET[id]) --> aadmindmin 으로 입력하면 가운데 admin이 사라지면서 다시 admin이 남는것을 확인할 수 있다. 이 원리를 이용한다.

 

두 번째 - substr(string $str, int $start, int $length)

(substr 함수는 비밀번호를 찾을 때나 아이디 값을 찾을 때 자주 사용되는 함수이다.)

1) substring(string $str, int $start, int $length)

2) mid(string $str, int $start, int $length)

 

세 번째 - ascii(string $str)

1) ord(string $str): ascii와 똑같은 기능을 하는 함수

2) hex(string $str): 문자열을 아스키코드 hex값으로 변환해준다.

 

반응형
LIST