Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active April 20, 2021 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kopiro/99d960162d3c8e3173b88fb3b4cd4377 to your computer and use it in GitHub Desktop.
Save kopiro/99d960162d3c8e3173b88fb3b4cd4377 to your computer and use it in GitHub Desktop.
import base64
import json
import socket
import math
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("socket.cryptohack.org", 13370))
data = s.recv(9)
mappina = []
for i in range(0, 20):
mappina.append(set())
all = set()
for i in range(0, 255):
all.add(i)
finished = False
max = 20 * 255
while not finished:
s.sendall(b'{"msg": "request"}')
data = json.loads(s.recv(50))
if 'ciphertext' in data:
c = base64.b64decode(data['ciphertext'])
for i in range(0, len(c)):
mappina[i].add(c[i])
finished = True
w = ""
p = 0
for e in mappina:
res = all.difference(e)
p += len(res)
if len(res) > 1:
w += "*"
finished = False
else:
w += chr(list(res)[0])
print(str(math.ceil(p/max*100)) + '% - ' +
str(p-20) + ' iteration remaining')
print(w)
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment