rex-socket 0.1.56 → 0.1.58
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.github/workflows/verify.yml +2 -1
- data/lib/rex/socket/version.rb +1 -1
- data/lib/rex/socket.rb +30 -25
- data/rex-socket.gemspec +1 -0
- data.tar.gz.sig +0 -0
- metadata +16 -2
- 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: fb38ba9938df81a01bc5fbfffe8055b10d09a8bbb3d19e3955904d70e6577e1b
|
4
|
+
data.tar.gz: f26d820ced28fc1d88120e3d60f4a3ad08440f69f12973754e3fa4d93bcaceec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b90f41b5ae712f69c467202d72d211e1e35b4b4a86dc49b80a2e369e716f002bb85189edf0e3e4618579af681fe69d8f98e638854694e0a4ad6e3ca582b685
|
7
|
+
data.tar.gz: e2b28c496f4c3cc30eb8d235aa2657084c338d6f782f1e22eb5a040c4b4285bd709f274fae3c2bb366923f1d619471ecd54cccf4518f33c198b8ddb2825c5ed0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
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
|
|
@@ -85,7 +86,7 @@ module Socket
|
|
85
86
|
#
|
86
87
|
|
87
88
|
# see: https://debugpointer.com/regex/regex-for-dns-name
|
88
|
-
MATCH_DNS_NAME = /^(((?!-))(xn--)?([a-z0-
|
89
|
+
MATCH_DNS_NAME = /^(((?!-))(xn--)?([a-z0-9_][a-z0-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4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/
|
91
92
|
|
@@ -133,7 +134,7 @@ module Socket
|
|
133
134
|
#
|
134
135
|
def self.is_name?(name)
|
135
136
|
return false if name.length > 253
|
136
|
-
name =~ MATCH_DNS_NAME ? (name =~ /\s/).nil? : false
|
137
|
+
name.delete_suffix('.') =~ MATCH_DNS_NAME ? (name =~ /\s/).nil? : false
|
137
138
|
end
|
138
139
|
|
139
140
|
#
|
@@ -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.58
|
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-11-22 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
|
metadata.gz.sig
CHANGED
Binary file
|