Module: Reaver
- Defined in:
- lib/reaver.rb,
lib/reaver/git.rb,
lib/reaver/walk.rb,
lib/reaver/banner.rb,
lib/reaver/version.rb,
lib/reaver/download.rb,
lib/reaver/metadata.rb,
lib/reaver/collection.rb
Overview
Defined Under Namespace
Classes: Collection, Git, MetaData, Walk
Constant Summary
collapse
- CACHE_DIR =
"#{ENV['HOME']}/.cache/reaver"
- WORKDIR =
ENV['XDG_CONFIG_HOME'] ? "#{ENV['XDG_CONFIG_HOME']}/reaver" : "#{ENV['HOME']}/.config/reaver"
- VERSION =
'0.20.1'
Class Method Summary
collapse
-
.agent_list ⇒ Object
-
.analyze_collection(info_next, forced = nil) ⇒ Object
-
.banner ⇒ Object
-
.collection_name(filename) ⇒ Object
-
.download(url, name, limit = 5) ⇒ Object
-
.get_the_file(res, dest) ⇒ Object
-
.just_add_ssl(http_object) ⇒ Object
-
.load_collection(pathname) ⇒ Object
-
.load_metadata(workdir, collection) ⇒ Object
-
.main ⇒ Object
-
.response_stuff(http, request, dest, limit) ⇒ Object
-
.time_to_download(workdir, collection, metadata) ⇒ Object
Class Method Details
.agent_list ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/reaver/download.rb', line 60
def agent_list
ag = ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.10 Safari/605.1.1',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.3',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.3',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.3',
'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']
ag.sample
end
|
.analyze_collection(info_next, forced = nil) ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/reaver.rb', line 66
def analyze_collection(info_next, forced = nil)
next_download = info_next
force_download = forced || false
return true if next_download < Time.new || force_download
puts " > Next download > #{next_download}"
false
end
|
.banner ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/reaver/banner.rb', line 5
def self.banner
<<~BANNER
____, ____, ____,__ _,____,____,
(-|__)(-|_, (-/_|(-\\ /(-|_,(-|__)
_| \\,_|__,_/ |, _\\/ _|__,_| \\,
( ( ( ( ( (
BANNER
end
|
.collection_name(filename) ⇒ Object
60
61
62
63
64
|
# File 'lib/reaver.rb', line 60
def collection_name(filename)
name = filename.split('/').last
name = name.split('.').first
"#{CACHE_DIR}/#{name}"
end
|
.download(url, name, limit = 5) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/reaver/download.rb', line 12
def download(url, name, limit = 5)
dest = name
url = URI.parse(url)
raise ArgumentError, 'url was invalid' unless url.respond_to?(:open)
raise ArgumentError, 'too many HTTP redirects' if limit.zero?
http_object = Net::HTTP.new(url.host, url.port)
just_add_ssl(http_object) http_object.start do |http|
request = Net::HTTP::Get.new(url.request_uri, { 'user-agent' => agent_list })
response_stuff(http, request, dest, limit)
end
end
|
.get_the_file(res, dest) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/reaver/download.rb', line 46
def get_the_file(res, dest)
Whirly.start do
Whirly.status = "Downloading #{dest}"
File.binwrite(dest, res.read_body)
end
end
|
.just_add_ssl(http_object) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/reaver/download.rb', line 38
def just_add_ssl(http_object)
store = OpenSSL::X509::Store.new
store.set_default_paths
http_object.use_ssl = true
http_object.verify_mode = OpenSSL::SSL::VERIFY_PEER
http_object.cert_store = store
end
|
.load_collection(pathname) ⇒ Object
47
48
49
50
51
|
# File 'lib/reaver.rb', line 47
def load_collection(pathname)
collection = Collection.new(pathname)
collection.load_yaml
collection
end
|
53
54
55
56
57
58
|
# File 'lib/reaver.rb', line 53
def load_metadata(workdir, collection)
FileUtils.mkdir_p(workdir)
md = MetaData.new(workdir, collection)
md.load_yaml
md
end
|
.main ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/reaver.rb', line 31
def main
Dir.glob("#{WORKDIR}/*.yml").each do |f|
workdir = collection_name(f)
collection = load_collection(f)
next unless collection.tasks
metadata = load_metadata(workdir, collection)
if analyze_collection(metadata.info['next'], collection.tasks['force_download'])
time_to_download(workdir, collection, metadata)
end
metadata.save_yaml
end
end
|
.response_stuff(http, request, dest, limit) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/reaver/download.rb', line 26
def response_stuff(http, request, dest, limit)
http.read_timeout = 500
http.request request do |response|
case response
when Net::HTTPSuccess then get_the_file(response, dest)
when Net::HTTPRedirection then download(response['location'], dest, limit - 1)
else
raise response.value
end
end
end
|
.time_to_download(workdir, collection, metadata) ⇒ Object
75
76
77
78
79
|
# File 'lib/reaver.rb', line 75
def time_to_download(workdir, collection, metadata)
FileUtils.chdir(workdir)
collection.launch(metadata)
end
|