Last modified: September 20, 2009 01:54:04.

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:


Version 7.x also provides improved locking features, including:

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 @SourceGuardian10515694031593685842//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.

Table of Contents

  1. Introduction
  2. 3 Ways to Protect your Code: Obfuscate, Encrypt, Compile
  3. PHP Encoding Software
    1. Zend Guard
    2. SourceGuardian
    3. ionCube
    4. CodeLock
  4. Summary