Nmap asn-query NSE Script
This page contains detailed information about how to use the asn-query NSE script. For list of all NSE scripts, visit the Nmap NSE Library.
Select: |
---|
Script Overview
Script source code: https://github.com/nmap/nmap/tree/master/scripts/asn-query.nse
Script categories: discovery, external, safe
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Script Description
The asn-query.nse script maps IP addresses to autonomous system (AS) numbers.
The script works by sending DNS TXT queries to a DNS server which in turn queries a third-party service provided by Team Cymru (https://www.team-cymru.org/Services/ip-to-asn.html) using an in-addr.arpa style zone set up especially for use by Nmap. The responses to these queries contain both Origin and Peer ASNs and their descriptions, displayed along with the BGP Prefix and Country Code. The script caches results to reduce the number of queries and should perform a single query for all scanned targets in a BGP Prefix present in Team Cymru's database.
Be aware that any targets against which this script is run will be sent
to and potentially recorded by one or more DNS servers and Team Cymru.
In addition your IP address will be sent along with the ASN to a DNS
server (your default DNS server, or whichever one you specified with the
dns
script argument).
Asn-query NSE Script Arguments
This is a full list of arguments supported by the asn-query.nse script:
dnsThe address of a recursive nameserver to use (optional).
- - -
To use this script argument, add it to Nmap command line like in this example:
nmap --script=asn-query --script-args dns=value <target>
Asn-query NSE Script Example Usage
Here's an example of how to use the asn-query.nse script:
nmap --script asn-query [--script-args dns=<DNS server>] <target>
Asn-query NSE Script Example Output
Here's a sample output from the asn-query.nse script:
Host script results:
| asn-query:
| BGP: 64.13.128.0/21 | Country: US
| Origin AS: 10565 SVCOLO-AS - Silicon Valley Colocation, Inc.
| Peer AS: 3561 6461
| BGP: 64.13.128.0/18 | Country: US
| Origin AS: 10565 SVCOLO-AS - Silicon Valley Colocation, Inc.
|_ Peer AS: 174 2914 6461
Asn-query NSE Script Example XML Output
There is no sample XML output for this module. However, by providing the -oX <file>
option, Nmap will produce a XML output and save it in the file.xml
file.
Authors
- jah
- Michael Pattrick
References
- https://nmap.org/nsedoc/scripts/asn-query.html
- https://github.com/nmap/nmap/tree/master/scripts/asn-query.nse
- https://www.team-cymru.org/Services/ip-to-asn.html
- http://www.team-cymru.org/Services/ip-to-asn.html#dns
See Also
Visit Nmap NSE Library for more scripts.
The asn-query.nse script may fail with the following error messages. Check for the possible causes by using the code snippets highlighted below found in the script source code. This can often times help in identifying the root cause of the problem.
Unknown Error
Here is a relevant code snippet related to the "Unknown Error" error message:
80: -- check for cached data
81: local in_cache, cache_data = check_cache( host.ip )
82:
83: if in_cache and type( cache_data ) == "table" then
84: combined_records = cache_data
85: elseif in_cache and type( cache_data ) == "string" and cache_data ~= "Unknown Error" then
86: output = cache_data
87: end
88:
89: if not in_cache then
90:
Error from dns.query(): %s
Here is a relevant code snippet related to the "Error from dns.query(): %s" error message:
211:
212: -- send the query
213: local status, decoded_response = dns.query( query, options)
214:
215: if not status then
216: stdnse.debug1("Error from dns.query(): %s", decoded_response )
217: end
218:
219: return status, decoded_response
220:
221: end
Error in get_assignment: Invalid prefix length.
Here is a relevant code snippet related to the "Error in get_assignment: Invalid prefix length." error message:
396: local some_ip, err = ipOps.ip_to_bin( ip )
397: if err then return nil, err end
398:
399: prefix = tonumber( prefix )
400: if not prefix or ( prefix < 0 ) or ( prefix > # some_ip ) then
401: return nil, "Error in get_assignment: Invalid prefix length."
402: end
403:
404: local hostbits = string.sub( some_ip, prefix + 1 )
405: hostbits = string.gsub( hostbits, "1", "0" )
406: local first = string.sub( some_ip, 1, prefix ) .. hostbits
Version
This page has been created based on Nmap version 7.92.
Go back to menu.