ftp NSE Library — Nmap Scripting Engine documentation (original) (raw)

Functions

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:

  1. Boolean true if auth succeeded, false otherwise
  2. FTP response code
  3. 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:

  1. socket The socket descriptor, or nil on errors
  2. code The numeric response code, as returned by read_reply, or error message if socket is nil.
  3. message The response message
  4. 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:

  1. The connected data socket, or nil on error
  2. 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:

  1. numeric code or nil.
  2. 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:

  1. Boolean true if AUTH TLS succeeded, false otherwise
  2. error string on failure