+ Reply to Thread
Results 1 to 7 of 7

Thread: PHP Obfuscation

  1. #1
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    PHP Obfuscation

    I am looking for some advice on protecting my code. I know there are php obfuscators out there, but are they really worth my time. What are your thoughts on protecting my code.

  2. #2
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: PHP Obfuscation

    PHP already has all the obfuscation you need.
    When it runs, PHP code is invisible, and will only output whatever you choose to output. Usually, a PHP page will look like it contains plain HTML, although it could be a picture or anything else you choose to make.

    The only exception is when you are sending your PHP files in a non supported format (such as being saved .txt) or when uploaded to a server without PHP installed. Generally, the only time you will send such is when you are sharing your code, in which case obfuscation would be pointless.


    Overall, obfuscation for PHP is quite a lot of hindrance, and no plus points.
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Obfuscation

    What do you want to protect your code from?
    Last edited by misson; 07-21-2009 at 01:56 PM.

  4. #4
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: PHP Obfuscation

    I might be going off topic and sorry if I hi-jack your thread. When I was reading this, it made me remember of something.

    Well actually I remember reading somewhere that if you are on a shared server and it has SSH. That other users can read your files? can anyone clarify if its true or not?

  5. #5
    zapzack is offline x10 Elder zapzack is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    606

    Re: PHP Obfuscation

    it depends on if they have permission to read your files.. usually they do not..

  6. #6
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: PHP Obfuscation

    My 2 cents on obfuscation:

    1. Obfuscating code is very easily undone. It's trivial at best for an experienced programmer to reverse engineer your code. It is just a matter of time.

    For example:
    Code:
    function abc($x) { // this function prints out array $x
        foreach ($x as $y) {
            echo "<td>$y</td>\n";
        }
    }
    becomes
    Code:
    function _a234aa235b($_2342q2245143){foreach($_2342q2245143 as $_asde323fassdf){echo"<td>$_asde323fassdf</td>";}}
    It doesn't take much imagination to figure out what is happening here, especially since builtin functions and key words don't change.


    2. Encrypting your code cannot be undone. But, the only users who can run your code will be those that are on servers supporting the encryption (see ioncube or zend encryption).

    For example the same php code from before might become:
    Code:
    aksjdtp24qipwahsdasdfj3h2g0wha0sdognjfiodfjh0aweht[eawpsdgasdjfahbn093h23
    Without the right software, nothing can read that.


    Either solution is not very beneficial to you or your users.

    As far as someone reading your code by typing in the URL, it's 99% impossible unless:
    1. You have an error in your code.
    2. You use the function to display your code.
    3. You edit your .htaccess to disassociate the .php extension with php
    4. Someone hacks into your FTP, webdisk, or CPanel
    5. Someone finds an exploit in your code and manages to execute 1-4
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Obfuscation

    Quote Originally Posted by diabolo View Post
    Well actually I remember reading somewhere that if you are on a shared server and it has SSH. That other users can read your files? can anyone clarify if its true or not?
    You should have started a new thread for this.

    Read up on Unix file permissions. By default, files have global read access (google "umask" for more info), which gives any process read access. A user doesn't need shell access to read your globally readable files; zhe can write a script which will run as the user that can access such files.

    To prevent most users from reading a file, remove global read access. To protect all files below a given directory, remove the global execute permission from the directory. You may or may not want to remove group read access. Any of these changes will cause problems for system processes than need to access the files. The web server for a site on a multi-site host (such as x10) generally runs under your user account, so removing global read won't cause problems for it.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers