Featured image of post BSidesTLV 2022 CTF - \

BSidesTLV 2022 CTF - "Medium Expectations"

Cracking Python's random.seed() for predictable number generation

I tried a pretty easy Crypto challenge.

After using Netcat, the server asks us to guess the correct numbers repeatedly.

After looking at the source code (“challenge.py”), it seemed that the server generates a random number in the appropriate range each time.

However, there is an interesting function - random.seed().

After reading about this function, I understood that it takes a number (the result of the operation inside it) and this will be the seed for the random functions (rand_range).

Okay, so it is not actually random. The random seed has a fixed value.

I checked the result of this operation and got a reasonable value, but it did not work after I tried it.

I thought it might be quicker if I just ran this program in PyCharm after modifying and printing the results for each iteration, and it worked. After connecting to the server, I just used the numbers and got the flag.

Happy Hacking,
Orel 🐇

-- views
Built with Hugo
Theme Stack designed by Jimmy