import requests
import time
chr_all = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
def get_encrypt(plaintext) :
get_encrypt= requests.get('http://aes.cryptohack.org/ctrime//encrypt/'+plaintext+'/')
encrypted=get_encrypt.json()["ciphertext"]
return encrypted
flag = b'crypto{'
ciphertext=get_encrypt(flag.hex())
flag_len=len(ciphertext)
while True:
for c in chr_all:
ciphertext = get_encrypt((flag+c.encode()).hex())
print(c, len(ciphertext))
if flag_len == len(ciphertext):
flag +=c.encode()
flag_len = len(ciphertext)
print(flag)
print(flag_len)
time.sleep(1)
break
if flag.endswith(b'M'):
flag += b'E'
print(flag.decode())
if c == chr_all[-1]:
flag_len += 2
break
if flag.endswith(b'}'):
print(flag)
break
M이후 텍스트의 길이가 70으로 증가하고, 그이후로 72이기에 E를 추가하고 브루트포싱을 하였다.