Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/core/author.rb
Views: 11778
# -*- coding: binary -*-12###3#4# An author of a piece of code in either the framework, a module, a script,5# or something entirely unrelated.6#7###8class Msf::Author910#11# Constants12#1314# A hash that maps known author names to email addresses15KNOWN = {16'amaloteaux' => 'alex_maloteaux' + 0x40.chr + 'metasploit.com',17'aushack' => 'patrick' + 0x40.chr + 'osisecurity.com.au',18'bannedit' => 'bannedit' + 0x40.chr + 'metasploit.com',19'bcoles' => 'bcoles' + 0x40.chr + 'gmail.com',20'Carlos Perez' => 'carlos_perez' + 0x40.chr + 'darkoperator.com',21'cazz' => 'bmc' + 0x40.chr + 'shmoo.com',22'CG' => 'cg' + 0x40.chr + 'carnal0wnage.com',23'ddz' => 'ddz' + 0x40.chr + 'theta44.org',24'egypt' => 'egypt' + 0x40.chr + 'metasploit.com',25'et' => 'et' + 0x40.chr + 'metasploit.com',26'Christian Mehlmauer' => 'FireFart' + 0x40.chr + 'gmail.com',27'hdm' => 'x' + 0x40.chr + 'hdm.io',28'I)ruid' => 'druid' + 0x40.chr + 'caughq.org',29'jcran' => 'jcran' + 0x40.chr + 'metasploit.com',30'jduck' => 'jduck' + 0x40.chr + 'metasploit.com',31'joev' => 'joev' + 0x40.chr + 'metasploit.com',32'juan vazquez' => 'juan.vazquez' + 0x40.chr + 'metasploit.com',33'kf' => 'kf_list' + 0x40.chr + 'digitalmunition.com',34'kris katterjohn' => 'katterjohn' + 0x40.chr + 'gmail.com',35'MC' => 'mc' + 0x40.chr + 'metasploit.com',36'Ben Campbell' => 'eat_meatballs' + 0x40.chr + 'hotmail.co.uk',37'msmith' => 'msmith' + 0x40.chr + 'metasploit.com',38'mubix' => 'mubix' + 0x40.chr + 'hak5.org',39'natron' => 'natron' + 0x40.chr + 'metasploit.com',40'optyx' => 'optyx' + 0x40.chr + 'no$email.com',41'pusscat' => 'pusscat' + 0x40.chr + 'metasploit.com',42'Ramon de C Valle' => 'rcvalle' + 0x40.chr + 'metasploit.com',43'sf' => 'stephen_fewer' + 0x40.chr + 'harmonysecurity.com',44'sinn3r' => 'sinn3r' + 0x40.chr + 'metasploit.com',45'skape' => 'mmiller' + 0x40.chr + 'hick.org',46'skylined' => 'skylined' + 0x40.chr + 'edup.tudelft.nl',47'spoonm' => 'spoonm' + 0x40.chr + 'no$email.com',48'stinko' => 'vinnie' + 0x40.chr + 'metasploit.com',49'theLightCosine' => 'theLightCosine' + 0x40.chr + 'metasploit.com',50'todb' => 'todb' + 0x40.chr + 'metasploit.com',51'vlad902' => 'vlad902' + 0x40.chr + 'gmail.com',52'wvu' => 'wvu' + 0x40.chr + 'metasploit.com',53'zeroSteiner' => 'zeroSteiner' + 0x40.chr + 'gmail.com'54}5556#57# Class Methods58#5960# Parses an {Author} instance from the specified string.61#62# @param str [String] the String to parse an Author instance from63# @return [Author] a valid {Author} instance64# @return nil if `str` is not the correct format65def self.from_s(str)66instance = self.new6768# If the serialization fails...69if instance.from_s(str) == true70instance71else72nil73end74end7576# Normalizes a single {Author} reference or an Array of {Author} references77# to an Array of {Author} references.78#79# @param src [Author, Array<Author>] a single {Author} or an Array of {Author} instances80# @return [Array<Author>] an Array of {Author} instances81def self.transform(src)82Rex::Transformer.transform(src, Array, [ self ], 'Author')83end8485# Constructs an {Author} from a given `name` and `email`86#87# @param name [String] the author's name88# @param email [String] the author's email89def initialize(name = nil, email = nil)90self.name = name91self.email = email || KNOWN[name]92end9394#95# Instance Attributes96#9798# @!attribute email99# An optional email associated with this {Author}.100#101# @return [String, nil]102attr_accessor :email103104# @!attribute name105# The name associated with this {Author}.106#107# @return [String]108attr_reader :name109110#111# Instance Methods112#113114# @return [Boolean] whether the {Author} instances are equal115def ==(tgt)116tgt.to_s == to_s117end118119# Serialize the {Author} instance to a string of the form `name` or `name <[email protected]>`120#121# @return [String] serialized {Author}122def to_s123str = "#{name}"124if (email and not email.empty?)125str += " <#{email}>"126end127str128end129130131# Parses {Author} details from the supplied string which may132# be of the form `name` or `name <[email protected]>`133#134# @param str [String] the String to parse from135# @return [Boolean] the translation succeeded136def from_s(str)137138# Supported formats:139# known_name140# user [at/@] host [dot/.] tld141# Name <user [at/@] host [dot/.] tld>142143if str.present?144if ((m = str.match(/^\s*([^<]+)<([^>]+)>\s*$/)))145self.name = m[1].sub(/<.*/, '')146self.email = m[2].sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.')147else148if (KNOWN[str])149self.email = KNOWN[str]150self.name = str151else152self.email = str.sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.').gsub(/^<|>$/, '')153m = self.email.match(/([^@]+)@/)154self.name = m ? m[1] : nil155if !(self.email and self.email.index('@'))156self.name = self.email157self.email = ''158end159end160end161end162163self.name.strip! if self.name.present?164165# The parse succeeds only when a name is found166self.name.present?167end168169# Sets the name of the author and updates the email if it's a known author.170# @param name [String] the name to set171def name=(name)172if KNOWN.has_key?(name)173self.email = KNOWN[name]174end175@name = name176end177178end179180181