Skip to content

Msf::Module::UUID: Generate UUID using UUID_CHARS.sample(8).join #20170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/msf/core/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def initialize(info = {})
@module_info_copy = info.dup

self.module_info = info
generate_uuid

set_defaults

Expand Down
24 changes: 10 additions & 14 deletions lib/msf/core/module/uuid.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
require 'rex/text'

# NOTE: Metasploit does not use real UUIDs currently.
# To modify this to be a real UUID we will need to do a database migration.
# See: https://github.com/rapid7/metasploit-framework/pull/20170
module Msf::Module::UUID
UUID_CHARS = [*('a'..'z'), *('0'..'9')].freeze
private_constant :UUID_CHARS

#
# Attributes
#

# @!attribute [r] uuid
# A unique identifier for this module instance
attr_reader :uuid
# @return [String] A unique identifier for this module instance
def uuid
@uuid ||= UUID_CHARS.sample(8).join
end

protected

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

# @!attribute [w] uuid
attr_writer :uuid


#
# Instance Methods
#

def generate_uuid
self.uuid = Rex::Text.rand_text_alphanumeric(8).downcase
end
end
Loading