ftp NSE Library — Nmap Scripting Engine documentation (original) (raw)
FTP functions.
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/ftp.lua
Functions
auth (socket, buffer, username, password, acct)
Authenticate with username and password
close (socket)
Close an FTP command connection
connect (host, port, opts)
Connects to the FTP server based on the provided options and returns the parsed banner.
pasv (socket, buffer)
Start PASV mode
read_reply (buffer)
Read an FTP reply and return the numeric code and the message. See RFC 959, section 4.2.
starttls (socket, buffer)
Issue a STARTTLS command.
Functions
auth (socket, buffer, username, password, acct)
Authenticate with username and password
May negotiate AUTH TLS if required
Parameters
socket
The connected command socket
buffer
The socket read buffer
username
The username to send
password
The password to send
acct
(optional) If the server requires it, send this account name. Default: username
Return values:
- Boolean true if auth succeeded, false otherwise
- FTP response code
- FTP response message
close (socket)
Close an FTP command connection
Parameters
socket
The socket with the live connection
connect (host, port, opts)
Connects to the FTP server based on the provided options and returns the parsed banner.
Parameters
host
The host table
port
The port table
opts
The connection option table, from comm.lua.
Return values:
- socket The socket descriptor, or nil on errors
- code The numeric response code, as returned by read_reply, or error message if socket is nil.
- message The response message
- buffer The socket read buffer function, to be passed to read_reply.
See also:
pasv (socket, buffer)
Start PASV mode
For IPv6 connections, attempts to use EPSV (RFC 2428). If the server sends an address that is not the target address, then this is an error.
Parameters
socket
The connected command socket
buffer
The receive buffer
Return values:
- The connected data socket, or nil on error
- Error message if data socket is nil
read_reply (buffer)
Read an FTP reply and return the numeric code and the message. See RFC 959, section 4.2.
Parameters
buffer
The buffer returned by ftp.connect or created withstdnse.make_buffer(socket, "\r?\n")
.
Return values:
- numeric code or
nil
. - text reply or error message.
starttls (socket, buffer)
Issue a STARTTLS command.
Parameters
socket
The connected command socket
buffer
The socket read buffer
Return values:
- Boolean true if AUTH TLS succeeded, false otherwise
- error string on failure