Module: Msf::Payload::Adapter::Fetch::Server::TFTP

Included in:
TFTP
Defined in:
lib/msf/core/payload/adapter/fetch/server/tftp.rb

Instance Method Summary collapse

Instance Method Details

#add_resource(fetch_service, uri, srv_entry) ⇒ Object



33
34
35
36
37
# File 'lib/msf/core/payload/adapter/fetch/server/tftp.rb', line 33

def add_resource(fetch_service, uri, srv_entry)
  vprint_status("Adding TFTP resource #{uri}")
  fetch_service.register_file(uri, srv_entry[:data], datastore['FETCH_SRVONCE'])
  @myresources << uri
end

#cleanup_tftp_fetch_service(fetch_service) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/msf/core/payload/adapter/fetch/server/tftp.rb', line 12

def cleanup_tftp_fetch_service(fetch_service)
  @myresources.each do |uri|
    fetch_service.deregister_file(uri)
  end
  @myresources = []
  fetch_service = nil
end

#fetch_protocolObject



20
21
22
# File 'lib/msf/core/payload/adapter/fetch/server/tftp.rb', line 20

def fetch_protocol
  'TFTP'
end

#initialize(*args) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/msf/core/payload/adapter/fetch/server/tftp.rb', line 3

def initialize(*args)
  super
  register_options(
    [
      Msf::OptBool.new('FETCH_SRVONCE', [ true, 'Stop serving the payload after it is retrieved', true ])
    ]
  )
end

#start_tftp_fetch_handler(srvport, srvhost) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/msf/core/payload/adapter/fetch/server/tftp.rb', line 39

def start_tftp_fetch_handler(srvport, srvhost)
  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 #{Rex::Socket.to_authority(srvhost, srvport)}")
  end
  fetch_service
end

#start_tftp_server(srvport, srvhost) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/msf/core/payload/adapter/fetch/server/tftp.rb', line 24

def start_tftp_server(srvport, srvhost)
  vprint_status("Starting TFTP server on #{Rex::Socket.to_authority(srvhost, srvport)}")
  Rex::ServiceManager.start(
    Rex::Proto::TFTP::Server,
    srvport, srvhost,
    { 'Msf' => framework, 'MsfExploit' => self }
  )
end