Tags: crypto python pwntools cipher 

Rating:

After connecting to the server you will be asked to provide some input text, which will be encrypted and return to you.
Then you will receive another encrypted message to decrypt.

If you feed the server sequential characters you will notice that you receive sequential characters back.
For example:

** ABCDEFGHIJK**

might return

** MNOPQRSTUVW**

so it's a simple shift cipher.

From there you can figure out the character set by feeding it sequential characters over and over until you have mapped out the full chain of characters.
The full character set, in order is:

`"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~ !\"#$%&'()*+,-./0123456789:;<=>?@"`

Now you can just connect to the server, send it a capital A and check what is returned to find the shift for that particular round.
From there you can reference the character set and use the shift to decrypt the message.
For example:

If you send **A** and receive **D** your shift for this round is **3**.

If you then receive the message "**SZQ**"

you can just shift them 3 characters backwards to receive "**PWN**"

After decrypting 50 messages the server will send you the flag!

The final python script to receive the flag using pwntools is in the linked github address.

Original writeup (https://github.com/Ov3rflow/TUCTF/tree/master/Never_ending_crypto).