LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 11-11-2009, 06:41 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: Chicago
Distribution: CentOS w/Cpanel
Posts: 1,134

Rep: Reputation: 51
How can I encrypt a perl script?


How can I encrypt a perl script?

So I can distribute it and no one can steal my source code.

TIA
 
Old 11-11-2009, 07:04 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 237Reputation: 237Reputation: 237
1) zip it up with a password
2) convert to executable binary for various platform. search google on key words "perl" "convert" "executable"
 
Old 11-11-2009, 07:05 PM   #3
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,747

Rep: Reputation: 333Reputation: 333Reputation: 333Reputation: 333
You don't.

Perl is an interpreted language, so the computer that runs the code needs to be able to read it. If you encrypted it so the user couldn't read it's contents, then the computer couldn't run it either.

There are tools to obfuscate Perl, which means make it very complicated to read and decipher, but the end-user could still figure it out if they wanted to. There was an article in 2600 about that not-long ago.

The only way to distribute software without the source being accessible is to use a compiled language like C and only put out binaries.
 
Old 11-11-2009, 07:08 PM   #4
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 59
It's a FAQ. In practical terms, you can't: http://perldoc.perl.org/perlfaq3.htm...erl-program%3f
 
Old 11-12-2009, 08:28 AM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 10,002

Rep: Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189
Quote:
Originally Posted by MS3FGX View Post
You don't.

Perl is an interpreted language, so the computer that runs the code needs to be able to read it. If you encrypted it so the user couldn't read it's contents, then the computer couldn't run it either.

There are tools to obfuscate Perl, which means make it very complicated to read and decipher, but the end-user could still figure it out if they wanted to. There was an article in 2600 about that not-long ago.

The only way to distribute software without the source being accessible is to use a compiled language like C and only put out binaries.
True, but even then, there's ways of 'de-compiling', or you can even run strings against the binary, and pull out a surprising amount of useful data.

You may want to look at pp ("perl packager"). It actually creates a binary file, that's *fairly* nice. However, when it executes, it does create temp files, that do expose a good bit of your source, if not all of it. The nicest thing about it, though, is that it puts all of the modules on your 'build box', into the package. So the box that runs it needs just a basic Perl installation....everything else is transported in the package, and is pulled out at run-time.
 
Old 11-12-2009, 09:34 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Puppy
Posts: 3,048

Rep: Reputation: 95
why?
perl itself is open source. linux is open source. BSD is open source.

this is the age of open source.

I think you'll find not many people will want an obfuscated perl script.
it's against the spirit of perl.
 
Old 11-12-2009, 10:58 AM   #7
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094

Rep: Reputation: 104Reputation: 104
Even if its executable, chances are someone can execute it and rip it from memory.
And on top of that as bigearbilly says it is the age of open source.
 
Old 11-12-2009, 12:25 PM   #8
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 10,002

Rep: Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189
Quote:
Originally Posted by bigearsbilly View Post
why?
perl itself is open source. linux is open source. BSD is open source.

this is the age of open source.

I think you'll find not many people will want an obfuscated perl script.
it's against the spirit of perl.
I agree. There are so many ways to get into a 'compiled' program, it's hardly worth the effort.

The only reason I use pp, is to make package delivery easier. I don't have to install a bunch of script-specific modules, to get the program to work...just ship the program itself.
 
Old 11-14-2009, 10:24 PM   #9
abefroman
Senior Member
 
Registered: Feb 2004
Location: Chicago
Distribution: CentOS w/Cpanel
Posts: 1,134

Original Poster
Rep: Reputation: 51
I'm getting errors when trying to use both perl2exe and pp.

Does anyone know a good free obfusecator?
 
Old 11-14-2009, 10:59 PM   #10
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094

Rep: Reputation: 104Reputation: 104
Quote:
Originally Posted by abefroman View Post
I'm getting errors when trying to use both perl2exe and pp.

Does anyone know a good free obfusecator?
obfusecators are ineffective, it just means it takes a few minutes more time to figure it out.
 
Old 11-14-2009, 11:24 PM   #11
abefroman
Senior Member
 
Registered: Feb 2004
Location: Chicago
Distribution: CentOS w/Cpanel
Posts: 1,134

Original Poster
Rep: Reputation: 51
How about something like the ioncube loaders for php?

Is that decryptable?

For example:
Code:
<?php //00440
// IONCUBE ENCODER 6.5 EVALUATION
// THIS LICENSE MESSAGE IS ONLY ADDED BY THE EVALUATION ENCODER AND
// IS NOT PRESENT IN PRODUCTION ENCODED FILES

if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);
?>
4+oV5CTwm4RStpXfZSDLPJ6mxCrAmrk9oIQdj9Ii8rMfyN3CU6iF3K+u1dG61LFjIqJzXqq4HXvc
iLqFThTRi7P7nbpP/r/CPqzBlpYaBtO7dWxeSZ+6zFMQXJzoHMwGEvGMNIMfAGSg0nwD/9yEAnw1
7W2Ouz0WzJ5BxEkfLycASbvFVEVXT8a8GVMDKXLs3KwF6p89y98D5dFsTP/aA2PYVxrMU7GH8/Ke
/MET4Bfns+xpW2OoMeOMgREwOMAsa3CvhlaUID3jsirST0+DWbC968NL1mbw/503JhchbNQTOerY
VhrIFL1Lv44rjL5tk6Zhnesojs3j5vYS2PjkuwU44xd5ALbGNlmlPLl2gRR9FQlS80vil8XFKCag
DskbzlEHxEeMUp/DNBNDAE1G
 
Old 11-15-2009, 10:17 AM   #12
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 10,002

Rep: Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189
Quote:
Originally Posted by abefroman View Post
How about something like the ioncube loaders for php?

Is that decryptable?

For example:
Code:
<?php //00440
// IONCUBE ENCODER 6.5 EVALUATION
// THIS LICENSE MESSAGE IS ONLY ADDED BY THE EVALUATION ENCODER AND
// IS NOT PRESENT IN PRODUCTION ENCODED FILES

if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);
?>
4+oV5CTwm4RStpXfZSDLPJ6mxCrAmrk9oIQdj9Ii8rMfyN3CU6iF3K+u1dG61LFjIqJzXqq4HXvc
iLqFThTRi7P7nbpP/r/CPqzBlpYaBtO7dWxeSZ+6zFMQXJzoHMwGEvGMNIMfAGSg0nwD/9yEAnw1
7W2Ouz0WzJ5BxEkfLycASbvFVEVXT8a8GVMDKXLs3KwF6p89y98D5dFsTP/aA2PYVxrMU7GH8/Ke
/MET4Bfns+xpW2OoMeOMgREwOMAsa3CvhlaUID3jsirST0+DWbC968NL1mbw/503JhchbNQTOerY
VhrIFL1Lv44rjL5tk6Zhnesojs3j5vYS2PjkuwU44xd5ALbGNlmlPLl2gRR9FQlS80vil8XFKCag
DskbzlEHxEeMUp/DNBNDAE1G
Yep. As with any 'run time' language, PHP has to be decrypted before it's loaded. There are some runtime things you can load on the server, but all that does is load the encrypted module, decrypt it, then run it. So not only does it slow things down, the decrypted stuff is still in ram and/or a temp file somewhere.

No matter what, you can decompile pretty much ANYTHING...
 
Old 11-15-2009, 05:23 PM   #13
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 805

Rep: Reputation: 161Reputation: 161
Quote:
Originally Posted by smeezekitty View Post
it just means it takes a few minutes more time to figure it out.
Sometimes for very very large values of "few".
 
Old 11-15-2009, 08:03 PM   #14
abefroman
Senior Member
 
Registered: Feb 2004
Location: Chicago
Distribution: CentOS w/Cpanel
Posts: 1,134

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by wje_lq View Post
Sometimes for very very large values of "few".
lol, few meaning days?
 
Old 11-15-2009, 08:33 PM   #15
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 10,002

Rep: Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189Reputation: 1189
Quote:
Originally Posted by abefroman View Post
lol, few meaning days?
Maybe...maybe longer, maybe shorter. Depends on the key, what you use for encryption, and how much effort you put in. A single PC chugging on something in its downtime will take a while....a cluster of 50 going 24/7 will crack it in no time.

The best thing is to consider everything you send out to be compromised, period. Programs? Obfuscation is good...keep a 'gold' copy of your source somewhere that YOU have access to it. Everything else, strip the comments, blank lines, tabs, and anything else that helps it to be easily read by humans. Compile that, and ship it out. Data/messages? Don't put anything in them, that you wouldn't mind being read by any random stranger.

Again, no matter WHAT you do, it's breakable. Spend more time making your code good, and less about 'protecting' it. Kinda like putting your house in a five-foot thick concrete dome, with a bank-vault front door. Are you safe? Nope...if someone wants in bad enough...they're getting in.


If you are worried about losing money, then send it through the copyright office, and fling vast amounts of slavering lawyers at anyone who steals what you did.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want my script to automatically encrypt my files. Doomhammer Linux - Security 6 06-06-2009 01:26 PM
[SOLVED] how to encrypt shell script bkcreddy17 Linux - Newbie 2 04-08-2009 06:51 AM
encrypt shell script Swakoo Linux - Security 29 02-08-2007 07:16 PM
How to Encrypt <STDIN> in PERL 5.8 SPo2 Programming 2 01-21-2006 12:46 AM
Compile/Encrypt Bash Script DoubleOTeC Programming 6 10-09-2005 07:33 PM


All times are GMT -5. The time now is 05:04 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration