Add some stuffs
This commit is contained in:
parent
59cc73340d
commit
d70f593d5b
19
python/foobar/three/hash_someone_else.py
Normal file
19
python/foobar/three/hash_someone_else.py
Normal 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
36
python/utils/connect.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user