A Python-based network scanner with a Tkinter GUI. It discovers hosts, performs SYN and UDP port scans, optionally detects OS, and visualizes network topology. Scan results can be saved.
- Network Discovery: Finds live hosts in an IP range.
- Port Scanning: SYN (TCP) and UDP scans.
- OS Detection: Optional operating system identification.
- GUI: User-friendly Tkinter interface.
- Results Table: Displays IP, port, protocol, state, and OS.
- Network Visualization: Interactive (HTML/Pyvis) and static (Matplotlib) network graphs.
- Save Results: Exports scan data to JSON.
- Status Bar: Shows logs and progress.
- Python 3
- Nmap (
python-nmapwrapper) - Tkinter (with
ttkthemes) - NetworkX, Matplotlib, Pyvis (for visualizations)
- Python 3: Install from python.org.
- Nmap: Install from nmap.org. Ensure it's added to your system PATH or configure its location as described below.
- Get the Code: Clone the repository or download the project files.
- Configure Nmap Path (If Necessary):
- The application attempts to find Nmap in your system's PATH by default.
- If Nmap is not in your PATH, or you need to use a specific Nmap installation:
- Copy
config.example.jsontoconfig.jsonin the project's root directory. - Edit
config.jsonand set thenmap_pathto the full path of yournmap.exe(or Nmap executable). Example for Windows (note the double backslashes\\which are required in JSON strings for literal backslashes):For Linux/macOS, a typical path might be{ "nmap_path": "C:\\Program Files (x86)\\Nmap\\nmap.exe" }"/usr/bin/nmap"or"/usr/local/bin/nmap"(single slashes are fine). - If
nmap_pathinconfig.jsonis empty or set to the placeholder, the system PATH will be tried.
- Copy
- Set Up Python Environment & Install Dependencies:
(
# Navigate to the project directory cd <your_project_directory> # Create and activate a virtual environment (recommended) python -m venv myenv # On Windows: myenv\Scripts\activate # On macOS/Linux: # source myenv/bin/activate # Install required libraries pip install -r requirements.txt
requirements.txtincludes:python-nmap,networkx,matplotlib,pyvis,ttkthemes)
Execute main.py from the project's root directory:
python main.pyThis will launch the Port Scanner GUI.
- Target IP(s): Enter IP addresses or ranges (e.g.,
192.168.1.1,192.168.1.1-100,192.168.1.0/24). - Scan Type: Choose "SYN Scan" (TCP) or "UDP Scan".
- OS Detection: Check the box to enable OS detection (may require admin/root privileges).
- Results: View scan output in the table. Hosts without open ports are also listed.
- Visualize: Click buttons to generate interactive (HTML) or static network maps.
- Save: Save detailed results to a JSON file.
- Path Priority: The application checks for Nmap in this order:
- Path specified in
config.json. - System PATH. For reliable operation, ensure Nmap is accessible via one of these methods.
- Path specified in
- Permissions: SYN scans and OS detection often require administrator/root privileges. If these scans fail or behave unexpectedly, try running the application with elevated permissions.
PortScanner/
├── .gitignore
├── main.py # Main entry point
├── gui.py # Tkinter GUI and user interactions
├── scanner.py # Core scanning logic (uses python-nmap)
├── visualization.py # Network graph generation
├── requirements.txt # Python dependencies
├── config.example.json # Example Nmap path configuration
├── README.md # This file