I need you to create a Windows application that allows me to view and control the devices connected to my home network.
Here's a basic example of a Windows application that uses the `scapy` library to scan the network and the `tkinter` library to create a GUI. This application will display a list of devices connected to the network and allow you to view their MAC addresses and IP addresses.
**Note:** This application requires administrative privileges to run.
**Required Libraries:**
* `scapy` for network scanning
* `tkinter` for GUI creation
* `psutil` for getting system information
**Installation:**
```bash
pip install scapy tkinter psutil
```
**Code:**
```python
import tkinter as tk
from tkinter import ttk
from scapy.all import ARP, Ether, srp
import psutil
import platform
class NetworkScanner:
def __init__(self, root):
self.root = root
self.root.title("Network Scanner")
self.root.geometry("800x600")
# Create tabs
self.notebook = ttk.Notebook(self.root)
self.notebook.pack(pady=10, expand=True)
self.scan_tab = ttk.Frame(self.notebook)
self.info_tab = ttk.Frame(self.notebook)
self.notebook.add(self.scan_tab, text="Scan")
self.notebook.add(self.info_tab, text="Info")
# Scan tab
self.scan_label = ttk.Label(self.scan_tab, text="Scan Network")
self.scan_label.pack(pady=10)
self.scan_button = ttk.Button(self.scan_tab, text="Scan", command=self.scan_network)
self.scan_button.pack(pady=10)
self.scan_text = tk.Text(self.scan_tab)
self.scan_text.pack(pady=10, expand=True, fill="both")
# Info tab
self.info_label = ttk.Label(self.info_tab, text="System Info")
self.info_label.pack(pady=10)
self.info_text = tk.Text(self.info_tab)
self.info_text.pack(pady=10, expand=True, fill="both")
self.get_system_info()
def scan_network(self):
self.scan_text.delete(1.0, tk.END)
arp = ARP(pdst="192.168.1.0/24") # Change to your network IP
ether = Ether(dst="ff:ff:ff:ff:ff:ff")
packet = ether/arp
result = srp(packet, timeout=3, verbose=0)[0]
self.scan_text.insert(tk.END, "IP\t\t\tMAC\n")
for sent, received in result:
self.scan_text.insert(tk.END, f"{received.psrc}\t{received.hwsrc}\n")
def get_system_info(self):
self.info_text.delete(1.0, tk.END)
self.info_text.insert(tk.END, f"System: {platform.system()}\n")
self.info_text.insert(tk.END, f"Release: {platform.release()}\n")
self.info_text.insert(tk.END, f"Version: {platform.version()}\n")
self.info_text.insert(tk.END, f"Machine: {platform.machine()}\n")
self.info_text.insert(tk.END, f"Processor: {platform.processor()}\n")
self.info_text.insert(tk.END, "\nNetwork Info:\n")
self.info_text.insert(tk.END, f"IP Address: {psutil.net_if_addrs()['Ethernet'][0].address}\n")
self.info_text.insert(tk.END, f"Subnet Mask: {psutil.net_if_addrs()['Ethernet'][0].netmask}\n")
self.info_text.insert(tk.END, f"Gateway: {psutil.net_if_addrs()['Ethernet'][0].gateway}\n")
if __name__ == "__main__":
root = tk.Tk()
app = NetworkScanner(root)
root.mainloop()
```
**Usage:**
1. Run the script.
2. Click on the "Scan" tab.
3. Click on the "Scan" button to scan the network.
4. The list of devices connected to the network will be displayed in the text box.
5. Click on the "Info" tab to view system information.
6. The system information will be displayed in the text box.
**Note:** This is a basic example and may not work on all networks. You may need to adjust the network IP and subnet mask to match your network configuration.