Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

The Raven

by Beatnik (Parson)
on Dec 24, 2001 at 15:21 UTC ( #134156=obfuscated: print w/replies, xml ) Need Help??

On the last day of Christmas, Santa gave to me... an obfu to call my own

Ah, distinctly I remember, it was in the bleak December,... Gotta admit, he could've ment Christmas :)
Anyway, the idea has been spooking around in my head for several weeks now... I planned on posting it for my 500th post but I failed to complete it at that time...
#!/usr/bin/perl my$raven='print:unpack("u" ,q|=5&AE(%)A=F5N (&)Y ($5D9V%R($%L;& 5N( %!O90H`|);prin t: pack("H*","5 1 7 56f74682074 686 5 2072617665 6e203 a0a");ope n(LEN ORE,"<$0 ")||d ie$!;$b ird=q |never more| ;@say ing=sp lit( //,$bir d); <LENORE> ;< LENORE>;f o r(<LENORE> ){s|\S|\x3a |g;s|\x 20|$saying[i nt$t++ %9]|ge;p rint;}cl o s e (LENORE) ;';$_=$raven;$_=~s/\s//gx; $_=~s/\x3a/\x20/g;eval;;;;
And yes, this DOESN'T run under strict :)

The details
How I got here?
  1. Look for a picture of a bird on the net
  2. Scale it accordingly
  3. Use a perl script with GD to convert it to ascii art
  4. Think about obfu code
  5. Think about obfu code
  6. Think about obfu code
  7. Think about obfu code
  8. Think about obfu code
  9. Stuff obfu code in a file and test it
  10. Write perl script to fill obfu code into ascii art
  11. Cheat a bit til it fits properly
  12. write perl script to test obfu code
  13. Write perl script to post code to PM
  14. Wish EVERYONE a Merry Christmas and a happy new year!!
This is the snippet I used to shape the raven :)
#!/usr/bin/perl open(RAVEN,"<raven.txt"); # ASCII Art open(OBFU,"<"); #Store the obfu code here <OBFU>;<OBFU>; #ignore 2 lines $line=<OBFU>; #stff everything on 1 line please @stuff=split(//,$line); #split it up local $/=undef; $raven=<RAVEN>; #read ascii art $raven =~s/#/$stuff[$i++]/mge; #use # as marker for text open(OUT,">"); print OUT '#!/usr/bin/perl',"\n\n",$raven; #write it close(OUT);

... Quidquid perl dictum sit, altum viditur.

Replies are listed 'Best First'.
Re: The Raven
by rob_au (Abbot) on Dec 24, 2001 at 15:45 UTC
    Been there, done that ... I ended up using a very neat Perl script (which unfortunately I now can't find again) written by the guys over at Think Geek for this groovy Tux poster to shape the source code into the raven graphic shape.

    ++Beatnik for the obfuscation though ... obfuscation is good ;-)


    perl -e 's&&[@.]/&&s&.com.&_&&&print'

Re: The Raven
by jryan (Vicar) on Dec 25, 2001 at 08:25 UTC

    Very nice. Although I had to cheat (had to print em) to figure out the unpack/pack combo, I was able so solve every thing else by hand. I had fun de-obfuing it. Note that the deobfu won't run the same as the original because spacing matters.

    # A long string containing code is assigned to $raven. Colons # are actually spaces, as you will see later: my$raven=' # I admit, I had to cheat here; I actually had to print these # out to find out what they are. But then again, its pack # and unpack, its near impossible to solve them by hand... # Btw, a hint on the unpack one: it is actually quoted with # a q||, its not a bareword. the unpack one is in unicode, # which is translated to ascii; the pack is in hex (the * # means "apply to all characters"), and it returns a list # (which is ok, since print accepts a list!) # oh, and btw, these print the title. print:unpack("u",q|=5&AE(%)A=F5N(&)Y($5D9V%R($%L;&5N(%!O90H`|); print:pack("H*","51756f74682074686520726176656e203a0a"); # open $0 (the name of the file this is in) and assign it to # the filehandle LENORE. The < means the handle is for reading # only. open(LENORE,"<$0")||die$!; # $bird = 'nevermore'; $bird=q|nevermore|; # @saying = ('n', 'e', 'v', 'e', 'r', 'm', 'o', 'r', 'e'); @saying=split(//,$bird); # get rid of the shebang by using the filehandle in void context; # since the source code of the file is in <LENORE> because of # the open, using it in void context is kind of like shift(ing) it. <LENORE>; # same context to get rid of blank line <LENORE>; # loop through the rest of LENORE for(<LENORE>) { # replac all non space characters with a colon # \x3a is a colon btw :) (its in hex; 3a = 58 in # decimal; the \x "chr(s)" it; print chr(58) if # you don't believe me :) s|\S|\x3a|g; # globally replace all spaces (\x20 is a space; also, the # shape of ascii art is a silhoutte of a raven; the # silhoutte is what is being modified) with # '$saying[int$t++%9]', the e modifier makes it eval it, # below is an explanation of the inside: # first of all, the reason for the non-strict and # non-warnings is because $t is never declared. It # starts off at 0, and gets ++(ed) every pass through # the loop. Next, it gets modulus(ed) by 9, which # happens to be the size of @saying ($#saying). # Finally, this value is int(ed) so the value is an # integer. In this way, the phrase 'nevermore' is # "looped" through. s|\x20|$saying[int$t++%9]|ge; # $_ (current value of <LENORE>) is printed. print; # loop ends } # filehandle closed like a good boy ;) close(LENORE); # raven is end-quoted. '; # $_ is set to $raven $_=$raven; # all spaces are removed. $_=~s/\s//gx; # colons are changed to spaces; $_=~s/\x3a/\x20/g;eval # the whole bloody think is evalled (meaning all # of the code in $raven is evalled since $_ was # set to $raven. # ick sloppy! I need to show you guys a few tricks # to avoid things like this in shaping ;) ;;;;

    P.S, don't be a panzy, shape by hand next time ;)

      Nice work :)

      Anyway, on the shape by hand comment... I tried that the first 10 attempts :) and eventually just wrote a small script. Squeezing filler chars in without cheating is quit hard, since the statements on the second last line can't have space in em. Anyway, the raven was my first obfu art. I'll try harder next time :))

      ... Quidquid perl dictum sit, altum viditur.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://134156]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2017-03-26 01:00 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (313 votes). Check out past polls.