ARP欺骗检测软件 - 防护您的网络安全
ARP欺骗检测软件 - 防护您的网络安全
该软件旨在帮助用户检测网络中常见的ARP欺骗攻击,并提供其他网络安全功能,例如:
- ARP欺骗攻击检测: 实时监控网络流量,检测是否存在ARP欺骗攻击。
- ICMP flood攻击检测: 检测网络中是否存在ICMP flood攻击。
- TCP攻击检测: 检测网络中是否存在TCP攻击。
- 扫描局域网主机: 扫描您的局域网中的主机,获取主机IP地址和MAC地址。
- 检测攻击源: 识别网络攻击的来源。
- 查看检测记录: 记录所有检测到的攻击事件,方便您进行分析和处理。
使用方法:
- 注册/登录: 您需要先注册一个账户并登录软件。
- 功能选择: 登录成功后,您将进入功能页面,可以选择需要的功能进行操作。
- 结果查看: 软件会显示检测结果,并记录在检测日志中。
技术细节:
该软件使用Python编写,并使用了Scapy库进行网络数据包分析。
联系我们:
如果您有任何问题或建议,请随时与我们联系。
免责声明:
本软件仅供学习和研究之用,请勿用于任何非法目的。
代码说明:
import os
import time
import sys
import platform
from scapy.all import *
from tkinter import *
from tkinter import messagebox
# 设置界面
root = Tk()
root.title('ARP欺骗检测软件')
root.geometry('400x300')
# 注册界面
def register():
register_window = Toplevel(root)
register_window.title('注册')
register_window.geometry('300x200')
Label(register_window, text='请输入用户名:').pack()
username = Entry(register_window)
username.pack()
Label(register_window, text='请输入密码:').pack()
password = Entry(register_window, show='*')
password.pack()
def register_confirm():
with open('user.txt', 'a') as f:
f.write(username.get() + ' ' + password.get() + '\n')
messagebox.showinfo('提示', '注册成功!')
register_window.destroy()
Button(register_window, text='确认', command=register_confirm).pack()
# 登录界面
def login():
global login_window
login_window = Toplevel(root)
login_window.title('登录')
login_window.geometry('300x200')
Label(login_window, text='请输入用户名:').pack()
username = Entry(login_window)
username.pack()
Label(login_window, text='请输入密码:').pack()
password = Entry(login_window, show='*')
password.pack()
def login_confirm():
with open('user.txt', 'r') as f:
users = f.readlines()
for user in users:
if user.split()[0] == username.get() and user.split()[1] == password.get():
messagebox.showinfo('提示', '登录成功!')
enter_func() # 登录成功后进入功能页面
return
messagebox.showerror('错误', '用户名或密码错误!')
Button(login_window, text='确认', command=login_confirm).pack()
# ICMP flood攻击检测
def icmp_flood():
sniff_filter = 'icmp'
sniff_timeout = 10
sniff_count = 0
sniff_packets = sniff(filter=sniff_filter, timeout=sniff_timeout)
for packet in sniff_packets:
sniff_count += 1
if sniff_count > 100:
messagebox.showwarning('警告', '检测到ICMP flood攻击!')
with open('detection_log.txt', 'a') as f:
f.write('ICMP flood攻击检测 - 检测结果:检测到ICMP flood攻击\n')
else:
messagebox.showinfo('提示', '未检测到ICMP flood攻击!')
with open('detection_log.txt', 'a') as f:
f.write('ICMP flood攻击检测 - 检测结果:未检测到ICMP flood攻击\n')
return
# TCP攻击检测
def tcp_attack():
sniff_filter = 'tcp'
sniff_timeout = 10
sniff_count = 0
sniff_packets = sniff(filter=sniff_filter, timeout=sniff_timeout)
for packet in sniff_packets:
sniff_count += 1
if sniff_count > 100:
messagebox.showwarning('警告', '检测到TCP攻击!')
with open('detection_log.txt', 'a') as f:
f.write('TCP攻击检测 - 检测结果:检测到TCP攻击\n')
else:
messagebox.showinfo('提示', '未检测到TCP攻击!')
with open('detection_log.txt', 'a') as f:
f.write('TCP攻击检测 - 检测结果:未检测到TCP攻击\n')
return
# ARP欺骗攻击检测
def arp_spoofing():
sniff_filter = 'arp'
sniff_timeout = 10
sniff_count = 0
sniff_packets = sniff(filter=sniff_filter, timeout=sniff_timeout)
for packet in sniff_packets:
sniff_count += 1
if sniff_count > 100:
messagebox.showwarning('警告', '检测到ARP欺骗攻击!')
with open('detection_log.txt', 'a') as f:
f.write('ARP欺骗攻击检测 - 检测结果:检测到ARP欺骗攻击\n')
else:
messagebox.showinfo('提示', '未检测到ARP欺骗攻击!')
with open('detection_log.txt', 'a') as f:
f.write('ARP欺骗攻击检测 - 检测结果:未检测到ARP欺骗攻击\n')
return
# 扫描局域网主机
def scan_network():
network = '192.168.31.0/24'
arp_request = ARP(pdst=network)
broadcast = Ether(dst='ff:ff:ff:ff:ff:ff')
arp_broadcast = broadcast/arp_request
answered_list = srp(arp_broadcast, timeout=1, verbose=False)[0]
clients = []
for element in answered_list:
client = {'ip': element[1].psrc, 'mac': element[1].hwsrc}
clients.append(client)
with open('clients.txt', 'w') as f:
for client in clients:
f.write(client['ip'] + ' ' + client['mac'] + '\n')
messagebox.showinfo('提示', '扫描完成!')
# 检测攻击源
def detect_attack():
with open('clients.txt', 'r') as f:
clients = f.readlines()
for client in clients:
ip = client.split()[0]
mac = client.split()[1]
sniff_filter = 'arp and src host ' + ip
sniff_timeout = 10
sniff_count = 0
sniff_packets = sniff(filter=sniff_filter, timeout=sniff_timeout)
for packet in sniff_packets:
sniff_count += 1
if sniff_count > 100:
messagebox.showwarning('警告', '检测到攻击源IP地址为' + ip + ',MAC地址为' + mac + '!')
with open('detection_log.txt', 'a') as f:
f.write('警告' + '检测到攻击源IP地址为' + ip + ',MAC地址为' + mac + '!\n')
else:
messagebox.showinfo('提示', '未检测到攻击源!')
with open('detection_log.txt', 'a') as f:
f.write('提示' + '未检测到攻击源!\n')
return
def view_detection_log():
with open('detection_log.txt', 'r') as f:
detection_log = f.read()
messagebox.showinfo('检测记录', detection_log)
# 创建用户和客户端记录文件
if not os.path.exists('user.txt'):
open('user.txt', 'w').close()
if not os.path.exists('clients.txt'):
open('clients.txt', 'w').close()
# 创建按钮
register_button = Button(root, text='注册', command=register)
register_button.pack(pady=10)
login_button = Button(root, text='登录', command=login)
login_button.pack(pady=10)
def enter_func():
# 关闭登录窗口
login_window.destroy()
# 创建新窗口
func_window = Toplevel(root)
func_window.title('功能页面')
func_window.geometry('400x300')
# 创建四个功能按钮
icmp_flood_button = Button(func_window, text='检测ICMP flood攻击', command=icmp_flood)
icmp_flood_button.pack(pady=10)
tcp_attack_button = Button(func_window, text='检测TCP攻击', command=tcp_attack)
tcp_attack_button.pack(pady=10)
arp_spoofing_button = Button(func_window, text='检测ARP欺骗攻击', command=arp_spoofing)
arp_spoofing_button.pack(pady=10)
detect_attack_button = Button(func_window, text='检测攻击源', command=detect_attack)
detect_attack_button.pack(pady=10)
scan_network_button = Button(func_window, text='扫描局域网主机', command=scan_network)
scan_network_button.pack(pady=10)
view_detection_log_button = Button(root, text='查看检测记录', command=view_detection_log)
view_detection_log_button.pack(pady=10)
root.mainloop()
问题解决
您提到的404错误可能是因为 enter_func() 函数定义在 login() 函数之后,导致在 login_confirm() 函数中调用 enter_func() 时找不到该函数。解决方法是将 enter_func() 函数的定义提前到 login() 函数之前。
修改后的代码:
...
# 登录界面
def login():
...
# 登录成功后进入功能页面
def enter_func():
...
...
此外,代码中还包含Flask框架相关的代码,这可能意味着该软件是作为一个Flask应用程序运行的。如果您想使用Flask框架来运行该软件,需要将代码整合到一个Flask应用程序中,并使用Flask的路由机制来处理不同的功能。
补充说明
- 该代码示例仅供参考,实际开发中需要根据具体需求进行修改和完善。
- 为了提高软件的安全性,建议使用更复杂的密码验证机制,例如使用哈希函数对密码进行加密。
- 该软件主要用于检测ARP欺骗攻击,对于其他类型的网络攻击,例如DDoS攻击,需要使用其他方法进行检测和防御。
希望以上信息能够帮助您更好地理解和使用ARP欺骗检测软件。
AI 优化版
原文地址:https://www.cveoy.top/t/topic/jn6Z 著作权归作者所有。请勿转载和采集!