Class: Msf::Author

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

Overview

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 that maps known author names to email addresses

{
  'amaloteaux'          => 'alex_maloteaux' + 0x40.chr + 'metasploit.com',
  'aushack'             => 'patrick' + 0x40.chr + 'osisecurity.com.au',
  'bannedit'            => 'bannedit' + 0x40.chr + 'metasploit.com',
  'bcoles'              => 'bcoles' + 0x40.chr + 'gmail.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',
  'Christian Mehlmauer' => 'FireFart' + 0x40.chr + 'gmail.com',
  'hdm'                 => 'x' + 0x40.chr + 'hdm.io',
  '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',
  'Ben Campbell'        => 'eat_meatballs' + 0x40.chr + 'hotmail.co.uk',
  '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',
  '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',
  'zeroSteiner'         => 'zeroSteiner' + 0x40.chr + 'gmail.com'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Constructs an Msf::Author from a given `name` and `email`

Parameters:

  • name (String) (defaults to: nil)

    the author's name

  • email (String) (defaults to: nil)

    the author's email


91
92
93
94
# File 'lib/msf/core/author.rb', line 91

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

Instance Attribute Details

#emailString?

An optional email associated with this Msf::Author.

Returns:

  • (String, nil)

104
105
106
# File 'lib/msf/core/author.rb', line 104

def email
  @email
end

#nameObject

Returns the value of attribute name


110
111
112
# File 'lib/msf/core/author.rb', line 110

def name
  @name
end

Class Method Details

.from_s(str) ⇒ Author

Parses an Msf::Author instance from the specified string.

Parameters:

  • str (String)

    the String to parse an Author instance from

Returns:


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

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

  # If the serialization fails...
  if instance.from_s(str) == true
    instance
  else
    nil
  end
end

.transform(src) ⇒ Array<Author>

Normalizes a single Msf::Author reference or an Array of Msf::Author references to an Array of Msf::Author references.

Parameters:

Returns:


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

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

Instance Method Details

#==(tgt) ⇒ Boolean

Returns whether the Msf::Author instances are equal.

Returns:

  • (Boolean)

    whether the Msf::Author instances are equal


117
118
119
# File 'lib/msf/core/author.rb', line 117

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

#from_s(str) ⇒ Boolean

Parses Msf::Author details from the supplied string which may be of the form `name` or `name <[email protected]>`

Parameters:

  • str (String)

    the String to parse from

Returns:

  • (Boolean)

    the translation succeeded


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/msf/core/author.rb', line 138

def from_s(str)

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

  if str.present?
    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
  end

  self.name.strip! if self.name.present?

  # The parse succeeds only when a name is found
  self.name.present?
end

#to_sString

Serialize the Msf::Author instance to a string of the form `name` or `name <[email protected]>`

Returns:


124
125
126
127
128
129
130
# File 'lib/msf/core/author.rb', line 124

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