From 7f126ce5f871e3c6441b33ced6cb33d6b304a2e1 Mon Sep 17 00:00:00 2001 From: Dongho Kim Date: Sat, 9 Nov 2024 23:02:43 +0900 Subject: [PATCH] solved and updated with enumeration --- week02/hard/client.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) 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