2024. 7. 13. 00:28ㆍSTUDY
SQL Injection
데이터베이스(DB)와 연동된 응용 프로그램에서 입력된 데이터에 대한 유효성 검증을 하지 않을 경우,
공격자가 입력 데이터에 SQL 쿼리문을 삽입하여 DB로부터 정보를 열람하거나 조작할 수 있는 보안 취약점
SQL
Structured Query Language
관계형 데이터베이스 관리 시스템(RDBMS)의 데이터를 관리하기 위해 설계된 특수 목적의 프로그래밍 언어
DDL, DML, DCL, TCL
DML
Data Manipulation Language
select, insert, update, delete, merge, call, explain plan, lock table
SQL Query
- Select [attribute] from [table_name]
== table_name에서 attribute 조회
- Select * from [table_name]
== table_name 전체 조회
- Select [attribute1] from [table_name] where [attribute2] = [value]
== table_name에서 attribute1가 value인 attribute1 조회
- Select [attribute1] from [table_name] order by [attribute2] [asc || desc]
== table_name에서 attribute2값 기준 asc(오름차순) or desc(내림차순)으로 attribute1 조회
Blind SQL Injection
참(True)/거짓(False) 쿼리문 입력시 반환되는 서버의 응답이 다른 것을 비교하여 데이터를 추출하는 공격
Numeric
정수값을 알아내기 위한 예시이다.
TRUE and (select money from account_table where name='dori') > 0 true
TRUE and (select money from account_table where name='dori') > 5 false
TRUE and (select money from account_table where name='dori') > 3 false
TRUE and (select money from account_table where name='dori') > 2 true
이런 결과가 나왔다면
dori의 money는 3이라는 것을 알 수 있다.
String
문자열을 알아내기 위한 예시이다.
TRUE and (SUBSTRING((select pw from account_table where name='dori'),1,1) > 'A') True
TRUE and (SUBSTRING((select pw from account_table where name='dori'),1,1) > 'E') False
dori의 pw의 첫글자는 A의 아스키값보다 크고 E의 아스키값보다 작다는 뜻이다.
즉, pw 첫글자는 B, C, D 중 하나일 것이다.
TRUE and (SUBSTRING((select pw from account_table where name='dori'),2,1) > 'l') True
TRUE and (SUBSTRING((select pw from account_table where name='dori'),2,1) > 'p') True
dori의 pw의 두번째 글자는 l의 아스키값보다 크고 p의 아스키값보다 작다는 뜻이다.
즉, pw 첫글자는 m, n, o 중 하나일 것이다.
TRUE and (SUBSTRING((select pw from account_table where name='dori'),3,1) == 'r') True
dori의 pw 세번째 글자가 r이라는 뜻이다.
TRUE and (SUBSTRING((select pw from account_table where name='dori'),4,1) > 'a') True
dori의 pw 네번째 글자가 소문자라는 뜻이다.
Command Injection
사용자 입력 값이 운영체제 명령어의 일부 또는 전부로 구성되어 실행되는 경우, 의도하지 않은 시스템 명령어가 실행되어 부적절하게 권한이 변경되거나 시스템 동작 및 운영에 악영향을 주는 공격
'STUDY' 카테고리의 다른 글
[NETWORK] Snipping (0) | 2024.07.14 |
---|---|
[NETWORK] Scanning (0) | 2024.07.13 |
[WEB] SSRF (0) | 2024.05.06 |
[WEB] File Vulnerability (0) | 2024.05.06 |
[WEB] command injection (0) | 2024.03.06 |