Class: Watobo::PassiveCheck

Inherits:
Object
  • Object
show all
Extended by:
Subscriber
Includes:
Constants
Defined in:
lib/watobo/core/passive_check.rb

Overview

:nodoc: all

Constant Summary collapse

@@lock =
Mutex.new

Constants included from Constants

Constants::AC_GROUP_APACHE, Constants::AC_GROUP_DOMINO, Constants::AC_GROUP_ENUMERATION, Constants::AC_GROUP_FILE_INCLUSION, Constants::AC_GROUP_FLASH, Constants::AC_GROUP_GENERIC, Constants::AC_GROUP_JBOSS, Constants::AC_GROUP_JOOMLA, Constants::AC_GROUP_SAP, Constants::AC_GROUP_SQL, Constants::AC_GROUP_TYPO3, Constants::AC_GROUP_XSS, Constants::AUTH_TYPE_BASIC, Constants::AUTH_TYPE_DIGEST, Constants::AUTH_TYPE_NONE, Constants::AUTH_TYPE_NTLM, Constants::AUTH_TYPE_UNKNOWN, Constants::CHAT_SOURCE_AUTO_SCAN, Constants::CHAT_SOURCE_FUZZER, Constants::CHAT_SOURCE_INTERCEPT, Constants::CHAT_SOURCE_MANUAL, Constants::CHAT_SOURCE_MANUAL_SCAN, Constants::CHAT_SOURCE_PROXY, Constants::CHAT_SOURCE_UNDEF, Constants::DEFAULT_PORT_HTTP, Constants::DEFAULT_PORT_HTTPS, Constants::FINDING_TYPE_HINT, Constants::FINDING_TYPE_INFO, Constants::FINDING_TYPE_UNDEFINED, Constants::FINDING_TYPE_VULN, Constants::FIRST_TIME_FILE, Constants::GUI_REGULAR_FONT_SIZE, Constants::GUI_SMALL_FONT_SIZE, Constants::ICON_PATH, Constants::LOG_DEBUG, Constants::LOG_INFO, Constants::SCAN_CANCELED, Constants::SCAN_FINISHED, Constants::SCAN_PAUSED, Constants::SCAN_STARTED, Constants::TE_CHUNKED, Constants::TE_COMPRESS, Constants::TE_DEFLATE, Constants::TE_GZIP, Constants::TE_IDENTITY, Constants::TE_NONE, Constants::VULN_RATING_CRITICAL, Constants::VULN_RATING_HIGH, Constants::VULN_RATING_INFO, Constants::VULN_RATING_LOW, Constants::VULN_RATING_MEDIUM, Constants::VULN_RATING_UNDEFINED

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Subscriber

clearEvents, notify, subscribe

Constructor Details

#initialize(project) ⇒ PassiveCheck

Returns a new instance of PassiveCheck.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/watobo/core/passive_check.rb', line 90

def initialize(project)
  @project = project
  @enabled = true

#@event_dispatcher_listeners = Hash.new

  @info = {
      :check_name => '', # name of check which briefly describes functionality, will be used for tree and progress views
      :check_group => '', # groupname of check, will be used to group checks, e.g. :Generic, SAP, :Enumeration
      :description => '', # description of checkfunction
      :author => "not modified", # author of check
      :version => "unversioned", # check version
      :target => nil # reserved
  }

  @finding = {
      :title => 'untitled', # [String] title name, used for finding tree
      :check_pattern => nil, # [String] regex of vulnerability check if possible, will be used for highlighting
      :proof_pattern => nil, # [String] regex of finding proof if possible, will be used for highlighting
      :threat => '', # threat of vulnerability, e.g. loss of information
      :measure => '', # measure
      :class => "undefined", # [String] vulnerability class, e.g. Stored XSS, SQL-Injection, ...
      :subclass => nil, # reserved
      :type => FINDING_TYPE_UNDEFINED, # FINDING_TYPE_HINT, FINDING_TYPE_INFO, FINDING_TYPE_VULN
      :chat => nil, # related chat must be linked
      :rating => VULN_RATING_UNDEFINED, #
      :cvss => "n/a", # CVSS Base Vector
      :icon => nil, # Icon Type
      :timestamp => nil # timestamp
  }

end

Instance Attribute Details

#infoObject (readonly)

Returns the value of attribute info.



8
9
10
# File 'lib/watobo/core/passive_check.rb', line 8

def info
  @info
end

Instance Method Details

#addFinding(details) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/watobo/core/passive_check.rb', line 11

def addFinding(details)
  t = Time.now

  now = t.strftime("%m/%d/%Y@%H:%M:%S")
  @@lock.synchronize {

    new_details = Hash.new
    new_details.update(@finding)
    new_details.update(details)

    new_details[:tstamp] = now

    unless new_details.has_key?(:fid)

      id_string = ''

      id_string << new_details[:chat].request.url.to_s if new_details[:chat]
      id_string << new_details[:class] if new_details[:class]
      id_string << new_details[:title] if new_details[:title]
      id_string << new_details[:unique] if new_details[:unique]

      if id_string.empty? then
        id_string = rand(10000)
      end
      #puts "Finding #{id_string}"
      new_details[:fid] = Digest::MD5.hexdigest(id_string)
    end

    new_details[:module] = self.class.to_s

    if details[:debug] == true then
      puts "---"
      puts new_details[:class]
      puts new_details[:title]
      puts "---"
    end
    request = new_details[:chat].request
    response = new_details[:chat].response
    new_details[:chat_id] = new_details[:chat].id

    # shorten pattern here because of crash in FXRex:match with large patterns
    unless new_details[:proof_pattern].nil?
      new_details[:proof_pattern] = new_details[:proof_pattern].length > 128 ? new_details[:proof_pattern][0..127] : new_details[:proof_pattern]
    end
    unless new_details[:check_pattern].nil?
      new_details[:check_pattern] = new_details[:check_pattern].length > 128 ? new_details[:check_pattern][0..127] : new_details[:check_pattern]
    end

    new_details.delete(:chat)

    new_finding = Watobo::Finding.new(request, response, new_details)

    Watobo::Findings.add new_finding

    #@project.addFinding(new_finding)
    # notify(:new_finding, new_finding)
  }
end

#disableObject



82
83
84
# File 'lib/watobo/core/passive_check.rb', line 82

def disable
  @enable = false
end

#do_test(chat) ⇒ Object



86
87
88
# File 'lib/watobo/core/passive_check.rb', line 86

def do_test(chat)
  raise "function do_test not defined"
end

#enableObject



78
79
80
# File 'lib/watobo/core/passive_check.rb', line 78

def enable
  @enabled = true
end

#enabled=(status) ⇒ Object



74
75
76
# File 'lib/watobo/core/passive_check.rb', line 74

def enabled=(status)
  @enabled = status
end

#enabled?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/watobo/core/passive_check.rb', line 70

def enabled?
  @enabled
end