A Python script that scans the local network for active hosts and displays them in a terminal user interface (TUI) built with curses. Designed primarily for Linux systems like Raspberry Pi OS, but should work on other Linux distributions and potentially macOS/Windows with the right dependencies.
- Auto-Detection: Automatically detects the local IP, netmask, gateway, and network range to scan.
- Terminal UI: Uses the
curseslibrary to provide an interactive terminal interface. - Host Discovery: Pings hosts in the specified network range to find active devices.
- Hostname Resolution: Attempts to resolve hostnames for found IP addresses.
- MAC Address Lookup: Tries to find MAC addresses using various methods (ARP table,
ip neigh,arp,arp-scan). - Host Details: View basic details (IP, Hostname, MAC), ping statistics, and results of a quick port scan for common ports (21, 22, 23, 25, 53, 80, 110, 135, 139, 443, 445, 3389, 8080).
- External Tool Integration: Provides options in the details view to launch
nmap(service scan) andtracerouteagainst the selected host (requires these tools and potentiallysudo). - Customizable Scan Range: Manually specify a different network range (CIDR notation) to scan.
- Background Scanning: Uses threading to perform scans without freezing the UI.
- Python 3.x
- Built-in modules:
ipaddress,subprocess,threading,time,queue,curses,socket,re,os,argparse,datetime,traceback. (Thecursesmodule might not be available by default on Windows).
These tools are called by the script and should be installed on your system and available in your PATH.
- Required:
ping(Usually provided byiputils-pingon Debian/Ubuntu)
- Recommended for full functionality:
ip(Usually provided byiproute2on Debian/Ubuntu)arp(Usually provided bynet-toolson Debian/Ubuntu)traceroute(Package nametracerouteon Debian/Ubuntu)nmap(Package namenmapon Debian/Ubuntu) - Needed for the 'Nmap Scan' option.arp-scan(Package namearp-scanon Debian/Ubuntu) - Used as a fallback for MAC address discovery, often requiressudo.
The script will check for these tools on startup.
-
Clone the repository:
git clone https://github.com/emphyri0/network_scanner cd network_scanner -
Install Dependencies (Example for Debian/Ubuntu): Make sure
pingis installed. For recommended tools:sudo apt update sudo apt install iproute2 net-tools traceroute nmap arp-scan python3
Note:
python3might already be installed. -
Make the script executable (Optional):
chmod +x network_scanner.py
Run the script from your terminal:
python3 network_scanner.py