Equat1onz— Cryptography Writeup

Ahmed K. A. Awaad
3 min readMar 19, 2022

Zain CTF 2022 — Cybertalents

Description : You won't pass our gate!
Category: Crytpography

FILE : Challenge.py

here is the challenge file , is a python code
as it seems open a file “flag.txt” and read it

Main function:

read every letter in flag and read it with ord() which gets the Ascii order of the letter.
then pass it to get_val() function and append it to enc variable “enc.append()”

get_val (x,i) function:

seems it check if “i” is even > pass the x parameter and “1” to calc() function
if “i” is odd > pass the x parameter and “0” to calc() function

calc(x,val) function:

seems it check if “val” is “0” > x = (x+1)/(x-1)
if “val” is “1”> x = 984512/(x-69964)+69964
x is the ascii order passed to get_val(x,i)

and there’s a comment down there

# [69949.90776101458, 1.0186915887850467, 69949.90876951923, 1.0196078431372548, 69949.90352371817, 1.0277777777777777, 69949.90614710683, 1.017094017094017, 69949.90594534237, 1.0186915887850467, 69949.90473463427, 1.017391304347826, 69949.90715584248, 1.018181818181818, 69949.90614710683, 1.024390243902439, 69949.90917288068, 1.0208333333333333, 69949.90534001432, 1.04, 69949.90917288068, 1.02, 69949.90876951923, 1.0175438596491229, 69949.90392737999, 1.0212765957446808, 69949.90574357212, 1.02, 69949.90876951923, 1.0175438596491229, 69949.90392737999, 1.0212765957446808, 69981.0168870452, 1.0212765957446808, 69949.90513822675, 1.0178571428571428, 69949.90473463427, 1.0192307692307692, 69949.90372555197, 1.0166666666666666, 69949.90312003322, 1.2222222222222223]

seems like the flag results after the whole operation, then decided to reverse it

then enc will be filled with “asci order number ” of each character in flag after performing the above equation depends on his order in flag string which is in flag.txt , either odd order {1,3,5,…etc} or even order {0,2,4,..etc}

so, i reversed each equation in a function depending on their order too.

then append each letter reversed from the commented enc list to “flag”

here is the code file

Then the flag come up : Final TEST >> flag{InvolutionS_ar3_easy_peasy_🍋_squizy}

--

--

Ahmed K. A. Awaad

Communication and Electronic Faculty of Engineering - CyberSecurity self learner