ryo 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ryo/aux/tlds.txt +2686 -1401
- data/lib/ryo/cli.rb +31 -6
- data/lib/ryo/error.rb +5 -1
- data/lib/ryo/version.rb +1 -1
- metadata +1 -1
data/lib/ryo/cli.rb
CHANGED
@@ -4,37 +4,62 @@ module Ryo
|
|
4
4
|
class CLI < Thor
|
5
5
|
desc "dir URL", "Discover directories and files belong to a given URL"
|
6
6
|
def dir(url)
|
7
|
-
hash =
|
7
|
+
hash = run_discovery(url, dir: true)
|
8
8
|
puts hash.to_json
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "subdomain URL", "Discover subdomains of a given URL"
|
12
12
|
def subdomain(url)
|
13
|
-
hash =
|
13
|
+
hash = run_discovery(url, subdomain: true)
|
14
14
|
puts hash.to_json
|
15
15
|
end
|
16
16
|
|
17
17
|
desc "tech URL", "Discover used technolgies of a given URL"
|
18
18
|
def tech(url)
|
19
|
-
hash =
|
19
|
+
hash = run_discovery(url, tech: true)
|
20
20
|
puts hash.to_json
|
21
21
|
end
|
22
22
|
|
23
23
|
desc "whois URL", "Discover whois information of a given URL"
|
24
24
|
def whois(url)
|
25
|
-
hash =
|
25
|
+
hash = run_discovery(url, whois: true)
|
26
|
+
puts hash.to_json
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "discover URL", "Run discovery plugin(s) against a given URL"
|
30
|
+
method_option :dir, type: :boolean, default: false
|
31
|
+
method_option :subdomain, type: :boolean, default: false
|
32
|
+
method_option :tech, type: :boolean, default: false
|
33
|
+
method_option :whois, type: :boolean, default: false
|
34
|
+
def discovery(url)
|
35
|
+
hash = run_discovery(url, options)
|
26
36
|
puts hash.to_json
|
27
37
|
end
|
28
38
|
|
29
39
|
desc "all URL", "Run all discovery plugins against a given URL"
|
30
40
|
def all(url)
|
31
|
-
hash =
|
41
|
+
hash = run_discovery(url, all: true)
|
32
42
|
puts hash.to_json
|
33
43
|
end
|
34
44
|
|
35
45
|
no_commands do
|
36
|
-
def
|
46
|
+
def validate_url(url)
|
47
|
+
uri = URI.parse(url)
|
48
|
+
raise InvalidURLError unless %w(http https).include?(uri.scheme)
|
49
|
+
end
|
50
|
+
|
51
|
+
def validate_options(options)
|
52
|
+
raise InvalidOptionsError unless options.any? { |_, v| v }
|
53
|
+
end
|
54
|
+
|
55
|
+
def run_discovery(url, options)
|
56
|
+
validate_url(url)
|
57
|
+
validate_options(options)
|
37
58
|
Ryo.discover url, options
|
59
|
+
rescue InvalidURLError => _
|
60
|
+
{ error: "Please input a valid URL" }
|
61
|
+
rescue InvalidOptionsError => _
|
62
|
+
{ error: "Please input at least one option" }
|
38
63
|
rescue StandardError => e
|
39
64
|
{ error: "Warning: #{e}" }
|
40
65
|
end
|
data/lib/ryo/error.rb
CHANGED
data/lib/ryo/version.rb
CHANGED