From 98eb70d9d25abef2cd2177136dc56afe2c8740f0 Mon Sep 17 00:00:00 2001 From: Mr Hobbits <7462443+MrHobbits@users.noreply.github.com> Date: Tue, 5 Apr 2022 20:26:06 -0700 Subject: [PATCH] Added Hostname detection using socket Changed lined 36 to include the hostname grabbed from the IP. --- network_scanner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/network_scanner.py b/network_scanner.py index 3aeb669..91a8a82 100644 --- a/network_scanner.py +++ b/network_scanner.py @@ -1,5 +1,6 @@ import scapy.all as scapy import argparse +import socket def get_args(): parser = argparse.ArgumentParser() @@ -30,9 +31,9 @@ def scan(ip): return result def display_result(result): - print("-----------------------------------\nIP Address\tMAC Address\n-----------------------------------") + print("-----------------------------------\nIP Address\tMAC Address\tHostname\n-----------------------------------") for i in result: - print("{}\t{}".format(i["ip"], i["mac"])) + print("{}\t{}\t{}".format(i["ip"], i["mac"], socket.gethostbyaddr(i["ip"][0])) options = get_args()