rex-socket 0.1.45 → 0.1.47

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faf5e107e5cabee49fbd28a5007c63151719d74671e2ec97588f23a8bfeebb49
4
- data.tar.gz: '04811e5e61dce894070fd82b9210052e24b6bc1c766a0c5497752d5b7ff0b6c2'
3
+ metadata.gz: ee17c01e1a4f7063f35a53e7bd069d772eb16499c796e566e59172c862ebe2f0
4
+ data.tar.gz: 95cec06b282479a208a793e572b312fdec938733c31ac39c11a35d4093ab6647
5
5
  SHA512:
6
- metadata.gz: 6aafffe07f0d89669c785c35b30fb6651c86ff46bf4bbad1f9612e08588b27c6842b74feb13c7816bc383553342fa9e951f52d10e20141e534dbb8e31ea7b8cb
7
- data.tar.gz: b8a1683cbb979abb898c3264030b3e20d0590190da1970cb717230060c9c4c1ac99d6a29052c17a07fd229edacdc192caa7a4e2209aa8018799084491360c7fd
6
+ metadata.gz: 194008d3f56ce2ed0a2f3472a2de73cc5f3d297ef8ff183ce1e9a380319356752c882171112b20b9edb75e44e52b644651e0bad3faabddfb158911175cd38d32
7
+ data.tar.gz: 766bf3d2c08fcf411aa8cc0a8137e4a140066bf730d606ba154d2e22c7da01b149b91f0365eb5c6dbc3b557b80e52661d4bb0b3888510a1877d04c2693cba34c
checksums.yaml.gz.sig CHANGED
@@ -1 +1 @@
1
- &�A��n՞��y YE�sQ����Ԗ�#�㜌�E��Bb{ gBVX�ؠV���K�KU@���B�������m|�4ӇԸd2A��DK����#�xm6G&��05H��*�7��1E��?�4%�M�7���ø�o�o�����c>if�Nf�y���+��c�e���X���|9r�-���E�4���
1
+ z�q�!F����i�·Ή iL�cn5eP�� �֧diR\7T��J]�ұw#c���bm&t5�@�et?����|n=7��8]!+S�ꁁ��$���i���%t7F���Uw>l���sGpх�R�o�;��G��
@@ -33,15 +33,16 @@ jobs:
33
33
  fail-fast: true
34
34
  matrix:
35
35
  ruby:
36
- - 2.7
37
- - 3.0
38
- - 3.1
36
+ - '2.7'
37
+ - '3.0'
38
+ - '3.1'
39
+ - '3.2'
39
40
  os:
40
41
  - ubuntu-20.04
41
42
  - ubuntu-latest
42
43
  exclude:
43
- - { os: ubuntu-latest, ruby: 2.7 }
44
- - { os: ubuntu-latest, ruby: 3.0 }
44
+ - { os: ubuntu-latest, ruby: '2.7' }
45
+ - { os: ubuntu-latest, ruby: '3.0' }
45
46
  test_cmd:
46
47
  - bundle exec rspec
47
48
 
@@ -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
 
@@ -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.45"
3
+ VERSION = "0.1.47"
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.45
4
+ version: 0.1.47
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-13 00:00:00.000000000 Z
96
+ date: 2023-02-06 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