rex-socket 0.1.57 → 0.1.59
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/verify.yml +2 -1
- data/lib/rex/socket/comm/local.rb +5 -4
- data/lib/rex/socket/parameters.rb +2 -1
- data/lib/rex/socket/proxies.rb +24 -0
- data/lib/rex/socket/version.rb +1 -1
- data/lib/rex/socket.rb +28 -23
- data/rex-socket.gemspec +1 -0
- data.tar.gz.sig +0 -0
- metadata +18 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e949497936b6f26c1c6da1830a2673f8708706e89598765b26ddf05179dceee0
|
4
|
+
data.tar.gz: 49e42e30d773df6f4b52539d360748fe77e51dd49bb1f1e2782a35217839eef3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8ea54f52f4f10c8050e181980de4caf16bc5443657c55cf0ce5ef1d20b1a5bca84448515ab502ab79c4bc3eef66b1a199ada9e095304a42c25150ee9d3062fe
|
7
|
+
data.tar.gz: aec32cadf5c60108aba67155731cf5eba9da3dba310f37fa6f6941f04a9e167762bae8953c05b5dfa7c6b096c8fdc44616b42a3f80e910a4cbc2b2e8c438308f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -9,6 +9,7 @@ require 'rex/socket/udp'
|
|
9
9
|
require 'rex/socket/sctp'
|
10
10
|
require 'rex/socket/sctp_server'
|
11
11
|
require 'rex/socket/ip'
|
12
|
+
require 'rex/socket/proxies'
|
12
13
|
require 'timeout'
|
13
14
|
|
14
15
|
###
|
@@ -353,7 +354,7 @@ class Rex::Socket::Comm::Local
|
|
353
354
|
|
354
355
|
def self.proxy(sock, type, host, port)
|
355
356
|
case type.downcase
|
356
|
-
when
|
357
|
+
when Rex::Socket::Proxies::ProxyType::SAPNI
|
357
358
|
packet_type = 'NI_ROUTE'
|
358
359
|
route_info_version = 2
|
359
360
|
ni_version = 39
|
@@ -422,7 +423,7 @@ class Rex::Socket::Comm::Local
|
|
422
423
|
raise Rex::ConnectionProxyError.new(host, port, type, "Connection to #{host}:#{port} failed (Unknown fail)")
|
423
424
|
end
|
424
425
|
|
425
|
-
when
|
426
|
+
when Rex::Socket::Proxies::ProxyType::HTTP
|
426
427
|
setup = "CONNECT #{host}:#{port} HTTP/1.0\r\n\r\n"
|
427
428
|
size = sock.put(setup)
|
428
429
|
if size != setup.length
|
@@ -445,7 +446,7 @@ class Rex::Socket::Comm::Local
|
|
445
446
|
if resp.code != 200
|
446
447
|
raise Rex::ConnectionProxyError.new(host, port, type, "The proxy returned a non-OK response"), caller
|
447
448
|
end
|
448
|
-
when
|
449
|
+
when Rex::Socket::Proxies::ProxyType::SOCKS4
|
449
450
|
supports_ipv6 = false
|
450
451
|
setup = [4,1,port.to_i].pack('CCn') + Rex::Socket.resolv_nbo(host, supports_ipv6) + Rex::Text.rand_text_alpha(rand(8)+1) + "\x00"
|
451
452
|
size = sock.put(setup)
|
@@ -465,7 +466,7 @@ class Rex::Socket::Comm::Local
|
|
465
466
|
if ret[1,1] != "\x5a"
|
466
467
|
raise Rex::ConnectionProxyError.new(host, port, type, "Proxy responded with error code #{ret[0,1].unpack("C")[0]}"), caller
|
467
468
|
end
|
468
|
-
when
|
469
|
+
when Rex::Socket::Proxies::ProxyType::SOCKS5
|
469
470
|
auth_methods = [5,1,0].pack('CCC')
|
470
471
|
size = sock.put(auth_methods)
|
471
472
|
if size != auth_methods.length
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: binary -*-
|
2
2
|
require 'rex/socket'
|
3
|
+
require 'rex/socket/proxies'
|
3
4
|
|
4
5
|
###
|
5
6
|
#
|
@@ -163,7 +164,7 @@ class Rex::Socket::Parameters
|
|
163
164
|
end
|
164
165
|
|
165
166
|
if hash['Proxies']
|
166
|
-
self.proxies = hash['Proxies']
|
167
|
+
self.proxies = Rex::Socket::Proxies.parse(hash['Proxies'])
|
167
168
|
end
|
168
169
|
|
169
170
|
# The protocol this socket will be using
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: binary -*-
|
2
|
+
|
3
|
+
module Rex
|
4
|
+
module Socket
|
5
|
+
module Proxies
|
6
|
+
module ProxyType
|
7
|
+
SAPNI = 'sapni'
|
8
|
+
HTTP = 'http'
|
9
|
+
SOCKS4 = 'socks4'
|
10
|
+
SOCKS5 = 'socks5'
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [String,nil] value A proxy chain of format {type:host:port[,type:host:port][...]}
|
14
|
+
# @return [Array] The array of proxies, i.e. {[['type', 'host', 'port']]}
|
15
|
+
def self.parse(value)
|
16
|
+
value.to_s.strip.split(',').map { |a| a.strip }.map { |a| a.split(':').map { |b| b.strip } }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.supported_types
|
20
|
+
ProxyType.constants.map { |c| ProxyType.const_get(c) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/rex/socket/version.rb
CHANGED
data/lib/rex/socket.rb
CHANGED
@@ -4,6 +4,7 @@ require 'socket'
|
|
4
4
|
require 'thread'
|
5
5
|
require 'resolv'
|
6
6
|
require 'rex/exceptions'
|
7
|
+
require 'dnsruby'
|
7
8
|
|
8
9
|
module Rex
|
9
10
|
|
@@ -939,26 +940,30 @@ protected
|
|
939
940
|
# @param resolver [Rex::Proto::DNS::CachedResolver] Resolver to query for the name
|
940
941
|
# @return [Array] Array mimicking the native getaddrinfo return type
|
941
942
|
def self.rex_getaddrinfo(name, resolver: @@resolver)
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
943
|
+
v4_sockaddrs = []
|
944
|
+
v6_sockaddrs = []
|
945
|
+
|
946
|
+
if name =~ /\A\d+\Z/ && name.to_i.between?(0, 0xffffffff)
|
947
|
+
v4_sockaddrs << self.to_sockaddr(name.to_i, 0)
|
948
|
+
elsif name =~ /\A0x[0-9a-fA-F]+\Z/ && name.to_i(16).between?(0, 0xffffffff)
|
949
|
+
v4_sockaddrs << self.to_sockaddr(name.to_i(16), 0)
|
950
|
+
elsif self.is_ipv4?(name)
|
951
|
+
v4_sockaddrs << self.to_sockaddr(name, 0)
|
952
|
+
elsif self.is_ipv6?(name)
|
953
|
+
v6_sockaddrs << self.to_sockaddr(name, 0)
|
954
|
+
else
|
955
|
+
v4, v6 = self.rex_resolve_hostname(name, resolver: resolver)
|
956
|
+
v4.each do |a4|
|
957
|
+
v4_sockaddrs << self.to_sockaddr(a4.address.to_s, 0)
|
958
|
+
end
|
959
|
+
v6.each do |a6|
|
960
|
+
v6_sockaddrs << self.to_sockaddr(a6.address.to_s, 0)
|
961
|
+
end
|
952
962
|
end
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
::Socket::AF_INET6,
|
957
|
-
::Socket::SOCK_STREAM,
|
958
|
-
::Socket::IPPROTO_TCP,
|
959
|
-
) unless v6.empty?
|
963
|
+
|
964
|
+
(v4_sockaddrs.map { |sa| [sa, ::Socket::AF_INET] } + v6_sockaddrs.map { |sa| [sa, ::Socket::AF_INET6] }).map do |sa, family|
|
965
|
+
Addrinfo.new(sa, family, ::Socket::SOCK_STREAM, ::Socket::IPPROTO_TCP)
|
960
966
|
end
|
961
|
-
return getaddrinfo
|
962
967
|
end
|
963
968
|
|
964
969
|
|
@@ -974,21 +979,21 @@ protected
|
|
974
979
|
) unless name.is_a?(String)
|
975
980
|
# Pull both record types
|
976
981
|
v4 = begin
|
977
|
-
resolver.send(name, ::
|
982
|
+
resolver.send(name, ::Dnsruby::Types::A).answer.select do |a|
|
978
983
|
a.type == Dnsruby::Types::A
|
979
984
|
end.sort_by do |a|
|
980
985
|
self.addr_ntoi(a.address.address)
|
981
986
|
end
|
982
|
-
rescue
|
987
|
+
rescue StandardError
|
983
988
|
[]
|
984
989
|
end
|
985
990
|
v6 = begin
|
986
|
-
resolver.send(name, ::
|
991
|
+
resolver.send(name, Dnsruby::Types::AAAA).answer.select do |a|
|
987
992
|
a.type == Dnsruby::Types::AAAA
|
988
993
|
end.sort_by do |a|
|
989
994
|
self.addr_ntoi(a.address.address)
|
990
995
|
end
|
991
|
-
rescue
|
996
|
+
rescue StandardError
|
992
997
|
[]
|
993
998
|
end
|
994
999
|
# Emulate ::Socket's error if no responses found
|
@@ -1012,7 +1017,7 @@ protected
|
|
1012
1017
|
if attribute.nil?
|
1013
1018
|
raise ArgumentError, "Invalid typeclass: #{typeclass}"
|
1014
1019
|
end
|
1015
|
-
const = ::
|
1020
|
+
const = Dnsruby::Types.const_get(typeclass)
|
1016
1021
|
|
1017
1022
|
resources = begin
|
1018
1023
|
resolver.send(name, const).answer.select do |a|
|
data/rex-socket.gemspec
CHANGED
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.
|
4
|
+
version: 0.1.59
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
DgscAao7wB3xW2BWEp1KnaDWkf1x9ttgoBEYyuYwU7uatB67kBQG1PKvLt79wHvz
|
35
35
|
Dxs+KOjGbBRfMnPgVGYkORKVrZIwlaboHbDKxcVW5xv+oZc7KYXWGg==
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2024-
|
37
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: rake
|
@@ -78,6 +78,20 @@ dependencies:
|
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: dnsruby
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
81
95
|
description: "The Ruby Exploitation (Rex) Socket Abstraction Library. This library\n
|
82
96
|
\ includes all of the code needed to turn sockets into Rex::Sockets
|
83
97
|
with the functionality\n for things like L3 pivoting used
|
@@ -104,6 +118,7 @@ files:
|
|
104
118
|
- lib/rex/socket/comm/local.rb
|
105
119
|
- lib/rex/socket/ip.rb
|
106
120
|
- lib/rex/socket/parameters.rb
|
121
|
+
- lib/rex/socket/proxies.rb
|
107
122
|
- lib/rex/socket/range_walker.rb
|
108
123
|
- lib/rex/socket/sctp.rb
|
109
124
|
- lib/rex/socket/sctp_server.rb
|
@@ -137,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
152
|
- !ruby/object:Gem::Version
|
138
153
|
version: '0'
|
139
154
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
155
|
+
rubygems_version: 3.5.22
|
141
156
|
signing_key:
|
142
157
|
specification_version: 4
|
143
158
|
summary: The Ruby Exploitation (Rex) Socket Abstraction Library.
|
metadata.gz.sig
CHANGED
Binary file
|