Module: Dap::Filter::BaseVulnMatch

Included in:
FilterVulnMatchHTTP, FilterVulnMatchIPMI, FilterVulnMatchMSSQL, FilterVulnMatchUPNP
Defined in:
lib/dap/filter/vulnmatch.rb

Instance Method Summary collapse

Instance Method Details

#lookup(hash, service) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dap/filter/vulnmatch.rb', line 19

def lookup(hash, service)
  SEARCHES[service].each do | entry |
    if hash[entry[:hash_key]]
      res = entry[:cvemap][hash[entry[:hash_key]]]
      if res
        hash[entry[:output_key]] = res
      end
    end
  end
  hash
end

#search(hash, service) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dap/filter/vulnmatch.rb', line 7

def search(hash, service)
  SEARCHES[service].each do | entry |
    entry[:regex].each do | regex, value |
      if regex =~ hash[entry[:hash_key]].force_encoding('BINARY')
        # Handle cases that could be multiple hits, not for upnp but could be others.
        hash[entry[:output_key]] = ( hash[entry[:output_key]] ? hash[entry[:output_key]] + value : value )
      end
    end if hash[entry[:hash_key]]
  end
  hash
end