SourceGuardian
SourceGuardian is a standalone encoder, and is available for both Windows and Mac OSX platforms. A command line encoder is also available for all platforms, including Linux. This is handy if you use an automated build process.
One major advantage of SourceGuardian is that the runtime loaders can be dynamically loaded from the current webserver directory, provided dynamic library loading is enabled in PHP (which it usually is by default, unless you're running PHP in Safe Mode). Otherwise, you will need to modify your PHP.ini file to load the runtime loader as a PHP extension. Runtime loaders are available for PHP 4/5 on all platforms.
Some of its major features include:
- Full native bytecode compilation and encryption
- supports PHP4/5 encoding
- Limiting to multiple IP/domain names/MAC address
- Date limiting with optional atomic clock servers checking
- Customised messages and constants
- Ability to encrypt multiple files, folders, projects
- Ability to include or exclude files during encoding
- Ability to encode HTML and non-PHP files
- Automatic protection from overwriting source files
- Option to include HTML or PHP code to run before a protected script, for including copyrights or for any other application specific requirements
- Option to replace standard error handler when the appropriate loader is not found
- Option to allow asp-style or short tags in source files
- Option to exclude the automatic script loader from protected scripts for advanced users and manual loader installation
Version 7.x also provides improved locking features, including:
- Using the IP address (or domain name) as part of the encryption key, thereby preventing protected scripts from being decrypted and run from another IP (or domain).
- Locking of an entire PHP project, so that no protected script can run if any other script is substituted with an unencoded one or encoded with another installation of SourceGuardian. This is ideal for protecting settings, passwords etc within a PHP project.
- Locking with an external license file produced by the built-in license generator. This is ideal for creating protected scripts to be distributed between different users and it will even allow different locking options for different users. The license generator tool can be run from the GUI or command line tool and provides a method for licenses to be dynamically generated
- Locking so the protected script will work only online
A "cute" feature of the encoder GUI is its skinnable interface. Personally, I didn't think much of it, but it could appeal to others.
Below is an example code snippet:
<?php
function hello($who) {
echo "hello $who...";
}
$who="coders";
hello($who);
?>
The resulting encrypted version looks something like this:
<?php @SourceGuardian; 1051569403; 1593685842; //v7.0 evaluation
if(!function_exists('sg_load')){$__v=phpversion();$__u=strtolower(substr(php_una
me(),0,3));$__f=$__f0='ixed.'.substr($__v,0,strpos($__v,'.',3)).'ev.'.$__u;$__ff
=$__ff0='ixed.'.$__v.'ev.'.$__u;$__ed=ini_get('extension_dir');if(!$__e=realpath
($__ed)) die('extension_dir does not exists
'.$__ed);if(file_exists($__e.'/'.$__ff)) dl($__ff);else
if(file_exists($__e.'/'.$__f)) dl($__f);else
{$__d=getcwd();if(@$__d[1]==':'){$__d=str_replace('\','/',substr($__d,2));$__e=
str_replace('\','/',substr($__e,2));}$__e.=($__h=str_repeat('/..',substr_count(
$__e,'/')));$__f='/ixed/'.$__f;$__ff='/ixed/'.$__ff;while(!file_exists($__e.$__d
.$__ff) && !file_exists($__e.$__d.$__f) &&
strlen($__d)>1){$__d=dirname($__d);}if (file_exists($__e.$__d.$__ff))
dl($__h.$__d.$__ff);else if (file_exists($__e.$__d.$__f))
dl($__h.$__d.$__f);}if(!function_exists('sg_load')){die('PHP script
<B>'.__FILE__.'</B> is protected by <A
HREF="http://www.sourceguardian.com/">SourceGuardian</A> and requires the
SourceGuardian loader <B>'.$__f0.'</B>. The SourceGuardian loader has not been
installed, or is not installed correctly. Please find the required loader in the
ixed subdirectory within your SourceGuardian installation
directory.');exit();}}return
sg_load('AAQAAAAMAAAABGgAAACABAAAAAAAAAD/YZbAFUTldlniVtZXk6EU6iuH1yNn6JqC8nNOx70
GkefI/Vh646Jplr0uE52jfYAA97sAoQBPGGOZRXhnMDvPOPjVyI7WoC7Hnkwi5lbgVtCHd2ycq9hteI1
xeoTwAUkv+mPureumLnHL0rKvPE/lBaIHSQAWSuvp+hdi+6KI5d0hTNu9N4JBQvEuJfVXtk2bRPXunOs
3xxsRvQLokXSc8E/ERBjEJ4C+96pyNSyjT4SCOtdZ23x7lb7gKqiVAb54Um8bjLiiwksOyaZnvBe2JK5
lGVtav2CfPMChJJCNii9bhzYMGMoiDxamqUjf+mXuJv6NlEQpd48A+pClgYwrGacqMRkG8gPAD+xQ2Cn
7eoC4sB74G1jphWpfrNLKHo/WA244f7I0VaZFJ6oAAk9G5sSOlcZajSWHCLRQFnGJKJoCPtHXoWJZo20
+gJD6OthHn1it92EH+/Ag4wlgQhxklsuewAPhFoaQO/pPeE7QikMNXfYVPtCziA=='); ?>
As you can see from the above example, one disadvantage of encoders, generally, is that the resulting encoded file is usually larger than the original script.
Priced at USD$199, SourceGuardian's latest offering provides tough competition for its competitors in the same price range.
A 7-day free trial demo version of SourceGuardian can be downloaded at http://www.sourceguardian.com.
phpSHIELD
If you don't require the time limiting, IP/Domain locking or advanced licensing features of SourceGuardian, you may want to try phpSHIELD instead. In 2006, phpSHIELD entered into a joint-development effort with the creators of SourceGuardian, Inovica Ltd, to develop phpSHIELD using the same code base as SourceGuardian. phpSHIELD uses the same native bytecode encoding and obfuscation engine, in an easy to use Windows GUI. Decoding Loaders are available for Linux, Windows and Mac OSX.