Nmap targets-sniffer NSE Script
This page contains detailed information about how to use the targets-sniffer 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/targets-sniffer.nse
Script categories: broadcast, discovery, safe
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Script Description
The targets-sniffer.nse script sniffs the local network for a configurable amount of time (10 seconds
by default) and prints discovered addresses. If the
newtargets
script argument is set, discovered addresses
are added to the scan queue.
Requires root privileges. Either the targets-sniffer.iface
script
argument or -e
Nmap option to define which interface to use.
Targets-sniffer NSE Script Arguments
This is a full list of arguments supported by the targets-sniffer.nse script:
newtargetsIf true, add discovered targets to the scan queue.
targets-sniffer.ifaceThe interface to use for sniffing.
targets-sniffer.timeout
The amount of time to listen for packets. Default 10s
.
Sets the number of the maximum allowed new targets. If set to 0 or less then there is no limit. The default value is 0.
- - -
To use these script arguments, add them to the Nmap command line using the --script-args arg1=value,[arg2=value,..]
syntax. For example:
nmap --script=targets-sniffer --script-args newtargets=value,targets-sniffer.iface=value <target>
Targets-sniffer NSE Script Example Usage
Here's an example of how to use the targets-sniffer.nse script:
nmap -sL --script=targets-sniffer --script-args=newtargets,targets-sniffer.timeout=5s,targets-sniffer.iface=eth0
Targets-sniffer NSE Script Example Output
Here's a sample output from the targets-sniffer.nse script:
Pre-scan script results:
| targets-sniffer:
| 192.168.0.1
| 192.168.0.3
| 192.168.0.35
|_192.168.0.100
Targets-sniffer 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.
Author
- Nick Nikolaou
References
- https://nmap.org/nsedoc/scripts/targets-sniffer.html
- https://github.com/nmap/nmap/tree/master/scripts/targets-sniffer.nse
See Also
Related NSE scripts to the targets-sniffer.nse script:
- targets-asn.nse
- targets-ipv6-map4to6.nse
- targets-ipv6-multicast-echo.nse
- targets-ipv6-multicast-invalid-dst.nse
- targets-ipv6-multicast-mld.nse
- targets-ipv6-multicast-slaac.nse
- targets-ipv6-wordlist.nse
- targets-traceroute.nse
- targets-xml.nse
Visit Nmap NSE Library for more scripts.
The targets-sniffer.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.
Error: Unable to get interface info. Did you specify the correct interface using 'targets-sniffer.iface=<interface>' or '-e <interface>'?
Here is a relevant code snippet related to the "Error: Unable to get interface info. Did you specify the correct interface using 'targets-sniffer.iface=<interface>' or '-e <interface>'?" error message:
80: timeout = (timeout or 10) * 1000
81: local interface = stdnse.get_script_args("targets-sniffer.iface") or nmap.get_interface()
82: interface_info = nmap.get_interface_info(interface)
83:
84: if interface_info==nil then -- Check if we have the interface information
85: stdnse.debug1("Error: Unable to get interface info. Did you specify the correct interface using 'targets-sniffer.iface=<interface>' or '-e <interface>'?")
86: return
87: end
88:
89:
90: if sock==nil then
Error - unable to open socket using interface %s
Here is a relevant code snippet related to the "Error - unable to open socket using interface %s" error message:
86: return
87: end
88:
89:
90: if sock==nil then
91: stdnse.debug1("Error - unable to open socket using interface %s",interface)
92: return
93: else
94: sock:pcap_open(interface, 104, true, "ip or ip6")
95: stdnse.debug1("Will sniff for %s seconds on interface %s.", (timeout/1000),interface)
96:
Version
This page has been created based on Nmap version 7.92.
Go back to menu.