Encoding a Plugin

resolveit

Verified User
Joined
Mar 22, 2004
Messages
764
Hi,

I'm not sure this is where this thread belongs but due to lack of a forum for PlugIns and lack of a forum for Encoding PHP scripts I've opted for the Forum that I believe suits my question best.

I have written a plugin but before I release it I would like to use SourceGuardian to protect it.

Encoding it with SourceGuardian is not a problem but when I install it on my server I run into problems.

The installation scripts are also PHP and DA complains that it cannot find the ixed libraries while trying to run the install script. Unencoded the install scripts run fine and then the second problem. The main page of the plugin returns blank when encoded, no error, just blank.

Any ideas on how to solve this problem?

Regards,
Onno Vrijburg
 
Last edited:
Hello,

I'm not too sure about SourceGuardian, I've never used it myself. Howver, one tip you can use to see any ouput send to stderr would be to stop DA, then start it up manually using:
Code:
cd /usr/local/directadmin
service directadmin stop
./directadmin
That will load up DA through the terminal and won't close any output sockets. If there are any stderr messages from your scripts, you'll be able to see them there.

Also remember that the scripts are run as the logged in user, so you'll need to ensure all your libraries are readable by the world (eg: 755).

John
 
encoding with zend would resolve a lot of issues, installatron and other plugins that use ixed seem to hit problems occasionaly.
 
Thanks John, I'll give it a try.

Chrysalis: Zend encoder costs almost $1000 and I don't see the plugins selling for anywhere near the amount I would have to charge to cover the cost. But thanks for the suggestion anyway.

Regards,
Onno
 
Hello,

I prefer ionCube to SourceGuardian personally. Both have their down points and up points, but overall I think ionCube is a stronger application.

However, about this specific SourceGuardian problem, I assume your "ixed" decoder directory is not inside the install script's current directory. For instance, if my ixed directory was at /usr/ixed I would need to cd /usr and then execute my encoded PHP script with /usr/local/bin/php /path/to/encoded/script.php. Otherwise SourceGuardian won't be able to find ixed.

Now, you say your plugin's install.sh script is written in PHP and encoded by SourceGuardian. I'm not sure what directory DA executes the plugin install scripts in, but you'll need to put ixed loaders inside whichever directory that is. The alternative to this is what we do with Installatron; leave the plugin's install script a shell script and use it to cd to the directory "ixed" (or in our case ioncube) resides. And then, after the current directory is properly set, we execute our encoded PHP install script through the PHP binary (similar to the instance in the previous paragraph above).

Another option is hardcoding the ixed loaders as an extension in PHP.ini. We don't do this with Installatron, it's messier to get working right than the hot-loading method. Also note that the PHP group is working on their own byte code system, which allows scripts to be complied to byte code, distributed in this form, and then ran on client machines using the PHP binary without being reassembled.

Good luck, Phil.
 
Hi Phil,

Thanks for pointing me in the right direction. As I have multiple licenses of Installatrom I took a peek at the unencrypted PHP code, hope you don't mind :)

As I use my own PHP.INI I had to adjust the concept you proposed slightly.

Here is what I did to get it working.

All scripts accessed first from the DA pannel cannot be encrypted (John, would it be possible somehow to get this to work so we don't have to leave unencrypted code).

I followed Phil's suggestion and wrote scripts that changed the current directory to the "home directory" of the plugin (/usr/local/directadmin/plugins/<pluginname>), then you need to include the script (you cannot run it from the commandline).

I also came accross another problem while doing this... The directory /usr/local/lib/php/extensions/no-debug-non-zts-20020429 has to exist otherwise you get an error message.

This means index.html in /admin, /reseller and /user (yes I said index.html in the plugin you can make this a shellscript, PHP or HTML and it will be executed), the install.sh, uninstall.sh and update.sh in the /scripts directory and any other script you might call from the commandline.

From the install.sh, uninstall.sh and update.sh I called my unencrypted PHP code to ensure everything is set up so I can run the encoded php scripts.

If anyone requires help with this, please don't hesitate to contact me.

Look for an announcement to be made soon regarding this PlugIn.

Phil if you mail me an IP I'll give you 1 license of the plugin for helping me to get the encoding figured out.

Regards,
Onno Vrijburg
 
resolveit if you encoded the script that DA runs to install your plugin then how would it get to the stage of installing the ixed loaders? at some point there has to be unencyrpted code if I am thinking right.
 
Hi Chrysalis,

The plugin is untarred by DA before the install.sh is called therefor the ..../plugins/<pluginname>/ixed directory exists before your install / update script is called.

The install.sh script in my case calls an unencrypted script that creates the directory I mentioned, then changes the current directory to ..../plugins/<pluginname> and then calls the encrypted script to setup everything else I need.

Here is the content of install.sh

Code:
#!/bin/sh

cd /usr/local/directadmin/plugins/<pluginname>
/usr/local/bin/php -c /usr/local/directadmin/plugins/<pluginname>/shared/php.ini /usr/local/directadmin/plugins/<pluginname>/scripts/install.php

exit 0;

and the code for install.php

Code:
#!/usr/local/bin/php -c /usr/local/directadmin/plugins/<pluginname>/shared/php.ini 
<?php  

if (!file_exists("/usr/local/lib/php/extensions"))
{
	echo "PHP Extensions directory does not exists, creating it...<br>";
	mkdir("/usr/local/lib/php/extensions");
}
if (!file_exists("/usr/local/lib/php/extensions/no-debug-non-zts-20020429"))
{
	echo "SourceGuardian PHP extension directory does not exists, creating it...<br>";
	mkdir("/usr/local/lib/php/extensions/no-debug-non-zts-20020429");
}

chdir('/usr/local/directadmin/plugins/<pluginname>/'); 
require_once '/usr/local/directadmin/plugins/<pluginname>/scripts/setup.php'; 

?>

the file setup.php is encrypted with SourceGuardian.

Regards,
Onno
 
ahh thats good, I only mentioned that because a recent version of installatron had a failed install.sh script due to a encrypted install script failed because of missing ixed dir.
 
I also had trouble with loaders and JTbox v1.
Not sure about the others, but for ioncube I have install.sh do a php.ini installation of the loaders
 
Hi John,

I wanted to avoid that because it's a nightmare with SourceGuardian. I don't know of anyone who actually got it working successfully by installing it into PHP.INI.

I'll post on thier forum to see if I can find out how to do it, might help somene here in the future.

Onno
 
Yeah, I'm not sure what php.ini installation entails for sourcegaurdian, but if you used ioncube it would be much easier.
 
Hi John,

I would certainly not disagree but as I own a license for SourceGuardian and don't own a license for ionCude or Zend (which might even be easier), I'll stick to SourceGuardian for not. I might purchase a license of ionCube in the future and then I might ask you for some help to get it working :)

Regards,
Onno
 
Back
Top