Home page logo
/
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Sponsors


Library comm

Common communication functions for network discovery tasks like banner grabbing and data exchange.

The functions in this module return values appropriate for use with exception handling via nmap.new_try.

These functions may be passed a table of options, but it's not required. The keys for the options table are:

  • bytes - minimum number of bytes to read.
  • lines - minimum number of lines to read.
  • proto - string, protocol to use. Default "tcp"
  • timeout - socket timeout in milliseconds. Default 8000
  • connect_timeout - override timeout for connection
  • request_timeout - override timeout for requests
  • recv_before - boolean, receive data before sending first payload

If both "bytes" and "lines" are provided, "lines" takes precedence. If neither are given, the functions read as many bytes as possible.

Author:
Kris Katterjohn 04/2008

Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html

Source: http://nmap.org/svn/nselib/comm.lua

Functions

exchange (host, port, data, opts)

This function connects to the specified port number on the specified host, sends data, then waits for and returns the response, if any.

get_banner (host, port, opts)

This function simply connects to the specified port number on the specified host and returns any data received.

tryssl (host, port, data, opts)

This function tries to open a connection based on the best option about which is the correct protocol



Functions

exchange (host, port, data, opts)

This function connects to the specified port number on the specified host, sends data, then waits for and returns the response, if any.

The first return value is true to signal success or false to signal failure. On success the second return value is the response from the remote host. On failure the second return value is an error message.

Parameters

  • host: The host to connect to.
  • port: The port on the host.
  • data: The data to send initially.
  • opts: The options. See the module description.

Return values:

  1. Status (true or false).
  2. Data (if status is true) or error string (if status is false).
get_banner (host, port, opts)

This function simply connects to the specified port number on the specified host and returns any data received.

The first return value is true to signal success or false to signal failure. On success the second return value is the response from the remote host. On failure the second return value is an error message.

Parameters

  • host: The host to connect to.
  • port: The port on the host.
  • opts: The options. See the module description.

Return values:

  1. Status (true or false).
  2. Data (if status is true) or error string (if status is false).
tryssl (host, port, data, opts)

This function tries to open a connection based on the best option about which is the correct protocol

If the best option fails, the function tries the other option

This function allows writing nse scripts in a way that the API will take care of ssl issues, making failure detection transparent to the programmer

Parameters

  • host: The host table
  • port: The port table
  • data: The first data payload of the connection
  • opts: Options, such as timeout

Return values:

  1. sd The socket descriptor
  2. response The response received for the payload
  3. correctOpt Correct option for connection guess
  4. earlyResp If opt recv_before is true, returns the value of the first receive (before sending data)

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]