1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Download a PHP file without executing it

Discussion in 'PHP' started by Boomachucka, May 27, 2010.

Thread Status:
Not open for further replies.
  1. #1
    Hey guys,
    SEMrush
    So I need to access the source on a PHP file without executing it. Currently, it simply returns an error if you don't user the javascript function that POSTs to the PHP file- Or is there possibly a way to figure out what it's doing through that POST? I don't see why I could do that, but that's why I'm here.

    It's not a protected file or anything so there's no reason to not be able to download it, I just can't grab it off the server without it executing.

    Thanks!
     
    Boomachucka, May 27, 2010 IP
    SEMrush
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Many ways:

    1. Login via ftp and download the file.

    2. Use PHP with the header() functionality:

    <?php
    //the php file you wish to download...
    $file_name = 'somefile.php';
    header('Content-type: application/octet-stream');
    
    header('Content-Disposition: attachment; filename='.basename($file_name));
    
    readfile($file_name);
    ?>
    PHP:
    3. Via .htaccess (by disabling php), create a .htaccess (if does'nt exist already) within the directory where the .php you wish to download resides and paste the following contents (Notice: It will disable execution of all .php files within that directory theirfore providing access to all your .php files to the public...)

    php_flag engine off
    Code (markup):
     
    danx10, May 27, 2010 IP
  3. Boomachucka

    Boomachucka Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry, I should have mentioned it's not on my server. My bad!

    I've already tried grabbing it via PHP, however in reading the file the server executes it and the same error is returned- Same as viewing it via HTML (Firefox or whatnot).

    Good suggestions though, I appreciate the help!
     
    Boomachucka, May 27, 2010 IP
  4. kaleshwar

    kaleshwar Peon

    Messages:
    43
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You just cant get the file if its not your server, just impossible to do so. If anyone could get php files from another server that would be an extremely huge security hole. Short of asking the website owner to give/sell you the file, theres nothing that can be done.
     
    kaleshwar, May 27, 2010 IP
  5. Travis

    Travis Peon

    Messages:
    539
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Short answer: Not possible.

    Long answer: Unless the host has some sort of an issue with rendering PHP files due to a strange setup (rare, but occasional - most often due to an error) it's impossible to download the source of a PHP file. For good reason. The only way to figure out how it's handling a post (without viewing the actual source) is to experiment and try and estimate what kind of checks are being run on it by trying different types of data and seeing what the result is.
     
    Travis, May 27, 2010 IP
  6. Boomachucka

    Boomachucka Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Kinda what I figured, but not really surprising. Thanks for the help everyone :)
     
    Boomachucka, May 27, 2010 IP
  7. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #7
    Hmmm...
    Therefore you're asking us to try to clone the scripts or steal that right??

    Thats not possible any way sorry! :)
     
    roopajyothi, May 28, 2010 IP
  8. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    haha...., i think you want to hack or copying some script...., but its 100.1% not possible....,

    i am dame sure..
     
    actress143, May 28, 2010 IP
  9. SalmanAbbas007

    SalmanAbbas007 Peon

    Messages:
    100
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    lol if it was possible thennnn............................ (not enough space)
     
    SalmanAbbas007, May 31, 2010 IP
    JEET likes this.
  10. rajamanickam.a

    rajamanickam.a Well-Known Member

    Messages:
    630
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    Digital Goods:
    2
    #10
    It is not possible to download the PHP file or any server side file from other people's servers through the browser without having ftp access to them. You can view the page source to find any clue about whether that page is part of any standard open source package (e.g wordpress, phpbb forum, etc) so that you can download that package from respective sources.
     
    rajamanickam.a, Jan 21, 2019 IP
  11. Fiverscripts

    Fiverscripts Moderator Staff

    Messages:
    1,840
    Likes Received:
    42
    Best Answers:
    1
    Trophy Points:
    370
    Digital Goods:
    9
    #11
    so you have basically just openly asked "how can i hack someones server" -but in a more polite way :p
     
    Fiverscripts, Jan 23, 2019 IP
    JEET likes this.
  12. NetStar

    NetStar Notable Member

    Messages:
    2,266
    Likes Received:
    467
    Best Answers:
    21
    Trophy Points:
    215
    #12
    If you're asking this question then you probably will have a thousand more questions once you get the code haha
     
    NetStar, Jan 27, 2019 IP
  13. JEET

    JEET Well-Known Member

    Messages:
    2,275
    Likes Received:
    118
    Best Answers:
    2
    Trophy Points:
    185
    #13
    You will need to learn hacking for this... or find their ftp password... LOL you reminded me of myself, from my beginner programming days.
     
    JEET, Mar 29, 2019 IP
Thread Status:
Not open for further replies.