tftp NSE Library — Nmap Scripting Engine documentation (original) (raw)
Library implementing a minimal TFTP server
Currently only write-operations are supported so that script can trigger TFTP transfers and receive the files and return them as result.
The library contains the following classes
Packet
** The Packet
classes contain one class for each TFTP operation.
File
** The File
class holds a received file including the name and contents
ConnHandler
** The ConnHandler
class handles and processes incoming connections.
The following code snippet starts the TFTP server and waits for the file incoming.txt to be uploaded for 10 seconds:
tftp.start() local status, f = tftp.waitFile("incoming.txt", 10) if ( status ) then return f:getContent() end
Author:
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/tftp.lua
Functions
new (self, filename, content, sender)
Creates a new file object
start ()
Starts the TFTP server and creates a new thread handing over to the dispatcher
waitFile (filename, timeout)
Waits for a file with a specific filename for at least the number of seconds specified by the timeout parameter.
Functions
new (self, filename, content, sender)
Creates a new file object
Parameters
self
filename
string containing the filename
content
string containing the file content
sender
Return value:
o new class instance
start ()
Starts the TFTP server and creates a new thread handing over to the dispatcher
waitFile (filename, timeout)
Waits for a file with a specific filename for at least the number of seconds specified by the timeout parameter.
If this function is called from the thread that's running the server it will wait until all the other threads have finished executing before returning.
Parameters
filename
string containing the name of the file to receive
timeout
number containing the minimum number of seconds to wait for the file to be received
Return values:
- status true on success false on failure
- File instance on success, nil on failure