Oracle Database Communication Protocol PDF
Oracle Database Communication Protocol PDF
Oracle Database Communication Protocol PDF
Communication Protocol
a pentesters view, or rude Oracle experiments
Roman Bazhin
ZeroNights E.0x04
@nezlooy
Who am I
Security researcher at Digital Security
r.bazhin@dsec.ru
@nezlooy
Agenda
Motivation
Oracle Client Drivers
Oracle Net Architecture
Oracle Database Protocol
TNSIntruder
Limitations and defense
Motivation
Interaction Scheme
RAC Node 1
Client
Oracle
RAC Node 2
Interaction Scheme
RAC Node 1
RAC Node 2
Testing Scheme
Proxy / Fuzzer
Oracle Client N
Reverse Fuzzing
Client
SYN
ACK
Fuzz
SYN-ACK server
Reverse Fuzzing
Client
SYN
ACK
Fuzz
SYN-ACK server
REQUEST
RESPONSE
Reverse Fuzzing
Client
SYN
ACK
Fuzz
SYN-ACK server
REQUEST
REQUEST RESPONSE
RESPONSE
Reverse Fuzzing
- *!
Client
SYN
ACK
Fuzz
SYN-ACK server
REQUEST
REQUEST RESPONSE
RESPONSE
Reverse Fuzzing
Striped hat / Ethical gop-stopping
Client
SYN
ACK
Fuzz
SYN-ACK server
REQUEST
REQUEST RESPONSE
RESPONSE
Pentester Requirements
!
? ?
Proxy / Fuzzer
Oracle Client N
Googling
?
Oracle TNS Protocol
http://www.thesprawl.org/research/oracle-tns-protocol/
Basic information about headers, type of packets / For beginners / Outdated.
Wireshark TNS data dissector.
http://anonsvn.wireshark.org/wireshark/trunk/epan/dissectors/packet-tns.c
Only headers, type of packets / Already have one.
Presentations by Jonah Harris
http://oracle-internals.com/
Basic information about headers, TTC, server internals / Good.
Oracle Protocol by Gwen Shapira
http://www.pythian.com/blog/repost-oracle-protocol/
Description of some types of messages, marshalling / Very good but outdated :(
Googling
?
pytnsproxy by Lszl Tth
http://soonerorlater.hu/index.khtml?article_id=515
Oracle 9i, 10g and 11g MITM-attack tool.
pytnspoison by Joxean Koret
http://seclists.org/fulldisclosure/2012/Apr/204
Oracle 9i, 10g and 11g TNS Listener Poison exploitation tool.
Amoeba
https://code.google.com/p/amoeba/
Amoeba is a Distributing database proxy / no longer supported.
Code
, :/
pytnspoison
Code
, :/
pytnsproxy
Code
:/
Amoeba
Client Drivers
?
Oracle Client Drivers overview
Oracle Net
Transport layer
Network layer
Physical layer
Oracle Net Architecture (Server)
Server
RDBMS
OPI
0000 00 00 00 9F 06 00 00 00 00 00 DE AD BE EF 00 95
0010 0A 20 00 00 00 04 00 00 04 00 03 00 00 00 00 00
0020 04 00 05 0A 20 00 00 00 08 00 01 09 09 09 09 09
0030 09 09 09 00 12 00 01 DE AD BE EF 00 03 00 00 00
0040 04 00 04 00 01 00 02 00 03 00 01 00 03 00 00 00
0050 00 00 04 00 05 0A 20 00 00 00 02 00 03 E0 E1 00
0060 02 00 06 FC FF 00 02 00 02 00 00 00 00 00 04 00
0070 05 0A 20 00 00 00 0C 00 01 00 01 08 0A 06 03 02
0080 0B 0C 0F 10 11 00 03 00 02 00 00 00 00 00 04 00
0090 05 0A 20 00 00 00 06 00 01 00 01 03 04 05 06 00
Types and formats of messages
Transparent Network Substrate (TNS)
Packet Size
0000 00 9F 00 00 06 00 00 00 00 00 DE AD BE EF 00 95 Packet Checksum
0010 0A 20 00 00 00 04 00 00 04 00 03 00 00 00 00 00
Packet Type
0020 04 00 05 0A 20 00 00 00 08 00 01 09 09 09 09 09
0030 09 09 09 00 12 00 01 DE AD BE EF 00 03 00 00 00 Header Flags
0040 04 00 04 00 01 00 02 00 03 00 01 00 03 00 00 00 Header Checksum
0050 00 00 04 00 05 0A 20 00 00 00 02 00 03 E0 E1 00
0060 02 00 06 FC FF 00 02 00 02 00 00 00 00 00 04 00
0070 05 0A 20 00 00 00 0C 00 01 00 01 08 0A 06 03 02
0080 0B 0C 0F 10 11 00 03 00 02 00 00 00 00 00 04 00
0090 05 0A 20 00 00 00 06 00 01 00 01 03 04 05 06 00
Types and formats of messages
Transparent Network Substrate (TNS) in Oracle 12c
Packet Size
0000 00 00 00 9F 06 00 00 00 00 00 DE AD BE EF 00 95 Packet Type
0010 0A 20 00 00 00 04 00 00 04 00 03 00 00 00 00 00
Header Flags
0020 04 00 05 0A 20 00 00 00 08 00 01 09 09 09 09 09
0030 09 09 09 00 12 00 01 DE AD BE EF 00 03 00 00 00 Header Checksum
0040 04 00 04 00 01 00 02 00 03 00 01 00 03 00 00 00
0050 00 00 04 00 05 0A 20 00 00 00 02 00 03 E0 E1 00
0060 02 00 06 FC FF 00 02 00 02 00 00 00 00 00 04 00
0070 05 0A 20 00 00 00 0C 00 01 00 01 08 0A 06 03 02
0080 0B 0C 0F 10 11 00 03 00 02 00 00 00 00 00 04 00
0090 05 0A 20 00 00 00 06 00 01 00 01 03 04 05 06 00
Types and formats of messages
TNS / Packet Types:
CONNECT = 0x01 ABORT = 0x09
ACCEPT = 0x02 RESEND = 0x0B
ACKNOWLEDGE = 0x03 MARKER = 0x0C
REFUSE = 0x04 ATTENTION = 0x0D
REDIRECT = 0x05 CONTROL INFORMATION * = 0x0E
DATA = 0x06 DATA DESCRIPTOR * = 0x0F
NULL = 0x07
Client Server
TTIPRO
TTIFUN -> OSESSKEY
TTIDTY
TTIFUN -> OAUTH
TTIRPA
TTIFUN -> OVERSION *
TTIRPA
TTIRPA
* Thin client, OCI use TTIPFN -> O80SES or not used at all
Sequence of messages
Selecting
TTIRPA
Client Server
TTISTA
TTIFUN -> OLOGOFF *
TTISTA
EOF
TTISTA
Features:
Classes and marshalling engine
Collector of sequences
Injecting arbitrary SQL queries (Session hijacking)
Demo
, !
TNSIntruder
Necessary to implement:
PL/SQL support
Network Data Encryption and Integrity Checks support
Whish list:
SQL-parser
Java-backdoors uploader in hijacked session *
https://github.com/nezlooy
Limitations and defense
!
Limitations and defense
Channel
Network Data Encryption and Integrity Checks
PKI (Oracle wallets)
Data protection
Authentication
Database attacks
Oracle Database Firewall
Antifraud solutions
Bonus
!
Gop-stopping of Instant Clients
Fuzzing with pyZZUF and Radamsa
OCI
Was fuzzed only 6 server responses
nezlooy