Motivated by this
question
I have been wondering how someone can secure his PHP code.
After a little research in the interwebz I’ve found that there are two
possible solutions:
Source Code Obfuscators
Source code is obfucated to make it hard to understand and make any changes.
Example of obfuscation can be removing line breaks, spaces, comments, renaming variables,
function names, etc. where applicable, as well as very simple source code encoding.
Restoring obfuscated source code is trivial. These solutions are truly insecure, can
result in sever performance degradation, and don’t offer 100% code compatibility. None
the less such solutions do have a place in the market and are suitable for some people
(mostly because they are cheap, about $20, or available for free). You’ll find a bunch
quering search engines for "free php obfuscator".
http://www.zubrag.com/articles/php-source-code-encoders-and-protectors.php
— zubrag.com
Encoders
Obfuscate (some can also optimize) PHP source code, compile it to bytecodes,
and eliminate the source code. Such solutions are stable and extremely hard
to reverse-engineer. Depending on the solution price these will provide you
with options to manage licenses, generate files to expire on a given date or
after a time period (trial period).
Roughly saying solutions of this type consist of two main parts:
-
Encoder - program which obfuscates, encodes/encrypts source files
-
Loader (decoder) - these programs are designed to decode encrypted sources
and feed PHP engine with decoded sources to execute. End user will need to have
decoder (loader) installed on their server in order to be able to run your encoded application.
Loaders are available for free download.
http://www.zubrag.com/articles/php-source-code-encoders-and-protectors.php
— zubrag.com
So, in other words an obfuscator changes many things regarding the
formatting of the program, making it unreadble at first glance. However,
the program can still become readable if someone put some effort into it.
The encoders actually encrypt the program by using an encryption
algorithm. In order to execute the PHP code a decryptor (loader) has
to be installed to the target maschine and the appropriate
public key be in place.
Above I’ll demonstrate you both concepts and later I’ll present you some
real world solutions!