rex-socket 0.1.66 → 0.1.68
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
- data/lib/rex/socket/comm/local.rb +16 -2
- data/lib/rex/socket/udp.rb +31 -13
- data/lib/rex/socket/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27acb62e9f5a756af4be153428826989e9287a3c61cf42ab472f531459ce4e6a
|
|
4
|
+
data.tar.gz: 6aaf1a0a93ce1563f3c2c0d2fb02e2f8fca12767e0bdad54e2bac13a19381ee5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0481a40864ca7aad2d346f510024ccff891f218b3ebbcea572e9342424d730241829218b4d0eadb69812c79fd4fa9e5a6b9e03749ee8eb22ac61ee71278ed5a3'
|
|
7
|
+
data.tar.gz: 7de451e877c242251ab8a004dc806f4465849748696547b752168dbb58c24b48fb25e95771656da33a89a989f68b7030e58579f5b38a92f91bef35e50572c600
|
|
@@ -264,7 +264,15 @@ class Rex::Socket::Comm::Local
|
|
|
264
264
|
sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_REUSEADDR, true)
|
|
265
265
|
end
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
if Rex::Socket.is_ip_addr?(param.localhost)
|
|
268
|
+
ip = param.localhost
|
|
269
|
+
elsif param.v6
|
|
270
|
+
ip = Rex::Socket.getaddresses(param.localhost, true).select { |address| Rex::Socket.is_ipv6?(address) }.sample
|
|
271
|
+
else
|
|
272
|
+
ip = Rex::Socket.getaddresses(param.localhost, false).select { |address| Rex::Socket.is_ipv4?(address) }.sample
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
sock.bind(Rex::Socket.to_sockaddr(ip, param.localport))
|
|
268
276
|
|
|
269
277
|
rescue ::Errno::EADDRNOTAVAIL,::Errno::EADDRINUSE
|
|
270
278
|
sock.close
|
|
@@ -343,7 +351,13 @@ class Rex::Socket::Comm::Local
|
|
|
343
351
|
ip = param.proxies.first.host
|
|
344
352
|
port = param.proxies.first.port
|
|
345
353
|
else
|
|
346
|
-
|
|
354
|
+
if Rex::Socket.is_ip_addr?(param.peerhost)
|
|
355
|
+
ip = param.peerhost
|
|
356
|
+
elsif param.v6
|
|
357
|
+
ip = Rex::Socket.getaddresses(param.peerhost, true).select { |address| Rex::Socket.is_ipv6?(address) }.sample
|
|
358
|
+
else
|
|
359
|
+
ip = Rex::Socket.getaddresses(param.peerhost, false).select { |address| Rex::Socket.is_ipv4?(address) }.sample
|
|
360
|
+
end
|
|
347
361
|
port = param.peerport
|
|
348
362
|
end
|
|
349
363
|
|
data/lib/rex/socket/udp.rb
CHANGED
|
@@ -97,23 +97,41 @@ module Rex::Socket::Udp
|
|
|
97
97
|
#
|
|
98
98
|
# Sends a datagram to the supplied host:port with optional flags.
|
|
99
99
|
#
|
|
100
|
+
# @deprecated Use {#send} with the stdlib 4-arg form send(mesg, flags, host, port) instead.
|
|
101
|
+
# Note the argument order differs: sendto(gram, host, port, flags) vs send(mesg, flags, host, port).
|
|
102
|
+
#
|
|
100
103
|
def sendto(gram, peerhost, peerport, flags = 0)
|
|
104
|
+
warn "#{self.class}#sendto is deprecated; use send(mesg, flags, host, port) instead", uplevel: 1
|
|
105
|
+
send(gram, flags, peerhost, peerport)
|
|
106
|
+
end
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
#
|
|
109
|
+
# Sends a datagram using the stdlib 4-arg form send(mesg, flags, host, port).
|
|
110
|
+
#
|
|
111
|
+
# The 4-arg form handles IPv6/IPv4 address mapping and dispatches via
|
|
112
|
+
# BasicSocket#send with a packed sockaddr, so channel/pivoted sockets that
|
|
113
|
+
# override sendto are not involved. Also accepts the 3-arg sockaddr form used
|
|
114
|
+
# by lower-level callers, and the 2-arg connected-socket form.
|
|
115
|
+
#
|
|
116
|
+
def send(mesg, flags, host = nil, port = nil)
|
|
117
|
+
if host && port
|
|
118
|
+
# Catch unconnected IPv6 sockets talking to IPv4 addresses
|
|
119
|
+
peer = Rex::Socket.resolv_nbo(host)
|
|
120
|
+
if peer.length == 4 && self.ipv == 6
|
|
121
|
+
host_address = Rex::Socket.getaddress(host, true)
|
|
122
|
+
host = '::ffff:' + host_address unless host_address.downcase.start_with?('::ffff:')
|
|
108
123
|
end
|
|
124
|
+
begin
|
|
125
|
+
super(mesg, flags, Rex::Socket.to_sockaddr(host, port))
|
|
126
|
+
rescue ::Errno::EHOSTUNREACH, ::Errno::ENETDOWN, ::Errno::ENETUNREACH, ::Errno::ENETRESET,
|
|
127
|
+
::Errno::EHOSTDOWN, ::Errno::EACCES, ::Errno::EINVAL, ::Errno::EADDRNOTAVAIL
|
|
128
|
+
nil
|
|
129
|
+
end
|
|
130
|
+
elsif host
|
|
131
|
+
super(mesg, flags, host)
|
|
132
|
+
else
|
|
133
|
+
super(mesg, flags)
|
|
109
134
|
end
|
|
110
|
-
|
|
111
|
-
begin
|
|
112
|
-
send(gram, flags, Rex::Socket.to_sockaddr(peerhost, peerport))
|
|
113
|
-
rescue ::Errno::EHOSTUNREACH,::Errno::ENETDOWN,::Errno::ENETUNREACH,::Errno::ENETRESET,::Errno::EHOSTDOWN,::Errno::EACCES,::Errno::EINVAL,::Errno::EADDRNOTAVAIL
|
|
114
|
-
return nil
|
|
115
|
-
end
|
|
116
|
-
|
|
117
135
|
end
|
|
118
136
|
|
|
119
137
|
#
|
data/lib/rex/socket/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.68
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Metasploit Hackers
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|