Activity
Now, I will leave it up to you to package both the network scanner and the port scanner into a library and use the libraries to write a more compact script that does a network scan and scan for open ports for each IP that is found.
Readers are recommended to follow the outlined steps to reinforce the concepts presented in this chapter. Every task designed within this activity aims to test and solidify the reader’s comprehension effectively:
- Package both code snippets into the library.
- Name your new Python file
network-and-port-scanner.py
. - Import both libraries into the new program.
- Use argument parsing to obtain the IP and port ranges for scanning.
- Pass the IP address range to the network mapper for ARP scanning and write the IPs to a file.
- Read the IPs from the file and provide the discovered IP addresses with the port range to the port scanner.
- Print the IPs and ports into a table in a more visually appealing manner.