Class: Msf::Module::Author

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

Overview

This data type represents an author of a piece of code in either the framework, a module, a script, or something entirely unrelated.

Constant Summary collapse

Known =

A hash of known author names

{
  'amaloteaux'       => 'alex_maloteaux' + 0x40.chr + 'metasploit.com',
  'anonymous'        => 'anonymous-contributor' + 0x40.chr + 'metasploit.com',
  'bannedit'         => 'bannedit' + 0x40.chr + 'metasploit.com',
  'Carlos Perez'     => 'carlos_perez' + 0x40.chr + 'darkoperator.com',
  'cazz'             => 'bmc' + 0x40.chr + 'shmoo.com',
  'CG'               => 'cg' + 0x40.chr + 'carnal0wnage.com',
  'ddz'              => 'ddz' + 0x40.chr + 'theta44.org',
  'egypt'            => 'egypt' + 0x40.chr + 'metasploit.com',
  'et'               => 'et' + 0x40.chr + 'metasploit.com',
  'hdm'              => 'hdm' + 0x40.chr + 'metasploit.com',
  'I)ruid'           => 'druid' +  0x40.chr + 'caughq.org',
  'jcran'            => 'jcran' + 0x40.chr + 'metasploit.com',
  'jduck'            => 'jduck' + 0x40.chr + 'metasploit.com',
  'joev'             => 'joev' + 0x40.chr + 'metasploit.com',
  'juan vazquez'     => 'juan.vazquez' + 0x40.chr + 'metasploit.com',
  'kf'               => 'kf_list' + 0x40.chr + 'digitalmunition.com',
  'kris katterjohn'  => 'katterjohn' + 0x40.chr + 'gmail.com',
  'MC'               => 'mc' + 0x40.chr + 'metasploit.com',
  'msmith'           => 'msmith' + 0x40.chr + 'metasploit.com',
  'mubix'            => 'mubix' + 0x40.chr + 'hak5.org',
  'natron'           => 'natron' + 0x40.chr + 'metasploit.com',
  'optyx'            => 'optyx' + 0x40.chr + 'no$email.com',
  'patrick'          => 'patrick' + 0x40.chr + 'osisecurity.com.au',
  'pusscat'          => 'pusscat' + 0x40.chr + 'metasploit.com',
  'Ramon de C Valle' => 'rcvalle' + 0x40.chr + 'metasploit.com',
  'sf'               => 'stephen_fewer' + 0x40.chr + 'harmonysecurity.com',
  'sinn3r'           => 'sinn3r' + 0x40.chr + 'metasploit.com',
  'skape'            => 'mmiller' + 0x40.chr + 'hick.org',
  'skylined'         => 'skylined' + 0x40.chr + 'edup.tudelft.nl',
  'spoonm'           => 'spoonm' + 0x40.chr + 'no$email.com',
  'stinko'           => 'vinnie' + 0x40.chr + 'metasploit.com',
  'theLightCosine'   => 'theLightCosine' + 0x40.chr + 'metasploit.com',
  'todb'             => 'todb' + 0x40.chr + 'metasploit.com',
  'vlad902'          => 'vlad902' + 0x40.chr + 'gmail.com',
  'wvu'              => 'wvu' + 0x40.chr + 'metasploit.com'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, email = nil) ⇒ Author


74
75
76
77
# File 'lib/msf/core/module/author.rb', line 74

def initialize(name = nil, email = nil)
  self.name  = name
  self.email = email || Known[name]
end

Instance Attribute Details

#emailObject

Returns the value of attribute email


145
146
147
# File 'lib/msf/core/module/author.rb', line 145

def email
  @email
end

#nameObject

Returns the value of attribute name


146
147
148
# File 'lib/msf/core/module/author.rb', line 146

def name
  @name
end

Class Method Details

.from_s(str) ⇒ Object

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


56
57
58
59
60
61
62
63
64
65
# File 'lib/msf/core/module/author.rb', line 56

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

  # If the serialization fails...
  if (instance.from_s(str) == false)
    return nil
  end

  return instance
end

.transform(src) ⇒ Object

Transforms the supplied source into an array of authors


70
71
72
# File 'lib/msf/core/module/author.rb', line 70

def self.transform(src)
  Rex::Transformer.transform(src, Array, [ self ], 'Author')
end

Instance Method Details

#==(tgt) ⇒ Object

Compares authors


82
83
84
# File 'lib/msf/core/module/author.rb', line 82

def ==(tgt)
  return (tgt.to_s == to_s)
end

#from_s(str) ⇒ Object

Translate the author from the supplied string which may have either just a name or also an email address


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/msf/core/module/author.rb', line 105

def from_s(str)


  # Supported formats:
  #   known_name
  #   user [at/@] host [dot/.] tld
  #   Name <user [at/@] host [dot/.] tld>


  if ((m = str.match(/^\s*([^<]+)<([^>]+)>\s*$/)))
    self.name  = m[1].sub(/<.*/, '')
    self.email = m[2].sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.')
  else
    if (Known[str])
      self.email = Known[str]
      self.name  = str
    else
      self.email = str.sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.').gsub(/^<|>$/, '')
      m = self.email.match(/([^@]+)@/)
      self.name = m ? m[1] : nil
      if !(self.email and self.email.index('@'))
        self.name  = self.email
        self.email = ''
      end
    end
  end

  self.name.strip! if self.name

  return true
end

#to_sObject

Serialize the author object to a string in form:

name <email>


91
92
93
94
95
96
97
98
99
# File 'lib/msf/core/module/author.rb', line 91

def to_s
  str = "#{name}"

  if (email and not email.empty?)
    str += " <#{email}>"
  end

  return str
end