Ascii_Roulette #Defcon_Red_Team_Village_CTF_Quals

Abdullah Shahbaz
3 min readAug 10, 2021

--

Get code from “Download here”

As we know that define can be consider as alias for example is case of

#define start main()

we can use start in all code when executing the code computer will replace every start with main() so to make code cleaner and easy to read just replace every first (start) word with second (main()) word for that i used sublime text find and replace feature after cleaning the code it look like this

After cleaning the code it is easier to read now we can see that it is taking strings from user than saving it to flag strings uses time function to get the seed for randomizing the number and then randomize number is module of 7 and 1 is added to it and value is saved to “ flag_rand ” loop is created for reading the strings given from user one by one which is being saved in “ flag_num ” than “ flag_num ” is being XOR with “ flag_rand “ and saved in “ flag_num ” if the loop variable (in this case is “ i ”) is even than 24 is added to “ flag_num ” and else 24 is subtracted and then result is printed

After modifing the code to add a non-stop loop and printing “ flag_rand ”

we get (basically we know start of flag and result so puting the start value untill desire result is found)

we note flag_rand (which is equal to 5) and then again modified the code compile it and insert the value to verify that flag_rand to make sure we get true value

Know we have to reverse every step to get the flag

Every thing is available at https://github.com/Lizardon001/CTF/tree/main/Defcon29_Red_Team_Village_CTF_Quals/ascii_roulette

--

--