Got some code which would take a Perl grand master to understand without running it? Post it in this section so we can stare at it in awe.

Word of warning, though: Don't be too cocky with your post — almost inevitably someone will post a reply that does the exact same thing in even fewer characters!

New Less than Readable Code
Side Comment Japh
1 direct reply — Read more / Contribute
by liverpole
on Aug 21, 2007 at 11:34
    It was this interesting meditation that gave me the idea for the following:
    $_ # Side Comment Japh -- by liverpole = q ? @ # = qw # --Just-another-Perl-hacker,-- # ; map { print "$_-" } @ # ?; y|-\n | |d; eval

    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
JAPH with shifting
1 direct reply — Read more / Contribute
by clinton
on Aug 18, 2007 at 08:55
    This is my first and probably last (intentional) obfu.

    This command line works on Windows and *nix, UTF8 enabled or not.

    perl -e "map {s/Z/\x24/g;eval()}map{m/(.*)/}q{map{Z\.=chr(96+(Zb|Z_>> +4&63||0xc0)&255);Zb=Z_<<8>>4&0xf0 }map{ord}map{utf8::decode(Z_);m/([^ +Â])/g}qq(¡Q1@\0\cPàñ@\xc2\x80Q \cA\0Q À\0\xc2\x80\cP0°Q );Z\.=qq[,\n] +,print''}"

    I'd be interested to see how you could do this with pack/unpack.

    Clint

    Update - now with the trailing comma, as pointed out by agianni

ACA JAPH
2 direct replies — Read more / Contribute
by goibhniu
on Aug 18, 2007 at 05:28

    Ok, this is my first japh. I haven't got it down to four lines, but 5 is almost 4 for really small values of 5.

    If you don't want clues, don't look up the ACA. I put it in the title because I wanted it to be more personal than "My first JAPH", but I didn't want to put too much in the title for those who have fun with de-obfuscating.

    @ca=(sub{@kp=split(//,shift);$c=shift;$p2{' '}=' ';$C2{' '}=' ';foreac +h(@kp, 'a'..'z'){if(!exists $p2{$_}){$k=chr(ord('A')+(($a++)+$c)%26);$p2{$_}= +$k; $C2{$k}=$_;}}},sub{$t=shift;$h=shift;foreach(split(//,$t)){$r=$r.($$h{ +$_});} return $r;});$ca[0]->('thequickbrownfoxjumpsoverthelazydogs',10);print + $ca[1]->('ZOCK FWUKLMT BMTE LFQR',\%C2)."\n";


    I humbly seek wisdom.
first obfuscation
1 direct reply — Read more / Contribute
by m0ve
on Aug 17, 2007 at 07:01
    here's my first try on obfuscation
    maybe i got to much time at work ;)

    $_="What is this?" ;my@t=unpack("C*",$_);my@ o;$o[0]=$t[0]-$t[12]+$t[9]-$t [6]+$t[2]+$t[9]-$t[10];$o[1]=$t[3] +$t[8]-$t[1]-$t[12]+$t[0]-$t[6]+$t[8]-$ t[10];$o[2]=$t[12]+$t[7]+$t[8]-$t[9]-$t[10] +$t[3];$o[3]=$t[9]-$t[12]+$t[9]-$t[7]-$t[8]+ $t[9];$o[4]=$t[8]-$t[0]+$t[6]-$t[10];$o[5]=$ t[6];$o[6]=$t[7];$o[7]=$t[10]+$t[9]-$t[12] -$t[7]-$t[8]+$t[9];$o[8]=$t[5];$o[9]=$t[3 ]+$t[8]-$t[12]-$t[0]+$t[4];$o[10]=$t[6];$ o[11]=$t[3];$o[12]=$t[7];$o[13]=$t[0]-$t[ 12]-$t[6]+$t[2]+$t[10];$o[14]=$t[9]-$t [12]-$t[7]-$t[8]+$ t[9]+$t[9]+$t[9] -$t[ 12]-$t[7]- $t[8]+$t[9 ];$ o[15]=$t[9 ]+$t[10] -$t[12]-$t [7]-$t[8]+$t [9];$o[16]=$t[3]+$t[8]-$ t[11] ;$o[17]=$t[6];$o[18]= $t[9]-$t[12]-$t[7]-$t [8]+$t[9]+$t[9]+$t[9 ]+$t[10]-$ t[12]- $t[7]-$t[8 ]; $o [19]=$t[2] ;$ o[ 20]=$t[3];$o[21]=$t[9]+$t[10]-$t[9];$o[22]=$t[0]-$t[12]-$t[6]+$t [2]+$t[10];$o[23]=$t[0]-$t[12]+$t[9]-$t[6]+$t[2];print pack ("C*",@o);
small sig line
2 direct replies — Read more / Contribute
by dbw
on Aug 15, 2007 at 14:40
    I've been looking for something short and sweet to put in my signature and I came up with this. It's not exactly an obfuscation, just a fairly dense bit of code. It prints something (IMO) more interesting than JAPH.
    /usr/bin/perl -le'X:for(my$x=1;;){$x%$_||next(X)for(2..$x++);print$x}'
    It can use strict and warnings without further modification and it's only 70 columns wide, so it fits most places. What do you think?
Fractal Generator
3 direct replies — Read more / Contribute
by my $self
on Aug 15, 2007 at 11:25
    for ($k = 1.2 ;$k >- 1.2 ;$k-=(2.4 )/40){ for ($j=-2.1 ;$j <.7 ;$j +=2.8 /100) {($x, $y, $i )=($j, $k, 0); + while (sqrt( $x** 2+$y + **2) <2 && $i<200) {($x ,$y )=( $x**2 -$y** 2+ $j,2 *$x*$y +$k ) ;$i++ ;} print ($i <12?( $i <4?($i <2? '#': + '%'): ($i <8?'&' :'*' )): ($i<50 ?($i <20? '+':'-') :( $i<80?',' :($i< 190 ?'.':' ') ))) ;} print"\n" ;}
    Draws a Mandelbrot fractal in the terminal
First JAPH
2 direct replies — Read more / Contribute
by johnlawrence
on Aug 02, 2007 at 11:00
    Planning: 20 mins
    Coding: 10 mins
    Formatting: 90 mins!

    At least it killed time on a long flight!

    $_="Who am I?"; my@f=unpack("C*",$_); $f[9]=$f[3]+$f[6]+$f[7]- $f[8];$f[25]=$f[5]-$f[9]+$f[7] ;$f[10]=$f[2]+$f[2]-$f[1]-$f[9]+ $f[7];$f[17]= $f[12]=$f[10]+ $f[7]-$f[9]; $f[11]=$f[12] +$f[7]-$f[9]; $f[26]=$f[21] =$f[13]=$f[3] ;$f[28]=$f[14] =$f[3]+$f[6]+ $f[13]-$f[7] +$f[9];$f[15] =$f[5]+$f[9] -$f[7];$f[16] =$f[2];$f[27] =$f[18]= $f[1];$f [31]=$f[ 23]=$f[19]=$ f[2]-$f[4]+$ f[0];$f[32] =$f[24]=$f[20] =$f[11]+$f[7]- $f[9];$f[22]= $f[10]+$f[10] +$f[10]-$f[0] -$f[0]-$f[14] ;$f[29]=$f[4 ]+$f[10]-$f[ 11];$f[30]=$ f[10]+$f[ 0]-$f[4]; print pack ("C*" ,@f[9 ..32]);
Fractal Japh
9 direct replies — Read more / Contribute
by liverpole
on Jul 28, 2007 at 21:40
    A few months ago, I was in the middle of another Perl project, and on an impulse took time out to try something new.  As is often the case, I didn't expect it would take more than a few days to finish it.

    Many weeks later, I have this obfuscation to show for it:

    use Tk ; ($ "= q \$ +; W) i(s -9o ),B )$,} n$ p90)=2+$ m$sdnr 0,;/)$,=w uo,ix+((; E,s)bw$ n3&" -())h=N -ot/9x?$} ?i(A>,fg 0"[xp (f"{n$"; ,e0,u$t" meP#$4q-$ s1|,yw," J5$9yhe|J( ;$ .=,Z])@q3 ($ $O"~9)+=B" ;1fM,%s0&)(,*@,,-$0/ :&($H"F4$>k2#2n[v()=)t a)xp4e:,$?@))f="/0xx $b$A;=t@x1,t]I,2Rm@e$3 0-;?)$:Ga_r_,09i)} B1Vp;(;A,0f(},/;{$1$(2 :(-$$$@(f0V041" ?Me2F"+0-,02.[-,:="r=>2 ,0"0>$1sea>d 5 7,e-uF;pqnse52-q9p,$l$dul ):3$]d1liW(b e,20Z+a)=t)${tA8:))t;("otd e(04{?e($&r -o(0,0p/($U"$${$,-,u;)b=,W f$k 27-s(;,~".) V)5 26h"$$/9=}=;5x0@:HB^0"s$f)4 :B";)(,,uMo,/6,e p=[3" b-rAg0Hqu(a6;N>((;,($s$-0 $PC$0$-$shez,W {aj,J6 b) @,]9.mn=2 =0,aS$+0=yv05~ :$n,F):s(a;5s 4B d$)/6p $s$ )/0,(H}i0 rq (j;#,$$;(), i,-<@h-cPp0?-n$h@_/3,,u.09 treA=80$$s.:0f ),;s0 :Cd h@$:"=6$p,7,)@UU6%@4jl301=I-;0d_0+i2,)(,1$ ,*;,+t0 9;1 $)r9%(-)",0n,A}=0.$w{,6:e$}(s:3ri$"01xP@0 q1f*, Z,:4t)F.r2"c6=$20};;.t0,o4$J4,$$p@(,Js0A;0 +sPrA$9($,[$,&=|i-s00q-$x-3$|n1*:,,bj=66c= t)$63$g]$00-1$}s06r=;Xx,$;/@+,0*>$=54bw; $$-)s"bs/5;h&HS9,ib=hg,$i_;*0Anl$i;9Sl( $$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i)7u$0@();, , Bn=5sa,A$-$($=t(:h,9)u 1M[y(($8@$0*,,=*,)A b0C _:($ 1M/ $;(+,,[3 $s )a]vm@$7$0 8O,;i),a _D5Y]0-$( n ($p),:=} , $P$W.I{\ )=~s"[ $/ ]""g ;map{$h{$_} .=substr $",0 ,1,""} split//, crypt(qw/ FRaCtal: /, q+rp +)x160; $_=join //,map {$h {$_ }} sort keys %h ;s /N / /xg; eval #l iv er po le

    The purpose of the program (if peek you must) is ...


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
The Joy of Overpunctuating
No replies — Read more | Post response
by mr_mischief
on Jul 24, 2007 at 18:29
    #!/usr/bin/perl -w #justanotherperlhacker use strict; open*_,$0;<_>; (y,#,,d,s,t,t ,,s,r,r ,,s,l,l ,,y,j,J,,y,p,P,,s,$,.,,print,goto'') for<_>


    ... and another happy little comma lives over here.

    Not particularly obfuscated, but I think it's enough to initially confuse someone who isn't paying attention. It does use a few fun tricks, though, and it passes warnings and strictures.
Quine generator
3 direct replies — Read more / Contribute
by Anonymous Monk
on Jul 16, 2007 at 02:34
    Not exactly on obfuscation, but I didn't know where else to put it... Warning: neither __END__ nor @data can be used anywhere in the programs in question, lest it will fail.
    #!/usr/bin/perl use strict; use warnings; die("File does not exist.\n") unless -e $ARGV[0]; open(QUINE, "+<", shift); my @quine = <QUINE>; push @quine, 'my @data = <DATA>;'."\n", 'print @data, @data'."\n", "__END__\n"; push @quine, @quine; seek(QUINE, 0, 0); print QUINE @quine; close(QUINE); my @data = <DATA>; print @data, @data __END__ #!/usr/bin/perl use strict; use warnings; die("File does not exist.\n") unless -e $ARGV[0]; open(QUINE, "+<", shift); my @quine = <QUINE>; push @quine, 'my @data = <DATA>;'."\n", 'print @data, @data'."\n", "__END__\n"; push @quine, @quine; seek(QUINE, 0, 0); print QUINE @quine; close(QUINE); my @data = <DATA>; print @data, @data __END__

Set the new obfuscation standard
Title:
code@?#!:
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.