rex-socket 0.1.46 → 0.1.48

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0b0474613c0bf2b204e3ebfc5f50b29b72ea6af1f98a4bd3e125d86a97aa295
4
- data.tar.gz: c01ea0331c2640f4283cbfa08baec9e44e216045e175a0a2ff5737a5483766ff
3
+ metadata.gz: 6894414c673fee731f0c6bcfc869f8cf31e80d0fdb1f4c8fe7e9ef3392240f87
4
+ data.tar.gz: c18cb6da9934c2b7ff1702672fb34e43ecddea590578e60ad7dddc557650aa64
5
5
  SHA512:
6
- metadata.gz: 7b71fa7bbec1a4e63d95518939742d3f1f8ee8114ee772efcce477953bfa6fce3405c0f9ed6c8818aeaca296072c4034e69e236f5eb5b10f39124e8ab21482b2
7
- data.tar.gz: b0b74b486a3416aca4c9cfdd974b670f62dfa51ca7d55a28fae7c56265129f0f9bf71a75a57f800aca4e83550b5b076e2e565c791e52a256fc2745246f6d1e85
6
+ metadata.gz: d8e9050d6776686079e75d45ec3541f84de8adfbf416687b95e6a659afe9ed9cb439e808caec9022e78328562362ea4b7abf6aee858c584644a913011de264a4
7
+ data.tar.gz: 705a73fe6836686aab49e49678a3131fa07dbdbe1925974d7280820b1275447908c29d36c21bfe714501526ba4ea40564a699c7e18e5105b5ec925a3653e7bc0
checksums.yaml.gz.sig CHANGED
Binary file
@@ -6,6 +6,8 @@ require 'rex/socket/tcp'
6
6
  require 'rex/socket/ssl_tcp'
7
7
  require 'rex/socket/ssl_tcp_server'
8
8
  require 'rex/socket/udp'
9
+ require 'rex/socket/sctp'
10
+ require 'rex/socket/sctp_server'
9
11
  require 'rex/socket/ip'
10
12
  require 'timeout'
11
13
 
@@ -34,6 +36,8 @@ class Rex::Socket::Comm::Local
34
36
  return create_by_type(param, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_TCP)
35
37
  when 'udp'
36
38
  return create_by_type(param, ::Socket::SOCK_DGRAM, ::Socket::IPPROTO_UDP)
39
+ when 'sctp'
40
+ return create_by_type(param, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_SCTP)
37
41
  when 'ip'
38
42
  return create_ip(param)
39
43
  else
@@ -194,15 +198,21 @@ class Rex::Socket::Comm::Local
194
198
  sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_BROADCAST, true)
195
199
  end
196
200
 
197
- # If a server TCP instance is being created...
201
+ # If a server instance is being created...
198
202
  if param.server?
199
203
  sock.listen(256)
200
204
 
201
205
  if !param.bare?
202
- klass = Rex::Socket::TcpServer
203
- if param.ssl
204
- klass = Rex::Socket::SslTcpServer
205
- end
206
+ if param.proto == 'tcp'
207
+ klass = Rex::Socket::TcpServer
208
+ if param.ssl
209
+ klass = Rex::Socket::SslTcpServer
210
+ end
211
+ elsif param.proto == 'sctp'
212
+ klass = Rex::Socket::SctpServer
213
+ else
214
+ raise Rex::BindFailed.new(param.localhost, param.localport), caller
215
+ end
206
216
  sock.extend(klass)
207
217
 
208
218
  sock.initsock(param)
@@ -309,6 +319,9 @@ class Rex::Socket::Comm::Local
309
319
  when 'udp'
310
320
  sock.extend(Rex::Socket::Udp)
311
321
  sock.initsock(param)
322
+ when 'sctp'
323
+ sock.extend(Rex::Socket::Sctp)
324
+ sock.initsock(param)
312
325
  end
313
326
  end
314
327
 
@@ -540,8 +540,11 @@ end
540
540
  class Host < Range
541
541
  attr_accessor :hostname
542
542
 
543
- def initialize(address, hostname=nil, options=nil)
544
- address = Rex::Socket.addr_atoi(address) if address.is_a? String
543
+ def initialize(address, hostname=nil, options={})
544
+ if address.is_a? String
545
+ options.merge!({ ipv6: Rex::Socket.is_ipv6?(address) }) if options[:ipv6].nil?
546
+ address = Rex::Socket.addr_atoi(address)
547
+ end
545
548
 
546
549
  super(address, address, options)
547
550
  @hostname = hostname
@@ -0,0 +1,66 @@
1
+ # -*- coding: binary -*-
2
+ require 'rex/socket'
3
+ require 'rex/io/stream'
4
+
5
+ class ::Socket
6
+ IPPROTO_SCTP = 132
7
+ SOL_SCTP = 132
8
+ end
9
+
10
+ ###
11
+ #
12
+ # This class provides methods for interacting with a SCTP client connection.
13
+ #
14
+ ###
15
+ module Rex::Socket::Sctp
16
+
17
+ include Rex::Socket
18
+ include Rex::IO::Stream
19
+
20
+ ##
21
+ #
22
+ # Factory
23
+ #
24
+ ##
25
+
26
+ #
27
+ # Creates the client using the supplied hash.
28
+ #
29
+ # @see create_param
30
+ # @see Rex::Socket::Parameters.from_hash
31
+ def self.create(hash = {})
32
+ hash['Proto'] = 'sctp'
33
+ self.create_param(Rex::Socket::Parameters.from_hash(hash))
34
+ end
35
+
36
+ #
37
+ # Wrapper around the base socket class' creation method that automatically
38
+ # sets the parameter's protocol to SCTP.
39
+ #
40
+ def self.create_param(param)
41
+ param.proto = 'sctp'
42
+ Rex::Socket.create_param(param)
43
+ end
44
+
45
+ ##
46
+ #
47
+ # Stream mixin implementations
48
+ #
49
+ ##
50
+
51
+ #
52
+ # Calls shutdown on the SCTP connection.
53
+ #
54
+ def shutdown(how = ::Socket::SHUT_RDWR)
55
+ begin
56
+ return (super(how) == 0)
57
+ rescue ::Exception
58
+ end
59
+ end
60
+
61
+ # returns socket type
62
+ def type?
63
+ return 'sctp'
64
+ end
65
+
66
+ end
@@ -0,0 +1,75 @@
1
+ # -*- coding: binary -*-
2
+ require 'rex/socket'
3
+ require 'rex/socket/sctp'
4
+ require 'rex/io/stream_server'
5
+
6
+ ###
7
+ #
8
+ # This class provides methods for interacting with a SCTP server. It
9
+ # implements the Rex::IO::StreamServer interface.
10
+ #
11
+ ###
12
+ module Rex::Socket::SctpServer
13
+
14
+ include Rex::Socket
15
+ include Rex::IO::StreamServer
16
+
17
+ ##
18
+ #
19
+ # Factory
20
+ #
21
+ ##
22
+
23
+ #
24
+ # Creates the server using the supplied hash.
25
+ #
26
+ def self.create(hash = {})
27
+ hash['Proto'] = 'sctp'
28
+ hash['Server'] = true
29
+ self.create_param(Rex::Socket::Parameters.from_hash(hash))
30
+ end
31
+
32
+ #
33
+ # Wrapper around the base class' creation method that automatically sets
34
+ # the parameter's protocol to SCTP and sets the server flag to true.
35
+ #
36
+ def self.create_param(param)
37
+ param.proto = 'sctp'
38
+ param.server = true
39
+ Rex::Socket.create_param(param)
40
+ end
41
+
42
+ #
43
+ # Accepts a child connection.
44
+ #
45
+ def accept(opts = {})
46
+ t = super()
47
+
48
+ # jRuby compatibility
49
+ if t.respond_to?('[]')
50
+ t = t[0]
51
+ end
52
+
53
+ if (t)
54
+ t.extend(Rex::Socket::Sctp)
55
+ t.context = self.context
56
+
57
+ pn = t.getpeername_as_array
58
+
59
+ # We hit a "getpeername(2)" from Ruby
60
+ return nil unless pn
61
+
62
+ t.peerhost = pn[1]
63
+ t.peerport = pn[2]
64
+
65
+ ln = t.getlocalname
66
+
67
+ t.localhost = ln[1]
68
+ t.localport = ln[2]
69
+ end
70
+
71
+ t
72
+ end
73
+
74
+ end
75
+
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Socket
3
- VERSION = "0.1.46"
3
+ VERSION = "0.1.48"
4
4
  end
5
5
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rex-socket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.46
4
+ version: 0.1.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Metasploit Hackers
@@ -93,7 +93,7 @@ cert_chain:
93
93
  EknWpNgVhohbot1lfVAMmIhdtOVaRVcQQixWPwprDj/ydB8ryDMDosIMcw+fkoXU
94
94
  9GJsSaSRRYQ9UUkVL27b64okU8D48m8=
95
95
  -----END CERTIFICATE-----
96
- date: 2023-01-31 00:00:00.000000000 Z
96
+ date: 2023-03-14 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
@@ -163,6 +163,8 @@ files:
163
163
  - lib/rex/socket/ip.rb
164
164
  - lib/rex/socket/parameters.rb
165
165
  - lib/rex/socket/range_walker.rb
166
+ - lib/rex/socket/sctp.rb
167
+ - lib/rex/socket/sctp_server.rb
166
168
  - lib/rex/socket/ssh_factory.rb
167
169
  - lib/rex/socket/ssl.rb
168
170
  - lib/rex/socket/ssl_tcp.rb
metadata.gz.sig CHANGED
Binary file