is this very simple ?

Discussion in 'PHP' started by chiplonkar, Feb 20, 2007.

  1. #1
    PHP portion added in the html page gets executed first at the server level and the result is shown to the browser through html. When the browser chosses the option to view the source code by right click of mouse, only the HTML portion is shown on the screen, hiding the php code.


    Are there any standard,and simple methods by which hackers can peep into the PHP code? If yes, how do I prevent it ?

    Chiplonkar
     
    chiplonkar, Feb 20, 2007 IP
  2. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #2
    PHP code just can be viewed so easily. When you request a php page, apache or any other server you are running, send php file to PHP complier (well its a interpreter actually) , compiler compiles file and return to server, then server throws it to client.
     
    designcode, Feb 20, 2007 IP
  3. Austars

    Austars Active Member

    Messages:
    1,437
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    95
    #3
    @designcode: I think you're missing what the OP meant.

    To the best of my knowledge, without a hacking gaining control/access to a server, there is no way they can get to your PHP files.
     
    Austars, Feb 20, 2007 IP
  4. JoshuaGross

    JoshuaGross Peon

    Messages:
    411
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4

    Correct. You need to view the files from the FTP server before Apache and PHP execute them.
     
    JoshuaGross, Feb 20, 2007 IP
  5. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #5
    Yeh thats what I said, I told the whole process, from client request to server response, if anything awful happens between this process, possibility exist that your code will be visible to client. For example, if there comes some problem in php compiler, and rather than parsing code, it returns the whole code as it is, then?

    Believe me, I have seen this happened once, I opened a website and it prompt me to open file with Programmers' Notepad, and next instance I was looking at the source code of index.php :)
     
    designcode, Feb 20, 2007 IP
  6. chiplonkar

    chiplonkar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Does it mean that writing a password openly in the php code for connecting to mysql database is safe ? e.g. are lines like this in the php code safe ?

    $result=mysql_connect("localhost","xyz","password");

    Chiplonkar
     
    chiplonkar, Feb 20, 2007 IP
  7. designcode

    designcode Well-Known Member

    Messages:
    738
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #7
    Yes its very safe until something awful like server hack, or apache crash happened.
     
    designcode, Feb 20, 2007 IP
  8. chiplonkar

    chiplonkar Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Does it mean that blocking the ftp access to public by setting DIRECTORY PERMISSIONs to "public_ftp" directory is safe enough to prevent access to php files?

    Chiplonkar
     
    chiplonkar, Feb 20, 2007 IP
  9. JoshuaGross

    JoshuaGross Peon

    Messages:
    411
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #9
    As long as you need a password to view the directory with PHP files, you're safe.
     
    JoshuaGross, Feb 20, 2007 IP
  10. rays

    rays Active Member

    Messages:
    563
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #10
    there are several other ways to hack the script ..

    for an example if you are allowing users to upload files on server ... users can upload a custom developed php file which they can run by typing www.yourdomain.com/uploads/customfile.php

    now as custom.php is programmed to collect all files present in DOCUMENT_ROOT i.e. your public_html and compress all files and email it to some id or even can transfer over ftp on diffrent server ...

    so caution is disallowing users to upload .php files, rather all sort of executable files .. only allow images and document files
     
    rays, Feb 21, 2007 IP