My current signature
Perhaps this looks familar to some of you. ;)Well, the first thing to notice is that we start with a substitution.s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
We're using + as the delimiter. Clearing away the cruft, we have:s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
So this substitutes "=END;" for nothing, in $_. The next character is for addition; let's add some whitespace to help make this more visible.s//=END;/+y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
Next we have a translation via the y/// operator, which is just a sed-like synonym for tr///.s//=END;/ + y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
The first set of characters has () as its delimiter, and the second set has }} as its. That's a sneaky little trick few Perl'ers know -- if you use a set of paired delimiters for the left-hand side of a s/// or a tr///, you can use ANY delimiter you want for the right-hand side; they don't have to use the same delimiter, or even be paired delimiters.s//=END;/ + y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
I'm also going to expand all the ranges in the classes, and structure it so you see exactly what gets changed to what. Notice how the interior of the right-hand side appears to contain two more y///'s -- one with y jjj and one that simply appears to be incomplete. Oh, and the ;-P is meant to be a smiley.
If we remove all the unneeded junk, we see that we're merely replacing "=END;" with "japhy".s//=END;/ + tr{;<=>?@ABCDEFGHIJKLMNOP} {y js++=;shajsj<++y(pq)} ?print:??;
Next, we have a question mark -- at this point, it indicates the ternary operator, ?:. To its left, then, is the conditional. The conditional is the sum of our subtitution (1) and our translation (5), which is 6, a true value.s//=END;/ + tr{;=DEN} {yjhap} ?print:??;
The expression executed for "true" is simply to print $_, which is what happens -- and "japhy" gets printed. The other expression is ??, which is an empty m?? regex. Although entirely unimportant and unrelated, the proximity of these ?'s to the other one is a "nice" thing.(s//=END;/ + tr/;=DEN/yjhap/) ? print : ??;
Therefore, the code becomes:
(s//=END;/ + tr/;=DEN/yjhap/) ? print : ??; # or s//=END;/; # $_ = "=END;" tr/;=DEN/yjhap/; # "=END;" => "japhy" print; # print $_
The True Nature of Perl
Here's a playful one that is meant to delight and amuse.This was fun to write.$^X and @ X=$^F**$^F;( $^X )=( $^X )=~m #perl#; die $^X =~m|[parley]{@X}|; $g or die( $^X );chop(@ XX=q q3";q^( $^X ));( $^X )=~s|[parley]{@X}|@XX$/|cgi; $g or die( $^X );
I'll get back to this one on Sunday. I'm leaving now for a weekend retreat with my fraternity.
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: japhy's 2nd obfuscation review
by tlhf (Scribe) on Aug 26, 2001 at 07:31 UTC | |
Re: japhy's 2nd obfuscation review
by Sigmund (Pilgrim) on Aug 27, 2001 at 17:13 UTC |
Back to
Obfuscated Code