Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

author.rb 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. require 'msf/core'
  2. ###
  3. #
  4. # This data type represents an author of a piece of code in either
  5. # the framework, a module, a script, or something entirely unrelated.
  6. #
  7. ###
  8. class Msf::Module::Author
  9. # A hash of known author names
  10. Known =
  11. {
  12. 'hdm' => 'hdm' + 0x40.chr + 'metasploit.com',
  13. 'spoonm' => 'spoonm' + 0x40.chr + 'no$email.com',
  14. 'skape' => 'mmiller' + 0x40.chr + 'hick.org',
  15. 'vlad902' => 'vlad902' + 0x40.chr + 'gmail.com',
  16. 'optyx' => 'optyx' + 0x40.chr + 'no$email.com',
  17. 'anonymous' => 'anonymous-contributor' + 0x40.chr + 'metasploit.com',
  18. 'stinko' => 'vinnie' + 0x40.chr + 'metasploit.com',
  19. 'MC' => 'mc' + 0x40.chr + 'metasploit.com',
  20. 'cazz' => 'bmc' + 0x40.chr + 'shmoo.com',
  21. 'pusscat' => 'pusscat' + 0x40.chr + 'metasploit.com',
  22. 'skylined' => 'skylined' + 0x40.chr + 'edup.tudelft.nl',
  23. 'patrick' => 'patrick' + 0x40.chr + 'aushack.com',
  24. 'ramon' => 'ramon' + 0x40.chr + 'risesecurity.org',
  25. 'I)ruid' => 'druid' + 0x40.chr + 'caughq.org',
  26. 'egypt' => 'egypt' + 0x40.chr + 'metasploit.com',
  27. 'kris' => 'katterjohn' + 0x40.chr + 'gmail.com',
  28. 'CG' => 'cg' + 0x40.chr + 'carnal0wnage.com'
  29. }
  30. #
  31. # Class method that translates a string to an instance of the Author class,
  32. # if it's of the right format, and returns the Author class instance
  33. #
  34. def self.from_s(str)
  35. instance = self.new
  36. # If the serialization fails...
  37. if (instance.from_s(str) == false)
  38. return nil
  39. end
  40. return instance
  41. end
  42. #
  43. # Transforms the supplied source into an array of authors
  44. #
  45. def self.transform(src)
  46. Rex::Transformer.transform(src, Array, [ self ], 'Author')
  47. end
  48. def initialize(name = nil, email = nil)
  49. self.name = name
  50. self.email = email || Known[name]
  51. end
  52. #
  53. # Compares authors
  54. #
  55. def ==(tgt)
  56. return (tgt.to_s == to_s)
  57. end
  58. #
  59. # Serialize the author object to a string in form:
  60. #
  61. # name <email>
  62. #
  63. def to_s
  64. str = "#{name}"
  65. if (email != nil)
  66. str += " <#{email}>"
  67. end
  68. return str
  69. end
  70. #
  71. # Translate the author from the supplied string which may
  72. # have either just a name or also an email address
  73. #
  74. def from_s(str)
  75. # Supported formats:
  76. # known_name
  77. # user [at/@] host [dot/.] tld
  78. # Name <user [at/@] host [dot/.] tld>
  79. if ((m = str.match(/^\s*([^<]+)<([^>]+)>\s*$/)))
  80. self.name = m[1].sub(/<.*/, '')
  81. self.email = m[2].sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.')
  82. else
  83. if (Known[str])
  84. self.email = Known[str]
  85. self.name = str
  86. else
  87. self.email = str.sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.').gsub(/^<|>$/, '')
  88. m = self.email.match(/([^@]+)@/)
  89. self.name = m ? m[1] : 'unknown'
  90. end
  91. end
  92. if self.name
  93. self.name.gsub!(/\s+$/, '')
  94. end
  95. return true
  96. end
  97. #
  98. # Sets the name of the author and updates the email if it's a known author.
  99. #
  100. def name=(name)
  101. self.email = Known[name] if (Known[name])
  102. @name = name
  103. end
  104. attr_accessor :email
  105. attr_reader :name
  106. end