From 2ed82826873cf93bc3968ede5c73f2244cc3d4e6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 29 Jun 2019 15:23:00 +0200 Subject: [PATCH] add script for diff'ing checksums --- bin/checksum_delta_diff_test.py | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bin/checksum_delta_diff_test.py diff --git a/bin/checksum_delta_diff_test.py b/bin/checksum_delta_diff_test.py new file mode 100644 index 0000000..05cd1c3 --- /dev/null +++ b/bin/checksum_delta_diff_test.py @@ -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