Skip to content

Commit 2bd7a67

Browse files
committed
Restructure parts of Author, fix some doc bugs.
1 parent e66c9be commit 2bd7a67

File tree

4 files changed

+235
-94
lines changed

4 files changed

+235
-94
lines changed

lib/msf/core/author.rb

Lines changed: 116 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,147 +3,177 @@
33

44
###
55
#
6-
# This data type represents an author of a piece of code in either
7-
# the framework, a module, a script, or something entirely unrelated.
6+
# An author of a piece of code in either the framework, a module, a script,
7+
# or something entirely unrelated.
88
#
99
###
1010
class Msf::Author
1111

12-
# A hash of known author names
13-
Known =
14-
{
15-
'amaloteaux' => 'alex_maloteaux' + 0x40.chr + 'metasploit.com',
16-
'anonymous' => 'Unknown',
17-
'bannedit' => 'bannedit' + 0x40.chr + 'metasploit.com',
18-
'Carlos Perez' => 'carlos_perez' + 0x40.chr + 'darkoperator.com',
19-
'cazz' => 'bmc' + 0x40.chr + 'shmoo.com',
20-
'CG' => 'cg' + 0x40.chr + 'carnal0wnage.com',
21-
'ddz' => 'ddz' + 0x40.chr + 'theta44.org',
22-
'egypt' => 'egypt' + 0x40.chr + 'metasploit.com',
23-
'et' => 'et' + 0x40.chr + 'metasploit.com',
24-
'Christian Mehlmauer' => 'FireFart' + 0x40.chr + 'gmail.com',
25-
'hdm' => 'hdm' + 0x40.chr + 'metasploit.com',
26-
'I)ruid' => 'druid' + 0x40.chr + 'caughq.org',
27-
'jcran' => 'jcran' + 0x40.chr + 'metasploit.com',
28-
'jduck' => 'jduck' + 0x40.chr + 'metasploit.com',
29-
'joev' => 'joev' + 0x40.chr + 'metasploit.com',
30-
'juan vazquez' => 'juan.vazquez' + 0x40.chr + 'metasploit.com',
31-
'kf' => 'kf_list' + 0x40.chr + 'digitalmunition.com',
32-
'kris katterjohn' => 'katterjohn' + 0x40.chr + 'gmail.com',
33-
'MC' => 'mc' + 0x40.chr + 'metasploit.com',
34-
'Ben Campbell' => 'eat_meatballs' + 0x40.chr + 'hotmail.co.uk',
35-
'msmith' => 'msmith' + 0x40.chr + 'metasploit.com',
36-
'mubix' => 'mubix' + 0x40.chr + 'hak5.org',
37-
'natron' => 'natron' + 0x40.chr + 'metasploit.com',
38-
'optyx' => 'optyx' + 0x40.chr + 'no$email.com',
39-
'patrick' => 'patrick' + 0x40.chr + 'osisecurity.com.au',
40-
'pusscat' => 'pusscat' + 0x40.chr + 'metasploit.com',
41-
'Ramon de C Valle' => 'rcvalle' + 0x40.chr + 'metasploit.com',
42-
'sf' => 'stephen_fewer' + 0x40.chr + 'harmonysecurity.com',
43-
'sinn3r' => 'sinn3r' + 0x40.chr + 'metasploit.com',
44-
'skape' => 'mmiller' + 0x40.chr + 'hick.org',
45-
'skylined' => 'skylined' + 0x40.chr + 'edup.tudelft.nl',
46-
'spoonm' => 'spoonm' + 0x40.chr + 'no$email.com',
47-
'stinko' => 'vinnie' + 0x40.chr + 'metasploit.com',
48-
'theLightCosine' => 'theLightCosine' + 0x40.chr + 'metasploit.com',
49-
'todb' => 'todb' + 0x40.chr + 'metasploit.com',
50-
'vlad902' => 'vlad902' + 0x40.chr + 'gmail.com',
51-
'wvu' => 'wvu' + 0x40.chr + 'metasploit.com'
52-
}
12+
#
13+
# Constants
14+
#
15+
16+
# A hash that maps known author names to email addresses
17+
KNOWN = {
18+
'amaloteaux' => 'alex_maloteaux' + 0x40.chr + 'metasploit.com',
19+
'anonymous' => 'Unknown',
20+
'bannedit' => 'bannedit' + 0x40.chr + 'metasploit.com',
21+
'Carlos Perez' => 'carlos_perez' + 0x40.chr + 'darkoperator.com',
22+
'cazz' => 'bmc' + 0x40.chr + 'shmoo.com',
23+
'CG' => 'cg' + 0x40.chr + 'carnal0wnage.com',
24+
'ddz' => 'ddz' + 0x40.chr + 'theta44.org',
25+
'egypt' => 'egypt' + 0x40.chr + 'metasploit.com',
26+
'et' => 'et' + 0x40.chr + 'metasploit.com',
27+
'Christian Mehlmauer' => 'FireFart' + 0x40.chr + 'gmail.com',
28+
'hdm' => 'hdm' + 0x40.chr + 'metasploit.com',
29+
'I)ruid' => 'druid' + 0x40.chr + 'caughq.org',
30+
'jcran' => 'jcran' + 0x40.chr + 'metasploit.com',
31+
'jduck' => 'jduck' + 0x40.chr + 'metasploit.com',
32+
'joev' => 'joev' + 0x40.chr + 'metasploit.com',
33+
'juan vazquez' => 'juan.vazquez' + 0x40.chr + 'metasploit.com',
34+
'kf' => 'kf_list' + 0x40.chr + 'digitalmunition.com',
35+
'kris katterjohn' => 'katterjohn' + 0x40.chr + 'gmail.com',
36+
'MC' => 'mc' + 0x40.chr + 'metasploit.com',
37+
'Ben Campbell' => 'eat_meatballs' + 0x40.chr + 'hotmail.co.uk',
38+
'msmith' => 'msmith' + 0x40.chr + 'metasploit.com',
39+
'mubix' => 'mubix' + 0x40.chr + 'hak5.org',
40+
'natron' => 'natron' + 0x40.chr + 'metasploit.com',
41+
'optyx' => 'optyx' + 0x40.chr + 'no$email.com',
42+
'patrick' => 'patrick' + 0x40.chr + 'osisecurity.com.au',
43+
'pusscat' => 'pusscat' + 0x40.chr + 'metasploit.com',
44+
'Ramon de C Valle' => 'rcvalle' + 0x40.chr + 'metasploit.com',
45+
'sf' => 'stephen_fewer' + 0x40.chr + 'harmonysecurity.com',
46+
'sinn3r' => 'sinn3r' + 0x40.chr + 'metasploit.com',
47+
'skape' => 'mmiller' + 0x40.chr + 'hick.org',
48+
'skylined' => 'skylined' + 0x40.chr + 'edup.tudelft.nl',
49+
'spoonm' => 'spoonm' + 0x40.chr + 'no$email.com',
50+
'stinko' => 'vinnie' + 0x40.chr + 'metasploit.com',
51+
'theLightCosine' => 'theLightCosine' + 0x40.chr + 'metasploit.com',
52+
'todb' => 'todb' + 0x40.chr + 'metasploit.com',
53+
'vlad902' => 'vlad902' + 0x40.chr + 'gmail.com',
54+
'wvu' => 'wvu' + 0x40.chr + 'metasploit.com'
55+
}
5356

5457
#
55-
# Class method that translates a string to an instance of the Author class,
56-
# if it's of the right format, and returns the Author class instance
58+
# Class Methods
59+
#
60+
61+
# Parses an {Author} instance from the specified string.
5762
#
63+
# @param str [String] the String to parse an Author instance from
64+
# @return [Author] a valid {Author} instance
65+
# @return nil if `str` is not the correct format
5866
def self.from_s(str)
5967
instance = self.new
6068

6169
# If the serialization fails...
62-
if (instance.from_s(str) == false)
63-
return nil
70+
if instance.from_s(str) == true
71+
instance
72+
else
73+
nil
6474
end
65-
66-
return instance
6775
end
6876

77+
# Normalizes a single {Author} reference or an Array of {Author} references
78+
# to an Array of {Author} references.
6979
#
70-
# Transforms the supplied source into an array of authors
71-
#
80+
# @param src [Author, Array<Author>] a single {Author} or an Array of {Author} instances
81+
# @return [Array<Author>] an Array of {Author} instances
7282
def self.transform(src)
7383
Rex::Transformer.transform(src, Array, [ self ], 'Author')
7484
end
7585

86+
# Constructs an {Author} from a given `name` and `email`
87+
#
88+
# @param name [String] the author's name
89+
# @param email [String] the author's email
7690
def initialize(name = nil, email = nil)
7791
self.name = name
78-
self.email = email || Known[name]
92+
self.email = email || KNOWN[name]
7993
end
8094

8195
#
82-
# Compares authors
96+
# Instance Attributes
8397
#
84-
def ==(tgt)
85-
return (tgt.to_s == to_s)
86-
end
8798

99+
# @!attribute email
100+
# An optional email associated with this {Author}.
101+
#
102+
# @return [String, nil]
103+
attr_accessor :email
104+
105+
# @!attribute name
106+
# The name associated with this {Author}.
88107
#
89-
# Serialize the author object to a string in form:
108+
# @return [String]
109+
attr_reader :name
110+
90111
#
91-
# name <email>
112+
# Instance Methods
92113
#
114+
115+
# @return [Boolean] whether the {Author} instances are equal
116+
def ==(tgt)
117+
tgt.to_s == to_s
118+
end
119+
120+
# Serialize the {Author} instance to a string of the form `name` or `name <[email protected]>`
121+
#
122+
# @return [String] serialized {Author}
93123
def to_s
94124
str = "#{name}"
95-
96125
if (email and not email.empty?)
97126
str += " <#{email}>"
98127
end
99-
100-
return str
128+
str
101129
end
102130

131+
132+
# Parses {Author} details from the supplied string which may
133+
# be of the form `name` or `name <[email protected]>`
103134
#
104-
# Translate the author from the supplied string which may
105-
# have either just a name or also an email address
106-
#
135+
# @param str [String] the String to parse from
136+
# @return [Boolean] the translation succeeded
107137
def from_s(str)
108138

109-
110139
# Supported formats:
111140
# known_name
112141
# user [at/@] host [dot/.] tld
113142
# Name <user [at/@] host [dot/.] tld>
114143

115-
116-
if ((m = str.match(/^\s*([^<]+)<([^>]+)>\s*$/)))
117-
self.name = m[1].sub(/<.*/, '')
118-
self.email = m[2].sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.')
119-
else
120-
if (Known[str])
121-
self.email = Known[str]
122-
self.name = str
144+
if str.present?
145+
if ((m = str.match(/^\s*([^<]+)<([^>]+)>\s*$/)))
146+
self.name = m[1].sub(/<.*/, '')
147+
self.email = m[2].sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.')
123148
else
124-
self.email = str.sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.').gsub(/^<|>$/, '')
125-
m = self.email.match(/([^@]+)@/)
126-
self.name = m ? m[1] : nil
127-
if !(self.email and self.email.index('@'))
128-
self.name = self.email
129-
self.email = ''
149+
if (KNOWN[str])
150+
self.email = KNOWN[str]
151+
self.name = str
152+
else
153+
self.email = str.sub(/\s*\[at\]\s*/, '@').sub(/\s*\[dot\]\s*/, '.').gsub(/^<|>$/, '')
154+
m = self.email.match(/([^@]+)@/)
155+
self.name = m ? m[1] : nil
156+
if !(self.email and self.email.index('@'))
157+
self.name = self.email
158+
self.email = ''
159+
end
130160
end
131161
end
132162
end
133163

134-
self.name.strip! if self.name
164+
self.name.strip! if self.name.present?
135165

136-
return true
166+
# The parse succeeds only when a name is found
167+
self.name.present?
137168
end
138169

139-
#
140170
# Sets the name of the author and updates the email if it's a known author.
141-
#
171+
# @param name [String] the name to set
142172
def name=(name)
143-
self.email = Known[name] if (Known[name])
173+
if KNOWN.has_key?(name)
174+
self.email = KNOWN[name]
175+
end
144176
@name = name
145177
end
146178

147-
attr_accessor :email
148-
attr_reader :name
149179
end

lib/msf/core/auxiliary/auth_brute.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def setup
5252
# This method takes a {Metasploit::Framework::CredentialCollection} and prepends existing NTLMHashes
5353
# from the database. This allows the users to use the DB_ALL_CREDS option.
5454
#
55-
# @param [Metasploit::Framework::CredentialCollection] the credential collection to add to
55+
# @param cred_collection [Metasploit::Framework::CredentialCollection]
56+
# the credential collection to add to
5657
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
5758
def prepend_db_hashes(cred_collection)
5859
if datastore['DB_ALL_CREDS'] && framework.db.active
@@ -67,7 +68,8 @@ def prepend_db_hashes(cred_collection)
6768
# This method takes a {Metasploit::Framework::CredentialCollection} and prepends existing SSHKeys
6869
# from the database. This allows the users to use the DB_ALL_CREDS option.
6970
#
70-
# @param [Metasploit::Framework::CredentialCollection] the credential collection to add to
71+
# @param cred_collection [Metasploit::Framework::CredentialCollection]
72+
# the credential collection to add to
7173
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
7274
def prepend_db_keys(cred_collection)
7375
if datastore['DB_ALL_CREDS'] && framework.db.active
@@ -82,7 +84,8 @@ def prepend_db_keys(cred_collection)
8284
# This method takes a {Metasploit::Framework::CredentialCollection} and prepends existing Password Credentials
8385
# from the database. This allows the users to use the DB_ALL_CREDS option.
8486
#
85-
# @param [Metasploit::Framework::CredentialCollection] the credential collection to add to
87+
# @param cred_collection [Metasploit::Framework::CredentialCollection]
88+
# the credential collection to add to
8689
# @return [Metasploit::Framework::CredentialCollection] the modified Credentialcollection
8790
def prepend_db_passwords(cred_collection)
8891
if datastore['DB_ALL_CREDS'] && framework.db.active

lib/msf/core/payload/jsp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# It provides methods to generate Java / JSP code.
77
module Msf::Payload::JSP
88

9-
# @param attributes [Hash{Symbol => String,nil}]
9+
# @param [Hash<Symbol, [String, nil]>] info
1010
def initialize(info = {})
1111
ret = super(info)
1212

0 commit comments

Comments
 (0)