Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

About Obfuscation

by Ananda (Pilgrim)
on Dec 20, 2002 at 06:33 UTC ( [id://221375]=perlquestion: print w/replies, xml ) Need Help??

Ananda has asked for the wisdom of the Perl Monks concerning the following question:

What is Obfuscation , why and where is it needed and what does it take to create/implement Obfuscation.

Monks Please do explain with coded examples.

CHEERS!!!!

Ananda

Replies are listed 'Best First'.
Re: About Obfuscation
by dws (Chancellor) on Dec 20, 2002 at 06:38 UTC
    An "obfuscation" is a piece of working Perl that has been deliberately written in an obscure a manner as possible. The Obfuscated Code section is full of them.

    "Obfuscation" is a form of the transitive verb "obfuscate", which means "to make obscure" or "confuse".

    What you need to write an Obfuscation is a twisted brain, a finely honed sense of the absurd, and lots of practice. (And the judgement to avoid doing obfuscations anywhere near production code.)

Re: About Obfuscation
by tachyon (Chancellor) on Dec 20, 2002 at 09:35 UTC

    What is Obfuscation

    An intellectual pursuit where you try to prove yourself cleverer than everyone else by writing completely incomprehensible code that still actually works. Bonus points for getting it to run with strict and warnings.

    why and where is it needed

    It is not *needed* although it has potential job security benefits ;-) Besides that it can be fun to write/decipher and certainly promotes a deep understanding of Perl

    and what does it take to create/implement Obfuscation.

    It takes 3 things. 1) imagination; 2) a fairly deep knowledge of the more arcane aspects of Perl; 3) far too much free time

    Monks Please do explain with coded examples.

    See my sig (you can run it and it will print "tachyon") or Obfuscation or some of the Best Nodes.....

    History

    As far as I can discern we owe a debt of gratitude to Randal Schwartz aka merlyn you started the craze and coined the infamous 'just another Perl hacker,' moniker which so many obfus eventually generate.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      I agree with tachyon on all counts!

      Obfuscated code, IMHO, is in direct opposition to an acronym that I live by that was taught to me in one of my first programming courses - the acronym is KISS, for Keep It Simple Stupid. If an obfuscated piece of code does 10 things in one line of code, but takes someone an hour to decipher, is compared to a piece of code that does those same 10 things in 10 lines of code, and only takes someone 10 seconds to understand, then I'll pick the later(more code, but easily understandable - easily understandable being the goal) every time.
Re: About Obfuscation
by jsprat (Curate) on Dec 20, 2002 at 09:33 UTC
Re: About Obfuscation
by submersible_toaster (Chaplain) on Dec 20, 2002 at 09:16 UTC
    Ok , Staying rigorously on topic with those questions.
    1. dws nailed it.
    2. It is needed to keep your mind fresh : )
    3. It is needed wherever you must disguise the nature of your beast, and or Obfuscated Code
    4. It takes skill, perseverance and bloody mindedness.


    there are literally hundreds of coded examples, some even have explanations. like this one.
Re: About Obfuscation
by derby (Abbot) on Dec 20, 2002 at 13:40 UTC
    Boshfpngvba vf nal grpuavdhr hfrq gb znxr fbzrguvat fb pbashfrq be bcndhr nf gb or qvssvphyg gb creprvir be haqrefgnaq.

    #!/usr/bin/perl -p y/A-Za-z/N-ZA-Mn-za-m/;

    -derby

    update: Of course, that's just obfuscated text, not obfuscated code.

Re: About Obfuscation
by domm (Chaplain) on Dec 20, 2002 at 20:52 UTC
    <shameless plug>
    I did a talk on Obfuscation at YAPC::EU::2002. The slides - which might anwser some of your questions - are available here.
    </shameless plug>
    -- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
Re: About Obfuscation
by Anonymous Monk on Dec 20, 2002 at 07:52 UTC
    Obfuscation determines how flexiable a programming lanuage is.
    And IMO that determines what is the best language.

      I disagree with the line of thinking that ease of obfuscation = flexibility = definition of the best programming language.

      All programs in all programming languages can be obfuscated. The quality of a language that allows a program to be especially obfuscated is not so much related to flexibility, as much as it is related to the number of language contexts, the allowable set of tokens in a language, and the large scope of operations possible using these tokens.

      In the simplest sense, this may relate to 'flexibility', however, there is no evidence that a language with a simpler, or more rigourous syntax, is any less capable, or 'flexible' than a language with a looser syntax, or a richer set of built-in operators. Assembly language has far more flexibility than Perl, in that all Perl can be represented using Assembly language. To many, most programs written or generated in Assembly appear obfuscated without any manipulation at all. This does not make Assembly the 'best language' for programs to be written in.

      Obfuscation is an art. Obfuscation is the opposite of poetry. Instead of creating patterns, and token sequences that are pleasant to the eye, obfuscation is the creation of apparently random token sequences that are impossible to ungroup or derive true intentions from. Although obfuscation is the opposite of poetry, it shares qualities and traits with poetry. Languages that provide the best opportunities for obfuscation, or poetry, are those that are not internally consistent, contain numerous contexts, and subtle differences, even for apparently similar token sequences.

      Larry Wall believes that programming languages that contain these traits are more naturally familiar to most programmers. The Perl programming language has followed an accelerated evolution that attempts to mimick the evolution of human languages such as English. For this reason, Perl represents an excellent language for those inclined to practice the art of obfuscation.

      I personally believe that these qualities of Perl make it popular, but do not make it better. I believe that Perl has evolved to the point that it is a significant competitor in terms of capabilities, even with languages that have been designed from scratch to be excellent, because of the number of talented people that have been drawn to use Perl, or develop Perl. Perl would be nothing without the rich libraries provided by CPAN, or the forced evolution by people who were not satisfied with Perl 4.x and earlier.

      Perl is a capable language because it was honed into a capable language over several years. The ability for Perl to be used as a language to practice the art of obfuscation is not a trait that I actively seek out when determining the proper language to be used for a product.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://221375]
Approved by dws
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-18 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found