© Sanjib Sinha 2017

Sanjib Sinha, Beginning Ethical Hacking with Python, 10.1007/978-1-4842-2541-7_24

24. Building an Nmap Network Scanner

Sanjib Sinha

(1)Howrah, West Bengal, India

Now we’re ready to do more network testing using python scripts. And this time we’ll try to build up a more robust scanner and we’ll also try to detect the open ports and see if there are any vulnerabilities.

Let us write the python script first. And after that we’ll see the output. Let us change the ‘test.py’ script to this:

#!/usr/bin/pythonimport nmapnm = nmap.PortScanner()print (nm.nmap_version())nm.scan('x.x.xx.xxx', '1-1024', '-v')print(nm.scaninfo())print(nm.csv())

Here ‘-v’ stands for version and the ‘1-1024’ stands for the range of the port numbers.

It’s a very ...

Get Beginning Ethical Hacking with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.