@@ -46,48 +46,25 @@ def process_uri_resource(uri)
46
46
# Figure out the mode based on the checksum
47
47
uri_csum = Rex ::Text . checksum8 ( uri_bare )
48
48
49
+ # Extract the UUID if the URI is long enough
49
50
uri_uuid = nil
50
-
51
51
if uri_bare . length >= URI_CHECKSUM_UUID_MIN_LEN
52
- uri_uuid =
53
- Msf ::Payload ::UUID . payload_uuid_parse_raw (
54
- Rex ::Text . decode_base64url (
55
- uri_bare [ 0 , Msf ::Payload ::UUID ::UriLength ] ) )
56
-
57
- # Verify the uri_uuid fields and unset everything but
58
- # the unique ID itself unless it looks wonky.
59
- if uri_uuid [ :timestamp ] > ( Time . now . utc . to_i + ( 24 *3600 *365 ) ) ||
60
- uri_uuid [ :timestamp ] < ( Time . now . utc . to_i - ( 24 *3600 *365 ) ) ||
61
- ( uri_uuid [ :arch ] . nil? && uri_uuid [ :platform ] . nil? )
62
- uri_uuid = { puid : uri_uuid [ :puid ] }
63
- end
52
+ uri_uuid = Msf ::Payload ::UUID . new ( uri : uri_bare )
64
53
end
65
54
66
55
uri_mode = URI_CHECKSUM_MODES [ uri_csum ]
67
56
68
- # Return a hash of URI attributes to the caller
69
- {
70
- uri : uri_bare ,
71
- sum : uri_csum ,
72
- uuid : uri_uuid ,
73
- mode : uri_mode
74
- }
57
+ # Return a hash of URI attributes
58
+ { uri : uri_bare , sum : uri_csum , uuid : uri_uuid , mode : uri_mode }
75
59
end
76
60
77
61
# Create a URI that matches the :connect mode with optional UUID, Arch, and Platform
78
62
#
79
- # @param uuid [Hash] An optional hash with the UUID parameters
80
- # @param arch [String] An optional architecture name to use if no UUID is provided
81
- # @param platform [String] An optional platform name to use if no UUID is provided
82
- # @return [String] The URI string that checksums to the given value
83
- def generate_uri_connect_uuid ( uuid = nil , arch = nil , platform = nil )
63
+ # @param uuid [Msf::Payload::UUID] A valid UUID object
64
+ # @return [String] The URI string for connections
65
+ def generate_uri_connect_uuid ( uuid )
84
66
curl_uri_len = URI_CHECKSUM_UUID_MIN_LEN +rand ( URI_CHECKSUM_CONN_MAX_LEN -URI_CHECKSUM_UUID_MIN_LEN )
85
- curl_prefix = Rex ::Text . encode_base64url (
86
- Msf ::Payload ::UUID . payload_uuid_generate_raw (
87
- uuid : uuid [ :puid ] ,
88
- arch : uuid [ :arch ] || arch ,
89
- platform : uuid [ :platform ] || platform ,
90
- timestamp : uuid [ :timestamp ] ) )
67
+ curl_prefix = uuid . to_uri
91
68
92
69
# Pad out the URI and make the checksum match :connect
93
70
"/" + generate_uri_checksum ( URI_CHECKSUM_CONN , curl_uri_len , curl_prefix )
0 commit comments