Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Trying to learn something about obfuscation

by Bismark (Scribe)
on Feb 06, 2003 at 18:06 UTC ( #233210=perlquestion: print w/replies, xml ) Need Help??
Bismark has asked for the wisdom of the Perl Monks concerning the following question:

I'll admit that I am probably getting way ahead of myself, but I have been looking at some of the obfuscation and some of it is just driving me crazy. Would someone please give me some hints as to how the following code could print out JaPh? I understand how it is printing, just do not see where the letters are coming from.
"Yet what are all such gaieties to me
Whose thoughts are full of indices and surds?"
quotes the Lama

Replies are listed 'Best First'.
Re: Trying to learn something about obfuscation
by gmax (Abbot) on Feb 06, 2003 at 20:19 UTC
Re: Trying to learn something about obfuscation
by rob_au (Abbot) on Feb 06, 2003 at 18:55 UTC
    In addition to the direction provided by Mr. Muskrat above, I would also point you to assistance which the perl compiler itself can provide when deciphering obfuscated code. For example, using the Deparse backend, a parsed version of the code can be generated which is invariably much more readable:

    rob@kathmandu:~$ perl -MO=Deparse -e 'die$;!~y//.-~/c.$;.([$^=~/./g]&~ +$").$&.($;&{}).$/' die !($; =~ tr//.-~/c) . $; . ([$^ =~ /./g] & ~$") . $& . ($; & {}) . +$/; -e syntax OK

    Note though that some code can be written to deliberately not be able to be parsed in this manner. The joy of obfuscation.


    perl -le 'print+unpack("N",pack("B32","00000000000000000000001000101011"))'

Re: Trying to learn something about obfuscation
by Mr. Muskrat (Canon) on Feb 06, 2003 at 18:42 UTC

    Start by breaking it down. Remember that y/// is the same as tr///.

    Looking at perlvar we see that $; is $SUBSCRIPT_SEPARATOR, $^ is $FORMAT_TOP_NAME, $" is $LIST_SEPARATOR, $& is $MATCH and $/ is $INPUT_RECORD_SEPARATOR.

    So what do we have now?


    That should as clear as mud :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://233210]
Approved by Paladin
and dust plays in a shaft of sunlight...

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

    Results (352 votes). Check out past polls.