simple_whatweb 0.2.1 → 0.3.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: fa93fc00fb8c3719932816eda5f66233849319c2c97536b74a9fd3590864f3ab
4
- data.tar.gz: a24e458f6488eeb31b5ca814b14af6662363b807d8f72f57053fe364f8f6aa41
3
+ metadata.gz: dc8a116eb5a0ba92f6c846d78124f349204dd2716da9d04f968bc0b9a2e0856e
4
+ data.tar.gz: caf26d9f9c8ba4f3bf91b0968d1bb188b3535a06be57889e612756e91711a2e0
5
5
  SHA512:
6
- metadata.gz: d42ceb9c118d0081712d4e5551b6899d0ec774af54ed3cf623744dbb59be8321ecdd785b32f3531a0a17ba7e4d0f77daa976bbf3fd1ea958b9bc84750a72d0a9
7
- data.tar.gz: 98609d498e9a948cf813d80031864f8d346905fecfa3e551497e970b2dff8f7525bb49b24d135baa67b97c3af523fc2b7701d00ab7fd3d7d1c95d721c8df9824
6
+ metadata.gz: c1398c10d4ac8a6cd4549ebe90e0da52a7fb025dc0c537dbdb05c42589c75579deee78ee9547467fd4274fb5f126948a9c97cab7b912fa76f0261309d3373045
7
+ data.tar.gz: b0822fe238bc0664bdaf74501c3ac0fb188ec56bb03313866be5f36323c0ab5482f73825496a1fab050d403ca6e57266b552117cf141b23e50c0914efaff4b57
@@ -7,10 +7,13 @@ module WhatWeb
7
7
  class CLI < Thor
8
8
  desc "scan URL", "Scan against a given URL"
9
9
  method_options aggressive: :boolean, default: false
10
+ method_options user_agent: :string
10
11
  def scan(url)
12
+ user_agent = options[:user_agent]
11
13
  is_aggressive = options[:aggressive]
14
+
12
15
  with_error_handling do
13
- hash = execute_plugins(url, is_aggressive)
16
+ hash = execute_plugins(url, user_agent: user_agent, is_aggressive: is_aggressive)
14
17
  puts hash.to_json
15
18
  end
16
19
  end
@@ -23,9 +26,12 @@ module WhatWeb
23
26
  end
24
27
 
25
28
  no_commands do
26
- def execute_plugins(url, is_aggressive = false)
29
+ def execute_plugins(url, options = {})
30
+ user_agent = options[:user_agent]
31
+ is_aggressive = options[:is_aggressive]
32
+
27
33
  plugins = PluginManager.instance.load_plugins
28
- target = Target.new(url)
34
+ target = Target.new(url, user_agent: user_agent)
29
35
 
30
36
  results = {}
31
37
  plugins.each do |name, plugin|
@@ -93,7 +93,6 @@ module WhatWeb
93
93
  results += matches.map { |match| matching(target, match) } if matches
94
94
  results += passive(target)
95
95
  results += aggressive(target) if is_aggressive
96
- # TODO: aggressive mode support
97
96
  results.flatten!
98
97
  results.compact!
99
98
  results.each { |result| result[:certainty] = 100 unless result.key?(:certainty) }
@@ -19,7 +19,7 @@ WhatWeb::Plugin.define "Allow" do
19
19
  m = []
20
20
 
21
21
  # Allow HTTP Header
22
- m << { module: target.headers["allow"].to_s } unless target.headers["allow"].nil?
22
+ m << { module: target.headers["allow"].to_s } if target.headers["allow"]
23
23
 
24
24
  m
25
25
  end
@@ -48,9 +48,7 @@ WhatWeb::Plugin.define "Apache-Tomcat" do
48
48
  new_target = WhatWeb::Target.new(new_url)
49
49
  if new_target.status == 404
50
50
  v = new_target.body.scan(/Apache Tomcat\/([456]\.\d+\.\d+)/)[0]
51
- unless v.nil?
52
- info << { name: "Tomcat version", certainty: 100, version: v }
53
- end
51
+ info << { name: "Tomcat version", certainty: 100, version: v } if v
54
52
  end
55
53
  info
56
54
  end
@@ -39,7 +39,7 @@ WhatWeb::Plugin.define "AppleIDiskServer" do
39
39
  m << { name: "WWW Authenticate" } if target.headers["www-authenticate"] =~ /Basic realm="me\.com"/
40
40
 
41
41
  # Account Detection # X-dmUser
42
- m << { account: target.headers["x-dmuser"] } unless target.headers["x-dmuser"].nil?
42
+ m << { account: target.headers["x-dmuser"] } if target.headers["x-dmuser"]
43
43
  end
44
44
 
45
45
  # Return passive matches
@@ -93,7 +93,7 @@ WhatWeb::Plugin.define "ASP_NET" do
93
93
  m = []
94
94
 
95
95
  # Version Detection # X-AspNetmvc-version HTTP header
96
- m << { string: "MVC" + target.headers['x-aspnetmvc-version'].to_s } unless target.headers['x-aspnetmvc-version'].nil?
96
+ m << { string: "MVC" + target.headers['x-aspnetmvc-version'].to_s } if target.headers['x-aspnetmvc-version']
97
97
 
98
98
  # Return passive results
99
99
  m
@@ -50,7 +50,7 @@ WhatWeb::Plugin.define "Atlassian-JIRA" do
50
50
  m << { name: "x-arequestid header" } if target.headers["x-arequestid"] =~ /^[\d]+x[\d]+x[\d]+$/
51
51
 
52
52
  # x-ausername
53
- m << { name: "x-ausername header" } unless target.headers["x-ausername"].nil?
53
+ m << { name: "x-ausername header" } if target.headers["x-ausername"]
54
54
 
55
55
  # atlassian.xsrf.token cookie
56
56
  m << { name: "atlassian.xsrf.token" } if target.headers["set-cookie"] =~ /atlassian\.xsrf\.token=/
@@ -47,10 +47,10 @@ WhatWeb::Plugin.define "Confluence" do
47
47
  m = []
48
48
 
49
49
  # x-confluence-cluster-node
50
- m << { name: "x-confluence-cluster-node header" } unless target.headers["x-confluence-cluster-node"].nil?
50
+ m << { name: "x-confluence-cluster-node header" } if target.headers["x-confluence-cluster-node"]
51
51
 
52
52
  # x-confluence-request-time
53
- m << { name: "x-confluence-request-time header" } unless target.headers["x-confluence-request-time"].nil?
53
+ m << { name: "x-confluence-request-time header" } if target.headers["x-confluence-request-time"]
54
54
 
55
55
  # Return passive matches
56
56
  m
@@ -80,9 +80,7 @@ WhatWeb::Plugin.define "Contao" do
80
80
  end
81
81
 
82
82
  # Set version if present
83
- unless version.nil?
84
- m << { name: "md5 sums of files", version: version }
85
- end
83
+ m << { name: "md5 sums of files", version: version } if version
86
84
 
87
85
  m
88
86
  end
@@ -15,7 +15,7 @@ WhatWeb::Plugin.define "PasswordField" do
15
15
  # Matches #
16
16
  @matches = [
17
17
 
18
- { name: "rss link type", regexp: /<input [^>]*?type=["']password["'][^>]*>/i },
18
+ { name: "input type", regexp: /<input [^>]*?type=["']password["'][^>]*>/i },
19
19
 
20
20
  ]
21
21
 
@@ -28,8 +28,8 @@ WhatWeb::Plugin.define "PasswordField" do
28
28
  field.scan(/name=["'](.*?)["']/i).first.first
29
29
  rescue StandardError
30
30
  nil
31
- end # rescues when there is no name= element
32
- m << { name: "field name", string: name } unless name.nil?
31
+ end
32
+ m << { name: "field name", string: name } if name
33
33
  end
34
34
  m
35
35
  end
@@ -92,9 +92,7 @@ WhatWeb::Plugin.define "PunBB" do
92
92
  end
93
93
 
94
94
  # Set version if present
95
- unless version.nil?
96
- m << { name: "md5 sums of files", version: version }
97
- end
95
+ m << { name: "md5 sums of files", version: version } if version
98
96
 
99
97
  # Return aggressive matches
100
98
  m
@@ -25,9 +25,7 @@ WhatWeb::Plugin.define "X-Powered-By" do
25
25
  m = []
26
26
 
27
27
  # X-Powered-By Headers
28
- unless target.headers["x-powered-by"].nil?
29
- m << { name: "x-powered-by string", string: target.headers["x-powered-by"] }
30
- end
28
+ m << { name: "x-powered-by string", string: target.headers["x-powered-by"] } if target.headers["x-powered-by"]
31
29
 
32
30
  # Return passive matches
33
31
  m
@@ -5,16 +5,18 @@ module WhatWeb
5
5
  using WhatWeb::Helper
6
6
 
7
7
  attr_accessor :response
8
+ attr_reader :user_agent
8
9
  attr_reader :url, :body, :headers, :raw_headers, :raw_response, :status, :uri
9
10
 
10
- def initialize(url, response = nil)
11
+ def initialize(url, opts = {})
11
12
  @url = url.to_s
12
- @response = response || open_url
13
+ @user_agent = opts[:user_agent] || "WhatWeb/#{VERSION}"
14
+ @response = opts[:response] || open_url
13
15
  build
14
16
  end
15
17
 
16
18
  def open_url
17
- HTTP.get url
19
+ HTTP.headers(user_agent: user_agent).get url
18
20
  end
19
21
 
20
22
  def build
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WhatWeb
4
- VERSION = "0.2.1"
4
+ VERSION = "0.3.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.2.1
4
+ version: 0.3.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-01 00:00:00.000000000 Z
11
+ date: 2018-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler