quesiton 3 and 4
This commit is contained in:
32
week03/hard/client.py
Normal file
32
week03/hard/client.py
Normal file
@ -0,0 +1,32 @@
|
||||
import socket
|
||||
|
||||
# Fill in the right target here
|
||||
HOST = "netsec.net.in.tum.de"
|
||||
PORT = 20203
|
||||
|
||||
|
||||
def create_packet(src_ip, dst_ip, protocol, src_port, dst_port) -> str:
|
||||
return f"{src_ip},{dst_ip},{protocol},{src_port},{dst_port}"
|
||||
|
||||
|
||||
def get_flag():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
s.connect((HOST, PORT))
|
||||
sf = s.makefile("rw") # we use a file abstraction for the sockets
|
||||
# TODO
|
||||
src_ip = "161.40.12.151"
|
||||
dst_ip = "10.0.0.1"
|
||||
protocol = "TCP"
|
||||
src_port = 7331
|
||||
dst_port = 1337
|
||||
packet = create_packet(src_ip, dst_ip, protocol, src_port, dst_port)
|
||||
print(f"Sending packet: {packet}")
|
||||
sf.write(packet + "\n")
|
||||
sf.flush()
|
||||
response = sf.readline().strip()
|
||||
print(f"Server response: {response}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_flag()
|
Reference in New Issue
Block a user