V
Vijoy Varghese
Hello Group
My manager wants me to encrypt/scramble the perl programs I created
before delivering to client. I tried to convince him that a 'legal
warning' will do the job, but he is not happy, and so is his boss.
I searched the web, and found a program called 'Perl Coder'. What it
does it, it will take the perl program as input and will create a new
perl file which looks like '@#$#@fasd$#'. All i need to do was to
change the Shebang line, and it was working fine.
But its not the end of the story, my project is lying over 48 files
called as 'require library_names.pl;'. There is only one executable
perl code 'index.pl'.
the structure is like this
.../cgi-bin/index.pl (executable)
/some/where/else/lib/library1.pl
/some/where/else/lib/library2.pl
/some/where/else/lib/one/library2_1.pl
..
..
/some/where/else/lib/five/library4_3.pl
I tried to encrypt each of the library files, and executed the
'index.pl' file, but it was not working.
Then I decided to find how 'Perl Coder' was encrypting/scrambling perl
files. It's something like, they does some kind of encryption of the
entire perl code, and store it in a variable like
$AXJXSXOXHXJXGXJXYXJXGXDXRXYXZXXYXZDXFXGXBVXAXQX, then at the end, they
use this code [which is packed()] to decrypt it.
$program = &ll0l($AXJXSXOXHXJXGXJXYXJXGXDXRXYXZXXYXZDXFXGXBVXAXQX);
sub ll0l{
my($lll)=@_;
$lll=~s,\+,,gm;
$lll=~s,\-,,g;
$lll=~s,\=,,gm;
$lll=~s,\n,,gm;
$lll=~s,Z,,gm;
$lll=~s,X,,gm;
return(pack('C*',split('l',$lll)));
}
then they call
eval ($program)
and, thats it!!!
The sad part is, i explained 'how simple its to decrypt it' to my
manager and still he want some kind of 'encryption'. So again, am
stuck!
So I created two functions, which encrypts and decrypts any file using
simple 'XOR'ing with a $key logic. Using this encryption algorithm, i
encrypted all my 48 library files. Then in my main 'index.pl' program,
i replaced all
require ("librarynames.pl");
with my custom requireNow function call
eval requireNow("encrypted_librarynames.pl");
and my requireNow function which resides in the index.pl file looks
something like this
sub requireNow{
my($file)=@_;
open(DAT,"$file");
my $prog = '';
{
my $key = 111;
local $/;
$prog = pack "c*",
map { $_ ^= $key }
unpack "c*", <DAT>;
}
return $prog;
}
Then I encrypted the index.pl file with 'Perl Coder', and everything
was looking fine.
I called index.pl in web-browser, and it was working most of the time.
But some times, i was getting errors like
Undefined subroutine &main:neOfMyFunctions called at (eval 17) line
9, <DAT> line 3.
This is how control flows in my program
program [index.pl]
#!/C:/perl/perl.exe
....
eval requireNow("encrypted_somecommonlib.pl");
eval requireNow("encrypted_anothercommonlib.pl");
.....
if($q->param("main") eq "one"){
eval requireNow("encrypted_one_lib.pl");
&oneFunction1(); # a function inside encrypted_one_lib.pl Working
fine!
...
}
elsif($q->param("main") eq "two"){
&Fun1;
}
else{
...
}
sub Fun1{
if($q->param("submain")){
eval requireNow ("encrypted_one_sub.pl");
&functionIn_one_sub(); # function inside encrypted_one_sub.pl, am
getting error here! :-(
}
else{
...
}
}
_____
So here is my question, is
eval requireNow("encrypted_one_lib.pl");
same as
require "one_lib.pl";
if not, can some one tell me how to achive the functionality of
'require' so that, i can decrypt the encrypted perl library file and
then load it to program.
thanks in advance,
Vijoy~
My manager wants me to encrypt/scramble the perl programs I created
before delivering to client. I tried to convince him that a 'legal
warning' will do the job, but he is not happy, and so is his boss.
I searched the web, and found a program called 'Perl Coder'. What it
does it, it will take the perl program as input and will create a new
perl file which looks like '@#$#@fasd$#'. All i need to do was to
change the Shebang line, and it was working fine.
But its not the end of the story, my project is lying over 48 files
called as 'require library_names.pl;'. There is only one executable
perl code 'index.pl'.
the structure is like this
.../cgi-bin/index.pl (executable)
/some/where/else/lib/library1.pl
/some/where/else/lib/library2.pl
/some/where/else/lib/one/library2_1.pl
..
..
/some/where/else/lib/five/library4_3.pl
I tried to encrypt each of the library files, and executed the
'index.pl' file, but it was not working.
Then I decided to find how 'Perl Coder' was encrypting/scrambling perl
files. It's something like, they does some kind of encryption of the
entire perl code, and store it in a variable like
$AXJXSXOXHXJXGXJXYXJXGXDXRXYXZXXYXZDXFXGXBVXAXQX, then at the end, they
use this code [which is packed()] to decrypt it.
$program = &ll0l($AXJXSXOXHXJXGXJXYXJXGXDXRXYXZXXYXZDXFXGXBVXAXQX);
sub ll0l{
my($lll)=@_;
$lll=~s,\+,,gm;
$lll=~s,\-,,g;
$lll=~s,\=,,gm;
$lll=~s,\n,,gm;
$lll=~s,Z,,gm;
$lll=~s,X,,gm;
return(pack('C*',split('l',$lll)));
}
then they call
eval ($program)
and, thats it!!!
The sad part is, i explained 'how simple its to decrypt it' to my
manager and still he want some kind of 'encryption'. So again, am
stuck!
So I created two functions, which encrypts and decrypts any file using
simple 'XOR'ing with a $key logic. Using this encryption algorithm, i
encrypted all my 48 library files. Then in my main 'index.pl' program,
i replaced all
require ("librarynames.pl");
with my custom requireNow function call
eval requireNow("encrypted_librarynames.pl");
and my requireNow function which resides in the index.pl file looks
something like this
sub requireNow{
my($file)=@_;
open(DAT,"$file");
my $prog = '';
{
my $key = 111;
local $/;
$prog = pack "c*",
map { $_ ^= $key }
unpack "c*", <DAT>;
}
return $prog;
}
Then I encrypted the index.pl file with 'Perl Coder', and everything
was looking fine.
I called index.pl in web-browser, and it was working most of the time.
But some times, i was getting errors like
Undefined subroutine &main:neOfMyFunctions called at (eval 17) line
9, <DAT> line 3.
This is how control flows in my program
program [index.pl]
#!/C:/perl/perl.exe
....
eval requireNow("encrypted_somecommonlib.pl");
eval requireNow("encrypted_anothercommonlib.pl");
.....
if($q->param("main") eq "one"){
eval requireNow("encrypted_one_lib.pl");
&oneFunction1(); # a function inside encrypted_one_lib.pl Working
fine!
...
}
elsif($q->param("main") eq "two"){
&Fun1;
}
else{
...
}
sub Fun1{
if($q->param("submain")){
eval requireNow ("encrypted_one_sub.pl");
&functionIn_one_sub(); # function inside encrypted_one_sub.pl, am
getting error here! :-(
}
else{
...
}
}
_____
So here is my question, is
eval requireNow("encrypted_one_lib.pl");
same as
require "one_lib.pl";
if not, can some one tell me how to achive the functionality of
'require' so that, i can decrypt the encrypted perl library file and
then load it to program.
thanks in advance,
Vijoy~