Script whois-ip

Script types: hostrule
Categories: discovery, external, safe
Download: https://svn.nmap.org/nmap/scripts/whois-ip.nse

Script Summary

Queries the WHOIS services of Regional Internet Registries (RIR) and attempts to retrieve information about the IP Address Assignment which contains the Target IP Address.

The fields displayed contain information about the assignment and the organisation responsible for managing the address space. When output verbosity is requested on the Nmap command line (-v) extra information about the assignment will be displayed.

To determine which of the RIRs to query for a given Target IP Address this script utilises Assignments Data hosted by IANA. The data is cached locally and then parsed for use as a lookup table. The locally cached files are refreshed periodically to help ensure the data is current. If, for any reason, these files are not available to the script then a default sequence of Whois services are queried in turn until: the desired record is found; or a referral to another (defined) Whois service is found; or until the sequence is exhausted without finding either a referral or the desired record.

The script will recognize a referral to another Whois service if that service is defined in the script and will continue by sending a query to the referred service. A record is assumed to be the desired one if it does not contain a referral.

To reduce the number unnecessary queries sent to Whois services a record cache is employed and the entries in the cache can be applied to any targets within the range of addresses represented in the record.

In certain circumstances, the ability to cache responses prevents the discovery of other, smaller IP address assignments applicable to the target because a cached response is accepted in preference to sending a Whois query. When it is important to ensure that the most accurate information about the IP address assignment is retrieved the script argument whodb should be used with a value of "nocache" (see script arguments). This reduces the range of addresses that may use a cached record to a size that helps ensure that smaller assignments will be discovered. This option should be used with caution due to the potential to send large numbers of whois queries and possibly be banned from using the services.

In using this script your IP address will be sent to iana.org. Additionally your address and the address of the target of the scan will be sent to one of the RIRs.

See also:

Script Arguments

whodb

Takes any of the following values, which may be combined:

  • whodb=nofile Prevent the use of IANA assignments data and instead query the default services.
  • whodb=nofollow Ignore referrals and instead display the first record obtained.
  • whodb=nocache Prevent the acceptance of records in the cache when they apply to large ranges of addresses.
  • whodb=[service-ids] Redefine the default services to query. Implies nofile.
slaxml.debug

See the documentation for the slaxml library.

http.host, http.max-body-size, http.max-cache-size, http.max-pipeline, http.pipeline, http.truncated-ok, http.useragent

See the documentation for the http library.

smbdomain, smbhash, smbnoguest, smbpassword, smbtype, smbusername

See the documentation for the smbauth library.

Example Usage

# Basic usage:
nmap target --script whois-ip

# To prevent the use of IANA assignments data supply the nofile value
# to the whodb argument:
nmap target --script whois-ip --script-args whodb=nofile
nmap target --script whois-ip --script-args whois.whodb=nofile

# Supplying a sequence of whois services will also prevent the use of
# IANA assignments data and override the default sequence:
nmap target --script whois-ip --script-args whodb=arin+ripe+afrinic
nmap target --script whois-ip --script-args whois.whodb=apnic*lacnic
# The order in which the services are supplied is the order in which
# they will be queried. (N.B. commas or semi-colons should not be
# used to delimit argument values.)

# To return the first record obtained even if it contains a referral
# to another service, supply the nofollow value to whodb:
nmap target --script whois-ip --script-args whodb=nofollow
nmap target --script whois-ip --script-args whois.whodb=nofollow+ripe
# Note that only one service (the first one supplied) will be used in
# conjunction with nofollow.

# To ensure discovery of smaller assignments even if larger ones
# exist in the cache, supply the nocache value to whodb:
nmap target --script whois-ip --script-args whodb=nocache
nmap target --script whois-ip --script-args whois.whodb=nocache

Script Output

Host script results:
|  whois-ip: Record found at whois.arin.net
|  netrange: 64.13.134.0 - 64.13.134.63
|  netname: NET-64-13-143-0-26
|  orgname: Titan Networks
|  orgid: INSEC
|_ country: US stateprov: CA

Requires


Author:

  • jah

License: Same as Nmap--See https://nmap.org/book/man-legal.html

action

action (host)

Queries WHOIS services until an applicable record is found or the list of services to query is exhausted and finishes by displaying elements of an applicable record.

Parameters

host
 

hostrule

hostrule (host)

This script will run only if the target IP address has been determined to be routable on the Internet.

Parameters

host