Add some stuffs

This commit is contained in:
Orien Vandenbergh 2016-09-09 14:25:55 -06:00
parent 59cc73340d
commit d70f593d5b
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,19 @@
def step(digest,prev_m):
k = 0
while True:
rem = ((digest ^ prev_m) + k * 256) % 129
if rem == 0:
return ((digest ^ prev_m) + k * 256) / 129
else:
k = k + 1
def answer(digest):
prev = 0
message = []
for index, num in enumerate(digest):
if index == 0:
message.append(step(num,0))
else:
message.append(step(num,message[-1]))
return message

36
python/utils/connect.py Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python3
import socket
import sys
def get_header(sock):
try:
data = sock.recv(4096, socket.MSG_DONTWAIT) # 0x40 : O_NONBLOCK
#sys.stdout.write(data)
print(data.decode("utf-8"), end="")
except socket.error as msg:
# Nothing left
pass
try:
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
except socket.error as msg:
print(msg)
sys.exit(1)
try:
sock = socket.create_connection((sys.argv[1], sys.argv[2]),60)
except socket.error as msg:
print(msg)
sock.close()
sys.exit(1)
if sock is None:
print('Unable to connect')
sys.exit(2)
#sock.setblocking(0)
sock.shutdown(socket.SHUT_WR)
print("Connected to %s:%s" % (sys.argv[1],sys.argv[2]))
get_header(sock)
sock.close()