$;=$\;$_=$"x5;$b=$|;for$%(map{$_*.04,$_/5=>$_}map{ord}split??, "A\4]bVvYd0\tR{4utI8gGbTPy\cNYXtu^Ku,"){if($%%5&4){$|[$a++]=chr $;;$;=0;print$_^=join$\,@|if!($a%=5);}else{$;=($;*4+$%%5^2);}}
I've been kicking this around for a while, trying to get it stylistically where I want it (down to two 75-character lines) but I'm not quite that good at golf. Also it seems to lose a bit of the obfu when it gets that short - not sure if it's because there are fewer places to hide, or just that I've been looking at it too long.

Replies are listed 'Best First'.
Re: Since JAPH seems to be popping out all over
by davido (Cardinal) on Feb 06, 2005 at 05:21 UTC

    You know what's interesting is the way in which B::Deparse breaks this obfu. In specific, Deparse breaks the portion that goes like this: $|[ $a++ ] = chr $;;. Deparse turns that into $|[ $a++ ] = chr $;. The important difference is the missing statement terminator, ';'. After being deparsed, until I manually add that back in, I get the following:

    Scalar found where operator expected at mytest2.pl line 16, near "$; $;" (Missing operator before $;?) syntax error at mytest2.pl line 16, near "$; $; " Execution of mytest2.pl aborted due to compilation errors.

    I know the old mantra is "Only perl can parse Perl", and this is an example of that being the case. I'd say it's a bug in B::Deparse, but then we can't expect it to be perfect, especially when presented with an obfu. I'm just surprised that it got tripped up by something so trivial as a statement terminating semicolon.


    Dave

      Yes, I happened across that mostly by accident when I was crafting this. It's not much of a break (if you're going to be running B::Deparse on this, you're going to be able to correct the output it gives you) but I figured it was worth leaving in.

      I suspect that something in Deparse mistakes $; as including the statement-terminating semicolon, particularly as it occurs on the end of a line. This is just guessing, though, as I have not really experimented with it much.

Re: Since JAPH seems to be popping out all over
by jdalbec (Deacon) on Feb 06, 2005 at 22:29 UTC
    Analysis:
    The characters in the long ugly string are expanded to 3-digit numbers in base 5.
    230 004 333 343 321 433 324 400 143 014 312 443 202 432 431 243 211 403 241 343 314 310 441 024 324 323 431 432 334 300 432 134
    These numbers are concatenated. The string is then (in effect) split at 4's since a 4 causes $; to be added to @| and then reset to 0.
    230004 33334 33214 33324 4 0014 3014 3124 4 32024 324 3124 32114 0324 134 3314 3104 4 1024 324 3234 314 32334 3004 32134
    The digits in each number (omitting the final "4") are xor'd with 2
    01222 1111 1103 1110 0 223 123 130 0 1020 10 130 1033 210 31 113 132 0 320 10 101 13 1011 122 1031
    and interpreted as numbers in base 4
    hex values: 6a 55 53 54 0 2b 1b 1c 0 48 4 1c 4f 24 d 17 1e 0 38 4 11 7 45 1a 4d
    which are converted back into (not necessarily printable) characters. These characters are (in effect) split into groups of 5 and each group is xor'd into $_ and the result is printed.
    20 20 20 20 20 $_ = " " 6a 55 53 54 0 @| 4a 75 73 74 20 $_ = "Just " 2b 1b 1c 0 48 @| 61 6e 6f 74 68 $_ = "anoth" 4 1c 4f 24 d @| 65 72 20 50 65 $_ = "er Pe" 17 1e 0 38 4 @| 72 6c 20 68 61 $_ = "rl ha" 11 7 45 1a 4d @| 63 6b 65 72 2c $_ = "cker,"
    I ran the code through perl -MO=Deparse and perltidy and added some comments:
    #! /usr/bin/perl # $;=$\;$_=$"x5;$b=$|;for$%(map{$_*.04,$_/5=>$_}map{ord}split??, # "A\4]bVvYd0\tR{4utI8gGbTPy\cNYXtu^Ku,"){if($%%5&4){$|[$a++]=chr # $;;$;=0;print$_^=join$\,@|if!($a%=5);}else{$;=($;*4+$%%5^2);}} use strict; # use warnings; $; = $\; # undef $_ = $" x 5; # " " $b = $|; # misdirection foreach $% ( map { $_ * 0.04, $_ / 5, $_; } map( { ord $_; } split ( ??, "A\cD]bVvYd0\tR{4utI8gGbTPy\cNYXtu^Ku +,", 0 ) ) ) # { print $%%5; } # 3-digit base 5 expansion { if ( $% % 5 & 4 ) { # terminate base-4 number $|[ $a++ ] = chr $;; $; = 0; # after 5 characters, xor and print print $_ ^= join ( $\, @| ) if not $a %= 5; } else { # interpret base-4 number after xor'ing digits w/2 $; = $; * 4 + $% % 5 ^ 2; } }