Nmap Port Scanner In Python

This assignment will require you to take advantage of third party utilities to create a port scanner and record the results. You’ll use the Nmap port scanning tool through the python-nmap module. Instead of printing the results of each scan, you’ll instead store the results in a SQLite3 database table. The final deliverable will be a single Python script. The requirements for the project are below followed by some extra credit that you can optionally incorporate into your script.

Points possible: 50; extra credit possible: 30


  • Include all the header pieces (shebang, imports, comments)

  • Hardcode hosts and ports variables and values near the beginning of the scripts

  • Utilize Nmap to scan host(s) and port(s) – your script must accept the following forms (w/ examples):

o Host as single IP address (string):

o Hosts as a range (string): or

o Port as single number (string): 22

o Ports as a range (string): 20-22

  • Create a single function that contains the database update operation (if you create multiple CRUD operations, be sure to create separate functions for each, or better yet, a separate module)

  • Wrap potentially troublesome CRUD operations in a try-except-fail block

  • Create your database table if it doesn’t already exist (test to make sure script your doesn’t blow up in either case)

  • At minimum, your table must have:

o A primary key that autoincrements

o A column that records the host for each result set

o A column that records the scan data for the corresponding host (this might include one or more port scans for each host)

  •  Clean up after the database code (commit data, close connections, etc.)

  •  Host and scan data that you store in the database must come from the scan result (i.e., don’t store the host that you get from the variable you created – it must come from the nmap scan result)

  • Test to make sure your script works before you submit it

Extra Credit:

  • (5 points) Add functionality to your script that reads hosts and ports from the command line instead of relying on hardcoded values inside the script

  • (5 points) Create additional columns in the database table and store important pieces of data from each scan result set that you’ve drilled down into and cherry picked (minimum 3 additional columns)

  • (10 points) Create additional table(s) with child relationships to the primary table that store additional information such as scan results for each port

o Nmap scan results are keyed by host and inside each host’s scan result, each result set is keyed by port number with individual results – as such, a child table that stores results for each port must refer back to the parent table using a foreign key (typically the primary key of the parent)

  •  (10 points) Create a neatly formatted PDF or XLS report based on the data from the database

o Must be nicely organized and human readable – not just data thrown on a page

o Data must be queried from the database

o This can be incorporated in the scanning script or be a script of its own

Contact Us to Get any python programming or project related help at contact@codersarts.com and get instant help with us.

Contact Us

Tel: (+91) 0120  4118730  

Time :   10 : 00  AM -  08 : 00 PM IST 

Registered address: G-69, Sector 63, 

 Noida - 201301, India

We Provide Services Across The different countries

USA    Australia   Canada   UK    UAE    Singapore   New Zealand    Malasia   India   Ireland   Germany

CodersArts is a Product by Sofstack Technology Solutions Pvt. Ltd.

  • CodersArts | Linkedin
  • Instagram