From 038dd7244a5ea611a22dca64632bbf28b7e4b6fb Mon Sep 17 00:00:00 2001 From: Sana147 <14mseeshabib@seecs.edu.pk> Date: Sun, 7 May 2023 03:24:03 +0000 Subject: [PATCH] Upload files to 'Test_Cases/Test_Case1' --- Test_Cases/Test_Case1/TestCase1_ACK.py | 32 +++++++++++++++++++++++ Test_Cases/Test_Case1/TestCase1_SYN.py | 32 +++++++++++++++++++++++ Test_Cases/Test_Case1/TestCase1_SYNACK.py | 32 +++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 Test_Cases/Test_Case1/TestCase1_ACK.py create mode 100644 Test_Cases/Test_Case1/TestCase1_SYN.py create mode 100644 Test_Cases/Test_Case1/TestCase1_SYNACK.py diff --git a/Test_Cases/Test_Case1/TestCase1_ACK.py b/Test_Cases/Test_Case1/TestCase1_ACK.py new file mode 100644 index 0000000..f750655 --- /dev/null +++ b/Test_Cases/Test_Case1/TestCase1_ACK.py @@ -0,0 +1,32 @@ +import socket + +# Sending a SYN packet + +def init_socket(): + s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) + s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) + return s + +def send_raw_packet(): + ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length + ip_header += b'\x00\x00\x00\x00' # Identification | Flags, Fragment Offset + ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum + ip_header += b'\xc8\xcc\x0a\x0c' # Source Address: 200.204.10.12 + ip_header += b'\xc8\xcc\x0a\x0e' # Destination Address: 200.204.10.14 + + tcp_header = b'\x04\xD2\x11\x5C' # Source Port | Destination Port + tcp_header += b'\x00\x00\x00\x00' # Sequence Number + tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number + tcp_header += b'\x50\x10\x00\x00' # Data Offset, Reserved, Flags | Window Size + tcp_header += b'\xa5\x41\x00\x00' # Checksum | Urgent Pointer + + packet = ip_header + tcp_header + return packet + +if __name__=="__main__": + dst_IP = '200.204.10.14' + + s = init_socket() + + packet = send_raw_packet() + s.sendto(packet, (dst_IP, 0)) diff --git a/Test_Cases/Test_Case1/TestCase1_SYN.py b/Test_Cases/Test_Case1/TestCase1_SYN.py new file mode 100644 index 0000000..a4b427b --- /dev/null +++ b/Test_Cases/Test_Case1/TestCase1_SYN.py @@ -0,0 +1,32 @@ +import socket + +# Sending a SYN packet + +def init_socket(): + s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) + s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) + return s + +def send_raw_packet(): + ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length + ip_header += b'\x00\x00\x00\x00' # Identification | Flags, Fragment Offset + ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum + ip_header += b'\xc8\xcc\x0a\x0c' # Source Address: 200.204.10.12 + ip_header += b'\xc8\xcc\x0a\x0e' # Destination Address: 200.204.10.14 + + tcp_header = b'\x04\xD2\x11\x5C' # Source Port | Destination Port + tcp_header += b'\x00\x00\x00\x00' # Sequence Number + tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number + tcp_header += b'\x50\x02\x00\x00' # Data Offset, Reserved, Flags | Window Size + tcp_header += b'\xe6\x32\x00\x00' # Checksum | Urgent Pointer + + packet = ip_header + tcp_header + return packet + +if __name__=="__main__": + dst_IP = '200.204.10.14' + + s = init_socket() + + packet = send_raw_packet() + s.sendto(packet, (dst_IP, 0)) diff --git a/Test_Cases/Test_Case1/TestCase1_SYNACK.py b/Test_Cases/Test_Case1/TestCase1_SYNACK.py new file mode 100644 index 0000000..bc65556 --- /dev/null +++ b/Test_Cases/Test_Case1/TestCase1_SYNACK.py @@ -0,0 +1,32 @@ +import socket + +# Sending a SYN packet + +def init_socket(): + s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP) + s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) + return s + +def send_raw_packet(): + ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length + ip_header += b'\x00\x01\x00\x00' # Identification | Flags, Fragment Offset + ip_header += b'\x28\x06\x95\x45' # TTL = 40s, Protocol = 6 for TCP | Header Checksum + ip_header += b'\xc8\xcc\x0a\x0e' # Source Address: 200.204.10.14 + ip_header += b'\xc8\xcc\x0a\x0c' # Destination Address: 200.204.10.12 + + tcp_header = b'\x11\x5c\x04\xD2' # Source Port | Destination Port + tcp_header += b'\x00\x00\x00\x00' # Sequence Number + tcp_header += b'\x00\x00\x00\x00' # Acknowledgement Number + tcp_header += b'\x50\x12\x00\x00' # Data Offset, Reserved, Flags | Window Size + tcp_header += b'\xa5\x41\x00\x00' # Checksum | Urgent Pointer + + packet = ip_header + tcp_header + return packet + +if __name__=="__main__": + dst_IP = '200.204.10.12' + + s = init_socket() + + packet = send_raw_packet() + s.sendto(packet, (dst_IP, 0))