I assume you're not wanting this to enter any obfuscation contests. I would be astonished if an automatic obfuscator could win -- oh, wait, they call that C, right? :)

If you just want this for playing around, BBQ has the right idea. It's much more fun (and instructive) to do this yourself. However, if you're one of those "security by obscurity" types (I certainly hope not!), you could try a simple method that I've seen routinely applied to JavaScript: convert all variables and sub names to random strings.

To be fair, it might be an impossible job to automate for any but the most simple scripts, but I would probably start by grabbing all variables in a package and grouping them by typeglobs. Then apply a new, random name to all members of the typeglob. Then you'd have to look at lexical and dynamic variables. You'd have to use strict (can you imagine some poor fool using variables for variable names and trying to get this scheme to work?).

Hmm... you'd also have to do that for sub names. And you've have to ensure that you're not changing anything that's imported into the script. Oy, I don't know how workable that would be. It might be one of those simple projects that falls into place, but I suspect not. I don't have the time to tackle this right now (I'm on my 16th working day in a row), but if someone else wants to ...

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.


In reply to (Ovid) RE: Automatic Perl Obfuscation by Ovid
in thread Automatic Perl Obfuscation by madCow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.