Skip to content

Instantly share code, notes, and snippets.

@paultopia
Last active June 3, 2016 22:10
Show Gist options
  • Select an option

  • Save paultopia/00a40b4c130b2b35da7d to your computer and use it in GitHub Desktop.

Select an option

Save paultopia/00a40b4c130b2b35da7d to your computer and use it in GitHub Desktop.
never_do_this.py
# NEVER DO THIS EXCEPT AS A PRANK ON YOUR WORST ENEMY
class foo(str):
def __call__(self):
try:
exec self
except Exception:
pass
str = foo
evil = str('print "EVIL"')
print evil
print len(evil)
evil()
# obviously never do this. it turns anything created with str() into a callable
# ... but it would make an AMAZING prank. think of all the accidental exec statements!
# think of the horrendous security holes! I think I've discovered a bit of Python
# code even more dangerous than https://github.com/ajalt/fuckitpy
#
# alas it doesn't make strings created without the str() function executable too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment