import tkinter as tk
import os
import sys
import time
import threading
import netifaces
from scapy.all import *
from scapy.layers.l2 import ARP
from tkinter import messagebox
from scapy.layers.l2 import getmacbyip

class ArpDetectorPage:
    def __init__(self, master):
        self.master = master
        self.frame = tk.Frame(self.master)

        self.status_label = tk.Label(self.frame, text='Idle')
        self.status_label.pack()

        self.start_button = tk.Button(self.frame, text='Start', command=self.start_detection)
        self.start_button.pack()

        self.stop_button = tk.Button(self.frame, text='Stop', command=self.stop_detection, state=tk.DISABLED)
        self.stop_button.pack()

        self.frame.pack()

    def start_detection(self):
        self.status_label.config(text='Running')
        self.start_button.config(state=tk.DISABLED)
        self.stop_button.config(state=tk.NORMAL)

        self.arp_detector = ArpDetector('ens33')
        self.arp_detector.start()

    def stop_detection(self):
        self.status_label.config(text='Idle')
        self.start_button.config(state=tk.NORMAL)
        self.stop_button.config(state=tk.DISABLED)

        self.arp_detector.stop()

class MainWindow:
    def __init__(self):
        self.root = tk.Tk()
        self.root.title('网络安全工具包')
        self.root.geometry('400x350')

        self.arp_button = tk.Button(self.root, text='ARP 欺骗检测', command=self.show_arp_page)
        self.arp_button.pack()

        self.icmp_button = tk.Button(self.root, text='ICMP 洪泛检测', command=self.show_icmp_page)
        self.icmp_button.pack()

        self.tcp_button = tk.Button(self.root, text='TCP 攻击检测', command=self.show_tcp_page)
        self.tcp_button.pack()

        self.network_button = tk.Button(self.root, text='网络扫描', command=self.show_network_page)
        self.network_button.pack()

        self.root.mainloop()

    def show_arp_page(self):
        self.arp_page = tk.Toplevel(self.root)
        ArpDetectorPage(self.arp_page)

if __name__ == '__main__':
    users = [{'username': 'admin', 'password': 'admin'}]
    login_window = LoginWindow()
    main_window = MainWindow()
基于 Scapy 的 Python 网络安全工具包

原文地址: https://www.cveoy.top/t/topic/jnVR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录