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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93a2eeaa43fcd931469e95e513127b480a2ba55dd7f8ada8986b076191c22ad9
4
- data.tar.gz: '09dc66492bfdddd8227b015c51ba5f41b3bf263001f1564cf4ae2ef75b80b2f8'
3
+ metadata.gz: fb38ba9938df81a01bc5fbfffe8055b10d09a8bbb3d19e3955904d70e6577e1b
4
+ data.tar.gz: f26d820ced28fc1d88120e3d60f4a3ad08440f69f12973754e3fa4d93bcaceec
5
5
  SHA512:
6
- metadata.gz: e614ceccfda078dbdf7cf75e68c79f47b8a663752cfe84e49909b4b1c1545284a98fc22b1003181fcb773da5785bfb5fbaf79beb6c292caa0b38153399217592
7
- data.tar.gz: 44b09208c1de7dfdfb93d1b6b44426466a229434ba7c1c9412e28847e1c00a1896b9e80da8c62ec6bff8f349f591faee37a6e2e93535c5110441989fc5c78094
6
+ metadata.gz: e5b90f41b5ae712f69c467202d72d211e1e35b4b4a86dc49b80a2e369e716f002bb85189edf0e3e4618579af681fe69d8f98e638854694e0a4ad6e3ca582b685
7
+ data.tar.gz: e2b28c496f4c3cc30eb8d235aa2657084c338d6f782f1e22eb5a040c4b4285bd709f274fae3c2bb366923f1d619471ecd54cccf4518f33c198b8ddb2825c5ed0
checksums.yaml.gz.sig CHANGED
Binary file
@@ -37,10 +37,11 @@ jobs:
37
37
  - '3.0'
38
38
  - '3.1'
39
39
  - '3.2'
40
+ - '3.3'
40
41
  os:
41
42
  - ubuntu-20.04
42
43
  - windows-2019
43
- - macos-11
44
+ - macos-13
44
45
  - ubuntu-latest
45
46
  exclude:
46
47
  - { os: ubuntu-latest, ruby: '2.7' }
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Socket
3
- VERSION = "0.1.56"
3
+ VERSION = "0.1.58"
4
4
  end
5
5
  end
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-9][a-z0-9\-]{0,59})?[a-z0-9]\.)*(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$/i
89
+ MATCH_DNS_NAME = /^(((?!-))(xn--)?([a-z0-9_][a-z0-9_\-]{0,59})?[a-z0-9_]\.)*(xn--)?([a-z0-9_\-]{1,61}|[a-z0-9_-]{1,30}\.[a-z]{2,})$/i
89
90
 
90
91
  MATCH_IPV6 = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((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})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((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})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((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}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((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}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((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}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((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}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,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
- v4, v6 = self.rex_resolve_hostname(name, resolver: resolver)
943
- # Build response array
944
- getaddrinfo = []
945
- v4.each do |a4|
946
- getaddrinfo << Addrinfo.new(
947
- self.to_sockaddr(a4.address.to_s, 0),
948
- ::Socket::AF_INET,
949
- ::Socket::SOCK_STREAM,
950
- ::Socket::IPPROTO_TCP,
951
- ) unless v4.empty?
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
- v6.each do |a6|
954
- getaddrinfo << Addrinfo.new(
955
- self.to_sockaddr(a6.address.to_s, 0),
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, ::Net::DNS::A).answer.select do |a|
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, ::Net::DNS::AAAA).answer.select do |a|
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 = ::Net::DNS.const_get(typeclass)
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
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rspec"
29
29
 
30
30
  spec.add_runtime_dependency "rex-core"
31
+ spec.add_runtime_dependency "dnsruby"
31
32
  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.56
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-02-14 00:00:00.000000000 Z
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