Files
metasploit-gs/modules/auxiliary/server/tftp.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.0 KiB
Ruby
Raw Normal View History

2010-07-08 23:34:33 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2010-07-08 23:34:33 +00:00
##
2014-03-07 10:41:18 -06:00
require 'tmpdir'
2010-07-08 23:34:33 +00:00
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Auxiliary
2010-07-08 23:34:33 +00:00
include Msf::Exploit::Remote::TFTPServer
include Msf::Auxiliary::Report
def initialize
super(
'Name' => 'TFTP File Server',
'Description' => %q{
This module provides a TFTP service
},
2014-03-07 10:41:18 -06:00
'Author' => [ 'jduck', 'todb' ],
2010-07-08 23:34:33 +00:00
'License' => MSF_LICENSE,
'Actions' =>
[
[ 'Service', 'Description' => 'Serve files via TFTP' ]
2010-07-08 23:34:33 +00:00
],
'PassiveActions' =>
[
2010-09-20 08:05:50 +00:00
'Service'
2010-07-08 23:34:33 +00:00
],
2010-09-20 08:05:50 +00:00
'DefaultAction' => 'Service'
2010-07-08 23:34:33 +00:00
)
register_options(
[
OptAddress.new('SRVHOST', [ true, "The local host to listen on.", '0.0.0.0' ]),
OptPort.new('SRVPORT', [ true, "The local port to listen on.", 69 ]),
2014-03-07 10:52:45 -06:00
OptPath.new('TFTPROOT', [ true, "The TFTP root directory to serve files from", Dir.tmpdir ]),
OptPath.new('OUTPUTPATH', [ true, "The directory in which uploaded files will be written.", Dir.tmpdir ])
])
2010-07-08 23:34:33 +00:00
end
def srvhost
datastore['SRVHOST'] || '0.0.0.0'
end
def srvport
datastore['SRVPORT'] || 69
end
2010-07-08 23:34:33 +00:00
def run
print_status("Starting TFTP server on #{srvhost}:#{srvport}...")
2010-07-08 23:34:33 +00:00
@tftp = Rex::Proto::TFTP::Server.new(
srvport,
srvhost,
{}
)
2010-07-08 23:34:33 +00:00
@tftp.set_tftproot(datastore['TFTPROOT'])
print_status("Files will be served from #{datastore['TFTPROOT']}")
2010-07-08 23:34:33 +00:00
@tftp.set_output_dir(datastore['OUTPUTPATH'])
print_status("Uploaded files will be saved in #{datastore['OUTPUTPATH']}")
2010-07-08 23:34:33 +00:00
# Individual virtual files can be served here -
#@tftp.register_file("ays", "A" * 2048) # multiple of 512 on purpose
@tftp.start
2010-08-14 04:58:27 +00:00
add_socket(@tftp.sock)
2010-07-08 23:34:33 +00:00
# Wait for finish..
2010-08-14 04:58:27 +00:00
while @tftp.thread.alive?
sleep 3
2010-08-14 04:58:27 +00:00
end
2010-07-08 23:34:33 +00:00
vprint_status("Stopping TFTP server")
2010-08-14 04:58:27 +00:00
@tftp.stop
2010-07-08 23:34:33 +00:00
end
end