Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I got the idea for this obfuscation from this utterly cool snippet by BooK, but this is in no way a rip-off. While the obfu by BooK executes code that is written as a boustrophedon, my obfu executes code that is written in a spiral, starting from the center of a code block and going outwards. Thus, the name "Spiraling Death", and the reference to boustrophedons in the title.

To examplify this, I also thought I'd better need some spiraling code, so this code will search a directory recursively, searching all files for a POD =head\d entry NAME or TITLE (case insensetive). If found, it will print the path and the NAME/TITLE of the file. Try it on your /usr/lib directory, or wherever perl has it's modules installed on your computer. The program takes the directory as a commandline parameter or defaults to the current directory. You must have File::Find installed, though.

The part before __END__ is the (obfuscated, of course) parser, that decodes and executes the spiraling code, which is of course after __END__. You can read it by finding the middle letter in both axis, then going first to the right, then down, then left, up, etc...

#!/usr/bin/perl -w use strict;#:-) @!=<DATA>;chomp @!;$_=@!;map{$_ =[split//]}@!;$ 0=1;$a=$b=int$_ /2;my$s=sub{for (0..$!){push@0, $![$a][$b]|| 0; ${$_[0]}+=$0;}} ;while($!<$_){& $s(\$b);&$s(\$a );$!++;$0=-$0;} eval join'',@0; __END__ }}close FILE;} ;_\n";last;}els 1$t && /\S/){pi "x; open(FILrf =tetub wnt{rEi( nnxs\&wnt,e,n/ ti$e;(le:: t t= xr(n)diusFsu$ h epf$'nF eihr_"e n;i .if;dnin)$a $"{y' || tf ;Fd {n)m ;)d-(fiwi\ )\>ELIF<(elihld ieman::dniF::e\ /)ELTIT|EMAN(+s

But wait! I am not finished yet. Maybe you would like to create your own spiraling code? Then you can use the following spirali(zi)ng code...

just stick whatever code you will want to "spiralize" into the variable $code, like the example shows. The number of letters in the code must be an even square (like the parser also is), like 49 (7*7), 81 (9*9) or 225 (15*15), or the program will die with a warning. This wouldn't be 100% necessary, but it made life much easier, and will produce a nice square block of code. If you are having trouble getting to an even sqaure, remember that whitespace counts too. You should avoid any newlines though. Just paste the output from this snippet after __END__ in the first program and try it! :)
#!/usr/bin/perl -w my $code = q($_="Put your code here, please!!\n"; print; exit;); use strict;#:-) @!=<DATA>;chomp @!;$_=@!;map{$_ =[split//]}@!;$ 0=1;$a=$b=int$_ /2;my$s=sub{for (0..$!){push@0, $![$a][$b]|| 0; ${$_[0]}+=$0;}} ;while($!<$_){& $s(\$b);&$s(\$a );$!++;$0=-$0;} eval join'',@0; __END__ ][$i];}print"\n";} _1);$a+=$0;}$!++;$0 $,+=$0;}last if($c= [+be($c<$l){for(0>- F+$l.";die;}my@F.=$ $c;ite must be ;.$0 t$)h'd=int($wham$l; n,1wno!my$wh=) y!)} ie,;sch;lengs)r$);f rd+)i w)=mytq{oc{fo po+2 f$el$ hrpo=$or {cc/"o(doc$(trt0Fr( )$$h. fi;)l$(i ;[(0 +(,w htgneL"tnn$$0. +re$l$." ,rebmu0a.. itd(tni=b$=a$;1=].$ $soc$(rtsbus=]b$[$# ;bus=]b$[]a$[F${)!F hw$<i$;0=i$ym(rof{)
The silly example should produce this:
; exit; tre, pl net yoe ihu$_ua r P"=rs pedoc e ;"n\!!
and when run with the parser, print a message before it exits. Yep, very contrived. :)

Tips: If something seems to not work, you can add the classic ... or die "$@"; to the last line of the parser, the one with the eval. If something went wrong with the execution of your code, this will show something. Not that it most likely will help much, in this case...

This was all I had for today, and I hope someone will like it. :)

You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

In reply to Spiraling Death: not a boustrophedon. by Dog and Pony

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (5)
    As of 2021-03-01 07:49 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found