add script for diff'ing checksums
This commit is contained in:
parent
c507ece3e1
commit
2ed8282687
1 changed files with 51 additions and 0 deletions
51
bin/checksum_delta_diff_test.py
Normal file
51
bin/checksum_delta_diff_test.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/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))
|
||||
|
||||
# print("chk_t = {}".format(t))
|
||||
t = TCP(dport=80, sport=1337)
|
||||
|
||||
#print("chk_t = {}".format(t))
|
||||
|
||||
d0 = ""
|
||||
d = "A"
|
||||
|
||||
p.append(e / i4 / t / d)
|
||||
p.append(e / i6 / t / d)
|
||||
|
||||
for packet in p:
|
||||
print("p = {}".format(packet.__repr__()))
|
||||
packet_rebuild = packet.__class__(str(packet))
|
||||
chk_old = packet[TCP].chksum
|
||||
chk_new = packet_rebuild[TCP].chksum
|
||||
print("chk1 = {} chk2={}".format(chk_old, chk_new))
|
||||
|
||||
# Checksums:
|
||||
# - tcp
|
||||
# - udp
|
||||
# - icmp6
|
||||
# - icmp
|
||||
# - ipv4 (no payload)
|
||||
#
|
||||
# t.chksum = None
|
Loading…
Reference in a new issue