http://qs321.pair.com?node_id=1110291

Following on from The First Ten Perl Monks, I thought it would be fun to explore the origins of PerlMonks Obfuscated code.

What was the first PerlMonks Obfuscated code?

As far as I can tell, it was written on Oct 13 1999 by the early PM developers at the very end of this ancient command line examples faq. Of course, this was well before the PerlMonks official opening on 23 Dec 1999. So, if we disqualify this pre-historic (accidental) obfuscation, the first deliberately obfuscated PerlMonks node was probably OBFUSCATE!!! by the thirteenth Perl Monk jdube on Dec 30 1999 at 04:51.

PerlMonks Obfuscation Founding Father: jdube

As was typical of early Perl Monks, jdube also had an everything2 account. Curiously, jdube further authored a companion POETRY!!! node, presumably a crude attempt to pressure vroom into creating PerlMonks Obfuscated code and Perl Poetry sections. Well, by using all caps and three exclamation marks in the node titles he was certainly shouting at vroom.

Anyway, it seems jdube's clever ploy worked because vroom did indeed create our much loved Obfuscated code and Perl Poetry sections later that same fateful day, Dec 30 1999. By the way, I was shocked to see that the historic Poetry and Obfuscated Sections by vroom has received just one up-vote (mine). If you feel this historic node is worth more than that, you know what you need to do. Update: the reason for the lack of up-votes was simply that there was no voting system back then! It came three months later.

An interesting piece of trivia is that jdube's medieval OBFUSCATE!!!/POETRY!!! barrage took place in the (now obsolete) perlcraft arena. It seems this ancient "perlcraft" section has since been re-branded as Cool Uses For Perl.

Tragically, our PerlMonks poetry and obfu founding father jdube does not appear in the first ten official Obfuscated nodes, listed below. Sadly, he never did write an official PerlMonks obfuscated node. Sadder still, Perl Monk number 13 jdube was last seen wandering around the monastery in May 2000, and his account now sits abandoned and disabled. Perhaps being the thirteenth user proved unlucky. I wonder what jdube is doing nowadays. Will he return one day to write us another obfu or poem?

Obu No 1: #!/usr/bin/perl by BBQ (last here Apr 07 2009)

Created: Dec 30 1999, Rep: 14, 3 replies.

%A=('r'=>"\n","\t"=>'#','/'=> 's','f'=>'p',"b"=>'n');@C=qw (e ! r/ / e );foreach $k (sort keys %A){ @B=(" ",'u','i',"\b",'l');$s .=qq{$k$B[$x++]$A{$k}$C[$x] \b};if ($x==1){$t=$k.$B[$x-1].$A{$k};}#ops } print$A{r}.$s;#i h8 left over \s's

The first official PerlMonks obfu was concocted in Brazil by Perl Monk number eleven BBQ, who has the further distinction of being the first foreign Perl Monk. In addition to being the first foreign monk, BBQ is the first non-insider Perl Monk without a companion everything2 account.

This historic obfu, which still works with modern perls, displays its node title #!/usr/bin/perl on the screen when run. It is a bit trickier than that though, in fact it writes the following 33 characters to stdout:

CR LF TAB SPACE #! SPACE BACKSPACE /usr/ SPACE BACKSPACE bin/ SPACE BA +CKSPACE f BACKSPACE pe SPACE BACKSPACE rl CR LF SPACE BACKSPACE

Though not in Erudil's class, that was a decent first attempt from BBQ. And he was well aware of its historical significance commenting:

I'm actually kinda proud I made it 1st into the obfuscated code bin. :o)
after vroom manually adjusted the node ownership to its rightful owner.

Obu No 2: WWWWolf's .signature by WWWWolf (last here Apr 11 2002)

Created: Jan 06 2000, Rep: 6, 0 replies.

$_='%?&%[=&+=?%=[%&+&%[*?]&=&~[;&+&{=?[?&%&[&{[%&^=?=[&%&]=?%~&~[?&+&~ +YiFF! =[=~| Weyfour WWWWolf (aka. Urpo Lankinen), a lupine technomancer |=?* +_=}?] %}&};| ICQ:4291042 | wwwwolf@iki.fi | http://www.iki.fi/wwwwolf/ |&;&= +~?]'; tr/?~=*;%&[{}]+_^ (),.:@\/\n0-9!|a-zA-Z/0-9acde/d; $_=pack("H*",$_); p +rint;

The second PM obfu is also from outside the USA, this time from Oulu, Finland. This one is not especially obfuscated, just the .signature file of WWWWolf (Weyfour WWWWolf's Web of Weird Things).

Yet again, we see a companion WWWWolf everything2 account. Though he hasn't visited PM since 2002, the artistic WWWWolf appears to be still active, focusing on Drupal, writing, and photography nowadays. So we may yet see a surprise return visit.

Obu No 3: ArrayHashMonster.pm by Anonymous Monk

Created: Feb 03 2000, Rep: 2, 0 replies.

$monster = new ArrayHashMonster ... ; print $monster->[1]; # This might print `Janvier' print $monster->{Jan}; # This can *also* print `Janvier'

This seems to be just an advertisement for Dominus's ArrayHashMonster CPAN module.

Obu No 4: Yearbook fun by Xavier (last here Jun 30 2000)

Created: Feb 04 2000, Rep: 9, 6 replies.

$a="User-Agent:PlMk";$u=" xavier.penguinpowered.com ";$h="GET / HTTP/1.\n";$u =~s/\n//gs;$d=`echo "$h$a "|nc $u 80`;$d=~s/.+?ml\r (.+)/$1/s;$d=~s/\n+|\s+ \ / /gsx;$d=~s/<a.+?f="(.*? )">(.+?)<\/a>/$2($1)/sgx; $d=~s/<(br|p|li)>/\n/g;$d =~s/<.+?>//gsx;print"$d";

Not especially obfuscated, just something to put in his high school yearbook, with limited space available. Yet again, we see a companion everything2 account.

Obu No 5: Tricks with tr/// by japhy (last here Oct 08 2014)

Created: Feb 09 2000, Rep: 18, 6 replies.

# to squish a string y sssscccc; y cccscsss; y yyysc; # to get the string length y yyyc; # to clear a string y ccccdddd; y dddcdccc; y yyycd;

Jeff "japhy" Pinyan is by far the highest rated Perl Monk among the first ten pioneer obfuscators. He was also a Perl Mongers pioneer, joining the first Perl Mongers user group, in New York City in the late 1990s.

His first (whimsical) obfu above plays around with Perl's tr (aka y) modifiers. These modifiers, and their companion m// and s// modifiers, are a lot of fun and very popular with obfuscators. For example, I remember a playful merlyn japh:

$Old_MacDonald = q#print #; $had_a_farm = (q-q:Just another Perl hacke +r,:-); s/^/q[Sing it, boys and girls...],$Old_MacDonald.$had_a_farm/eieio;

and a $A++ obfu from mtve:

y ccccd x s vvchr oct oct ord uc ave x s vvucve le s vvuc ave x s vvchr oct oct oct ord uc bve x eval

This sort of syntactic flexibility is why Perl is, and seems likely to remain for the foreseeable future, the premier language for writing elegant and amusing obfuscated code.

Obu No 6: Use the arrow keys by Foochre (last here Jun 29 2001)

Created: Feb 15 2000, Rep: 10, 2 replies.

#!/usr/bin/perl use Curses;keypad initscr;nodelay 1;box qw{| -};($l,$d,$k,@f)=(1..3,[1 +0,10]);& n;while(){refresh;@f=([$f[0][0]+$d%2-($d==1)*2,$f[0][1]+$d%2-1+($d==2) +*2],@f); select$f,$f,$f,.06;($c=getch)+1and$d=4-($c%2?2:0)-($c<260);addch@{pop@ +f},' 'if @f>$l;$l+=$_=inch@{$f[0]};if(!/ /){/\d/||die;addstr 0, 60,$l;&n}addch@ +{$f[0]}, 'O'}sub n{while(){@v=(rand 24,rand 80);inch(@v)eq' '&&last}addch@v,''. +rand 10}

Was this the first obfu to attempt fancy "visual effects"? Displaying mind-blowing visual effects became wildly popular with obfuscators that followed, for example:

Obu No 7: My 2 cents worth by Erudil (last here Sep 18 2008)

Created: Mar 02 2000, Rep: 216, 13 replies.

#!/usr/bin/perl -w # my 2 cents worth use strict; $_='$_=tue($=+(two ($;)>>(two($;)>>2+2))){tue (too(two(tue($=+(two($;)>>(two ($;)>>2+2))))+(two($;)>>2+2))){tue (too(two(tue($=+(two($;)>>(two($;)>>2+ 2))))+(two($;)>>2+2))-2){tue(too(two(tue ($=+(two($;)>>(two($;)>>2+2)))))){tue(too( too(two($;)>>(two($;) >>2+2)))){tue(too($=+ +(two($;)>>2+2))){tue ((two($;)<<2)-2){tue ((two($;)<<2)-(two($; )>>2+2)){tue(too(two( tue($=+(two($;)>>(two ($;)>>2+2)))))){{tue (too($=+(two($;)>>2)+ (two($;)>>2+2))){{tue (too($=+(two($;)>>2)- 2)){{{tue(too($=+(two ($;)>>(two($;)>>2+2)) -2)){tue(too(too(two( $;)>>(two($;)>>2+2))) ){tue(too(too(too(too (two($;)>>(two($;)>>2 +2)))))){{tue(too($=+ (two($;)>>2)-2))}tue( too($=+(two($;)>>(two ($;)>>2+2))-2)){tue(( two($;)<<2)-((two($;) >>2>>2)<<2))}tue(too( too(two($;)>>(two($;) >>2+2))))}}tue(too($= +(two($;)>>2)+(two($;)>>2+2)))}}tue(too($=+( two($;)>>2+2)))}}tue(too((two($;)<<(two($;)>> 2>>2))+(two($;)>>2)))}}}tue((two($;)<<2)-((two ($;)>>2>>2)<<2)-(two($;)>>2>>2))}}}tue(too($=+( two($;)>>2)-2))}}}tue(too($=+(two($;)>>(two($;) >>2+2))-2))}}}tue(too(too(two($;)>>(two($;)>>2+ 2)))+(two($;)>>(two($;)>>2+2))-2);';y;{};..;sd; s;two;ord;g;s;too;hex;g;s;tue;chr;g;eval;print;

Wow! Erudil wrote only 13 nodes, all with 100+ rep, and including the highest rated PM node of all time! Given the above masterwork was his "first attempt", I trust you can see why he is a PerlMonks legend, still revered and fondly remembered today.

This node has the further distinction of being the first ever "block-buster obfu", given its 200+ reputation. Erudil elevated Perl obfu to a true art form.

Obu No 8: Smile! by Anonymous Monk

Created: Mar 04 2000, Rep: 9, 1 replies.

# smiley - ($R=q#for (split/&/ =>q;4a&75@^ 73&74@20^41 &@6e@@6f^&@74 ^68&&65@72&20 &^50@65&@72 ^@6c&@20^48 @@61&@63& 6b@65&72;) {print &@pack ^c@&=> hex$_} ;print "\n"#) =~s,[&^@\s]+, ,g;eval$R

Obu No 9: recursive self modifying eval japh by Anonymous Monk

Created: Mar 13 2000, Rep: 6, 3 replies.

$_='",",/[J|]$/?m)^.J)?(m~"(.+?)"~):s](^(.)(.*\)\?p.*)|(\)\?)(.' .'*))\|(.)]$4$2$6$3$5|]<<eval:s<([\w -%])(?=[^|]*$)><pack+q*c*,' .'(ord$1)-++$i%3>eg!~eval#@|xslvuuipfem#pwht%uimwssd$yvyO'=>eval

Obu No 10: Tribute to Larry by whitton (last here Apr 07 2000)

Created: Mar 28 2000, Rep: 9, 0 replies.

#!/usr/bin/perl -- what is larry wall? @_=qw(l a r r y w a l l);for(0..1){$_[$_] =~ y#a-z#e-w#;} $_[3]=$_[$#_].' ';$_[4]=~s$y$h$;($_[5],$_[6])=($_[6],$_[5]); ++$_[6];$_[7]=chr 3+ord $_[7];$_[8]=~y~a-z~g-t~;print @_,".\n"

Where are they now?

Sadly, most of the obfu pioneers listed above have not been sighted for five years or more, the only exception being japhy ... though he only drops in occasionally nowadays.

References