http://qs321.pair.com?node_id=142042
Category: Cryptography
Author/Contact Info Alex the Serb
Description: This script is tested on Linux platform, but could probably be run under Cygwin if Perl and GNU C compiler are installed. The script changes the original Perl script text by some values stored in @codes variable. Then, it makes the C file and make script for it to be compiled. After compilation the script is embeded in exe file, but its not visible in original form, so it will be not easy to change it in Hex editor. You could use this script with changed numbers in @codes variable every time you compile a new script. This will add additional difficulties to anyone who tries to crack it. Many thanks goes to Damian Conway, who told me to read perlembed, perlxs and stuff like that, because his module Morse.pm was not good enough! .. thanks dude! You call this script with one argument that points to Perl script that you want to transform. After transformation of the script, you should run make that was created during transformation. After that the file called "exe" is created. That is executable created from your script that will be executed real fast, much faster than using Damian's Morse or Bleach modules!!!

Important: This script was tested on many Perl scripts, however, because the Perl interpreter is statically linked into executable, the size of new script will be: (the size of Perl interpretter) + (the size of integer) * (number of characters of your script)

Also, the modules that are dinamically linked during execution must be available on the server that you are porting to. However, the most of you are like me (I don't port the scripts from one server to another that often), so you should probably compile Perl interpreter with dinamic library option libperl.so that will render Perl interpreter to only 15 Kb or so!

Important2: Its after nearly 3-4 months of succesfull execution of executables made by this script that I dared myself to put it in here .. so there is no fear of bad stuff happening to your computer :)

So, if you are paranoic like me or if you are surrounded by sharks .. like me .. feel free to use this script to protect your work from "accidental" change.

Update: Its acctually a good thing to repeat some of the codes, because the fact that every code is different from any other incresses the probability of cracking!
#!/usr/bin/perl -w

use strict;

die if !(@ARGV);

my @codes = qw(61 31 21 1 44 16 21 11 7 9 37 39 33 3 2 1 0 32 51 41 10
+);

open TARGET,"$ARGV[0]";
open NEW,">$ARGV[0]\.c";

print NEW "#include <EXTERN.h>\n#include <perl.h>\n\n";
print NEW "extern void xs_init();\n";
print NEW "static PerlInterpreter *perl;\n\nvoid main() {\n";
print NEW "        int execute[] = {";
my $total = 0;
my $counter = 0;
my $beginning = 1;
while(<TARGET>) {
    my @tmp = split //,$_;
    $total += $#tmp;
    for(my $i=0;$i<=$#tmp;$i++) {
        my $check = $tmp[$i];
        if($beginning) { $beginning = 0;
                   $tmp[$i] = ord($tmp[$i])+$codes[$counter];
                   print NEW $tmp[$i];
        }
        else { 
            $tmp[$i] = ord($tmp[$i])+$codes[$counter];
            print NEW ",".$tmp[$i];
        }
        $counter++;
        $counter = 0 if $counter>$#codes;
    }
    $total++;
}

print NEW ",0};\n    int i = 0;\n    int codes[] = {61,31,21,1,44,16,2
+1,11,7,9,37,39,33,3,2,1,0,32,51,41,10};\n        char *embedding[] = 
+{ \"\",\"-e\",\"0\" };\n";
print NEW "    char str[".$total."];\n";
print NEW "        int count = 0;\n";
print NEW "    while(execute[i]!=0) {\n                str[i] = (char)
+(execute[i] - codes[count]);\n";
print NEW "                i++;\n              count++;\n             
+     if(count>40) count=0;\n        }\n        str[i]='\0';\n";
print NEW "    perl = perl_alloc();\n        perl_construct(perl);\n  
+      perl_parse(perl,xs_init,3,embedding,NULL);\n        perl_run(pe
+rl);\n        eval_pv(str,TRUE);\n        perl_destruct(perl);\n  per
+l_free(perl);\n}";

close TARGET;
close NEW;

open MAKE,">make";
my $name = $ARGV[0];
print MAKE "perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c ";
while(shift @ARGV) { if($ARGV[0]) { print MAKE $ARGV[0]," "; } }
print MAKE "\n";
print MAKE "cc -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`\n";
print MAKE "cc -c $name\.c  `perl -MExtUtils::Embed -e ccopts`\n";
print MAKE "cc -o exe perlxsi.o $name\.o `perl -MExtUtils::Embed -e ld
+opts -- -std DynaLoader `\n";
`chmod 700 ./make`;
close MAKE;