Last active
April 20, 2021 19:00
-
-
Save kopiro/99d960162d3c8e3173b88fb3b4cd4377 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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