CIDR-aware Nmap scanner that runs one subprocess per IP and writes XML output per host into a results directory.
- Python 3
nmapinstalled and available inPATH
python3 servicediscovery.py 10.0.0.0/24
python3 servicediscovery.py 192.168.1.10 --test
python3 servicediscovery.py 10.0.0.0/24 --top 200 --threads 8
python3 servicediscovery.py 10.0.0.0/24 --udp- Accepts one or more IPs/CIDRs as targets, separated by spaces.
- Launches one
nmapsubprocess per IP. - Runs multiple subprocesses in parallel (default: 4).
- Writes a separate XML file per host into
results/. - Supports TCP SYN or TCP connect scans.
- Optional UDP scanning.
Each scanned IP produces one XML file in the results directory:
- IPv4:
results/192.168.1.10.xml - IPv6: colons are replaced with underscores, e.g.
results/2001_db8__1.xml
One or more IP addresses or CIDRs (IPv4 or IPv6), separated by spaces.
Example:
python3 servicediscovery.py 10.0.0.0/24 192.168.1.10 172.16.0.0/16Number of parallel Nmap subprocesses.
- Default:
4
Nmap timing template. Lower is slower/stealthier, higher is faster.
- Default:
T3for TCP-only scansT4for UDP-enabled scans (unless you explicitly set--timing)
Directory for per-host XML output.
- Default:
results
Scan top ports instead of all ports.
- If
--topis present with no value, defaults to1000top ports. - If
--top Nis provided, scans topNports.
Single-IP test mode using top ports only.
- Requires exactly one IP target.
- Uses
--topvalue if provided, otherwise1000top ports.
Explicit path to the nmap binary if it is not in PATH.
TCP scan type:
syn:-sS(default, requires elevated privileges on most systems)connect:-sT(no special privileges required)
Enable UDP scanning by adding -sU.
- When enabled and
--timingis not specified, the default timing isT4.
Enable host discovery.
- Default behavior is
-Pn(treat all hosts as up). - Use
--pingif you want Nmap to probe for host discovery.
All ports (default), 4 threads, T3:
python3 servicediscovery.py 10.0.0.0/24Top ports only:
python3 servicediscovery.py 10.0.0.0/24 --top
python3 servicediscovery.py 10.0.0.0/24 --top 200Single IP test (top ports only):
python3 servicediscovery.py 192.168.1.10 --testUDP + TCP with rapid timing defaults:
python3 servicediscovery.py 10.0.0.0/24 --udpExplicit timing and connect scan:
python3 servicediscovery.py 10.0.0.0/24 --scan-type connect --timing 2- SYN (
-sS) and UDP (-sU) scans often require elevated privileges. If you see warnings, run with appropriate privileges or use--scan-type connectfor TCP. - Scanning large CIDRs with
-p-and UDP enabled can be very heavy. Consider--topfor faster discovery runs.