A Python wrapper for Nmap enabling parallel network scans with full DTD support and asynchronous callbacks for efficient vulnerability analysis.
Nmap wrapper for python with full Nmap DTD support, parallel scans and threaded callback methods support for faster analytics.
This tool is designed for security professionals and network administrators who need to automate and accelerate network scanning tasks using Nmap within Python environments. It facilitates parallel TCP and UDP scans with threaded callbacks, making it ideal for large-scale network monitoring and vulnerability assessments. Users can easily save scan reports in multiple formats for further analysis or integration into security workflows.
Requires Python 3.7+ and a local installation of Nmap. The asynchronous callback methods run in separate threads, so users should ensure thread-safe operations within callbacks. The tool supports saving reports in multiple formats, facilitating integration with other security analytics tools. Donations are encouraged to support ongoing development.
Install Python 3.7 (or compatible version)
Install python3-pip package
Install Nmap from https://github.com/nmap/nmap
Run `pip3 install nmap-scan` to install the nmap-scan Python packagefrom nmap_scan.NmapArgs import NmapArgs from nmap_scan.NmapScanMethods import NmapScanMethods from nmap_scan.Scanner import Scanner args = NmapArgs(['192.168.0.1/24']) scanner = Scanner(args) def callback_method(report, scan_method): filename = { NmapScanMethods.TCP: 'tcp', NmapScanMethods.UDP: 'udp', } report.save('reports/scan-' + filename.get(scan_method) + '.xml') report.save_html('reports/scan-' + filename.get(scan_method) + '.html') report.save_json('reports/scan-' + filename.get(scan_method) + '.json') scanner.scan_udp_background(callback_method) scanner.scan_tcp_background(callback_method) scanner.wait_all()
Performs parallel TCP and UDP scans on a subnet asynchronously, saving reports in XML, HTML, and JSON formats via a callback.
from nmap_scan.MultiScanner import MultiScanner from nmap_scan.MultiScannerConfiguration import MultiScannerConfiguration from nmap_scan.NmapArgs import NmapArgs from nmap_scan.NmapScanMethods import NmapScanMethods args = NmapArgs(['192.168.0.0/24']) args2 = NmapArgs(['192.168.1.0/24']) def callback_method(ip, report, scan_method): filename = { NmapScanMethods.TCP: 'tcp', NmapScanMethods.UDP: 'udp', } report.save('reports/' + ip + '_' + filename.get(scan_method) + '.xml') report.save_html('reports/' + ip + '_' + filename.get(scan_method) + '.html') report.save_json('reports/' + ip + '_' + filename.get(scan_method) + '.json') configs = [ MultiScannerConfiguration(nmap_args=args, scan_methods=[NmapScanMethods.TCP, NmapScanMethods.UDP], callback_method=callback_method), MultiScannerConfiguration(nmap_args=args2, scan_methods=[NmapScanMethods.TCP], callback_method=callback_method), ] scanner = MultiScanner(configs) scanner.scan_background()
Executes parallel scans on multiple network configurations with asynchronous callbacks for each host, saving reports in multiple formats.