Skip to content

Commit 3c59519

Browse files
author
HD Moore
committed
Add PayloadUUIDRaw for manual PUID specification
1 parent 96f8a45 commit 3c59519

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/msf/core/payload/uuid_options.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def initialize(info = {})
1515
super
1616
register_advanced_options(
1717
[
18-
Msf::OptString.new('PayloadUUIDSeed', [ false, 'A string to use when generating the payload UUID (deterministic)'])
18+
Msf::OptString.new('PayloadUUIDSeed', [ false, 'A string to use when generating the payload UUID (deterministic)']),
19+
Msf::OptString.new('PayloadUUIDRaw', [ false, 'A hex string representing the raw 8-byte PUID value for the UUID']),
1920
], self.class)
2021
end
2122

@@ -33,8 +34,8 @@ def generate_uri_uuid_mode(mode,len=nil)
3334
# The URI length may not have room for an embedded checksum
3435
if len && len < URI_CHECKSUM_UUID_MIN_LEN
3536
# Throw an error if the user set a seed, but there is no room for it
36-
if datastore['PayloadUUIDSeed'].to_s.length > 0
37-
raise ArgumentError, "A PayloadUUIDSeed was specified, but this payload doesn't have enough room for a UUID"
37+
if datastore['PayloadUUIDSeed'].to_s.length > 0 ||datastore['PayloadUUIDRaw'].to_s.length > 0
38+
raise ArgumentError, "A PayloadUUIDSeed or PayloadUUIDRaw value was specified, but this payload doesn't have enough room for a UUID"
3839
end
3940
return "/" + generate_uri_checksum(sum, len, prefix="")
4041
end
@@ -50,10 +51,21 @@ def generate_payload_uuid
5051
platform: self.platform
5152
}
5253

54+
# Handle user-specified seed values
5355
if datastore['PayloadUUIDSeed'].to_s.length > 0
5456
conf[:seed] = datastore['PayloadUUIDSeed'].to_s
5557
end
5658

59+
# Handle user-specified raw payload UID values
60+
if datastore['PayloadUUIDRaw'].to_s.length > 0
61+
puid_raw = [datastore['PayloadUUIDRaw'].to_s].pack("H*")
62+
if puid_raw.length != 8
63+
raise ArgumentError, "The PayloadUUIDRaw value must be exactly 16 bytes of hex"
64+
end
65+
conf.delete(:seed)
66+
conf[:puid] = puid_raw
67+
end
68+
5769
Msf::Payload::UUID.new(conf)
5870
end
5971

0 commit comments

Comments
 (0)