Here's a breakdown of the code:
#!/usr/bin/perl -w
use strict;
No explanation needed
$_="Perl in a box";
for(/\S/g){
@_=(@_=>lc)
}
Put all of the characters from $_ into @_ in order after they've been lower cased, but no spaces.
my($i,$k)=(0,'');
Variable decalaration
for(@_){
$_{$_}=$i++
}
Sets up the magic decoder ring for the first level encoding. For each character in @_, set a value in %_ for the key corresponding to the character to the offset in @_. i.e. $_{p} = 0, $_{e} = 1, etc.
undef $/;
$_=<DATA>;
Unset the input record separator and slurp in the encoded info in from DATA.
s;\s;;g;
for(/../g){
After blowing away all whitespace in the encoded data, loop over the data 2 characters at a time.
my@k=/./g;
Split the characters into @k.
@k=(pop@k,@k)if($k[1]ne lc$k[1]);
Reverse the characters in the array if the second one is not lower case.
for my $k (@k){
$k=$_{lc$k};
}
Decode the letters in @k with the magic decoder ring to get 2 numbers.
$k.=chr(30+pop(@k)+10*pop(@k));
Multiply the first number in @k by 10, add 30 and the first number in @k, turn it into a character and add it onto the string $k, which is different than the $k we used in the for loop above.
}
End the for(/../g) loop
$_=$k;
s|(.{20})|$1\n|g;
Assign $k to $_ so the substitution looks better and do the substitution to turn $_ into 20 character long lines.
eval
Eval the second obfuscated code. Wheew. Are we done yet? Nope. Here's what the second level decoder looks like:
$_=q[s;.*;94eae6e840
c2dcdee8d0cae440a0ca
e4 d8
40 d0
c2 c6
d6 ca
e4 14
;s ;@
_= /.
./ g;
fo r(
@_ ){
$_ =c
hr ((
he x)
>>1)}$_=join'',@_;pr
int];s; |\n;;g;eval;
In a slightly more readable form:
$_=q[
s;.*;94eae6e840c2dcdee8d0cae440a0cae4d840d0c2c6d6cae414;s;
@_=/../g;
for(@_){
$_=chr((hex)>>1);
}
$_=join'',@_;
print
];
s; |\n;;g;
eval;
This code simply sets up more code that loops through the encoded string (The 94eae6.... string that is put into $_ inside the quoted code to be evaled) 2 characters at a time, turns those characters into a real hex value, which in turn is shifted right 1 bit and turned into a character. After all of the characters have been decoded, they are crammed together and printed.
A nice head-scratcher. |