Browse Source

add an IP packet generator function

dustin.born 7 years ago
parent
commit
3af5afbb76
1 changed files with 11 additions and 0 deletions
  1. 11 0
      code/Iteration1/IPPacketGenerator.py

+ 11 - 0
code/Iteration1/IPPacketGenerator.py

@@ -0,0 +1,11 @@
+from scapy.layers.inet import IP, Ether, TCP
+from scapy.packet import Raw
+
+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",
+					   port_src=1337, port_dst=6442, tcpflags="S", payload = ""):
+
+	ether = Ether(src=mac_src, dst=mac_dst)
+	ip = IP(src=ip_src, dst=ip_dst)
+	tcp = TCP(sport=port_src, dport=port_dst, flags=tcpflags)
+	packet = ether / ip / tcp / Raw(load=payload)
+	return packet