Skip to content

Commit 96f8a45

Browse files
author
HD Moore
committed
Additional yardoc comments for the UUID class
1 parent 9145b6d commit 96f8a45

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

lib/msf/core/payload/uuid.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ def self.parse_uri(uri)
187187
parse_raw(Rex::Text.decode_base64url(uri))
188188
end
189189

190+
191+
#
192+
# Look up the numeric platform ID given a string or PlatformList as input
193+
#
194+
# @param platform [String] The name of the platform to lookup
195+
# @return [Fixnum] The integer value of this platform
196+
#
190197
def self.find_platform_id(platform)
191198
# Handle a PlatformList input by grabbing the first entry
192199
if platform.respond_to? :platforms
@@ -200,6 +207,12 @@ def self.find_platform_id(platform)
200207
}.first || Platforms[0] ).to_i
201208
end
202209

210+
#
211+
# Look up the numeric architecture ID given a string as input
212+
#
213+
# @param name [String] The name of the architecture to lookup
214+
# @return [Fixnum] The integer value of this architecture
215+
#
203216
def self.find_architecture_id(name)
204217
name = name.first if name.kind_of? ::Array
205218
( Architectures.keys.select{ |k|
@@ -242,10 +255,22 @@ def initialize(opts=nil)
242255
self.timestamp ||= Time.now.utc.to_i
243256
end
244257

258+
#
259+
# Initializes a UUID object given a raw 16+ byte blob
260+
#
261+
# @param raw [String] The string containing at least 16 bytes of encoded data
262+
# @return [Hash] The attributes encoded into this UUID
263+
#
245264
def load_raw(raw)
246265
self.class.filter_invalid(self.class.parse_raw(raw))
247266
end
248267

268+
#
269+
# Initializes a UUID object given a 22+ byte URI
270+
#
271+
# @param uri [String] The URI containing at least 22 bytes of encoded data
272+
# @return [Hash] The attributes encoded into this UUID
273+
#
249274
def load_uri(uri)
250275
self.class.filter_invalid(self.class.parse_uri(uri))
251276
end
@@ -254,6 +279,11 @@ def load_new
254279
self.class.parse_raw(self.class.generate_raw())
255280
end
256281

282+
#
283+
# Provides a string representation of a UUID
284+
#
285+
# @return [String] The human-readable version of the UUID data
286+
#
257287
def to_s
258288
arch_id = self.class.find_architecture_id(self.arch).to_s
259289
plat_id = self.class.find_platform_id(self.platform).to_s
@@ -265,6 +295,11 @@ def to_s
265295
].join("/")
266296
end
267297

298+
#
299+
# Provides a hash representation of a UUID
300+
#
301+
# @return [Hash] The hash representation of the UUID suitable for creating a new one
302+
#
268303
def to_h
269304
{
270305
puid: self.puid,
@@ -274,18 +309,36 @@ def to_h
274309
}
275310
end
276311

312+
#
313+
# Provides a raw byte representation of a UUID
314+
#
315+
# @return [String] The 16-byte raw encoded version of the UUID
316+
#
277317
def to_raw
278318
self.class.generate_raw(self.to_h)
279319
end
280320

321+
#
322+
# Provides a URI-encoded representation of a UUID
323+
#
324+
# @return [String] The 22-byte URI encoded version of the UUID
325+
#
281326
def to_uri
282327
Rex::Text.encode_base64url(self.to_raw)
283328
end
284329

330+
#
331+
# Provides a hex representation of the Payload UID of the UUID
332+
#
333+
# @return [String] The 16-byte hex string representing the Payload UID
334+
#
285335
def puid_hex
286336
self.puid.unpack('H*').first
287337
end
288338

339+
#
340+
# Clears the two random XOR keys used for obfuscation
341+
#
289342
def xor_reset
290343
self.xor1 = self.xor2 = nil
291344
self

0 commit comments

Comments
 (0)