38 lines
849 B
Python
38 lines
849 B
Python
|
#!/usr/bin/python3
|
||
|
|
||
|
from scapy.all import *
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
p = []
|
||
|
|
||
|
e0 = Ether(src="00:00:00:00:00:00",
|
||
|
dst="00:00:00:00:00:00")
|
||
|
|
||
|
e = Ether(src="02:53:55:42:45:01",
|
||
|
dst='ff:ff:ff:ff:ff:ff')
|
||
|
|
||
|
i0 = IP(src = "0.0.0.0",
|
||
|
dst = "0.0.0.0")
|
||
|
|
||
|
i4 = IP(src = "192.168.1.1",
|
||
|
dst = "192.168.4.2")
|
||
|
|
||
|
i6 = IPv6(src = "2001:db8:42::1",
|
||
|
dst = "2001:db8::2")
|
||
|
|
||
|
t0 = TCP(dport=0, sport=0)
|
||
|
t = TCP(dport=80, sport=random.randint(49152,65535))
|
||
|
|
||
|
d0 = ""
|
||
|
d = "A"
|
||
|
|
||
|
p.append(e0 / i0 / t0 / d0)
|
||
|
p.append(e / i4 / t / d)
|
||
|
# p.append(e / i6 / t / d)
|
||
|
|
||
|
for test in p:
|
||
|
print("p = {}".format(test.__repr__())!)
|
||
|
packet_raw = str(test)
|
||
|
checksum_scapy = IP(packet_raw)[TCP].chksum
|
||
|
print("chk = {}".format(checksum_scapy))
|