Skip to content

Commit 18c21f1

Browse files
authored
Merge pull request #20170 from bcoles/msf-module-uuid
Msf::Module::UUID: Generate UUID using UUID_CHARS.sample(8).join
2 parents d553aa6 + ffcc145 commit 18c21f1

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

lib/msf/core/module.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def initialize(info = {})
114114
@module_info_copy = info.dup
115115

116116
self.module_info = info
117-
generate_uuid
118117

119118
set_defaults
120119

lib/msf/core/module/uuid.rb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
require 'rex/text'
2-
1+
# NOTE: Metasploit does not use real UUIDs currently.
2+
# To modify this to be a real UUID we will need to do a database migration.
3+
# See: https://github.com/rapid7/metasploit-framework/pull/20170
34
module Msf::Module::UUID
5+
UUID_CHARS = [*('a'..'z'), *('0'..'9')].freeze
6+
private_constant :UUID_CHARS
7+
48
#
59
# Attributes
610
#
711

8-
# @!attribute [r] uuid
9-
# A unique identifier for this module instance
10-
attr_reader :uuid
12+
# @return [String] A unique identifier for this module instance
13+
def uuid
14+
@uuid ||= UUID_CHARS.sample(8).join
15+
end
1116

1217
protected
1318

@@ -17,13 +22,4 @@ module Msf::Module::UUID
1722

1823
# @!attribute [w] uuid
1924
attr_writer :uuid
20-
21-
22-
#
23-
# Instance Methods
24-
#
25-
26-
def generate_uuid
27-
self.uuid = Rex::Text.rand_text_alphanumeric(8).downcase
28-
end
2925
end

0 commit comments

Comments
 (0)