Class: WhatWeb::Plugin
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#dorks ⇒ Object
readonly
Returns the value of attribute dorks.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#website ⇒ Object
readonly
Returns the value of attribute website.
Class Method Summary collapse
Instance Method Summary collapse
- #aggressive(_target) ⇒ Object
- #execute(target, is_aggressive = false) ⇒ Object
-
#initialize(name, &block) ⇒ Plugin
constructor
A new instance of Plugin.
- #lock ⇒ Object
- #locked? ⇒ Boolean
- #matchers(target, match) ⇒ Object
- #matching(target, match) ⇒ Object
- #passive(_target) ⇒ Object
- #randstr ⇒ Object
-
#shutdown ⇒ Object
individual plugins can override this.
-
#startup ⇒ Object
individual plugins can override this.
- #unlock ⇒ Object
- #version_detection? ⇒ Boolean
Constructor Details
#initialize(name, &block) ⇒ Plugin
Returns a new instance of Plugin.
9 10 11 12 13 14 |
# File 'lib/whatweb/plugin.rb', line 9 def initialize(name, &block) @name = name @locked = false instance_eval(&block) startup end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def @author end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def description @description end |
#dorks ⇒ Object (readonly)
Returns the value of attribute dorks.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def dorks @dorks end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def matches @matches end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def version @version end |
#website ⇒ Object (readonly)
Returns the value of attribute website.
8 9 10 |
# File 'lib/whatweb/plugin.rb', line 8 def website @website end |
Class Method Details
.define(name, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/whatweb/plugin.rb', line 16 def self.define(name, &block) plugin = new(name, &block) PluginManager.instance.add_plugin plugin plugin end |
Instance Method Details
#aggressive(_target) ⇒ Object
36 37 38 |
# File 'lib/whatweb/plugin.rb', line 36 def aggressive(_target) [] end |
#execute(target, is_aggressive = false) ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/whatweb/plugin.rb', line 91 def execute(target, is_aggressive = false) results = [] results += matches.map { |match| matching(target, match) } if matches results += passive(target) results += aggressive(target) if is_aggressive results.flatten! results.compact! results.each { |result| result[:certainty] = 100 unless result.key?(:certainty) } results end |
#lock ⇒ Object
40 41 42 |
# File 'lib/whatweb/plugin.rb', line 40 def lock @locked = true end |
#locked? ⇒ Boolean
48 49 50 |
# File 'lib/whatweb/plugin.rb', line 48 def locked? @locked end |
#matchers(target, match) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/whatweb/plugin.rb', line 56 def matchers(target, match) { ghdb: Matcher::GHDB.new(target, match), text: Matcher::Text.new(target, match), md5: Matcher::MD5.new(target, match), tag_pattern: Matcher::TagPattern.new(target, match), regexp: Matcher::Common.new(target, match), account: Matcher::Common.new(target, match), version: Matcher::Common.new(target, match), os: Matcher::Common.new(target, match), module: Matcher::Common.new(target, match), model: Matcher::Common.new(target, match), string: Matcher::Common.new(target, match), firmware: Matcher::Common.new(target, match), filepath: Matcher::Common.new(target, match), } end |
#matching(target, match) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/whatweb/plugin.rb', line 74 def matching(target, match) results = [] matchers(target, match).each do |key, matcher| next unless match.key?(key) && matcher.match? results << match # if a matcher is the common matcher, replace the key's value to the regexp match result results.last[key] = matcher.match_results if common_matcher?(matcher) end # return results if there is any match so far return results if results # if url and status are present, they must both match # url and status cannot be alone. there must be something else that has already matched results << match if Matcher::Status.match?(target, match) results << match if Matcher::URL.match?(target, match) results end |
#passive(_target) ⇒ Object
32 33 34 |
# File 'lib/whatweb/plugin.rb', line 32 def passive(_target) [] end |
#randstr ⇒ Object
52 53 54 |
# File 'lib/whatweb/plugin.rb', line 52 def randstr rand(36**8).to_s(36) end |
#shutdown ⇒ Object
individual plugins can override this
30 |
# File 'lib/whatweb/plugin.rb', line 30 def shutdown; end |
#startup ⇒ Object
individual plugins can override this
27 |
# File 'lib/whatweb/plugin.rb', line 27 def startup; end |
#unlock ⇒ Object
44 45 46 |
# File 'lib/whatweb/plugin.rb', line 44 def unlock @locked = false end |
#version_detection? ⇒ Boolean
22 23 24 |
# File 'lib/whatweb/plugin.rb', line 22 def version_detection? matches.any? { |match| match.key? :version } end |