Sana147
2 years ago
6 changed files with 160 additions and 0 deletions
-
32Test_Cases/Test_Case3/TestCase3_ACK.py
-
32Test_Cases/Test_Case3/TestCase3_FIN.py
-
32Test_Cases/Test_Case3/TestCase3_FINACK.py
-
32Test_Cases/Test_Case3/TestCase3_SYN.py
-
32Test_Cases/Test_Case3/TestCase3_SYNACK.py
-
BINTest_Cases/Test_Case3/Third_Test_Case.png
@ -0,0 +1,32 @@ |
|||||
|
import socket |
||||
|
|
||||
|
# Sending a ACK 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\x03\x00\x00' # Identification | Flags, Fragment Offset |
||||
|
ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum |
||||
|
ip_header += b'\xac\xa8\x05\x03' # Source Address: 172.168.5.3 |
||||
|
ip_header += b'\xac\xa8\x05\x04' # Destination Address: 172.168.5.4 |
||||
|
|
||||
|
tcp_header = b'\x15\xb3\x1a\x0a' # 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'\xe6\x32\x00\x00' # Checksum | Urgent Pointer |
||||
|
|
||||
|
packet = ip_header + tcp_header |
||||
|
return packet |
||||
|
|
||||
|
if __name__=="__main__": |
||||
|
dst_IP = '172.168.5.4' |
||||
|
|
||||
|
s = init_socket() |
||||
|
|
||||
|
packet = send_raw_packet() |
||||
|
s.sendto(packet, (dst_IP, 0)) |
@ -0,0 +1,32 @@ |
|||||
|
import socket |
||||
|
|
||||
|
# Sending a FIN 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\x03\x00\x00' # Identification | Flags, Fragment Offset |
||||
|
ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum |
||||
|
ip_header += b'\xac\xa8\x05\x03' # Source Address: 172.168.5.3 |
||||
|
ip_header += b'\xac\xa8\x05\x04' # Destination Address: 172.168.5.4 |
||||
|
|
||||
|
tcp_header = b'\x15\xb3\x1a\x0a' # 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\x01\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 = '172.168.5.4' |
||||
|
|
||||
|
s = init_socket() |
||||
|
|
||||
|
packet = send_raw_packet() |
||||
|
s.sendto(packet, (dst_IP, 0)) |
@ -0,0 +1,32 @@ |
|||||
|
import socket |
||||
|
|
||||
|
# Sending a FIN+ACK 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\x03\x00\x00' # Identification | Flags, Fragment Offset |
||||
|
ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum |
||||
|
ip_header += b'\xac\xa8\x05\x04' # Source Address: 172.168.5.4 |
||||
|
ip_header += b'\xac\xa8\x05\x03' # Destination Address: 172.168.5.3 |
||||
|
|
||||
|
tcp_header = b'\x1a\x0a\x15\xb3' # 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\x11\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 = '172.168.5.3' |
||||
|
|
||||
|
s = init_socket() |
||||
|
|
||||
|
packet = send_raw_packet() |
||||
|
s.sendto(packet, (dst_IP, 0)) |
@ -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\x03\x00\x00' # Identification | Flags, Fragment Offset |
||||
|
ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum |
||||
|
ip_header += b'\xac\xa8\x05\x03' # Source Address: 172.168.5.3 |
||||
|
ip_header += b'\xac\xa8\x05\x04' # Destination Address: 172.168.5.4 |
||||
|
|
||||
|
tcp_header = b'\x15\xb3\x1a\x0a' # 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 = '172.168.5.4' |
||||
|
|
||||
|
s = init_socket() |
||||
|
|
||||
|
packet = send_raw_packet() |
||||
|
s.sendto(packet, (dst_IP, 0)) |
@ -0,0 +1,32 @@ |
|||||
|
import socket |
||||
|
|
||||
|
# Sending a SYN+ACK 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\x03\x00\x00' # Identification | Flags, Fragment Offset |
||||
|
ip_header += b'\x28\x06\xa6\xec' # TTL = 40s, Protocol = 6 for TCP | Header Checksum |
||||
|
ip_header += b'\xac\xa8\x05\x04' # Source Address: 172.168.5.4 |
||||
|
ip_header += b'\xac\xa8\x05\x03' # Destination Address: 172.168.5.3 |
||||
|
|
||||
|
tcp_header = b'\x1a\x0a\x15\xb3' # 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'\xe6\x32\x00\x00' # Checksum | Urgent Pointer |
||||
|
|
||||
|
packet = ip_header + tcp_header |
||||
|
return packet |
||||
|
|
||||
|
if __name__=="__main__": |
||||
|
dst_IP = '172.168.5.3' |
||||
|
|
||||
|
s = init_socket() |
||||
|
|
||||
|
packet = send_raw_packet() |
||||
|
s.sendto(packet, (dst_IP, 0)) |
After Width: 1920 | Height: 1080 | Size: 428 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue