Operating System - HP-UX
1821980 Members
3046 Online
109638 Solutions
New Discussion юеВ

how to make perl script to be binary program in HP-UX?

 
Donald23
Occasional Advisor

how to make perl script to be binary program in HP-UX?

Hi,
I just wonder there is any way to compile perl script to be binary for the security of the code.
Donald
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: how to make perl script to be binary program in HP-UX?

Well, if your Perl is pretty simple, you can give perlcc a try but don't expect too much.

perlcc -o myfile myfile.pl

Man perlcc and read it fully.
If it ain't broke, I can fix that.
Donald23
Occasional Advisor

Re: how to make perl script to be binary program in HP-UX?

I have installed perl5. I didn't find any command like "perlcc", but "perl -P"
-P run script through C preprocessor before compilation

Is it OK?
Donald
A. Clay Stephenson
Acclaimed Contributor

Re: how to make perl script to be binary program in HP-UX?

No Perl -P merely invokes the C Pre-processor before interpreting your Perl source. It's useful for things line this:

#define SECONDS_PER_DAY 84600

Now everywhere you had SECONDS_PER_DAY in your Perl code, 86400 would be substitued "on the fly". Of course, it's much better to use this construct
use constant SECONDS_PER_DAY => 86400;
or better still and no performance penalty
use constant SECONDS_PER_DAY => (24 * 60 * 60);

This does nothing about turning your Perl source into an executable. That's the job of perlcc. It's shipped with Perl 5.6.1 for sure sure but it's considered to be experimental; I wouldn't use it.

You can also try this:
perl -MO=C myfile.pl > myfile.c
If that works, you then cc -o myfile myfile.c.

If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: how to make perl script to be binary program in HP-UX?

Let me give you a better Plan B:

Look into the Filter Module which is available from www.perl.org/CPAN:

Here's how it would work:
Your Perl "executable" would contain a few line in plaintext (if you wish) like copyright notices or other comments and then
use Filter::decrypt;
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b456ertyysll;lk'235

Everything after the use Filter::decrypt; is encrypted BUT the beauty of the decrypt module is that the source code is filtered BEFORE it is parsed by the Perl interpreter.
It's a pretty neat technique but it does require some work on your part. The decryption routine that is supplied is very trivial and it intended to only be a demo version but you can easily replace it with as robust a routine as you wish. You also have to write a script to do the encrytion but that's not very difficult either. If you really want to produce secure Perl code that actually executes perfectly this is the way to go. All of the Perl to binary compilers are very trouble prone.
If it ain't broke, I can fix that.
Hein van den Heuvel
Honored Contributor

Re: how to make perl script to be binary program in HP-UX?

"binary for the security of the code."

Unbelievable... some folks still think that "Security through obfuscation" serves a useful purpose. Sad.
Hopefully I misinterpreted the post though.

Good luck! (sic!)
Hein.
Donald23
Occasional Advisor

Re: how to make perl script to be binary program in HP-UX?

It seems too complicated,and I wanna give up.
Might be better to create C code.
Thanks a lot!!!
More new things we can discuss, pls reply it.
Donald
H.Merijn Brand (procura
Honored Contributor

Re: how to make perl script to be binary program in HP-UX?

As Hein said. perl is not the language to be used for your definition of secure code. MY definition of secure code still holds for Perl though :)

That said, any program written in perl can be descrambled. There are some internal modules available to `disassemble' the target code to readable lines again. This is more easy in Perl than it is with C object files, but it is possible in any language. I know. I've even disassembles optimized pa-risc code to find things I needed to know.

Please assign points to the answers if you expect more replies.

Some hints if you want you C code to be more secret than avarage:

- strip your code
- use illogical names for subroutines (message () instead of exit (), forward () instead of init (), read_password () instead of unlink ())
- spread the letters of your strings accross the code, so 'strings' will not reveal them
- calculate yout constants instead of using constants
- search the forum, there have been more threads like this

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn