rex-socket 0.1.25 → 0.1.26

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: 63508bcf572f70073bf97d0e02fefc113862dd596c349b698efadeaa39e1e684
4
- data.tar.gz: fc699f97f15cdf6301d484b5c26532c9177a4e58d4bef99ca9b7b4bd0833c8d8
3
+ metadata.gz: b0bf99960d66db7491db5490f75d4c87a8bfde429dcc76a4e4e1d07306cf61b8
4
+ data.tar.gz: 7e665ba1dba7574c1fa7adb9523b9e8781daff17185daef8300cc0d1f5cd8d0b
5
5
  SHA512:
6
- metadata.gz: e5e7ea9a929fa979e8155da874b4bb1f5f1f10157e4ce017e65a8384b7e6deb86e1b5b87e3513959e9fe306b9be8bf7ef0ec5472a865722c4cbb6dce7ee463af
7
- data.tar.gz: 34080d04f0950a7bfb43189c98390ed8e72dea4167b2f4bfa0ec186bd5ae2ce57cfcaff07788e34fc8ab9418c52861a5c2057668f42408b6619cb23e3526916b
6
+ metadata.gz: a15da2ba7b185bf822db6f467fde6ae641008861f2758c865b9c66b524904dffd02add948e18cb544105747aaf8ce5f90f3083c8eaa18ac84284917ff29fe9cf
7
+ data.tar.gz: c6585bddb9cc7b52f29f3d9f193200132801fbb141162550f9d6a9553af51a853a3946c3c42fca55dbaed217a88cd68372066db5d76a8bcbc356a780c6bde61a
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,57 @@
1
+ name: Verify
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '*'
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-16.04
14
+ timeout-minutes: 40
15
+
16
+ strategy:
17
+ fail-fast: true
18
+ matrix:
19
+ ruby:
20
+ - 2.5
21
+ - 2.6
22
+ - 2.7
23
+ - 3.0
24
+ test_cmd:
25
+ - bundle exec rspec
26
+
27
+ env:
28
+ RAILS_ENV: test
29
+
30
+ name: Ruby ${{ matrix.ruby }} - ${{ matrix.test_cmd }}
31
+ steps:
32
+ - name: Checkout code
33
+ uses: actions/checkout@v2
34
+
35
+ - uses: actions/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+
39
+ - name: Setup bundler
40
+ run: |
41
+ gem install bundler
42
+ - uses: actions/cache@v2
43
+ with:
44
+ path: vendor/bundle
45
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
46
+ restore-keys: |
47
+ ${{ runner.os }}-gems-
48
+ - name: Bundle install
49
+ run: |
50
+ bundle config path vendor/bundle
51
+ bundle install --jobs 4 --retry 3
52
+ - name: ${{ matrix.test_cmd }}
53
+ run: |
54
+ echo "${CMD}"
55
+ bash -c "${CMD}"
56
+ env:
57
+ CMD: ${{ matrix.test_cmd }}
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rex-socket.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'pry-byebug'
8
+ end
data/lib/rex/socket.rb CHANGED
@@ -174,7 +174,7 @@ module Socket
174
174
  end
175
175
 
176
176
  #
177
- # Wrapper for +::Socket.gethostbyname+ that takes special care to see if the
177
+ # Wrapper for +::Addrinfo.getaddrinfo+ that takes special care to see if the
178
178
  # supplied address is already an ASCII IP address. This is necessary to
179
179
  # prevent blocking while waiting on a DNS reverse lookup when we already
180
180
  # have what we need.
@@ -186,26 +186,14 @@ module Socket
186
186
  return [hostname]
187
187
  end
188
188
 
189
- res = ::Socket.gethostbyname(hostname)
190
- return [] if not res
189
+ res = ::Addrinfo.getaddrinfo(hostname, 0, ::Socket::AF_UNSPEC, ::Socket::SOCK_STREAM)
191
190
 
192
- # Shift the first three elements out, leaving just the list of
193
- # addresses
194
- res.shift # name
195
- res.shift # alias hostnames
196
- res.shift # address_family
191
+ res.map! do |address_info|
192
+ address_info.ip_address
193
+ end
197
194
 
198
- # Rubinius has a bug where gethostbyname returns dotted quads instead of
199
- # NBO, but that's what we want anyway, so just short-circuit here.
200
- if res[0] =~ MATCH_IPV4 || res[0] =~ MATCH_IPV6
201
- unless accept_ipv6
202
- res.reject!{ |ascii| ascii =~ MATCH_IPV6 }
203
- end
204
- else
205
- unless accept_ipv6
206
- res.reject!{ |nbo| nbo.length != 4 }
207
- end
208
- res.map!{ |nbo| self.addr_ntoa(nbo) }
195
+ unless accept_ipv6
196
+ res.reject! { |ascii| ascii =~ MATCH_IPV6 }
209
197
  end
210
198
 
211
199
  res
@@ -217,7 +205,9 @@ module Socket
217
205
  # not occur. This is done in order to prevent delays, such as would occur
218
206
  # on Windows.
219
207
  #
208
+ # @deprecated Please use {#getaddress}, {#resolv_nbo}, or similar instead.
220
209
  def self.gethostbyname(host)
210
+ warn "NOTE: #{self}.#{__method__} is deprecated, use getaddress, resolve_nbo, or similar instead. It will be removed in the next Major version"
221
211
  if is_ipv4?(host)
222
212
  return [ host, [], 2, host.split('.').map{ |c| c.to_i }.pack("C4") ]
223
213
  end
@@ -259,15 +249,18 @@ module Socket
259
249
  #
260
250
  # Resolves a host to raw network-byte order.
261
251
  #
262
- def self.resolv_nbo(host)
263
- self.gethostbyname( Rex::Socket.getaddress(host, true) )[3]
252
+ def self.resolv_nbo(host, accepts_ipv6 = true)
253
+ ip_address = Rex::Socket.getaddress(host, accepts_ipv6)
254
+ IPAddr.new(ip_address).hton
264
255
  end
265
256
 
266
257
  #
267
258
  # Resolves a host to raw network-byte order.
268
259
  #
269
260
  def self.resolv_nbo_list(host)
270
- Rex::Socket.getaddresses(host).map{|addr| self.gethostbyname(addr)[3] }
261
+ Rex::Socket.getaddresses(host).map do |addresses|
262
+ IPAddr.new(addresses).hton
263
+ end
271
264
  end
272
265
 
273
266
  #
@@ -1,5 +1,5 @@
1
1
  module Rex
2
2
  module Socket
3
- VERSION = "0.1.25"
3
+ VERSION = "0.1.26"
4
4
  end
5
5
  end
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.25
4
+ version: 0.1.26
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: 2020-11-30 00:00:00.000000000 Z
96
+ date: 2021-03-10 00:00:00.000000000 Z
97
97
  dependencies:
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rake
@@ -147,9 +147,9 @@ executables: []
147
147
  extensions: []
148
148
  extra_rdoc_files: []
149
149
  files:
150
+ - ".github/workflows/verify.yml"
150
151
  - ".gitignore"
151
152
  - ".rspec"
152
- - ".travis.yml"
153
153
  - CODE_OF_CONDUCT.md
154
154
  - Gemfile
155
155
  - LICENSE
metadata.gz.sig CHANGED
Binary file
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- sudo: false
2
- group: stable
3
- cache: bundler
4
- language: ruby
5
- rvm:
6
- - 2.7.2