Don't blow up if the user doesn't set a filename

Can't actually require FILENAME or REMOTE_FILENAME because I don't know
if you're going to upload or download. However, there shouldn't be a
stacktrace when you just try to go with neither.
unstable
Tod Beardsley 2011-12-21 16:23:56 -06:00
parent 2db697cd7a
commit 743a0546f1
2 changed files with 21 additions and 4 deletions

View File

@ -54,7 +54,7 @@ class Client
self.peer_port = params["PeerPort"] || 69
self.context = params["Context"] || {}
self.local_file = params["LocalFile"]
self.remote_file = params["RemoteFile"] || ::File.split(self.local_file).last
self.remote_file = params["RemoteFile"] || (::File.split(self.local_file).last if self.local_file)
self.mode = params["Mode"] || "octet"
self.action = params["Action"] || (raise ArgumentError, "Need an action.")
self.block_size = params["BlockSize"] || 512

View File

@ -60,7 +60,8 @@ class Metasploit3 < Msf::Auxiliary
end
def remote_file
datastore['REMOTE_FILENAME'] || ::File.split(datastore['FILENAME']).last
return datastore['REMOTE_FILENAME'] if datastore['REMOTE_FILENAME']
return ::File.split(datastore['FILENAME']).last if datastore['FILENAME']
end
def rport
@ -138,8 +139,24 @@ class Metasploit3 < Msf::Auxiliary
end
def run
run_upload() if action.name == 'Upload'
run_download() if action.name == 'Download'
case action.name
when 'Upload'
if file
run_upload()
else
print_error "Need at least a local file name or file data to upload."
return
end
when 'Download'
if remote_file
run_download()
else
print_error "Need at least a remote file name to download."
return
end
else
print_error "Unknown action: '#{action.name}'"
end
while not @tftp_client.complete
select(nil,nil,nil,1)
print_status [rtarget,"TFTP transfer operation complete."].join