Page 1 of 1

Extensions for hiding source

Posted: Sat May 06, 2006 8:44 am
by Ree
I have downloaded a trial version of a PHP product. I found that all the files do nothing more than loading a custom extension and executing the only function that extension provides:

Code: Select all

// Load the extenion (.so file)
$stuff = 'KqhaSkZO5qbA...'; // long gibberish
the_custom_decode_function($stuff);
The only thing that differs among the files is (obviously) the $stuff string. Everything else is the same.

I found it interesting. I wonder if this is what people usually do to actually hide the source code? I imagine you cannot 'decompile' .so files (I think the equivalent on Windows is .dll)?

Posted: Sat May 06, 2006 9:06 am
by feyd
they can be decompiled.. Getting back to the original source file isn't always a simple feat, but decompiling back to assembler is easily done.

Posted: Sat May 06, 2006 9:29 am
by Ree
So from what I posted, it seems that they (the creators) have implemented all the functionality in C (within the extension)?

Posted: Sat May 06, 2006 9:31 am
by feyd
As long as it compiles to a compliant library (.so or .dll) it can be written in any language.

Posted: Sat May 06, 2006 1:19 pm
by Ree
This is ineteresting. Then in theory, I could write my app completely in C and compile the source into PHP extensions. But what about the usual stuff like form processing, reserved PHP globals etc? Can it also be done within such extensions? For example, can I 'ask' PHP to provide me with $_GET vars so that these could be used in the extensions?

Posted: Sat May 06, 2006 2:24 pm
by Ambush Commander
I'm fairly certain you can. Good reading here: http://us2.php.net/manual/en/internals.php

Posted: Mon May 08, 2006 3:14 am
by Ree
I wonder if people often write whole apps in C and put them in extensions? Isn't it a good way to build a commercial, closed source, licensed product? It must be done pretty often I think, unless there are any significant disadvantages of doing it that way.

Posted: Mon May 08, 2006 3:46 am
by onion2k
Ree wrote:I wonder if people often write whole apps in C and put them in extensions? Isn't it a good way to build a commercial, closed source, licensed product? It must be done pretty often I think, unless there are any significant disadvantages of doing it that way.
90% of web developers wouldn't know how to install it, or wouldn't have the level of server access required to install it. Unless it's something you can sell to hosting companies you'll be limited to people who run their own servers .. still not particularly common in the industry.

Posted: Mon May 08, 2006 4:14 am
by Ree
Install what? Extensions? Installing extensions is easy enough.

But yes, I imagine there are pretty much no shared hosts that would allow you to load your own extensions? In that case you really limit your potential customers...