Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Perl Obsfucate Or Encrypter

by sohaib
on May 28, 2003 at 20:22 UTC ( #261402=perlquestion: print w/ replies, xml ) Need Help??
sohaib has asked for the wisdom of the Perl Monks concerning the following question:

Is there any one .. who can easily provide me some sort of perl command line encrypter which can encrypt perl files with no problem , and it can also encrypt the code doesnt matter if the script is using mod_perl or something.. Does any one have or made any command line code to encrypt the perl script. Thanks

Comment on Perl Obsfucate Or Encrypter
Replies are listed 'Best First'.
Re: Perl Obsfucate Or Encrypter
by diotalevi (Canon) on May 28, 2003 at 20:30 UTC

    No... I created but didn't release B::Obfuscate. I have released B::Deobfuscate though. I'm thinking of working on a project to make deobfuscating perl especially easy by providing a nice environment with interactive symbol renaming. I'm also thinking of doing some static analysis so that symbols used as filehandles perhaps get named that or some such.

    All this should tell you is that there is determined resistance to helping you make other's lives harder.

Re: Perl Obsfucate Or Encrypter
by pzbagel (Chaplain) on May 28, 2003 at 20:34 UTC

    I don't know if this is what you are looking for, but Damian Conway has a couple entertaining modules such as Acme::Morse (which converts your program to morse code) and Acme::Bleach(which converts your programs to series of spaces and tabs, IIRC). These a most definately for fun. Please explain more about why you want to do this so we can better address your question.


Re: Perl Obsfucate Or Encrypter
by crenz (Priest) on May 28, 2003 at 20:36 UTC
Re: Perl Obsfucate Or Encrypter
by thelenm (Vicar) on May 28, 2003 at 20:37 UTC
    man crypt ? Did you want to decrypt it too? :-) Seriously, though, I'm not sure how you're trying to use encryption for your Perl programs, but if you're trying to hide your source code, you may want to check out How can I hide the source for my Perl program?

    -- Mike


Re: Perl Obsfucate Or Encrypter
by theorbtwo (Prior) on May 29, 2003 at 02:13 UTC

    It's theoreticly very difficult to get right. In fact, I don't think you can do it without compiling your own version of perl.

    • If perl can decrypt the code, then all the information to decrypt should be there.
    • You can set breakpoints inside perl.
    • -MO=Deparse will see through source filters.
    • You can set environment vars to load deparse even if argv gets filtered.

    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Perl Obsfucate Or Encrypter
by Aristotle (Chancellor) on May 28, 2003 at 22:08 UTC
    Are you ashamed of it?

    Makeshifts last the longest.

Re: Perl Obsfucate Or Encrypter
by Itatsumaki (Friar) on May 29, 2003 at 19:28 UTC

    This is probably a bad approach, but I can't personally see why so maybe wiser monks can inform?

    What if... the CGI is just a wrapper program? It takes the parameters, passes them along to another PERL script which does the real processing and returns a nice long HTML string. The CGI program receives the string, prints it back to the browser and... presto! Code is hidden! There will be a cost in maintenance complexity and in performance. But, aside from those issues are there any hidden "gotcha" issues that make that approach unwise?

      Read How can I hide the source for my Perl program?. If someone can read the source of your CGI script, they can read the source of the script that the CGI calls (meaning they have access to the system via a means other than the web browser).

        The FAQ you listed didn't seem to say anything about that, did I miss it?

        Either way, can't you get around that by calling the script via backticks (``) or through a system call? If you call a C program via system or backticks does that reveal the object-code to the calling script too?

Rot13 (was Re: Perl Obsfucate Or Encrypter)
by cciulla (Friar) on May 31, 2003 at 03:17 UTC

    Let's see if I got the requirements down:

    • Command line encrypter [sic]
    • Encrypt it with no problem

    Given that the OP's requirements did not specify that the resultant output of the command line encrypter must be able to be interpreted, I present...

    #!/usr/bin/perl use strict; use warnings; my ($final, $rot); $_ = shift; open (INFILE, $_) || die "Can't open $_: $!"; while (<INFILE>) { foreach (split //) { if (/[a-m]/i) { $rot = 13; } elsif (/[n-z]/i) { $rot = -13; } else { $rot = 0; } $final .= chr(ord() + $rot); } } close(INFILE); print $final;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://261402]
Approved by Zaxo
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2016-04-30 11:14 GMT
Find Nodes?
    Voting Booth?
    :nehw tseb si esrever ni gnitirW

    Results (441 votes). Check out past polls.