Sha256: 752dccf60939bacda5c7ccbd75a2bc0b7d0dce35e13df992541ce7e718d39614

Contents?: true

Size: 1.33 KB

Versions: 58

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env ruby
require 'oj'

# Searches contains each of the services, within each service it contains
# a hash key that will be compared against each of the items in the
# regex hash, and if a hit is returned the value from the regex is inserted
# into the hash with the output_key as the key.
#
SEARCHES = {
    :upnp => {
      :hash_key   => 'data.upnp_server',
      :output_key => 'vulnerability',
      :regex      => {
        /MiniUPnPd\/1\.0([\.\,\-\~\s]|$)/mi     => ['CVE-2013-0229'],
        /MiniUPnPd\/1\.[0-3]([\.\,\-\~\s]|$)/mi => ['CVE-2013-0230'],
        /Intel SDK for UPnP devices.*|Portable SDK for UPnP devices(\/?\s*$|\/1\.([0-5]\..*|8\.0.*|(6\.[0-9]|6\.1[0-7])([\.\,\-\~\s]|$)))/mi => ['CVE-2012-5958', 'CVE-2012-5959']
      }
  }
}

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

$stdin.each_line do |line|
  json = Oj.load(line.unpack("C*").pack("C*").strip) rescue nil
  next unless json
  puts Oj.dump(search(json, :upnp))
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
dap-1.3.1 tools/upnp-vulns.rb
dap-1.3.0 tools/upnp-vulns.rb
dap-1.2.9 tools/upnp-vulns.rb
dap-1.2.8 tools/upnp-vulns.rb
dap-1.2.7 tools/upnp-vulns.rb
dap-1.2.6 tools/upnp-vulns.rb
dap-1.2.5 tools/upnp-vulns.rb
dap-1.2.4 tools/upnp-vulns.rb
dap-1.2.3 tools/upnp-vulns.rb
dap-1.2.2 tools/upnp-vulns.rb
dap-1.2.1 tools/upnp-vulns.rb
dap-1.2.0 tools/upnp-vulns.rb
dap-1.0.2 tools/upnp-vulns.rb
dap-1.0.1 tools/upnp-vulns.rb
dap-1.0.0 tools/upnp-vulns.rb
dap-0.1.24 tools/upnp-vulns.rb
dap-0.1.23 tools/upnp-vulns.rb
dap-0.1.22 tools/upnp-vulns.rb
dap-0.1.21 tools/upnp-vulns.rb
dap-0.1.20 tools/upnp-vulns.rb