Hack The Box – Challenges – Baby Encryption

In this write-up we will go through the BabyEncryption Challenge in HTB.

The first thing we will do is download the challenge files and then poke around a little bit

So we have an encrypted message and the python code for encrypting the plaintext.

So, in theory, if the encryption is not great, we can use this script to reverse the encryption and attempt to decrypt the cyphertext.

Looking at the python file, we can see in the encryption function ct.append where we take 123*char+18 mod 256, to reverse this we will look up the reverse modulus of 123%256

Online Calc: https://planetcalc.com/3311/

From this, we can see the inverse modulus for char * 123 % 256 is char * 179 % 256.

So now we will make a new python script to reverse this 

I wish I could say this script worked on the first try but eventually we have the correct logic and are able to decrypt the file and get the key.

Leave a comment