Class: Msf::Module::SiteReference

Inherits:
Reference
  • Object
show all
Defined in:
lib/msf/core/module/reference.rb

Overview

A reference to a website.

Instance Attribute Summary collapse

Attributes inherited from Reference

#str

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Reference

#==

Constructor Details

#initialize(in_ctx_id = 'Unknown', in_ctx_val = '') ⇒ SiteReference

Initialize the site reference.


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/msf/core/module/reference.rb', line 91

def initialize(in_ctx_id = 'Unknown', in_ctx_val = '')
  self.ctx_id  = in_ctx_id
  self.ctx_val = in_ctx_val

  if (in_ctx_id == 'OSVDB')
    self.site = 'http://www.osvdb.org/' + in_ctx_val.to_s
  elsif (in_ctx_id == 'CVE')
    self.site = "http://cvedetails.com/cve/#{in_ctx_val.to_s}/"
  elsif (in_ctx_id == 'CWE')
    self.site = "http://cwe.mitre.org/data/definitions/#{in_ctx_val.to_s}.html"
  elsif (in_ctx_id == 'BID')
    self.site = 'http://www.securityfocus.com/bid/' + in_ctx_val.to_s
  elsif (in_ctx_id == 'MSB')
    self.site = 'http://technet.microsoft.com/en-us/security/bulletin/' + in_ctx_val.to_s
  elsif (in_ctx_id == 'EDB')
    self.site = 'http://www.exploit-db.com/exploits/' + in_ctx_val.to_s
  elsif (in_ctx_id == 'WVE')
    self.site = 'http://www.wirelessve.org/entries/show/WVE-' + in_ctx_val.to_s
  elsif (in_ctx_id == 'US-CERT-VU')
    self.site = 'http://www.kb.cert.org/vuls/id/' + in_ctx_val.to_s
  elsif (in_ctx_id == 'BPS')
    self.site = 'https://strikecenter.bpointsys.com/bps/advisory/BPS-' + in_ctx_val.to_s
  elsif (in_ctx_id == 'ZDI')
    self.site = 'http://www.zerodayinitiative.com/advisories/ZDI-' + in_ctx_val.to_s
  elsif (in_ctx_id == 'URL')
    self.site = in_ctx_val.to_s
  else
    self.site  = in_ctx_id
    self.site += " (#{in_ctx_val})" if (in_ctx_val)
  end
end

Instance Attribute Details

#ctx_idObject

The context identifier of the site, such as OSVDB.


152
153
154
# File 'lib/msf/core/module/reference.rb', line 152

def ctx_id
  @ctx_id
end

#ctx_valObject

The context value of the reference, such as MS02-039


156
157
158
# File 'lib/msf/core/module/reference.rb', line 156

def ctx_val
  @ctx_val
end

#siteObject

The site being referenced.


148
149
150
# File 'lib/msf/core/module/reference.rb', line 148

def site
  @site
end

Class Method Details

.from_a(ary) ⇒ Object

Initializes a site reference from an array. ary is the site and ary is the site context identifier, such as OSVDB.


82
83
84
85
86
# File 'lib/msf/core/module/reference.rb', line 82

def self.from_a(ary)
  return nil if (ary.length < 2)

  self.new(ary[0], ary[1])
end

.from_s(str) ⇒ Object

Class method that translates a URL into a site reference instance.


68
69
70
71
72
73
74
75
76
# File 'lib/msf/core/module/reference.rb', line 68

def self.from_s(str)
  instance = self.new

  if (instance.from_s(str) == false)
    return nil
  end

  return instance
end

Instance Method Details

#from_s(str) ⇒ Object

Serializes a site URL string.


133
134
135
136
137
138
139
140
141
142
143
# File 'lib/msf/core/module/reference.rb', line 133

def from_s(str)
  if (/(http:\/\/|https:\/\/|ftp:\/\/)/.match(str))
    self.site = str
    self.ctx_id  = 'URL'
    self.ctx_val = self.site
  else
    return false
  end

  return true
end

#to_sObject

Returns the absolute site URL.


126
127
128
# File 'lib/msf/core/module/reference.rb', line 126

def to_s
  return site || ''
end