quesiton 3 and 4
This commit is contained in:
BIN
week03/.DS_Store
vendored
Normal file
BIN
week03/.DS_Store
vendored
Normal file
Binary file not shown.
22
week03/easy/client.py
Normal file
22
week03/easy/client.py
Normal file
@ -0,0 +1,22 @@
|
||||
import socket
|
||||
|
||||
# Fill in the right target here
|
||||
HOST = 'this.is.not.a.valid.domain' # TODO
|
||||
PORT = 0 # TODO
|
||||
|
||||
|
||||
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
|
||||
|
||||
message1 = sf.readline().rstrip('\n')
|
||||
# TODO
|
||||
|
||||
sf.close()
|
||||
s.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
get_flag()
|
51
week03/easy/client_ans.py
Normal file
51
week03/easy/client_ans.py
Normal file
@ -0,0 +1,51 @@
|
||||
import socket
|
||||
|
||||
# Updated connection details
|
||||
HOST = "netsec.net.in.tum.de"
|
||||
PORT = 20103
|
||||
|
||||
|
||||
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
|
||||
|
||||
full_message = []
|
||||
collecting = False
|
||||
while True:
|
||||
try:
|
||||
message = sf.readline()
|
||||
if not message:
|
||||
break
|
||||
|
||||
message = message.rstrip("\n")
|
||||
print(f"Server says: {message}")
|
||||
|
||||
if "team number" in message.lower():
|
||||
sf.write("153\n")
|
||||
sf.flush()
|
||||
elif "In this challenge" in message:
|
||||
collecting = True
|
||||
full_message = [message]
|
||||
elif collecting:
|
||||
full_message.append(message)
|
||||
if "solution" in message.lower():
|
||||
answer = '[("192.168.0.126", "8.8.8.8", "udp", 53836, 53), ("192.168.0.126", "31.192.117.132", "tcp", 41160, 80), ("73.73.73.73", "192.168.0.20", "tcp", 38451, 23), ("192.168.0.126", "54.54.54.54", "tcp", 57020, 25)]'
|
||||
sf.write(answer + "\n")
|
||||
sf.flush()
|
||||
collecting = False
|
||||
full_message = []
|
||||
|
||||
except socket.timeout:
|
||||
continue
|
||||
except (EOFError, ConnectionError) as e:
|
||||
print(f"Connection error: {e}")
|
||||
break
|
||||
|
||||
sf.close()
|
||||
s.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_flag()
|
BIN
week03/easy/description/description.pdf
Normal file
BIN
week03/easy/description/description.pdf
Normal file
Binary file not shown.
BIN
week03/hard/.DS_Store
vendored
Normal file
BIN
week03/hard/.DS_Store
vendored
Normal file
Binary file not shown.
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()
|
BIN
week03/hard/description/description.pdf
Normal file
BIN
week03/hard/description/description.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user