Files
metasploit-gs/lib/msf/core/module/author.rb
T

133 lines
3.3 KiB
Ruby
Raw Normal View History

2005-07-09 21:18:49 +00:00
require 'msf/core'
2005-06-05 00:03:23 +00:00
###
#
# This data type represents an author of a piece of code in either
# the framework, a module, a script, or something entirely unrelated.
#
###
class Msf::Module::Author
2005-11-24 05:13:40 +00:00
# A hash of known author names
Known =
{
2006-10-06 04:02:55 +00:00
'hdm' => 'hdm' + 0x40.chr + 'metasploit.com',
'spoonm' => 'spoonm' + 0x40.chr + 'no$email.com',
'skape' => 'mmiller' + 0x40.chr + 'hick.org',
'vlad902' => 'vlad902' + 0x40.chr + 'gmail.com',
'optyx' => 'optyx' + 0x40.chr + 'no$email.com',
'anonymous' => 'anonymous-contributor' + 0x40.chr + 'metasploit.com',
'stinko' => 'vinnie' + 0x40.chr + 'metasploit.com',
2009-01-02 12:22:35 +00:00
'MC' => 'mc' + 0x40.chr + 'metasploit.com',
2006-10-06 04:02:55 +00:00
'cazz' => 'bmc' + 0x40.chr + 'shmoo.com',
2007-05-14 21:00:46 +00:00
'pusscat' => 'pusscat' + 0x40.chr + 'metasploit.com',
2006-10-06 04:02:55 +00:00
'skylined' => 'skylined' + 0x40.chr + 'edup.tudelft.nl',
2007-09-26 13:44:25 +00:00
'patrick' => 'patrick' + 0x40.chr + 'aushack.com',
2008-02-09 04:35:21 +00:00
'ramon' => 'ramon' + 0x40.chr + 'risesecurity.org',
'I)ruid' => 'druid' + 0x40.chr + 'caughq.org',
'egypt' => 'egypt' + 0x40.chr + 'metasploit.com',
2009-04-03 15:05:35 +00:00
'kris katterjohn' => 'katterjohn' + 0x40.chr + 'gmail.com',
2009-04-12 02:00:50 +00:00
'CG' => 'cg' + 0x40.chr + 'carnal0wnage.com',
'et' => 'et' + 0x40.chr + 'metasploit.com',
'sf' => 'stephen_fewer' + 0x40.chr + 'harmonysecurity.com',
'kf' => 'kf_list' + 0x40.chr + 'digitalmunition.com',
'ddz' => 'ddz' + 0x40.chr + 'theta44.org'
2006-01-06 00:57:14 +00:00
}
2005-11-24 05:13:40 +00:00
2005-06-05 00:03:23 +00:00
#
# Class method that translates a string to an instance of the Author class,
# if it's of the right format, and returns the Author class instance
#
def self.from_s(str)
instance = self.new
# If the serialization fails...
if (instance.from_s(str) == false)
return nil
end
return instance
end
#
# Transforms the supplied source into an array of authors
#
def self.transform(src)
Rex::Transformer.transform(src, Array, [ self ], 'Author')
end
def initialize(name = nil, email = nil)
self.name = name
2005-11-24 05:13:40 +00:00
self.email = email || Known[name]
2005-06-05 00:03:23 +00:00
end
2005-07-10 00:16:48 +00:00
#
# Compares authors
#
def ==(tgt)
return (tgt.to_s == to_s)
end
2005-06-05 00:03:23 +00:00
#
# Serialize the author object to a string in form:
#
# name <email>
#
def to_s
str = "#{name}"
if (email and not email.empty?)
2005-06-05 00:03:23 +00:00
str += " <#{email}>"
end
return str
end
#
# Translate the author from the supplied string which may
# have either just a name or also an email address
#
def from_s(str)
2005-12-25 22:47:38 +00:00
# Supported formats:
# known_name
2009-01-14 15:17:03 +00:00
# user [at/@] host [dot/.] tld
# Name <user [at/@] host [dot/.] tld>
2005-12-25 22:47:38 +00:00
2007-09-26 13:44:25 +00:00
2005-12-25 22:47:38 +00:00
if ((m = str.match(/^\s*([^<]+)<([^>]+)>\s*$/)))
self.name = m[1].sub(/<.*/, '')
2009-01-14 15:17:03 +00:00
self.email = m[2].sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.')
2005-06-05 00:03:23 +00:00
else
2005-12-25 22:47:38 +00:00
if (Known[str])
self.email = Known[str]
self.name = str
2005-06-05 00:03:23 +00:00
else
2009-01-14 15:17:03 +00:00
self.email = str.sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.').gsub(/^<|>$/, '')
2005-12-25 22:47:38 +00:00
m = self.email.match(/([^@]+)@/)
self.name = m ? m[1] : nil
if(not (self.email and self.email.index('@')))
self.name = self.email
self.email = ''
end
2005-06-05 00:03:23 +00:00
end
end
self.name.strip! if self.name
2007-09-26 13:44:25 +00:00
2005-06-05 00:03:23 +00:00
return true
end
2005-11-24 05:13:40 +00:00
#
# Sets the name of the author and updates the email if it's a known author.
#
def name=(name)
self.email = Known[name] if (Known[name])
@name = name
end
attr_accessor :email
attr_reader :name
end