Possible to view PHP code of a website?

112,844

Solution 1

A bug or security vulnerability in the server (either Apache or the PHP engine), or your own PHP code, might allow an attacker to obtain access to your code.

For instance if you have a PHP script to allow people to download files, and an attacker can trick this script into download some of your PHP files, then your code can be leaked.

Since it's impossible to eliminate all bugs from the software you're using, if someone really wants to steal your code, and they have enough resources, there's a reasonable chance they'll be able to.

However, as long as you keep your server up-to-date, someone with casual interest is not able to see the PHP source unless there are some obvious security vulnerabilities in your code.

Read the Security section of the PHP manual as a starting point to keeping your code safe.

Solution 2

By using exploits or on badly configured servers it could be possible to download your PHP source. You could however either obfuscate and/or encrypt your code (using Zend Guard, Ioncube or a similar app) if you want to make sure your source will not be readable (to be accurate, obfuscation by itself could be reversed given enough time/resources, but I haven't found an IonCube or Zend Guard decryptor yet...).

Share:
112,844
Admin
Author by

Admin

Updated on March 13, 2020

Comments

  • Admin
    Admin about 4 years

    Is it possible to somehow view another websites php files/codes?

    Or to rephrase the question, Can my php codes be viewed by anybody except for those who have access to the file?

    If so, how can I best prevent this?

    Ps: Server OS is Ubuntu 9.10 and PHP version is 5+ (Apache2)