How can I write a program in python to predict the random key (urandom) that is used for encryption? I tried to search and I couldn’t find anything related to guessing and predicting urandom in python
It might be possible to write a program that has some success with this if the program executes a side-channel attack on the underlying pseudorandom generator of /dev/urandom. If the system that we are running on is starved of entropy (think headless server without a hardware random number generator), it is not inconceivable that a process running on the same system might be able to gather side-channel information (from process timing or any other internal sensors available to it) that allows reconstructing the state of the internal RBG and maybe some of the data that is being mixed into the entropy pool from outside. It could then use that information to predict the pseudorandom output of the generator.
However, doing this would still easily qualify as a research project and if successful (even to a modest degree, for instance showing an ability to predict some RBG output in an entropy-starved laboratory setting after one initial good seeding of the state) it would likely yield a nice paper. Until someone writes that paper, there is no certainty that something like this is doable. Given that, the chances of finding an implementation of such an attack on the internet are currently effectively zero.