From 237f48ea1f0bb5d98614088ea7b7f2a304d1f44c Mon Sep 17 00:00:00 2001 From: Sana147 <14mseeshabib@seecs.edu.pk> Date: Wed, 3 May 2023 07:55:58 +0000 Subject: [PATCH] Upload files to 'server' --- server/sending_raw_packets.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 server/sending_raw_packets.py diff --git a/server/sending_raw_packets.py b/server/sending_raw_packets.py new file mode 100644 index 0000000..47bbeb4 --- /dev/null +++ b/server/sending_raw_packets.py @@ -0,0 +1,23 @@ +import socket + +s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) +s.bind(("wlp1s0", 8000)) + +ethernet = b'\x00\x0c\x29\xd3\xbe\xd6' # MAC Address Destination +ethernet += b'\x00\x0c\x29\xe0\xc4\xaf' # MAC Address Source +ethernet += b'\x08\x00' # Protocol-Type: IPv4 + +ip_header = b'\x45\x00\x00\x28' # Version, IHL, Type of Service | Total Length +ip_header += b'\xab\xcd\x00\x00' # Identification | Flags, Fragment Offset +ip_header += b'\x40\x06\xa6\xec' # TTL, Protocol | Header Checksum +ip_header += b'\x0a\x0a\x0a\x02' # Source Address +ip_header += b'\x0a\x0a\x0a\x01' # Destination Address + +tcp_header = b'\x30\x39\x00\x50' # 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\x71\x10' # Data Offset, Reserved, Flags | Window Size +tcp_header += b'\xe6\x32\x00\x00' # Checksum | Urgent Pointer + +packet = ethernet + ip_header + tcp_header +s.send(packet) \ No newline at end of file