본문 바로가기
category/SQL INJECTION

blind sql injection - 1

by 자운대고라니 2020. 9. 1.
반응형

blind sql injection을 성공하기 위해서는

꼭 알아야 할 함수가 있다.

 

substr, ascii함수이다.

 

substr 문자열 중 원하는 만큼의 범위를 지정하여 문자열로 리턴해준다.

substr("apple", 1, 1) : a

substr("apple", 2, 1) : p

substr("apple", 1, 3) : app

 

ascii : 아스키코드값을 리턴해준다.

ascii(a) : 97

ascii(b) : 98

ascii(c) : 99

 

이 두 함수를 혼합하여 사용할 수 있다.

injection 하려는 변수 이름이 password라고 가정하고, password = "banana"라고 가정한다면

 

(ascii(substr(password, 1, 1)) = 97) = FALSE

(ascii(substr(password, 1, 1) = 98)) = TRUE -> 첫 번째 값은 b

(ascii(substr(password, 2, 1) = 97) = TRUE -> 두 번째 값은 a

(ascii(substr(password, 3, 1)) = 97) = FALSE

(ascii(substr(password, 3, 1)) = 98) = FALSE

(ascii(substr(password, 3, 1)) = 99) = FALSE

(ascii(substr(password, 3, 1)) = 100) = FALSE

(ascii(substr(password, 3, 1)) = 101) = FALSE

(ascii(substr(password, 3, 1)) = 102) = FALSE

(ascii(substr(password, 3, 1)) = 103) = FALSE

(ascii(substr(password, 3, 1)) = 104) = FALSE

(ascii(substr(password, 3, 1)) = 105) = FALSE

(ascii(substr(password, 3, 1)) = 106) = FALSE

(ascii(substr(password, 3, 1)) = 107) = FALSE

(ascii(substr(password, 3, 1)) = 108) = FALSE

(ascii(substr(password, 3, 1)) = 109) = FALSE

(ascii(substr(password, 3, 1) = 110)) = TRUE -> 세 번째 값은 n

(ascii(substr(password, 4, 1) = 97)) = TRUE -> 네 번째 값은 a

(ascii(substr(password, 5, 1)) = 97) = FALSE

(ascii(substr(password, 5, 1)) = 98) = FALSE

(ascii(substr(password, 5, 1)) = 99) = FALSE

(ascii(substr(password, 5, 1)) = 100) = FALSE

(ascii(substr(password, 5, 1)) = 101) = FALSE

(ascii(substr(password, 5, 1)) = 102) = FALSE

(ascii(substr(password, 5, 1)) = 103) = FALSE

(ascii(substr(password, 5, 1)) = 104) = FALSE

(ascii(substr(password, 5, 1)) = 105) = FALSE

(ascii(substr(password, 5, 1)) = 106) = FALSE

(ascii(substr(password, 5, 1)) = 107) = FALSE

(ascii(substr(password, 5, 1)) = 108) = FALSE

(ascii(substr(password, 5, 1)) = 109) = FALSE

(ascii(substr(password, 5, 1)) = 110) = TRUE -> 다섯 번째 값은 n

(ascii(substr(password, 6, 1)) = 97) = TRUE -> 여섯 번째 값은 a

 

이런 식으로 값을 유추할 수 있다.

이를 파이썬 자동화 툴로 만들면 노가다 할 필요 없이 훨씬 빠르게 sql injection을 수행할 수 있다.

 

반응형

댓글