🐍 Serpentine CTF Challenge Writeup

So, this challenge came with a Python script. I downloaded it using wget inside the webshell so I could inspect the source.

🧠 The Python Script

Here's the key part of the script (serpentine.py):

Actually running the script i couldnt think about anything, but i found something interesting in the

We can see that the flag is being encrypted using a simple XOR with the string 'enkidu'. The encryption method just repeats the key until it's the same length as the flag, then does a XOR character by character.

The encrypted flag is stored like this:

🧩 Reversing the Logic

So i basicly have the flag encripted, and the key, and the method he is usign, i just need to figure out how the encription actually works, and do it on reverse. Searching around i found out that he is usign ~xor~ method, kind obvius because its in the functions name, and works something like, ~flag XOR encript_key = flag_encripted. so i got the encript_key and the flag_encripted, reversing it, i can get the flag, and i didnt wanted to do it by hand, so i was thinking about building a little script that does it for me, since im learning C, im gonna do it in C.

πŸ’» Writing My Own Decryptor (In C)

WIth it compiling it printed the flag 4 me, so i solved the challenge.

Last updated