$_ = ( '_[]@^' ^ '/>/,~' ) . # 'perl '
'-' . # '-'
( '>]' ^ '[}' ) . # 'e '
'"' . # '"'
( '^])@*{.|~%{{]\\-' ^
'./@.^[}(:`))}-\\' ) . # 'print STDERR qq'
'(' . # '('
( '*\\(]{\\./(@[-^-%^,{(!]+>^' ^
'@)[)[=@@\\(>_~]@,@[@@>@[,' ) . # 'just another perl hacker'
'\\' . # '\'
( '.' ^ '@' ) . # 'n'
')"'; # ')"'
`$_`
basically it's a concatenation of strings, using the bitwise xor operator '^' to generate alphanumeric characters, per chester's line noise JAPH. For example the 'p' in the first 'perl' comes by xoring '_' and '/':
perl -e "print '_' ^ '/'"
p
Deparsing de-obfuscates it because the entire xoring and concatenation is made up of literals, so the compiler calculates the result and substitutes it into the compiled version. Deparse simply translates the compiled code back into Perl code. A simpler example might be:
perl -MO=Deparse -e "print 2 * 2"
print 4;
-e syntax OK
'2 * 2' is translated to '4' at compile time and deparse leaves it that way.
HTH
Roger
P.S. blokhead pointed out to me that this too has been done before! |