Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Unobfuscated obfuscated perl course

by autark (Friar)
on Oct 25, 2000 at 08:47 UTC ( #38298=obfuscated: print w/replies, xml ) Need Help??

(. This is an atempt to demystify the black art of perl obfuscation. Below is a commented and indented version of an obfuscated perl script. Hopefully, it will be clear to you all how it works. This is actually one of the very few obfuscated perl scripts which depends on the hash-key insertion ordering. What does that mean ? Well, if the insertion of the keys in the hash in the second do-block was rearanged to: { crackers => "rekc", queen => "lr" } then the code would no longer output the expected result.

Well, enough psychobabbling from me, here is the unobfuscated obfuscated perl script... .)

Enjoy,
Autark

#!perl -l # The use of perl special variables are very popular in obfuscation. # This will put spaces between each element of a printed list. # For other strange perl variables see the perlvar manpage. $, = " "; # Using implicit returns values and seldom used constructs adds to # the obfuscation. 'do' just returns the last value interpreted, # which happens to be a hash reference. $ja = do { # A hash with the words "just", "another" as hash values (only # reversed). { typehighs => "rehtona", noh_art => "tsuj" } }; $ph = do { # A hash with the words "cker", "rl" as hash values (only # reversed). # "cker" -> "ha" + "cker" = "hacker" # "rl" -> "pe" + "rl" = "perl" { queen => "lr", crackers => "rekc" } }; # Append the missing characters for the strings "lr" and "rekc". # This is done by using certain characteristics in the ja-hash keys $ph->{crackers} .= join("", $ph, map { substr($_, 4,1) } keys %$ja); $ph->{queen} .= join("", map { substr($_, 0,3) } keys %$ja); # Use of map and grep always confuse people. Use the default # variable as much as possible. Since all our values are # reversed, we first have to reverse each of them, as a # finishing touch, we uppercase the first letter in each word print map { ucfirst reverse } map { grep { defined } values %$_ } $ja,$ph;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://38298]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2020-11-24 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?