Although the output of Nmap gives us an overview of the live hosts on the scanned network, we can enhance it and have a better output view. For example, I need to know the total number of hosts at the beginning of the output, then the IP address, MAC address, and MAC vendor for each one, but in tabular form, so I can easily locate any host and all of the information associated with it.
For that reason, I will design a function and name it nmap_report(). This function will take the standard output generated from the subprocess pipe and will extract the required information and format it in table format:
def nmap_report(data): mac_flag = "" ip_flag = "" Host_Table = PrettyTable(["IP", "MAC", "Vendor"]) number_of_hosts = ...