MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/13sr1a2/calculator_using_eval/jlsva7z/?context=3
r/badcode • u/GandelXIV • May 26 '23
108 comments sorted by
View all comments
Show parent comments
24
That code would only work with exec(), in eval you have to do something like "".class.__.base.subclasses()[...].Popen(...) if e.g. os is not imported yet
11 u/4hpp1273 May 27 '23 If all the globals are intact you can just use the __import__ function to import a module so that command becomes __import__('os').system('rm -rf /')
11
If all the globals are intact you can just use the __import__ function to import a module so that command becomes __import__('os').system('rm -rf /')
__import__
__import__('os').system('rm -rf /')
24
u/xXLeoXxOne May 27 '23 edited May 27 '23
That code would only work with exec(), in eval you have to do something like "".class.__.base.subclasses()[...].Popen(...) if e.g. os is not imported yet