cruel python [08/05/2007 04:01:55]
Going through some old code, I found this obfuscated python poem I wrote five years ago:
cruel_python, what_have_i_done
='evil.append(list(eachone))',
"awful code is so much fun"
if 'i am smart': 'it just might run'
"it's so much worse than 'hello world'"
"these next three lines look just like perl!"
'while(<>){chomp;s/perl/python;print}';oranges='fruit';
bad="'enitlavo ruoy knird'=gsm;gsm labolgxgsm tnirp";
empty="";global eachone;evil=[];
'but a secret here is in your reach'
apples=oranges, "eachone=each"
def do(task="do what i ask"):
global eachone; exec task
"and just in case you're not perplexed,"
worse,now = (bad.split('x'),"!")
for each in worse:
exec apples[1]
if each in worse:
do(cruel_python)
worse = evil; "evil".split().reverse()
[each.reverse() for each in worse]
"and now we've reached the final verse";
map(do, map(empty.join, worse))
I originally posted this as a cryptogam on comp.lang.python, after my previous cryptogram was cracked after only half an hour.
Turns out, even with garbage code like this, python's syntax and whitespace made it trivial to crack the simple cipher.
