If we faced the Python script as follow, we cannot use common modules used for escalating privileges ("os", "system", etc.).
It appeared in Newbie CTF 2019.
#! /usr/bin/python3
def main():
text = input('>> ')
for keyword in ['eval', 'exec', 'import', 'open', 'os', 'read', 'system', 'write']:
if keyword in text:
print("No!!!")
return
else:
exec(text)
if __name__ == "__main__":
main()
We need to modify module names to allow us to execute them.
explains in details.