net-tns 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/bin/tns_oradb_version.rb +15 -0
- data/bin/tns_sid_enumeration.rb +52 -0
- data/bin/tns_sid_list.rb +43 -0
- data/lib/net/tns/client.rb +94 -0
- data/lib/net/tns/connection.rb +201 -0
- data/lib/net/tns/exceptions.rb +34 -0
- data/lib/net/tns/gem_version.rb +5 -0
- data/lib/net/tns/helpers/string_helpers.rb +49 -0
- data/lib/net/tns/packet.rb +82 -0
- data/lib/net/tns/packets/abort_packet.rb +12 -0
- data/lib/net/tns/packets/accept_packet.rb +19 -0
- data/lib/net/tns/packets/ack_packet.rb +7 -0
- data/lib/net/tns/packets/attention_packet.rb +9 -0
- data/lib/net/tns/packets/connect_packet.rb +55 -0
- data/lib/net/tns/packets/control_packet.rb +7 -0
- data/lib/net/tns/packets/data_packet.rb +20 -0
- data/lib/net/tns/packets/marker_packet.rb +18 -0
- data/lib/net/tns/packets/null_packet.rb +7 -0
- data/lib/net/tns/packets/redirect_packet.rb +10 -0
- data/lib/net/tns/packets/refuse_packet.rb +12 -0
- data/lib/net/tns/packets/resend_packet.rb +7 -0
- data/lib/net/tns/version.rb +15 -0
- data/lib/net/tns.rb +20 -0
- data/lib/net/tti/client.rb +90 -0
- data/lib/net/tti/connection.rb +142 -0
- data/lib/net/tti/crypto.rb +189 -0
- data/lib/net/tti/data_types/chunked_string.rb +63 -0
- data/lib/net/tti/data_types/key_value_pair.rb +25 -0
- data/lib/net/tti/data_types.rb +2 -0
- data/lib/net/tti/exceptions.rb +62 -0
- data/lib/net/tti/message.rb +50 -0
- data/lib/net/tti/messages/data_type_negotiation_request.rb +133 -0
- data/lib/net/tti/messages/data_type_negotiation_response.rb +9 -0
- data/lib/net/tti/messages/error_message.rb +14 -0
- data/lib/net/tti/messages/function_call.rb +46 -0
- data/lib/net/tti/messages/function_calls/authentication.rb +45 -0
- data/lib/net/tti/messages/function_calls/authentication_x64.rb +42 -0
- data/lib/net/tti/messages/function_calls/authentication_x86.rb +53 -0
- data/lib/net/tti/messages/function_calls/pre_authentication_response.rb +32 -0
- data/lib/net/tti/messages/protocol_negotiation_request.rb +29 -0
- data/lib/net/tti/messages/protocol_negotiation_response.rb +44 -0
- data/lib/net/tti.rb +18 -0
- metadata +128 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative "authentication"
|
2
|
+
|
3
|
+
module Net
|
4
|
+
module TTI
|
5
|
+
class AuthenticationX64 < Authentication
|
6
|
+
uint32le :unknown2, :initial_value => 0x00001201
|
7
|
+
uint8 :unknown3, :initial_value => 0x00
|
8
|
+
uint32le :logon_mode, :initial_value => :_logon_mode
|
9
|
+
uint8 :unknown4, :initial_value => 0x01
|
10
|
+
uint32le :parameter_count, :value => lambda {parameters.count}
|
11
|
+
uint16le :unknown5, :initial_value => 0x0101
|
12
|
+
# username_length and username might be a chunked string, but we
|
13
|
+
# don't need to worry about chunking since Oracle usernames can't
|
14
|
+
# be longer than 30 characters.
|
15
|
+
uint8 :username_length, :value => lambda { username.length }
|
16
|
+
string :username
|
17
|
+
array :parameters, :type => :key_value_pair, :read_until => lambda {index == parameter_count-1}
|
18
|
+
|
19
|
+
def _function_code
|
20
|
+
return FUNCTION_CODE_AUTH
|
21
|
+
end
|
22
|
+
private :_function_code
|
23
|
+
|
24
|
+
def _logon_mode
|
25
|
+
return Authentication::LOGON_MODE_AUTH
|
26
|
+
end
|
27
|
+
private :_logon_mode
|
28
|
+
end
|
29
|
+
|
30
|
+
class PreAuthenticationX64 < AuthenticationX64
|
31
|
+
def _function_code
|
32
|
+
return FUNCTION_CODE_PRE_AUTH
|
33
|
+
end
|
34
|
+
private :_function_code
|
35
|
+
|
36
|
+
def _logon_mode
|
37
|
+
return Authentication::LOGON_MODE_PRE_AUTH
|
38
|
+
end
|
39
|
+
private :_logon_mode
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative "authentication"
|
2
|
+
|
3
|
+
module Net
|
4
|
+
module TTI
|
5
|
+
class AuthenticationX86 < Authentication
|
6
|
+
# Clients seem to change this without any effect on the server. It looks
|
7
|
+
# like it's probably 4 8-bit values, but if we're ignoring them all, we
|
8
|
+
# can ignore them as one structure
|
9
|
+
uint32le :unknown2, :initial_value => 0xFFFFFFFE
|
10
|
+
# Some Oracle clients instead send username.length*3 here to 11g servers,
|
11
|
+
# but it doesn't seem to matter
|
12
|
+
uint32le :unknown3, :value => lambda { username.length }
|
13
|
+
# 0x1 => preauth, 0x101 => auth
|
14
|
+
uint32le :logon_mode, :initial_value => :_logon_mode
|
15
|
+
# Ditto for unknown2. Oracle clients put the same value into the upper
|
16
|
+
# 16 bits of unknown4, unknown5 and unknown6 in each request, but I can't
|
17
|
+
# figure out its meaning
|
18
|
+
uint32le :unknown4, :initial_value => 0xFFFFFFFE
|
19
|
+
uint32le :parameter_count, :value => lambda {parameters.count}
|
20
|
+
# See unknown4
|
21
|
+
uint32le :unknown5, :initial_value => 0xFFFFFFFE
|
22
|
+
uint32le :unknown6, :initial_value => 0xFFFFFFFE
|
23
|
+
# username_length and username might be a chunked string, but we
|
24
|
+
# don't need to worry about chunking since Oracle usernames can't
|
25
|
+
# be longer than 30 characters
|
26
|
+
uint8 :username_length, :value => lambda { username.length }
|
27
|
+
string :username
|
28
|
+
array :parameters, :type => :key_value_pair, :read_until => lambda {index == parameter_count-1}
|
29
|
+
|
30
|
+
def _function_code
|
31
|
+
return FUNCTION_CODE_AUTH
|
32
|
+
end
|
33
|
+
private :_function_code
|
34
|
+
|
35
|
+
def _logon_mode
|
36
|
+
return Authentication::LOGON_MODE_AUTH
|
37
|
+
end
|
38
|
+
private :_logon_mode
|
39
|
+
end
|
40
|
+
|
41
|
+
class PreAuthenticationX86 < AuthenticationX86
|
42
|
+
def _function_code
|
43
|
+
return FUNCTION_CODE_PRE_AUTH
|
44
|
+
end
|
45
|
+
private :_function_code
|
46
|
+
|
47
|
+
def _logon_mode
|
48
|
+
return Authentication::LOGON_MODE_PRE_AUTH
|
49
|
+
end
|
50
|
+
private :_logon_mode
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "net/tti/data_types"
|
2
|
+
|
3
|
+
module Net
|
4
|
+
module TTI
|
5
|
+
class PreAuthenticationResponse < Message
|
6
|
+
uint16le :parameter_count
|
7
|
+
array :parameters, :type => :key_value_pair, :read_until => lambda {index == parameter_count-1}
|
8
|
+
|
9
|
+
def _ttc_code
|
10
|
+
return TTC_CODE_OK
|
11
|
+
end
|
12
|
+
private :_ttc_code
|
13
|
+
|
14
|
+
def auth_sesskey
|
15
|
+
param = find_param("AUTH_SESSKEY", true)
|
16
|
+
return param.kvp_value.tns_unhexify
|
17
|
+
end
|
18
|
+
|
19
|
+
def auth_vfr_data
|
20
|
+
param = find_param("AUTH_VFR_DATA", true)
|
21
|
+
return param.kvp_value.tns_unhexify
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_param(key, raise_if_not_found=false)
|
25
|
+
param = self.parameters.find {|p| p.kvp_key == key}
|
26
|
+
raise "No #{key} parameter found" if param.nil? && raise_if_not_found
|
27
|
+
return param
|
28
|
+
end
|
29
|
+
private :find_param
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Net
|
2
|
+
module TTI
|
3
|
+
class ProtocolNegotiationRequest < Message
|
4
|
+
# BinData fields
|
5
|
+
# In the request, this will be the version(s) the client supports; in the
|
6
|
+
# response, this will be the version the server chooses. These are a
|
7
|
+
# concatenated string of version numbers (e.g. 060504).
|
8
|
+
stringz :client_versions_string
|
9
|
+
stringz :protocol_handler
|
10
|
+
|
11
|
+
def _ttc_code
|
12
|
+
TTC_CODE_PROTOCOL_NEGOTIATION
|
13
|
+
end
|
14
|
+
private :_ttc_code
|
15
|
+
|
16
|
+
def self.create_request(client_versions=[6], protocol_handler="IBMPC/WIN_NT-8.1.0")
|
17
|
+
request = self.new
|
18
|
+
request.client_versions = client_versions
|
19
|
+
request.protocol_handler = protocol_handler
|
20
|
+
|
21
|
+
return request
|
22
|
+
end
|
23
|
+
|
24
|
+
def client_versions=(versions)
|
25
|
+
self.client_versions_string = versions.pack("C*")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Net
|
2
|
+
module TTI
|
3
|
+
class ProtocolNegotiationResponse < Message
|
4
|
+
handles_response_for_ttc_code TTC_CODE_PROTOCOL_NEGOTIATION
|
5
|
+
|
6
|
+
# BinData fields
|
7
|
+
stringz :versions_string # The protocol (TTC?) version negotiated
|
8
|
+
stringz :protocol_handler
|
9
|
+
uint16le :character_set
|
10
|
+
|
11
|
+
uint8 :unknown1
|
12
|
+
uint16le :unknown2_length
|
13
|
+
string :unknown2, :read_length => lambda {unknown2_length * 5}
|
14
|
+
uint16be :unknown3_length
|
15
|
+
string :unknown3, :read_length => :unknown3_length
|
16
|
+
uint8 :unknown4_length
|
17
|
+
string :unknown4, :read_length => :unknown4_length
|
18
|
+
uint8 :unknown5_length
|
19
|
+
string :unknown5, :read_length => :unknown5_length
|
20
|
+
|
21
|
+
def version
|
22
|
+
self.versions_string[0,1].unpack("C").first
|
23
|
+
end
|
24
|
+
|
25
|
+
def populate_connection_parameters( conn_params )
|
26
|
+
conn_params.ttc_version = self.version
|
27
|
+
|
28
|
+
case self.protocol_handler
|
29
|
+
when "IBMPC/WIN_NT-8.1.0"
|
30
|
+
conn_params.architecture = :x86
|
31
|
+
conn_params.platform = :windows
|
32
|
+
when "Linuxi386/Linux-2.0.34-8.1.0"
|
33
|
+
conn_params.architecture = :x86
|
34
|
+
conn_params.platform = :linux
|
35
|
+
when "x86_64/Linux 2.4.xx"
|
36
|
+
conn_params.architecture = :x64
|
37
|
+
conn_params.platform = :linux
|
38
|
+
else
|
39
|
+
raise Net::TTI::Exceptions::UnsupportedPlatform.new( self.protocol_handler )
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/net/tti.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "net/tns/helpers/string_helpers"
|
2
|
+
|
3
|
+
module Net
|
4
|
+
module TTI
|
5
|
+
require "pathname"
|
6
|
+
Dir.glob("#{Pathname.new(__FILE__).dirname}/tti/*.rb") { |file| require file }
|
7
|
+
|
8
|
+
def self.logger
|
9
|
+
unless defined?(@@logger)
|
10
|
+
require "logger"
|
11
|
+
@@logger = Logger.new(STDERR)
|
12
|
+
@@logger.progname = "Net::TTI"
|
13
|
+
@@logger.sev_threshold = 6 unless $DEBUG
|
14
|
+
end
|
15
|
+
return @@logger
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: net-tns
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Woodbury
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bindata
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-its
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
description: A pure Ruby (partial) implementation of the Oracle TNS protocol
|
56
|
+
email: woodbusy@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- LICENSE
|
62
|
+
- bin/tns_oradb_version.rb
|
63
|
+
- bin/tns_sid_enumeration.rb
|
64
|
+
- bin/tns_sid_list.rb
|
65
|
+
- lib/net/tns.rb
|
66
|
+
- lib/net/tns/client.rb
|
67
|
+
- lib/net/tns/connection.rb
|
68
|
+
- lib/net/tns/exceptions.rb
|
69
|
+
- lib/net/tns/gem_version.rb
|
70
|
+
- lib/net/tns/helpers/string_helpers.rb
|
71
|
+
- lib/net/tns/packet.rb
|
72
|
+
- lib/net/tns/packets/abort_packet.rb
|
73
|
+
- lib/net/tns/packets/accept_packet.rb
|
74
|
+
- lib/net/tns/packets/ack_packet.rb
|
75
|
+
- lib/net/tns/packets/attention_packet.rb
|
76
|
+
- lib/net/tns/packets/connect_packet.rb
|
77
|
+
- lib/net/tns/packets/control_packet.rb
|
78
|
+
- lib/net/tns/packets/data_packet.rb
|
79
|
+
- lib/net/tns/packets/marker_packet.rb
|
80
|
+
- lib/net/tns/packets/null_packet.rb
|
81
|
+
- lib/net/tns/packets/redirect_packet.rb
|
82
|
+
- lib/net/tns/packets/refuse_packet.rb
|
83
|
+
- lib/net/tns/packets/resend_packet.rb
|
84
|
+
- lib/net/tns/version.rb
|
85
|
+
- lib/net/tti.rb
|
86
|
+
- lib/net/tti/client.rb
|
87
|
+
- lib/net/tti/connection.rb
|
88
|
+
- lib/net/tti/crypto.rb
|
89
|
+
- lib/net/tti/data_types.rb
|
90
|
+
- lib/net/tti/data_types/chunked_string.rb
|
91
|
+
- lib/net/tti/data_types/key_value_pair.rb
|
92
|
+
- lib/net/tti/exceptions.rb
|
93
|
+
- lib/net/tti/message.rb
|
94
|
+
- lib/net/tti/messages/data_type_negotiation_request.rb
|
95
|
+
- lib/net/tti/messages/data_type_negotiation_response.rb
|
96
|
+
- lib/net/tti/messages/error_message.rb
|
97
|
+
- lib/net/tti/messages/function_call.rb
|
98
|
+
- lib/net/tti/messages/function_calls/authentication.rb
|
99
|
+
- lib/net/tti/messages/function_calls/authentication_x64.rb
|
100
|
+
- lib/net/tti/messages/function_calls/authentication_x86.rb
|
101
|
+
- lib/net/tti/messages/function_calls/pre_authentication_response.rb
|
102
|
+
- lib/net/tti/messages/protocol_negotiation_request.rb
|
103
|
+
- lib/net/tti/messages/protocol_negotiation_response.rb
|
104
|
+
homepage: https://github.com/SpiderLabs/net-tns
|
105
|
+
licenses:
|
106
|
+
- Apache-2.0
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 2.0.0
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Ruby implementation of the Oracle TNS protocol
|
128
|
+
test_files: []
|