forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tftp.rb
36 lines (30 loc) · 976 Bytes
/
tftp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Msf::Payload::Adapter::Fetch::Server::TFTP
def start_tftp_server(srvport, srvhost)
vprint_status("Starting TFTP server on #{Rex::Socket.to_authority(srvhost, srvport)}")
Rex::Proto::TFTP::Server.new(srvport, srvhost, {})
end
def initialize(*args)
super
register_options(
[
Msf::OptBool.new('FETCH_SRVONCE', [ true, 'Stop serving the payload after it is retrieved', true ])
]
)
end
def cleanup_tftp_fetch_service(fetch_service)
fetch_service.stop
end
def fetch_protocol
'TFTP'
end
def start_tftp_fetch_handler(srvport, srvhost, srvuri, srvexe)
fetch_service = start_tftp_server(srvport, srvhost)
if fetch_service.nil?
cleanup_handler
fail_with(Msf::Exploit::Failure::BadConfig, "Fetch handler failed to start on #{srvhost}:#{srvport}\n#{e}")
end
fetch_service.register_file(srvuri, srvexe, datastore['FETCH_SRVONCE'])
fetch_service.start
fetch_service
end
end