BabyEncryption

import string
from secret import MSG

def encryption(msg):
    ct = []
    for char in msg:
        ct.append((123 * char + 18) % 256)
    return bytes(ct)

ct = encryption(MSG)
f = open('./msg.enc','w')
f.write(ct.hex())
f.close()
#The encyrpted message in hex
enc = '6e0a9372ec49a3f6930ed8723f9df6f6720ed8d89dc4937222ec7214d89d1e0e352ce0aa6ec82bf622227bb70e7fb7352249b7d893c493d8539dec8fb7935d490e7f9d22ec89b7a322ec8fd80e7f8921'
#break the encypted message into list in decimal
cmsg = [ int(enc[i:i+2], 16) for i in range(0, len(enc), 2) ]
#build the lookup table
tbl = [ (i * 123 + 18) % 256 for i in range(256) ]

#the clear message
msg=''
#loop through the lookup table to find the each chr in cmsg
for i in range(len(cmsg)):
    for j in range(len(tbl)):
        if cmsg[i]==tbl[j]:
            msg += chr(j)
            break
print(msg)
kali@kali:~/0.htb/challenges/Crypto/BabyEncryption$ python3 baby.py
Th3 nucl34r w1ll 4rr1v3 0n fr1d4y.
HTB{l00k_47_y0u_r3v3rs1ng_3qu4710n5_c0ngr475}

Navigation