reaver 0.18.1 → 0.19.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 137f52f4df99e56407d711cf500344f4d6dbd77616b3ff9a4bcabe4ad973ea68
4
- data.tar.gz: 3d308ca92833ad46fe7cc90c7d77b356a58619dc630c73d9440db8e60ad1b77b
3
+ metadata.gz: 6834d2796f8a39032bde1bca4048096894c9eee6f86ba94827d91c602bd77472
4
+ data.tar.gz: 36930811fdab7dcc96659fe57d65197211111eb1b571d9a0cb17b34d3a13a503
5
5
  SHA512:
6
- metadata.gz: 98b0be9ab2dbf8681de1b09a790d5b9407f4e229bb072da470cae53bb941b7c39ddaef0f01e5a5aae442270e790891e95865cc37e2a5b9b555a83ca035724c44
7
- data.tar.gz: 072eedc65a9875d449e9d60b29a238ed2e7fdcb71c3d6f0f061ff77eb855fd61e3d3065de73f4429d5efcac05fbf625ac51591bd9aba7d5605df99ce5cb549a9
6
+ metadata.gz: e6a5baf04b9dfd95ae78faff572036a085917e97b23bd6d5fb486aa46d71b6aa6f89df684038e5714ed0e6a613ef8f968bed8e2d8d418f89e48b17d4cb3c572c
7
+ data.tar.gz: 9063460fa6da35548ff7e1834e2e3f110c0fdc1046296a9c9b7107c4f91837ab1d9570ebb92bca1c0569c4b6959151fb01d38e7ae2200b87c677c6860449ad51
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
- ## 0.18.1
1
+ ## 0.19.1
2
2
 
3
+ - Download with net/http(s) instead of open-uri
3
4
  - Remove threading, need more test.
4
5
 
5
6
  ## 0.18.0 - Oct. 2025
@@ -2,26 +2,56 @@
2
2
 
3
3
  require 'open-uri'
4
4
  require 'net/http'
5
- require 'tempfile'
6
- require 'fileutils'
5
+ require 'net/https'
7
6
 
8
7
  # Download link
9
8
  module Reaver
10
9
  module_function
11
10
 
12
- def download(url, name)
11
+ # https://github.com/ruby/open-uri/blob/master/lib/open-uri.rb
12
+ def download(url, name, limit = 5)
13
13
  dest = name
14
- url = URI(url)
15
- raise Error, 'url was invalid' unless url.respond_to?(:open)
14
+ url = URI.parse(url)
15
+ raise ArgumentError, 'url was invalid' unless url.respond_to?(:open)
16
+ raise ArgumentError, 'too many HTTP redirects' if limit.zero?
16
17
 
17
- options = {}
18
+ http_object = Net::HTTP.new(url.host, url.port)
19
+ just_add_ssl(http_object) # if url.scheme == 'https'
20
+ http_object.start do |http|
21
+ request = Net::HTTP::Get.new(url.request_uri, { 'user-agent' => agent_list })
22
+ response_stuff(http, request, dest, limit)
23
+ end
24
+ end
25
+
26
+ def response_stuff(http, request, dest, limit)
27
+ http.read_timeout = 500
28
+ http.request request do |response|
29
+ case response
30
+ when Net::HTTPSuccess then get_the_file(response, dest)
31
+ when Net::HTTPRedirection then download(response['location'], dest, limit - 1)
32
+ else
33
+ raise response.value
34
+ end
35
+ end
36
+ end
18
37
 
38
+ def just_add_ssl(http_object)
39
+ store = OpenSSL::X509::Store.new
40
+ store.set_default_paths
41
+ http_object.use_ssl = true
42
+ http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER
43
+ http_object.cert_store = store
44
+ end
45
+
46
+ def get_the_file(res, dest)
19
47
  Whirly.start do
20
48
  Whirly.status = "Downloading #{dest}"
21
- options['User-Agent'] = agent_list
22
- downloaded_file = URI.open(url, options)
23
-
24
- get_the_link(downloaded_file, dest)
49
+ File.binwrite(dest, res.read_body)
50
+ # open(dest, 'wb') do |io|
51
+ # res.read_body do |chunk|
52
+ # io.write chunk
53
+ # end
54
+ # end
25
55
  end
26
56
  end
27
57
 
@@ -35,18 +65,4 @@ module Reaver
35
65
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Trailer/93.3.8652.5']
36
66
  ag.sample
37
67
  end
38
-
39
- def get_the_link(file, dest)
40
- # open-uri will return a StringIO instead of a Tempfile if the filesize
41
- # is less than 10 KB, so we patch this behaviour by converting it into
42
- # a Tempfile.
43
- if file.is_a?(StringIO)
44
- tempfile = Tempfile.new('open-uri', binmode: true)
45
- IO.copy_stream(file, tempfile.path)
46
- FileUtils.mv tempfile.path, dest
47
- else
48
- IO.copy_stream(file, dest)
49
- end
50
- file
51
- end
52
68
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reaver
4
- VERSION = '0.18.1'
4
+ VERSION = '0.19.1'
5
5
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
metadata.gz.sig CHANGED
Binary file