ryo 0.1.0

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.
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thread"
4
+ require "thread/pool"
5
+
6
+ module Ryo
7
+ module Plugin
8
+ class Dir
9
+ attr_reader :uri, :threads
10
+ def initialize(uri)
11
+ @uri = uri.is_a?(URI::HTTP) ? uri : URI.parse(uri)
12
+ @threads = 10
13
+ end
14
+
15
+ def paths
16
+ File.readlines(File.expand_path("./aux/paths.txt", __dir__)).map(&:chomp).compact
17
+ end
18
+
19
+ def url_for(path)
20
+ "#{uri.scheme}://#{uri.host}:#{uri.port}/#{path}"
21
+ end
22
+
23
+ def discover
24
+ pool = Thread.pool(threads)
25
+ results = []
26
+ paths.map { |path| url_for(path) }.each do |url|
27
+ pool.process {
28
+ res = Client.http.get(url)
29
+ results << url if res.code == 200
30
+ }
31
+ end
32
+ pool.shutdown
33
+ results
34
+ end
35
+
36
+ def self.discover(uri)
37
+ new(uri).discover
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "subdomain/base"
4
+ require_relative "subdomain/dnsdumpster"
5
+ require_relative "subdomain/find_subdomains"
6
+
7
+ module Ryo
8
+ module Plugin
9
+ module Subdomain
10
+ def self.discover(fld)
11
+ subdomains = []
12
+ subdomains << DNSDumpster.discover(fld)
13
+ subdomains << FindSubDomains.discover(fld)
14
+ subdomains.flatten.uniq.sort_by { |e| e[:domain] }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryo
4
+ module Plugin
5
+ module Subdomain
6
+ class Base
7
+ attr_reader :fld
8
+ def initialize(fld)
9
+ @fld = fld
10
+ end
11
+
12
+ def endpoint
13
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
14
+ end
15
+
16
+ def fetch_body
17
+ res = Client.http.get("#{endpoint}/#{fld}")
18
+ res.body.to_s
19
+ end
20
+
21
+ def doc
22
+ @doc ||= Oga.parse_html(fetch_body)
23
+ end
24
+
25
+ def parse
26
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
27
+ end
28
+
29
+ def discover
30
+ parse
31
+ end
32
+
33
+ def self.discover(fld)
34
+ new(fld).discover
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryo
4
+ module Plugin
5
+ module Subdomain
6
+ class DNSDumpster < Base
7
+ def endpoint
8
+ "https://dnsdumpster.com"
9
+ end
10
+
11
+ def fetch_body
12
+ res = Client.http.get(endpoint)
13
+ csrftoken = res.cookies.find { |c| c.name == "csrftoken" }.value
14
+ params = { csrfmiddlewaretoken: csrftoken, targetip: fld }
15
+
16
+ res = Client.http.cookies(csrftoken: csrftoken).headers(referer: endpoint).post(endpoint, form: params)
17
+ res.body.to_s
18
+ end
19
+
20
+ def parse
21
+ tables = doc.css("table.table")
22
+ return [] if tables.empty?
23
+ table = tables.last
24
+ table.css("tr").map do |row|
25
+ cols = row.css("td")
26
+ domain = cols.first.text.lines.first.chomp
27
+ ip = cols[1].text.lines.first.chomp
28
+ { domain: domain, ip: ip }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryo
4
+ module Plugin
5
+ module Subdomain
6
+ class FindSubDomains < Base
7
+ def endpoint
8
+ "https://findsubdomains.com/subdomains-of"
9
+ end
10
+
11
+ def parse
12
+ table = doc.at_css("table#table-view")
13
+ return [] if table.nil?
14
+ table.css("tr")[1..-1].map do |row|
15
+ cols = row.css("td")
16
+ domain = cols.first.at_css("a")&.text&.strip
17
+ ip = cols[1].at_css("a").nil? ? "N/A" : cols[1].at_css("a").text.strip
18
+ { domain: domain, ip: ip }
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "whatweb"
4
+
5
+ module Ryo
6
+ module Plugin
7
+ class Tech
8
+ def self.discover(uri)
9
+ target = WhatWeb::Target.new(uri)
10
+ plugins = WhatWeb::PluginManager.load_plugins
11
+ results = {}
12
+ plugins.each do |name, plugin|
13
+ result = plugin.execute(target)
14
+ results[name] = result unless result.empty?
15
+ end
16
+ results
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,64 @@
1
+ module Ryo
2
+ module Plugin
3
+ class Whois
4
+ attr_reader :domain
5
+ def initialize(domain)
6
+ @domain = domain
7
+ end
8
+
9
+ def endpoint
10
+ "https://domainbigdata.com"
11
+ end
12
+
13
+ def fetch_body
14
+ res = Client.http.get("#{endpoint}/#{domain}")
15
+ res.body.to_s
16
+ end
17
+
18
+ def doc
19
+ @doc ||= Oga.parse_html(fetch_body)
20
+ end
21
+
22
+ def parse
23
+ h = {}
24
+ h[:globa_stats] = globa_stats
25
+ h[:registrant] = registrant
26
+ h
27
+ end
28
+
29
+ def globa_stats
30
+ h = {}
31
+ h[:title] = doc.at_css("#trTitle > td:nth-child(2)")&.text
32
+ h[:date_creation] = doc.at_css("#trDateCreation > td:nth-child(2)")&.text
33
+ h[:date_creation] = doc.at_css("#trDateCreation > td:nth-child(2)")&.text
34
+ h[:web_age] = doc.at_css("#trWebAge > td:nth-child(2)")&.text
35
+ h[:ip] = doc.at_css("#trIP > td:nth-child(2)")&.text
36
+ h[:ip_geolocation] = doc.at_css("#trIPGeolocation > td:nth-child(2)")&.text&.strip
37
+ h.compact
38
+ end
39
+
40
+ def registrant
41
+ h = {}
42
+ h[:name] = doc.at_css("#trRegistrantName > td:nth-child(2) > a")&.text
43
+ h[:organization] = doc.at_css("#MainMaster_trRegistrantOrganization > td:nth-child(2) > a")&.text
44
+ h[:email] = doc.at_css("#trRegistrantEmail > td:nth-child(2)")&.text
45
+ h[:address] = doc.at_css("#trRegistrantAddress > td:nth-child(2)")&.text
46
+ h[:city] = doc.at_css("#trRegistrantCity > td:nth-child(2)")&.text
47
+ h[:state] = doc.at_css("#trRegistrantState > td:nth-child(2)")&.text
48
+ h[:country] = doc.at_css("#trRegistrantCountry > td:nth-child(2)")&.text
49
+ h[:phone] = doc.at_css("#trRegistrantTel > td:nth-child(2)")&.text
50
+ h[:fax] = doc.at_css("#trRegistrantFax > td:nth-child(2)")&.text
51
+ h[:private] = doc.at_css("#MainMaster_divRegistrantIDCard > div:nth-child(4) > table > tbody > tr:nth-child(10) > td:nth-child(2)")&.text
52
+ h.compact
53
+ end
54
+
55
+ def discover
56
+ parse
57
+ end
58
+
59
+ def self.discover(domain)
60
+ new(domain).discover
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ipaddr"
4
+
5
+ module Ryo
6
+ class Target
7
+ attr_reader :uri, :domain
8
+ def initialize(uri)
9
+ @uri = URI.parse(uri)
10
+ @domain = @uri.host
11
+ end
12
+
13
+ def fld
14
+ @fld ||= String.new.tap do |out|
15
+ removed_tlds_domain = domain.gsub(tlds_regexp, "")
16
+ # test.com => ["test"]
17
+ # dev.test.com => ["dev", "test"]
18
+ parts = removed_tlds_domain.split(".")
19
+ if parts.length == 1 || ip?
20
+ out << domain
21
+ else
22
+ idx = domain.split(".").index(parts.last)
23
+ out << domain.split(".")[idx..-1].join(".")
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def tlds
31
+ File.readlines(File.expand_path("./aux/tlds.txt", __dir__)).map(&:chomp).compact
32
+ end
33
+
34
+ def tlds_regexp
35
+ Regexp.new tlds.map { |domain| "#{domain.split('.').join('\\.')}$" }.join("|")
36
+ end
37
+
38
+ def ip?
39
+ IPAddr.new(domain.to_s)
40
+ true
41
+ rescue IPAddr::InvalidAddressError => _
42
+ false
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ryo
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "ryo/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "ryo"
9
+ spec.version = Ryo::VERSION
10
+ spec.authors = ["Manabu Niseki"]
11
+ spec.email = ["manabu.niseki@gmail.com"]
12
+
13
+ spec.summary = "Ryo is a yet another website recon tool."
14
+ spec.description = "Ryo is a yet another website recon tool."
15
+ spec.homepage = "https://github.com/ninoseki/ryo"
16
+ spec.license = "MIT"
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "coveralls", "~> 0.8"
29
+ spec.add_development_dependency "glint", "~> 0.1"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "vcr", "~> 4.0"
33
+ spec.add_development_dependency "webmock", "~> 3.4"
34
+
35
+ spec.add_dependency "http", "~> 3.3"
36
+ spec.add_dependency "oga", "~> 2.15"
37
+ spec.add_dependency "simple_whatweb", "~> 0.2"
38
+ spec.add_dependency "thor", "~> 0.19"
39
+ spec.add_dependency "thread", "~> 0.2.2"
40
+ end
metadata ADDED
@@ -0,0 +1,240 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ryo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manabu Niseki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-09-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: glint
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: http
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.3'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: oga
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.15'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.15'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simple_whatweb
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.2'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.2'
153
+ - !ruby/object:Gem::Dependency
154
+ name: thor
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.19'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.19'
167
+ - !ruby/object:Gem::Dependency
168
+ name: thread
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.2.2
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.2.2
181
+ description: Ryo is a yet another website recon tool.
182
+ email:
183
+ - manabu.niseki@gmail.com
184
+ executables:
185
+ - ryo
186
+ extensions: []
187
+ extra_rdoc_files: []
188
+ files:
189
+ - ".gitignore"
190
+ - ".rspec"
191
+ - ".travis.yml"
192
+ - Gemfile
193
+ - LICENSE
194
+ - README.md
195
+ - Rakefile
196
+ - bin/console
197
+ - bin/setup
198
+ - exe/ryo
199
+ - lib/ryo.rb
200
+ - lib/ryo/aux/tlds.txt
201
+ - lib/ryo/cli.rb
202
+ - lib/ryo/client.rb
203
+ - lib/ryo/error.rb
204
+ - lib/ryo/plugin.rb
205
+ - lib/ryo/plugin/aux/paths.txt
206
+ - lib/ryo/plugin/dir.rb
207
+ - lib/ryo/plugin/subdomain.rb
208
+ - lib/ryo/plugin/subdomain/base.rb
209
+ - lib/ryo/plugin/subdomain/dnsdumpster.rb
210
+ - lib/ryo/plugin/subdomain/find_subdomains.rb
211
+ - lib/ryo/plugin/tech.rb
212
+ - lib/ryo/plugin/whois.rb
213
+ - lib/ryo/target.rb
214
+ - lib/ryo/version.rb
215
+ - ryo.gemspec
216
+ homepage: https://github.com/ninoseki/ryo
217
+ licenses:
218
+ - MIT
219
+ metadata: {}
220
+ post_install_message:
221
+ rdoc_options: []
222
+ require_paths:
223
+ - lib
224
+ required_ruby_version: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ required_rubygems_version: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ requirements: []
235
+ rubyforge_project:
236
+ rubygems_version: 2.7.6
237
+ signing_key:
238
+ specification_version: 4
239
+ summary: Ryo is a yet another website recon tool.
240
+ test_files: []