Last active
June 3, 2016 22:10
-
-
Save paultopia/00a40b4c130b2b35da7d to your computer and use it in GitHub Desktop.
never_do_this.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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