Eric Roode on 17 Aug 2004 10:56:12 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Horrific JAPH


Very nice analysis, Robert!

[SPOILER ALERT]
My own comments follow Robert's message, below.  If you want to figure it out on
your own, read no further.

Quoting Robert Spier <rspier@pobox.com>:

> > `$=`;$_=\%!;($_)=/(.)/ ;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,
> > $:)= $!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/;$=++;$.
> > ++;$.++;$_++;$_++;($_,$\,$,)=($~.$". "$;$/ $_$\$,$: ",$"&$~,$#)
> > ;$,++;$,++;$^|=$";`$_$\$,$/$:$;$~$* $.$~$*$# $;$\$"$^$~$*.>&$=`
> 
> Nice job.
> 
> If anyone wants to know how it works, you can look here:
> 
> --- SPOILER URL ALERT ---
> 
> Do not look here if you don't want to know how the above works.  YouT
> have been warned.
> 
> http://newbabe.pobox.com/~rspier/tmp/roode.pl
> 
> --- SPOILER URL ALERT ---
> 
> It was fun to take apart..  but only one or two real scary tricks.
> 
> If you've never tried taking one of these apart before, this one is a
> good one to play with.  A good place to start is with this hint:  ";"
> 
> -R

The goal of this japh is to build the string "echo Just another Perl hacker" and
to execute it in the shell.

The first problem was to gather those particular characters together.  The way I
did this was to set $! to a known value (which contained most of those letters)
by executing a nonexistent program.

None of the special variables are used for its regular meaning; they are only
used because they're non-alphanumeric and they're writable.

The next problem was generating the letters that didn't exist in the error
string.  Perl's alphanumeric ++ operator came in handy here -- for example, to
turn the H (from HASH) into a J.

I'm kind of proud of $^|=$" -- now there's a statement to haunt your dreams!  It
was the only way I could figure out to generate the 'k'.

Once the string was assembled, all that remained was to execute it -- but it
gave me no output, until I figured out (as Robert points out) that `` was
capturing the output.  So I hit upon using >&2 to have the shell redirect to
STDERR.

It's not too complex of a program, actually -- but it sure does look hideous,
no?  When I came up with the concept, I thought the program would be much
longer; I was pleasantly surprised that it came in at 250 characters, short
enouch for a mail signature.

Hope you've enjoyed it.  :-)

-- 
Eric

___________________________________________________________________

Privacy Notice: This message has been sent via www.zoemail.net using
patented e-mail protection technology developed by AT&T Labs. Reply to
the "keyed address" above to ensure delivery.

-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**