Roger on that obfu working. And it is a "precioussssss" obfu, if I may say so. Thanks for the fun and for making me remeber "my precioussss", maverick.

I dont know if it's good PM etiquete to discuss the functioning of an obfu, but that's the fun of it, so here it goes a first look into it Warning, spoiler ahead:

The main code is inside the first interpolation q. That code goes into the @d array, wich is reordered in the for at the bottom

for(my $i=0;$i<$#d/2;$i+=2) { my $t=$d[$i]; $d[$i]=$d[$#d-$i]; $d[$#d-$i]=$t }

This reorders all that code in @d, swapping every third line with the one that has the same index if you started counting from the end of the @d

So, doing the swap we get the code that will be run, wich I formated for your viewing pleasure :

my $h = [[['t','o'],[['d','i'],'n']],[[['s','r'],['l','h']],['e',[['m' +,['f','b']] ,[[['k',['w','p']],['g','u']],'a']]]]]; my $m = '_001011110^_001_1000.000001.100111110111010110^00010111101110 +0.111111010 1010b_001011110._001_1000^000001.11101001010110100.000101111011100d_00 +101111 0._001_1000^000001.111011100101010111111010.000101111011100.1111110101 +010b_1 11110110100^0101011^0001011110._0100111111001111100001111010001000^111 +011010 10110100.000101111011100b_0101011^0001011110^_1010111110110100^0011110 +10._10 011100100111000010110100^1111001010111101001110^0001011110._11110011_1 +001.10 1001011101000d^....^^...^...^^..--._0001011110^_101000110010100^001111 +010.00 01011110._1001010101111110101000bb1111001011010101010c.100000110010001 +1111'; $m =~s!\s!!g; my %h=('^',' ','.',' ','b',"\n",'d',"\n",'c',',','e',',','-','-',); my $u; sub d { my($t,$d)=@_; if(ref($t)) { my $c=shift @{$d}; while($c !~ /^\d$/x && length $c) { ($c eq'_') ? $u=1 : print $h{$c}; $c = shift@{$d}; } return d($t->[$c],$d); } else { if ($u) { $u=0; print uc($t); } else { print $t; } return @{$d}; } } my @d = split//,$m; while(scalar @d) { @d = d($h,\@d); } print"\n";

It now looks much better, but the thing is, now it's realy getting harder.

Maverick used the sub d, with an array called d passed by reference and that gets changed in there, adding a new level to this obfuing (am I coining a term here ? ;^).The recursive call to sub d inside almost made me croak ;-)

OK, the main idea is that the binary string in $m (later splited into an array with each of its characters in @d) will be used in sub d to choose wich of the sub-arrays and elements of $h will be used.

Zeros make the array get shifted, ones means that that particular sub array will be used. The shifting occurs in the recursive call to d.

Each time a element of the array is reached (i.e. a character), as it's not a reference to an array, it will get printed (in upper case depending on a flag set by the _ in the control stream (er, $m), with some more caracters provided by %h.

This was a very nice use of recursion, passing arrays by ref, acessing arrays inside arrays of an array passed by reference, interpolation, eval, etc.

Until today, I wondered why people did obfuscation. It seamed just a way to use the worst of perl, the most arcane syntax and realy, just a bad thing to throw at people who are trying to grasp the elementary stuff in perl.

Well, i can now see *two* good motives for doing it,

  • one : you've got to learn (or know how to use) some of the hard but usefull things in perl and sometimes it makes to you run to documentation
  • two : it's Major fun
  • three : your ability to do math gets improved ;^)

    Thanks again to maverick and to all obfuers in general :-)


    In reply to Re: With apologies to J.R.R (explained) by sevensven
    in thread With apologies to J.R.R by maverick

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.