IPPacketGenerator.py 466 B

1234567891011
  1. from scapy.layers.inet import IP, Ether, TCP
  2. from scapy.packet import Raw
  3. def generate_ip_packet(ip_src="192.168.64.32", ip_dst="192.168.64.48", mac_src="56:6D:D9:BC:70:1C", mac_dst="F4:2B:95:B3:0E:1A",
  4. port_src=1337, port_dst=6442, tcpflags="S", payload = ""):
  5. ether = Ether(src=mac_src, dst=mac_dst)
  6. ip = IP(src=ip_src, dst=ip_dst)
  7. tcp = TCP(sport=port_src, dport=port_dst, flags=tcpflags)
  8. packet = ether / ip / tcp / Raw(load=payload)
  9. return packet