simple_whatweb 0.3.0 → 0.4.0

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: dc8a116eb5a0ba92f6c846d78124f349204dd2716da9d04f968bc0b9a2e0856e
4
- data.tar.gz: caf26d9f9c8ba4f3bf91b0968d1bb188b3535a06be57889e612756e91711a2e0
3
+ metadata.gz: e379339998ec6d96d736a6fc0224913cca8b7bc04811a820e7b5488073bf2c73
4
+ data.tar.gz: 5c7d9ef2327082b1e252accf95159a57352f5518b6f013b97f89af5064d3e0b1
5
5
  SHA512:
6
- metadata.gz: c1398c10d4ac8a6cd4549ebe90e0da52a7fb025dc0c537dbdb05c42589c75579deee78ee9547467fd4274fb5f126948a9c97cab7b912fa76f0261309d3373045
7
- data.tar.gz: b0822fe238bc0664bdaf74501c3ac0fb188ec56bb03313866be5f36323c0ab5482f73825496a1fab050d403ca6e57266b552117cf141b23e50c0914efaff4b57
6
+ metadata.gz: a58bcaa3e6073c54cfd14e97eb8a3bd40f383f878ebcb1c51e620f4dd86b06680fa440b3fb4f9043e2dc156d587fa1270ef2c9050d07667932630fd169ae01d2
7
+ data.tar.gz: 2dc32cc469fd26d264d86f84da39fd793a0e6f1fefe84a5ec47ba2b65f1b66cedef93d7f3e413d5f64d21079dc09375ab2fe16302581a95e0da847fd0523ae08
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.16"
28
28
  spec.add_development_dependency "coveralls", "~> 0.8"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "rake", "~> 12.3"
30
+ spec.add_development_dependency "rspec", "~> 3.8"
31
31
  spec.add_development_dependency "vcr", "~> 4.0"
32
32
  spec.add_development_dependency "webmock", "~> 3.4"
33
33
 
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency "oga", "~> 2.15"
36
36
  spec.add_dependency "require_all", "~> 2.0"
37
37
  spec.add_dependency "thor", "~> 0.19"
38
+ spec.add_dependency "thread", "~> 0.2.2"
38
39
  end
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
2
5
 
3
6
  require "whatweb"
4
7
 
@@ -13,4 +13,39 @@ require "whatweb/matcher"
13
13
  require "whatweb/plugin"
14
14
  require "whatweb/cli"
15
15
 
16
- module WhatWeb; end
16
+ require "thread/pool"
17
+
18
+ module WhatWeb
19
+ def self.execute_plugins(url, options = {})
20
+ user_agent = options[:user_agent] || "WhatWeb/#{VERSION}"
21
+ is_aggressive = options[:is_aggressive] || false
22
+ max_threads = options[:max_threads] || 10
23
+
24
+ plugins = PluginManager.instance.load_plugins
25
+ target = Target.new(url, user_agent: user_agent)
26
+
27
+ pool = Thread.pool(max_threads)
28
+ results = {}
29
+ plugins.each do |name, plugin|
30
+ pool.process do
31
+ result = plugin.execute(target, is_aggressive)
32
+ results[name] = result unless result.empty?
33
+ end
34
+ end
35
+ pool.shutdown
36
+ results
37
+ end
38
+
39
+ def self.plugin_names
40
+ plugins = PluginManager.instance.load_plugins
41
+ plugins.map do |name, plugin|
42
+ {
43
+ name: name,
44
+ author: plugin.author.encode("UTF-8"),
45
+ description: plugin.description.encode("UTF-8"),
46
+ website: plugin.website,
47
+ version: plugin.version
48
+ }
49
+ end
50
+ end
51
+ end
@@ -3,17 +3,21 @@
3
3
  require "json"
4
4
  require "thor"
5
5
 
6
+ require "thread/pool"
7
+
6
8
  module WhatWeb
7
9
  class CLI < Thor
8
10
  desc "scan URL", "Scan against a given URL"
9
- method_options aggressive: :boolean, default: false
10
- method_options user_agent: :string
11
+ method_option :aggressive, type: :boolean, default: false
12
+ method_option :user_agent, type: :string
13
+ method_option :max_threads, type: :numeric, default: 10
11
14
  def scan(url)
12
15
  user_agent = options[:user_agent]
13
16
  is_aggressive = options[:aggressive]
17
+ max_threads = options[:max_threads]
14
18
 
15
19
  with_error_handling do
16
- hash = execute_plugins(url, user_agent: user_agent, is_aggressive: is_aggressive)
20
+ hash = WhatWeb.execute_plugins(url, user_agent: user_agent, is_aggressive: is_aggressive, max_threads: max_threads)
17
21
  puts hash.to_json
18
22
  end
19
23
  end
@@ -21,39 +25,11 @@ module WhatWeb
21
25
  desc "list_plugins", "List all plugins"
22
26
  def list_plugins
23
27
  with_error_handling do
24
- puts plugin_names.to_json
28
+ puts WhatWeb.plugin_names.to_json
25
29
  end
26
30
  end
27
31
 
28
32
  no_commands do
29
- def execute_plugins(url, options = {})
30
- user_agent = options[:user_agent]
31
- is_aggressive = options[:is_aggressive]
32
-
33
- plugins = PluginManager.instance.load_plugins
34
- target = Target.new(url, user_agent: user_agent)
35
-
36
- results = {}
37
- plugins.each do |name, plugin|
38
- result = plugin.execute(target, is_aggressive)
39
- results[name] = result unless result.empty?
40
- end
41
- results
42
- end
43
-
44
- def plugin_names
45
- plugins = PluginManager.instance.load_plugins
46
- plugins.map do |name, plugin|
47
- {
48
- name: name,
49
- author: plugin.author.encode("UTF-8"),
50
- description: plugin.description.encode("UTF-8"),
51
- website: plugin.website,
52
- version: plugin.version
53
- }
54
- end
55
- end
56
-
57
33
  def with_error_handling
58
34
  yield
59
35
  rescue StandardError => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhatWeb
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_whatweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-02 00:00:00.000000000 Z
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '12.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '3.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '3.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: vcr
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.19'
153
+ - !ruby/object:Gem::Dependency
154
+ name: thread
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.2.2
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.2.2
153
167
  description: Simplified ver. of WhatWeb.
154
168
  email:
155
169
  - manabu.niseki@gmail.com