33 lines
770 B
Python
Executable file
33 lines
770 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import sys
|
|
from scapy.all import *
|
|
|
|
import checksum_from_scapy
|
|
|
|
if __name__ == '__main__':
|
|
iface = sys.argv[1]
|
|
|
|
e = Ether(src="00:00:0a:00:00:03", dst='00:00:0a:00:00:01')
|
|
|
|
i = IP(src = "10.0.0.1", dst = "10.1.1.1")
|
|
u = UDP(dport=80, sport=80)
|
|
d = "V4-OK"
|
|
|
|
v6 = IPv6(src="2001:db8:1::a00:1", dst="2001:db8::1")
|
|
|
|
pkg = e / i / u / d
|
|
|
|
pkg_v6 = e / v6 / u / d
|
|
|
|
packet_rebuild = pkg.__class__(str(pkg))
|
|
print("pkg = {}".format(pkg.__repr__()))
|
|
print("checksum = {}".format(packet_rebuild[UDP].chksum))
|
|
|
|
v6_rebuild = pkg_v6.__class__(str(pkg_v6))
|
|
print("v6: {} - {}".format(v6_rebuild.__repr__(), v6_rebuild[UDP].chksum))
|
|
|
|
# checksum_from_scapy.checksum()
|
|
|
|
|
|
sendp(pkg, iface=iface, verbose=True)
|